From 92261c16beb9ef64fe432bed4e27462338250e64 Mon Sep 17 00:00:00 2001 From: Riccardo Binetti Date: Mon, 6 May 2013 01:46:44 +0200 Subject: [PATCH 1/8] Added player's resonators plugin --- plugins/players-resonators.user.js | 99 ++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 plugins/players-resonators.user.js diff --git a/plugins/players-resonators.user.js b/plugins/players-resonators.user.js new file mode 100644 index 00000000..63fcf280 --- /dev/null +++ b/plugins/players-resonators.user.js @@ -0,0 +1,99 @@ +// ==UserScript== +// @id iitc-plugin-players-resonators@rbino +// @name IITC plugin: Player's Resonators +// @version 0.1.3.20130505.233200 +// @namespace https://github.com/jonatkins/ingress-intel-total-conversion +// @updateURL http://ingress.rbino.com/iitc-plugin-players-resonators.user.js +// @downloadURL http://ingress.rbino.com/iitc-plugin-players-resonators.user.js +// @description The plugins finds the resonators of a given player. The input is in the sidebar. Useful for revenge. +// @include https://www.ingress.com/intel* +// @include http://www.ingress.com/intel* +// @match https://www.ingress.com/intel* +// @match http://www.ingress.com/intel* +// ==/UserScript== + +// Changelog: +// +// 0.1.3 Effective player name (with wrong capitalization) if it finds some reso +// 0.1.2 Made nickname case insensitive +// 0.1.1 Added mouseover for portal location. Dirty hack to not show mousehover when the alert is fired. +// 0.1.0 First public release + +function wrapper() { +// ensure plugin framework is there, even if iitc is not yet loaded +if(typeof window.plugin !== 'function') window.plugin = function() {}; + + +// PLUGIN START //////////////////////////////////////////////////////// + +// use own namespace for plugin +window.plugin.playersResonators = function() {}; + +window.plugin.playersResonators.findReso = function(playername) { + var s = ""; + var portalSet = {}; + var effectiveName = ""; + var nickFind = playername.toLowerCase(); + $.each(window.portals, function(ind, portal){ + var r = portal.options.details.resonatorArray.resonators; + $.each(r, function(ind, reso) { + if (!reso) return true; + var nick = getPlayerName(reso.ownerGuid); + if (nick.toLowerCase() === nickFind){ + if (!effectiveName) { + effectiveName = nick; + } + if (!portalSet.hasOwnProperty(portal.options.guid)){ + portalSet[portal.options.guid] = true; + console.log(portalSet); + var latlng = [portal.options.details.locationE6.latE6/1E6, portal.options.details.locationE6.lngE6/1E6].join(); + var guid = portal.options.guid; + var jsDoubleClick = 'window.zoomToAndShowPortal(\''+guid+'\', ['+latlng+']);return false'; + var perma = '/intel?latE6='+portal.options.details.locationE6.latE6+'&lngE6='+portal.options.details.locationE6.lngE6+'&z=17&pguid='+guid; + var a = $('',{ + "class": 'help', + text: portal.options.details.portalV2.descriptiveText.TITLE, + title: portal.options.details.portalV2.descriptiveText.ADDRESS, + href: perma, + onClick: jsDoubleClick + })[0].outerHTML; + s += a + "\n"; + } + } + }); + }); + if (s) { + fakeLinkPlayer = '' + effectiveName + '' + s = fakeLinkPlayer + " has resonators on these portals:\n\n" + s; + } else { + fakeLinkPlayer = '' + playername + '' + s = fakeLinkPlayer + " has no resonators in this range\n"; + } + alert(s); +} + +var setup = function() { + var content = '
' + ''; + $('#sidebar').append(content); + $("#playerReso").keypress(function(e) { + if((e.keyCode ? e.keyCode : e.which) !== 13) return; + var data = $(this).val(); + window.plugin.playersResonators.findReso(data); + }); +} + +// PLUGIN END ////////////////////////////////////////////////////////// + +if(window.iitcLoaded && typeof setup === 'function') { + setup(); +} else { + if(window.bootPlugins) + window.bootPlugins.push(setup); + else + window.bootPlugins = [setup]; +} +} // wrapper end +// inject code into site context +var script = document.createElement('script'); +script.appendChild(document.createTextNode('('+ wrapper +')();')); +(document.body || document.head || document.documentElement).appendChild(script); From 11f7c31ce742a4d6d2cf67c5c046a3d4eaed7326 Mon Sep 17 00:00:00 2001 From: Riccardo Binetti Date: Mon, 6 May 2013 01:58:23 +0200 Subject: [PATCH 2/8] Fixed version date time, updateurl, downloadurl and description --- plugins/players-resonators.user.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/players-resonators.user.js b/plugins/players-resonators.user.js index 63fcf280..530430de 100644 --- a/plugins/players-resonators.user.js +++ b/plugins/players-resonators.user.js @@ -1,11 +1,11 @@ // ==UserScript== // @id iitc-plugin-players-resonators@rbino // @name IITC plugin: Player's Resonators -// @version 0.1.3.20130505.233200 +// @version 0.1.3.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion -// @updateURL http://ingress.rbino.com/iitc-plugin-players-resonators.user.js -// @downloadURL http://ingress.rbino.com/iitc-plugin-players-resonators.user.js -// @description The plugins finds the resonators of a given player. The input is in the sidebar. Useful for revenge. +// @updateURL @@UPDATEURL@@ +// @downloadURL @@DOWNLOADURL@@ +// @description [@@BUILDNAME@@-@@BUILDDATE@@] The plugins finds the resonators of a given player. The input is in the sidebar. Useful for revenge. // @include https://www.ingress.com/intel* // @include http://www.ingress.com/intel* // @match https://www.ingress.com/intel* From e34fd27e9ef2d3165505a21f8f6bfbeb5b086390 Mon Sep 17 00:00:00 2001 From: Riccardo Binetti Date: Tue, 7 May 2013 01:05:19 +0200 Subject: [PATCH 3/8] Added focus link in the toolbox. Some renaming. Removed div to use sidebar style. --- plugins/players-resonators.user.js | 39 +++++++++++++++++------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/plugins/players-resonators.user.js b/plugins/players-resonators.user.js index 530430de..7e6186cd 100644 --- a/plugins/players-resonators.user.js +++ b/plugins/players-resonators.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @id iitc-plugin-players-resonators@rbino // @name IITC plugin: Player's Resonators -// @version 0.1.3.@@DATETIMEVERSION@@ +// @version 0.1.4.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ @@ -12,12 +12,15 @@ // @match http://www.ingress.com/intel* // ==/UserScript== -// Changelog: -// -// 0.1.3 Effective player name (with wrong capitalization) if it finds some reso -// 0.1.2 Made nickname case insensitive -// 0.1.1 Added mouseover for portal location. Dirty hack to not show mousehover when the alert is fired. -// 0.1.0 First public release +/********************************************************************************************************* +* Changelog: +* +* 0.1.4 Added focus link in the toolbox. Some renaming. Removed div to use sidebar style. +* 0.1.3 Effective player name (with wrong capitalization) if it finds some reso +* 0.1.2 Made nickname case insensitive +* 0.1.1 Added mouseover for portal location. Dirty hack to not show mousehover when the alert is fired. +* 0.1.0 First public release +*********************************************************************************************************/ function wrapper() { // ensure plugin framework is there, even if iitc is not yet loaded @@ -32,30 +35,31 @@ window.plugin.playersResonators = function() {}; window.plugin.playersResonators.findReso = function(playername) { var s = ""; var portalSet = {}; - var effectiveName = ""; - var nickFind = playername.toLowerCase(); + var effectiveNick = ""; + // Assuming there can be no agents with same nick with different lower/uppercase + var nickToFind = playername.toLowerCase(); $.each(window.portals, function(ind, portal){ var r = portal.options.details.resonatorArray.resonators; $.each(r, function(ind, reso) { if (!reso) return true; var nick = getPlayerName(reso.ownerGuid); - if (nick.toLowerCase() === nickFind){ - if (!effectiveName) { - effectiveName = nick; + if (nick.toLowerCase() === nickToFind){ + if (!effectiveNick) { + effectiveNick = nick; } if (!portalSet.hasOwnProperty(portal.options.guid)){ portalSet[portal.options.guid] = true; console.log(portalSet); var latlng = [portal.options.details.locationE6.latE6/1E6, portal.options.details.locationE6.lngE6/1E6].join(); var guid = portal.options.guid; - var jsDoubleClick = 'window.zoomToAndShowPortal(\''+guid+'\', ['+latlng+']);return false'; + var zoomPortal = 'window.zoomToAndShowPortal(\''+guid+'\', ['+latlng+']);return false'; var perma = '/intel?latE6='+portal.options.details.locationE6.latE6+'&lngE6='+portal.options.details.locationE6.lngE6+'&z=17&pguid='+guid; var a = $('',{ "class": 'help', text: portal.options.details.portalV2.descriptiveText.TITLE, title: portal.options.details.portalV2.descriptiveText.ADDRESS, href: perma, - onClick: jsDoubleClick + onClick: zoomPortal })[0].outerHTML; s += a + "\n"; } @@ -63,18 +67,19 @@ window.plugin.playersResonators.findReso = function(playername) { }); }); if (s) { - fakeLinkPlayer = '' + effectiveName + '' + // Showing the playername as a "fake" link to avoid the auto-mouseover effect on the first portal + fakeLinkPlayer = '' + effectiveNick + '' s = fakeLinkPlayer + " has resonators on these portals:\n\n" + s; } else { - fakeLinkPlayer = '' + playername + '' s = fakeLinkPlayer + " has no resonators in this range\n"; } alert(s); } var setup = function() { - var content = '
' + ''; + var content = ''; $('#sidebar').append(content); + $('#toolbox').append(' Player\'s Reso'); $("#playerReso").keypress(function(e) { if((e.keyCode ? e.keyCode : e.which) !== 13) return; var data = $(this).val(); From 8eb65c57641df56f76e705a14d13cd78c4bea2b6 Mon Sep 17 00:00:00 2001 From: Riccardo Binetti Date: Tue, 7 May 2013 01:18:08 +0200 Subject: [PATCH 4/8] Fixed wrong name if no reso found --- plugins/players-resonators.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/players-resonators.user.js b/plugins/players-resonators.user.js index 7e6186cd..28c03791 100644 --- a/plugins/players-resonators.user.js +++ b/plugins/players-resonators.user.js @@ -71,7 +71,7 @@ window.plugin.playersResonators.findReso = function(playername) { fakeLinkPlayer = '' + effectiveNick + '' s = fakeLinkPlayer + " has resonators on these portals:\n\n" + s; } else { - s = fakeLinkPlayer + " has no resonators in this range\n"; + s = playername + " has no resonators in this range\n"; } alert(s); } From e2f8c7c5cf4240fb035996bf9c34bf9d0c07041c Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 7 May 2013 16:01:23 +0200 Subject: [PATCH 5/8] enable portals, fields and links per default --- code/boot.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/boot.js b/code/boot.js index 0539fa42..fcc04011 100644 --- a/code/boot.js +++ b/code/boot.js @@ -171,20 +171,20 @@ window.setupMap = function() { var t = (i === 0 ? 'Unclaimed' : 'Level ' + i) + ' Portals'; addLayers[t] = portalsLayers[i]; // Store it in hiddenLayer to remove later - if(!isLayerGroupDisplayed(t)) hiddenLayer.push(portalsLayers[i]); + if(!isLayerGroupDisplayed(t, true)) hiddenLayer.push(portalsLayers[i]); } fieldsLayer = L.layerGroup([]); map.addLayer(fieldsLayer, true); addLayers['Fields'] = fieldsLayer; // Store it in hiddenLayer to remove later - if(!isLayerGroupDisplayed('Fields')) hiddenLayer.push(fieldsLayer); + if(!isLayerGroupDisplayed('Fields', true)) hiddenLayer.push(fieldsLayer); linksLayer = L.layerGroup([]); map.addLayer(linksLayer, true); addLayers['Links'] = linksLayer; // Store it in hiddenLayer to remove later - if(!isLayerGroupDisplayed('Links')) hiddenLayer.push(linksLayer); + if(!isLayerGroupDisplayed('Links', true)) hiddenLayer.push(linksLayer); window.layerChooser = new L.Control.Layers({ 'MapQuest OSM': views[0], From 0eaf076a750f621d3c408d454df788d1a6d65578 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 7 May 2013 19:41:37 +0200 Subject: [PATCH 6/8] made action bar optional in fullscreen mode (see #216) --- mobile/res/values/strings.xml | 6 ++++-- mobile/res/xml/preferences.xml | 11 ++++++++--- mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/mobile/res/values/strings.xml b/mobile/res/values/strings.xml index d1fd5f71..9316a1f0 100644 --- a/mobile/res/values/strings.xml +++ b/mobile/res/values/strings.xml @@ -34,10 +34,12 @@ Misc Plugins Available plugins - Show zoom control - Shows +/- buttons even on multitouch capable devices. Display user location Show users position on map + Show zoom control + Shows +/- buttons even on multitouch capable devices. + Hide Action Bar in fullscreen mode + Nice for screenshots. Note: IITCM cannot be controlled without Action Bar. Force https Disabling may improve performance Developer options diff --git a/mobile/res/xml/preferences.xml b/mobile/res/xml/preferences.xml index 5cd6e03d..f986bc1e 100644 --- a/mobile/res/xml/preferences.xml +++ b/mobile/res/xml/preferences.xml @@ -12,15 +12,20 @@ + diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java index 0ab3510b..03f8cdf4 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java @@ -39,6 +39,7 @@ public class IITC_Mobile extends Activity { private LocationListener loc_listener = null; private boolean keyboad_open = false; private boolean fullscreen_mode = false; + private boolean fullscreen_actionbar = false; private ActionBar actionBar; @Override @@ -58,6 +59,7 @@ public class IITC_Mobile extends Activity { actionBar.setTitle(getString(R.string.menu_map)); actionBar.setHomeButtonEnabled(true); + // do something if user changed something in the settings SharedPreferences sharedPref = PreferenceManager .getDefaultSharedPreferences(this); listener = new OnSharedPreferenceChangeListener() { @@ -67,6 +69,12 @@ public class IITC_Mobile extends Activity { if (key.equals("pref_user_loc")) user_loc = sharedPreferences.getBoolean("pref_user_loc", false); + if (key.equals("pref_fullscreen_actionbar")) { + fullscreen_actionbar =sharedPreferences.getBoolean("pref_fullscreen_actionbar", + false); + if (fullscreen_mode) + IITC_Mobile.this.getActionBar().hide(); + } IITC_Mobile.this.loadUrl(intel_url); } }; @@ -222,6 +230,8 @@ public class IITC_Mobile extends Activity { public void onBackPressed() { // leave fullscreen mode if it is enabled if (fullscreen_mode) { + if (fullscreen_actionbar) + this.getActionBar().show(); // show notification bar again WindowManager.LayoutParams attrs = getWindow().getAttributes(); attrs.flags ^= WindowManager.LayoutParams.FLAG_FULLSCREEN; @@ -280,6 +290,8 @@ public class IITC_Mobile extends Activity { // toggle fullscreen case R.id.toggle_fullscreen : if (!this.fullscreen_mode) { + if (fullscreen_actionbar) + this.getActionBar().hide(); // hide notification bar WindowManager.LayoutParams attrs = getWindow() .getAttributes(); @@ -291,6 +303,8 @@ public class IITC_Mobile extends Activity { "Press back button to exit fullscreen", Toast.LENGTH_SHORT).show(); } else { + if (fullscreen_actionbar) + this.getActionBar().show(); // show notification bar again WindowManager.LayoutParams attrs = getWindow() .getAttributes(); From f3fae16fe668b88bc8a0b642830f2e1fb3fa1353 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 7 May 2013 20:28:17 +0200 Subject: [PATCH 7/8] set fetch dev-mode default value to false --- mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java index 9a32366f..f606d5ac 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java @@ -142,7 +142,7 @@ public class IITC_WebViewClient extends WebViewClient { SharedPreferences sharedPref = PreferenceManager .getDefaultSharedPreferences(context); Set plugin_list = sharedPref.getStringSet("pref_plugins", null); - boolean dev_enabled = sharedPref.getBoolean("pref_dev_checkbox", true); + boolean dev_enabled = sharedPref.getBoolean("pref_dev_checkbox", false); // iterate through all enabled plugins and load them if (plugin_list != null) { From 6e72f516e6d808e667079ccc2e19fecde9cae1f5 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 7 May 2013 22:04:34 +0200 Subject: [PATCH 8/8] load actionbar setting onCreate too (see #216) --- mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java index 03f8cdf4..47deeccc 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java @@ -137,6 +137,8 @@ public class IITC_Mobile extends Activity { loc_listener); } + fullscreen_actionbar = sharedPref.getBoolean("pref_fullscreen_actionbar", false); + // load new iitc web view with ingress intel page Intent intent = getIntent(); String action = intent.getAction();