From aa6581fb85a712179197598f0e0d5756ac28c4e6 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sun, 14 Apr 2013 19:27:15 -0700 Subject: [PATCH 01/46] Make any nickname class element clickible to fill @ nick in chat --- code/chat.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/code/chat.js b/code/chat.js index 919ce854..6efaf839 100644 --- a/code/chat.js +++ b/code/chat.js @@ -241,7 +241,8 @@ window.chat.renderFull = function(oldMsgsWereAdded) { // common // -window.chat.nicknameClicked = function(event, nickname) { +window.chat.nicknameClicked = function(event, nickname, dom) { + nickname = nickname ? nickname : $(dom).text(); var hookData = { event: event, nickname: nickname }; if (window.runHooks('nicknameClicked', hookData)) { @@ -410,7 +411,7 @@ window.chat.renderMsg = function(msg, nick, time, team, msgToPlayer, systemNarro var s = 'style="cursor:pointer; color:'+color+'"'; var title = nick.length >= 8 ? 'title="'+nick+'" class="help"' : ''; var i = ['<', '>']; - return ''+t+''+i[0]+''+ nick+''+i[1]+''+msg+''; + return ''+t+''+i[0]+''+ nick+''+i[1]+''+msg+''; } window.chat.addNickname= function(nick){ @@ -589,7 +590,11 @@ window.chat.setup = function() { window.requests.addRefreshFunction(chat.request); var cls = PLAYER.team === 'ALIENS' ? 'enl' : 'res'; - $('#chatinput mark').addClass(cls) + $('#chatinput mark').addClass(cls); + + $(window).on('click', '.nickname', function(event) { + window.chat.nicknameClicked(event, null, this); + }); } From eb7d021449450e0db70058fa3553bee6a3f041a3 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sun, 14 Apr 2013 19:32:07 -0700 Subject: [PATCH 02/46] Double space issue when clicking a nickname with a space already present in chat --- code/chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/chat.js b/code/chat.js index 6efaf839..2038c2bf 100644 --- a/code/chat.js +++ b/code/chat.js @@ -416,7 +416,7 @@ window.chat.renderMsg = function(msg, nick, time, team, msgToPlayer, systemNarro window.chat.addNickname= function(nick){ var c = document.getElementById("chattext"); - c.value = [c.value, nick, " "].join(" ").trim() + " "; + c.value = [c.value.trim(), nick].join(" ").trim() + " "; c.focus() } From e4d3c0d9f0a5742ac3520dad775caaa85c89d38d Mon Sep 17 00:00:00 2001 From: Kevin Date: Sun, 14 Apr 2013 19:42:05 -0700 Subject: [PATCH 03/46] Change cursor to pointer on any nickname class element --- style.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/style.css b/style.css index c208f48e..96247477 100644 --- a/style.css +++ b/style.css @@ -68,6 +68,10 @@ body { color: #fff; } +.nickname { + cursor: pointer !important; +} + a { color: #ffce00; cursor: pointer; From 2719d3bc98aea822f58b3c3507487db30995f9c6 Mon Sep 17 00:00:00 2001 From: vita10gy Date: Mon, 15 Apr 2013 00:13:57 -0500 Subject: [PATCH 04/46] extras --- main.js | 2 +- style.css | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 77443adf..5b31324b 100644 --- a/main.js +++ b/main.js @@ -87,7 +87,7 @@ document.getElementsByTagName('body')[0].innerHTML = '' + '
 loading global control stats
' + '
' + ' ' - + ' ' + + ' ' + '
' + '
' + ' ' diff --git a/style.css b/style.css index e3ea2d2f..b90831ce 100644 --- a/style.css +++ b/style.css @@ -434,6 +434,7 @@ input { #geosearchwrapper img{ vertical-align: bottom; margin-bottom: 2px; + cursor: pointer; } ::-webkit-input-placeholder { font-style: italic; From 032f70eb6ff74da716a869e9637218ae14c810e9 Mon Sep 17 00:00:00 2001 From: Kevin Date: Mon, 15 Apr 2013 02:03:42 -0700 Subject: [PATCH 05/46] Show linked portals quote bugfix --- plugins/show-linked-portals.user.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/show-linked-portals.user.js b/plugins/show-linked-portals.user.js index a42003d0..e380557c 100644 --- a/plugins/show-linked-portals.user.js +++ b/plugins/show-linked-portals.user.js @@ -71,9 +71,18 @@ window.plugin.showLinkedPortal.getPortalByGuid = function (guid) { var portalDetails = window.portals[guid].options.details; portalInfoString = ''; var portalNameAdressAlt = "'" + portalDetails.portalV2.descriptiveText.TITLE + "' (" + portalDetails.portalV2.descriptiveText.ADDRESS + ")"; - var portalNameAdressTitle = "'" + portalDetails.portalV2.descriptiveText.TITLE + "'
(" + portalDetails.portalV2.descriptiveText.ADDRESS + ")"; + var portalNameAdressTitle = $('
').append('\'') + .append($('').text(portalDetails.portalV2.descriptiveText.TITLE)) + .append('\'') + .append($('
')) + .append($('').text('(' + portalDetails.portalV2.descriptiveText.ADDRESS + ')')) + .html(); var imageUrl = (portalDetails.imageByUrl ? portalDetails.imageByUrl.imageUrl : window.DEFAULT_PORTAL_IMG); - portalInfoString = '' + portalNameAdressAlt + ''; + portalInfoString = $('
').html($('').attr('src', imageUrl) + .attr('class', 'minImg') + .attr('alt', portalNameAdressAlt) + .attr('title', portalNameAdressTitle)) + .html(); } return portalInfoString; }; From 83a20f3f0b35024855e64fb36cef01788027fc30 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 16 Apr 2013 23:37:53 +0200 Subject: [PATCH 06/46] updated mobile hacking.md --- mobile/HACKING.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/mobile/HACKING.md b/mobile/HACKING.md index 3a7c2976..fdaa464f 100644 --- a/mobile/HACKING.md +++ b/mobile/HACKING.md @@ -1,7 +1,11 @@ How does this basically work? ----------------------------- -At the moment, the Android App is nothing more then a WebView which renders the normal web page. The IITC script is injected on page load and after this, it works the same way as on desktop browser. More functionality will be added soon... +At the moment, the Android App is a WebView which renders the normal web page. The IITC script is injected before page load and after this, it works the same way as on desktop browser. + +Communication from app to script is handled by loading Javascript function calls. For example: ```iitc_view.loadUrl("javascript: window.goBack();");``` + +Communication from script to app is handled by the JavascriptInterface (see /mobile/src/com/cradle/iitc\_mobile/IITC_JSInterface.java). If a method ```foo(String)``` is defined in JSInterface, it can be with by ```android.foo("Hello World")``` in the IITC script. Debugging --------- @@ -16,13 +20,8 @@ Debugging IITC(M) **before** it has booted requires the Android Developer Tools. Building the APK ---------------- -- **Eclipse:** Just import this project and klick the build button. - **ant:** Set the ANDROID_HOME environment variable: ```export ANDROID_HOME=/path/to/android_sdk``` - and build the project with ant: - `ant debug` -- You can use `build_mobile.js`, too, which builds IITC, compresses - it and uses ant to build a release APK of IITCM. It requires that - you have Python and uglifyjs installed. You need to set the - `ANDROID_HOME`, like explained above. + Then build the app via the build.py script ```./build.py mobile``` +- **Eclipse:** Just import this project and klick the build button. Ensure that you have iitc.js in your assets folder. This is automatically created, when executing ```./build.py mobile```. Otherwise, just copy the IITC script to the assets folder and rename it to iitc.js From 4ebade124527798cac06d3bee78221b2d0b30266 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 16 Apr 2013 23:40:05 +0200 Subject: [PATCH 07/46] updated mobile readme --- mobile/README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mobile/README.md b/mobile/README.md index a12f1568..c57da39f 100644 --- a/mobile/README.md +++ b/mobile/README.md @@ -1,6 +1,4 @@ -ingress intel total conversion (IITC) +ingress intel total conversion mobile (IITCM) ===================================== -# [User documentation moved to the wiki. Please see there!](https://github.com/breunigs/ingress-intel-total-conversion/wiki/IITC-Mobile) - -### [For developer docs, please see HACKING.md](https://github.com/breunigs/ingress-intel-total-conversion/blob/gh-pages/mobile/HACKING.md) +### [For developer docs, please see HACKING.md](https://github.com/jonatkins/ingress-intel-total-conversion/blob/master/mobile/HACKING.md) From 88ee267c66933daff3a4adb1a8ab38fa6bb4fa9f Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 16 Apr 2013 23:48:12 +0200 Subject: [PATCH 08/46] updated HACKING.md --- mobile/HACKING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/HACKING.md b/mobile/HACKING.md index fdaa464f..71a9449e 100644 --- a/mobile/HACKING.md +++ b/mobile/HACKING.md @@ -5,7 +5,7 @@ At the moment, the Android App is a WebView which renders the normal web page. T Communication from app to script is handled by loading Javascript function calls. For example: ```iitc_view.loadUrl("javascript: window.goBack();");``` -Communication from script to app is handled by the JavascriptInterface (see /mobile/src/com/cradle/iitc\_mobile/IITC_JSInterface.java). If a method ```foo(String)``` is defined in JSInterface, it can be with by ```android.foo("Hello World")``` in the IITC script. +Communication from script to app is handled by the JavascriptInterface (see /mobile/src/com/cradle/iitc\_mobile/IITC_JSInterface.java). If a method ```foo(String)``` is defined in JSInterface, it can be called by ```android.foo("Hello World")``` in the IITC script. Debugging --------- From b7329a611c67308fb86d5f64d031ef387136afdd Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Wed, 17 Apr 2013 00:00:56 +0200 Subject: [PATCH 09/46] updated mobile README.md --- mobile/README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/mobile/README.md b/mobile/README.md index c57da39f..24bed1fc 100644 --- a/mobile/README.md +++ b/mobile/README.md @@ -1,4 +1,22 @@ ingress intel total conversion mobile (IITCM) ===================================== +The Android App behaves like the desktop version, but uses the mobile view, which is optimized for mobile devices, as default. Furthermore, there are some nice additions: + +- it should be much faster than the standard mobile ingress intel map + +- a gmaps intent is sent, when a portals Map link is clicked (lets you navigate to portals) + +- a geolocate button (you have to enable GPS satellites + location access to use this feature) + +- toggle between desktop and mobile view (nice for tablets) + +- possibility to use a custom IITC script source + +- a click on Portal link copies it to clipboard + +- more features will be added soon... + +**The App only works with Android 4.0+** + ### [For developer docs, please see HACKING.md](https://github.com/jonatkins/ingress-intel-total-conversion/blob/master/mobile/HACKING.md) From 6b04ee4939992444a9889804bc0014028a9e8358 Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 16 Apr 2013 15:04:26 -0700 Subject: [PATCH 10/46] Don't modify nicknameClicked function, pull name in event calling function --- code/chat.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/code/chat.js b/code/chat.js index 2038c2bf..df42dd2a 100644 --- a/code/chat.js +++ b/code/chat.js @@ -241,8 +241,7 @@ window.chat.renderFull = function(oldMsgsWereAdded) { // common // -window.chat.nicknameClicked = function(event, nickname, dom) { - nickname = nickname ? nickname : $(dom).text(); +window.chat.nicknameClicked = function(event, nickname) { var hookData = { event: event, nickname: nickname }; if (window.runHooks('nicknameClicked', hookData)) { @@ -593,7 +592,7 @@ window.chat.setup = function() { $('#chatinput mark').addClass(cls); $(window).on('click', '.nickname', function(event) { - window.chat.nicknameClicked(event, null, this); + window.chat.nicknameClicked(event, $(this).text()); }); } From acc0db1ce87528fb705047c195d3608efc4d8678 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Wed, 17 Apr 2013 00:12:44 +0200 Subject: [PATCH 11/46] one more update for HACKING.md --- mobile/HACKING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/HACKING.md b/mobile/HACKING.md index 71a9449e..cfa2a9ae 100644 --- a/mobile/HACKING.md +++ b/mobile/HACKING.md @@ -1,7 +1,7 @@ How does this basically work? ----------------------------- -At the moment, the Android App is a WebView which renders the normal web page. The IITC script is injected before page load and after this, it works the same way as on desktop browser. +At the moment, the Android App is a WebView which renders the normal web page. The IITC script is injected by calling the ```iitc_view.loadIITC_JS(Context)```. The app uses a local version of the script, which is located in the assets folder, if no external source is given (see "pref\_iitc\_source"). Communication from app to script is handled by loading Javascript function calls. For example: ```iitc_view.loadUrl("javascript: window.goBack();");``` From 901d30287ac2082dc40d66f94b83799756479c65 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Wed, 17 Apr 2013 00:13:39 +0200 Subject: [PATCH 12/46] fixed typo --- mobile/HACKING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/HACKING.md b/mobile/HACKING.md index cfa2a9ae..76d8d54e 100644 --- a/mobile/HACKING.md +++ b/mobile/HACKING.md @@ -1,7 +1,7 @@ How does this basically work? ----------------------------- -At the moment, the Android App is a WebView which renders the normal web page. The IITC script is injected by calling the ```iitc_view.loadIITC_JS(Context)```. The app uses a local version of the script, which is located in the assets folder, if no external source is given (see "pref\_iitc\_source"). +At the moment, the Android App is a WebView which renders the normal web page. The IITC script is injected by calling ```iitc_view.loadIITC_JS(Context)```. The app uses a local version of the script, which is located in the assets folder, if no external source is given (see "pref\_iitc\_source"). Communication from app to script is handled by loading Javascript function calls. For example: ```iitc_view.loadUrl("javascript: window.goBack();");``` From 9d350b206eb5909eee178524ecb22c3c1d71802b Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Tue, 16 Apr 2013 23:51:35 +0100 Subject: [PATCH 13/46] add background colour to large portal images - as some (e.g. zipcar) have transparency --- style.css | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/style.css b/style.css index 458b905f..fc043a41 100644 --- a/style.css +++ b/style.css @@ -692,9 +692,8 @@ h3 { } #largepreview img { box-shadow: 0 0 40px #000; -} -#largepreview img { border: 2px solid #f8ff5e; + background-color: rgba(8, 48, 78, 0.9); /* as some images - eg ZipCar - have transparency */ } /* tooltips, dialogs */ From ae8200d7be3a9ef5fff69bb819345335e56dd729 Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 16 Apr 2013 20:18:21 -0700 Subject: [PATCH 14/46] Add ATTRIBUTION.md to About IITC pop up --- build.py | 30 ++++++++++++++++++++++++++++++ code/utils_misc.js | 10 +++++++--- style.css | 5 +++++ 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/build.py b/build.py index 42b1e4bf..e8389985 100755 --- a/build.py +++ b/build.py @@ -8,6 +8,10 @@ import base64 import sys import os import shutil +import json +import urllib2 +import shelve +import hashlib # load settings file @@ -66,6 +70,31 @@ def loaderRaw(var): fn = var.group(1) return readfile(fn) +def loaderGFM(var): + fn = var.group(1) + db = shelve.open('build/GFM.dat') + if db.has_key('files'): + files = db['files'] + else: + files = {} + file = readfile(fn) + filemd5 = hashlib.md5(file).hexdigest() + # check if file has already been parsed by the github api + if fn in files and filemd5 in files[fn]: + # use the stored copy if nothing has changed to avoid hiting the api more then the 60/hour when not signed in + return files[fn][filemd5] + else: + url = 'https://api.github.com/markdown' + payload = {'text': readfile(fn), 'mode': 'gfm', 'context': 'jonatkins/ingress-intel-total-conversion'} + req = urllib2.Request(url) + req.add_header('Content-Type', 'application/json') + gfm = urllib2.urlopen(req, json.dumps(payload)).read().replace('\n', '').replace('\'', '\\\'') + files[fn] = {} + files[fn][filemd5] = gfm + db['files'] = files + db.close() + return gfm + def loaderImage(var): fn = var.group(1) return 'data:image/png;base64,{0}'.format(base64.encodestring(open(fn, 'rb').read()).decode('utf8').replace('\n', '')) @@ -86,6 +115,7 @@ def doReplacements(script,updateUrl,downloadUrl): script = re.sub('@@INCLUDERAW:([0-9a-zA-Z_./-]+)@@', loaderRaw, script) script = re.sub('@@INCLUDESTRING:([0-9a-zA-Z_./-]+)@@', loaderString, script) + script = re.sub('@@INCLUDEGFM:([0-9a-zA-Z_./-]+)@@', loaderGFM, script) script = re.sub('@@INCLUDEIMAGE:([0-9a-zA-Z_./-]+)@@', loaderImage, script) script = script.replace('@@BUILDDATE@@', buildDate) diff --git a/code/utils_misc.js b/code/utils_misc.js index 84562c92..394ded79 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -1,7 +1,8 @@ // UTILS + MISC /////////////////////////////////////////////////////// window.aboutIITC = function(){ - var v = '@@BUILDNAME@@-@@BUILDDATE@@' + var v = '@@BUILDNAME@@-@@BUILDDATE@@'; + var attrib = '@@INCLUDEGFM:ATTRIBUTION.md@@'; var a = '' + '
About IITC
' + '
Ingress Intel Total Conversion
' @@ -20,8 +21,11 @@ window.aboutIITC = function(){ + ' MapQuest OSM tiles Courtesy of MapQuest ' + '
' + '
' - + '
Version: ' + v + '
'; - alert(a); + + '
Version: ' + v + '
' + + '
' + + '
' + attrib + '
'; + alert(a, true, function() {$('.ui-dialog').removeClass('ui-dialog-aboutIITC');}); + $('.ui-dialog').addClass('ui-dialog-aboutIITC'); } diff --git a/style.css b/style.css index fc043a41..c9ac9dd2 100644 --- a/style.css +++ b/style.css @@ -762,6 +762,11 @@ h3 { text-decoration: underline; } +.ui-dialog-aboutIITC { + max-width: 600px !important; + width: 600px !important; +} + td { padding: 0; vertical-align: top; From d59e2e2816562ac9e4f093fd426e9a6bfcafefbc Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 16 Apr 2013 20:22:09 -0700 Subject: [PATCH 15/46] Use already read file instead of rereading --- build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.py b/build.py index e8389985..e7acaa1c 100755 --- a/build.py +++ b/build.py @@ -85,7 +85,7 @@ def loaderGFM(var): return files[fn][filemd5] else: url = 'https://api.github.com/markdown' - payload = {'text': readfile(fn), 'mode': 'gfm', 'context': 'jonatkins/ingress-intel-total-conversion'} + payload = {'text': file, 'mode': 'gfm', 'context': 'jonatkins/ingress-intel-total-conversion'} req = urllib2.Request(url) req.add_header('Content-Type', 'application/json') gfm = urllib2.urlopen(req, json.dumps(payload)).read().replace('\n', '').replace('\'', '\\\'') From f767b939ad623fd00f67bc9dc3330dd6fc98ce52 Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 16 Apr 2013 20:30:25 -0700 Subject: [PATCH 16/46] Only need markdown and not GFM for .md files --- build.py | 6 +++--- code/utils_misc.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.py b/build.py index e7acaa1c..9c84031f 100755 --- a/build.py +++ b/build.py @@ -70,7 +70,7 @@ def loaderRaw(var): fn = var.group(1) return readfile(fn) -def loaderGFM(var): +def loaderMD(var): fn = var.group(1) db = shelve.open('build/GFM.dat') if db.has_key('files'): @@ -85,7 +85,7 @@ def loaderGFM(var): return files[fn][filemd5] else: url = 'https://api.github.com/markdown' - payload = {'text': file, 'mode': 'gfm', 'context': 'jonatkins/ingress-intel-total-conversion'} + payload = {'text': file, 'mode': 'markdown'} req = urllib2.Request(url) req.add_header('Content-Type', 'application/json') gfm = urllib2.urlopen(req, json.dumps(payload)).read().replace('\n', '').replace('\'', '\\\'') @@ -115,7 +115,7 @@ def doReplacements(script,updateUrl,downloadUrl): script = re.sub('@@INCLUDERAW:([0-9a-zA-Z_./-]+)@@', loaderRaw, script) script = re.sub('@@INCLUDESTRING:([0-9a-zA-Z_./-]+)@@', loaderString, script) - script = re.sub('@@INCLUDEGFM:([0-9a-zA-Z_./-]+)@@', loaderGFM, script) + script = re.sub('@@INCLUDEMD:([0-9a-zA-Z_./-]+)@@', loaderMD, script) script = re.sub('@@INCLUDEIMAGE:([0-9a-zA-Z_./-]+)@@', loaderImage, script) script = script.replace('@@BUILDDATE@@', buildDate) diff --git a/code/utils_misc.js b/code/utils_misc.js index 394ded79..4d12fcd9 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -2,7 +2,7 @@ window.aboutIITC = function(){ var v = '@@BUILDNAME@@-@@BUILDDATE@@'; - var attrib = '@@INCLUDEGFM:ATTRIBUTION.md@@'; + var attrib = '@@INCLUDEMD:ATTRIBUTION.md@@'; var a = '' + '
About IITC
' + '
Ingress Intel Total Conversion
' From 60a65d227a5e34873d4ba2ba2a663ceade6e0869 Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 16 Apr 2013 20:34:02 -0700 Subject: [PATCH 17/46] More changes from gfm to md --- build.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.py b/build.py index 9c84031f..41ea60e8 100755 --- a/build.py +++ b/build.py @@ -72,7 +72,7 @@ def loaderRaw(var): def loaderMD(var): fn = var.group(1) - db = shelve.open('build/GFM.dat') + db = shelve.open('build/MD.dat') if db.has_key('files'): files = db['files'] else: @@ -88,12 +88,12 @@ def loaderMD(var): payload = {'text': file, 'mode': 'markdown'} req = urllib2.Request(url) req.add_header('Content-Type', 'application/json') - gfm = urllib2.urlopen(req, json.dumps(payload)).read().replace('\n', '').replace('\'', '\\\'') + md = urllib2.urlopen(req, json.dumps(payload)).read().replace('\n', '').replace('\'', '\\\'') files[fn] = {} - files[fn][filemd5] = gfm + files[fn][filemd5] = md db['files'] = files db.close() - return gfm + return md def loaderImage(var): fn = var.group(1) From 0a1857130897741046e45ad55cb42f0464c9adb0 Mon Sep 17 00:00:00 2001 From: vita10gy Date: Tue, 16 Apr 2013 23:04:06 -0500 Subject: [PATCH 18/46] Fix desktop geosearch on mobile #154. Mobile seems messed up though. (Even without these changes.) Not sure if something is off with my build, or if something else changed. This should fix though. --- mobile/smartphone.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mobile/smartphone.css b/mobile/smartphone.css index ff2ead8a..fa7e937a 100644 --- a/mobile/smartphone.css +++ b/mobile/smartphone.css @@ -19,6 +19,14 @@ body { } +#geosearch{ + width:301px; +} + +#geosearchwrapper img{ + display:none; +} + #chatcontrols { height: 38px; width: 100%; From fe7d782b717eab66dfa8f37650962741c7305396 Mon Sep 17 00:00:00 2001 From: vita10gy Date: Tue, 16 Apr 2013 23:36:38 -0500 Subject: [PATCH 19/46] New Highlighter New AP/Energy Highligher, reword previous names. --- ...hlighter-portal-ap-energy-relative.user.js | 118 ++++++++++++++++++ ...tal-highlighter-portal-ap-relative.user.js | 4 +- plugins/portal-highlighter-portal-ap.user.js | 2 +- 3 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 plugins/portal-highlighter-portal-ap-energy-relative.user.js diff --git a/plugins/portal-highlighter-portal-ap-energy-relative.user.js b/plugins/portal-highlighter-portal-ap-energy-relative.user.js new file mode 100644 index 00000000..677c2ab5 --- /dev/null +++ b/plugins/portal-highlighter-portal-ap-energy-relative.user.js @@ -0,0 +1,118 @@ +// ==UserScript== +// @id iitc-plugin-highlight-portals-by-ap-by-energy-relative@vita10gy +// @name IITC plugin: highlight portals by ap/energy (relative) +// @version 0.1.1.@@DATETIMEVERSION@@ +// @namespace https://github.com/jonatkins/ingress-intel-total-conversion +// @updateURL @@UPDATEURL@@ +// @downloadURL @@DOWNLOADURL@@ +// @description [@@BUILDNAME@@-@@BUILDDATE@@] Uses the fill color of the portals to denote AP/Energy value relative to what's currently on the screen. Brighter is better. Orange means your standard 8 down 8 up swap. +// @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== + +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.portalHighligherPortalAPPerEnergyRelative = function() {}; + +window.plugin.portalHighligherPortalAPPerEnergyRelative.minAP = null; +window.plugin.portalHighligherPortalAPPerEnergyRelative.maxAP = null; +//This is the AP for a run of the mill takedown/putback +window.plugin.portalHighligherPortalAPPerEnergyRelative.baseSwapAP = 2350; + + +window.plugin.portalHighligherPortalAPPerEnergyRelative.highlight = function(data) { + var d = data.portal.options.details; + var color = 'red'; + + if(window.plugin.portalHighligherPortalAPPerEnergyRelative.minAP == null || + window.plugin.portalHighligherPortalAPPerEnergyRelative.maxAP == null) { + window.plugin.portalHighligherPortalAPPerEnergyRelative.calculateAPLevels(); + } + var minApE = window.plugin.portalHighligherPortalAPPerEnergyRelative.minAP; + var maxApE = window.plugin.portalHighligherPortalAPPerEnergyRelative.maxAP; + + if(PLAYER.team !== d.controllingTeam.team) { + var ap = getAttackApGain(d); + var energy = getCurrentPortalEnergy(d); + if(energy < 1) { + energy = 1; + } + portal_ap = ap.enemyAp; + + var opacity = 1; + if(minApE !== maxApE) { + opacity = ((ap.enemyAp / energy) - minApE) / (maxApE - minApE); + } + + if(opacity < 0) { + opacity = 0; + } + if(opacity > 1) { + opacity = 1; + } + data.portal.setStyle({fillColor: color, fillOpacity: opacity}); + window.COLOR_SELECTED_PORTAL = '#f0f'; + } +} + +window.plugin.portalHighligherPortalAPPerEnergyRelative.resetAPLevels = function() { + window.plugin.portalHighligherPortalAPPerEnergyRelative.minAP = null; + window.plugin.portalHighligherPortalAPPerEnergyRelative.maxAP = null; +} + +window.plugin.portalHighligherPortalAPPerEnergyRelative.calculateAPLevels = function() { + var displayBounds = map.getBounds(); + $.each(window.portals, function(qk, portal) { + if(displayBounds.contains(portal.getLatLng())) { + if(PLAYER.team !== portal.options.details.controllingTeam.team) { + var ap = getAttackApGain(portal.options.details); + var energy = getCurrentPortalEnergy(portal.options.details); + if(energy < 1) { + energy = 1; + } + var portal_ap = ap.enemyAp / energy; + if(window.plugin.portalHighligherPortalAPPerEnergyRelative.minAP === null || + portal_ap < window.plugin.portalHighligherPortalAPPerEnergyRelative.minAP) { + window.plugin.portalHighligherPortalAPPerEnergyRelative.minAP = portal_ap; + } + if(window.plugin.portalHighligherPortalAPPerEnergyRelative.maxAP === null || + portal_ap > window.plugin.portalHighligherPortalAPPerEnergyRelative.maxAP) { + window.plugin.portalHighligherPortalAPPerEnergyRelative.maxAP = portal_ap; + } + + } + } + }); +} + + + +var setup = function() { + window.addPortalHighlighter('AP/Energy (Relative)', window.plugin.portalHighligherPortalAPPerEnergyRelative.highlight); + window.addHook('requestFinished', window.plugin.portalHighligherPortalAPPerEnergyRelative.resetAPLevels); + +} + +// 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); diff --git a/plugins/portal-highlighter-portal-ap-relative.user.js b/plugins/portal-highlighter-portal-ap-relative.user.js index 08059865..a96941bb 100644 --- a/plugins/portal-highlighter-portal-ap-relative.user.js +++ b/plugins/portal-highlighter-portal-ap-relative.user.js @@ -90,10 +90,8 @@ window.plugin.portalHighligherPortalAPRelative.calculateAPLevels = function() { }); } - - var setup = function() { - window.addPortalHighlighter('Portal AP (Relative)', window.plugin.portalHighligherPortalAPRelative.highlight); + window.addPortalHighlighter('AP (Relative)', window.plugin.portalHighligherPortalAPRelative.highlight); window.addHook('requestFinished', window.plugin.portalHighligherPortalAPRelative.resetAPLevels); } diff --git a/plugins/portal-highlighter-portal-ap.user.js b/plugins/portal-highlighter-portal-ap.user.js index 3dc17f6c..30ced897 100644 --- a/plugins/portal-highlighter-portal-ap.user.js +++ b/plugins/portal-highlighter-portal-ap.user.js @@ -54,7 +54,7 @@ window.plugin.portalHighligherPortalAP.highlight = function(data) { } var setup = function() { - window.addPortalHighlighter('Portal AP', window.plugin.portalHighligherPortalAP.highlight); + window.addPortalHighlighter('AP (Static)', window.plugin.portalHighligherPortalAP.highlight); } // PLUGIN END ////////////////////////////////////////////////////////// From 11d5b54ea4df2c73ad02ea1434399aa556fcaf9d Mon Sep 17 00:00:00 2001 From: vita10gy Date: Tue, 16 Apr 2013 23:53:10 -0500 Subject: [PATCH 20/46] Color by Portal level One of the more frequently requested, but IMO useless, features. --- .../portal-highlighter-level-color.user.js | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 plugins/portal-highlighter-level-color.user.js diff --git a/plugins/portal-highlighter-level-color.user.js b/plugins/portal-highlighter-level-color.user.js new file mode 100644 index 00000000..ac6344ff --- /dev/null +++ b/plugins/portal-highlighter-level-color.user.js @@ -0,0 +1,51 @@ +// ==UserScript== +// @id iitc-plugin-highlight-portals-level-color@vita10gy +// @name IITC plugin: highlight portals by level color +// @version 0.1.0.@@DATETIMEVERSION@@ +// @namespace https://github.com/jonatkins/ingress-intel-total-conversion +// @updateURL @@UPDATEURL@@ +// @downloadURL @@DOWNLOADURL@@ +// @description [@@BUILDNAME@@-@@BUILDDATE@@] Uses the fill color of the portals level color. +// @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== + +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.portalHighligherPortalsLevelColor = function() {}; + +window.plugin.portalHighligherPortalsLevelColor.colorLevel = function(data) { + var d = data.portal.options.details; + var portal_level = Math.floor(getPortalLevel(d)); + var opacity = .6; + data.portal.setStyle({fillColor: COLORS_LVL[portal_level], fillOpacity: opacity}); + window.COLOR_SELECTED_PORTAL = '#f0f'; +} + +var setup = function() { + window.addPortalHighlighter('Level Color', window.plugin.portalHighligherPortalsLevelColor.colorLevel); +} + +// 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 86a7996db56dc921f8add7ab2ecd8925bfc91b48 Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 17 Apr 2013 22:53:14 -0700 Subject: [PATCH 21/46] Change portal image urls to https if necessary in the portal object --- code/map_data.js | 10 +++++++++- code/portal_detail_display.js | 5 +---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/code/map_data.js b/code/map_data.js index 45af74c3..317d7877 100644 --- a/code/map_data.js +++ b/code/map_data.js @@ -105,7 +105,15 @@ window.handleDataResponse = function(data, textStatus, jqXHR) { && urlPortal !== ent[0] ) return; - + if('imageByUrl' in ent[2] && 'imageUrl' in ent[2].imageByUrl) { + if(window.location.protocol === 'https:') { + ent[2].imageByUrl.imageUrl = ent[2].imageByUrl.imageUrl.indexOf('www.panoramio.com') !== -1 + ? ent[2].imageByUrl.imageUrl.replace(/^http:\/\/www/, 'https://ssl').replace('small', 'medium') + : ent[2].imageByUrl.imageUrl.replace(/^http:\/\//, '//'); + } + } else { + ent[2].imageByUrl = {'imageUrl': DEFAULT_PORTAL_IMG}; + } ppp.push(ent); // delay portal render } else if(ent[2].edge !== undefined) { diff --git a/code/portal_detail_display.js b/code/portal_detail_display.js index 8937da8f..636230ed 100644 --- a/code/portal_detail_display.js +++ b/code/portal_detail_display.js @@ -44,10 +44,7 @@ window.renderPortalDetails = function(guid) { var resoDetails = '' + getResonatorDetails(d) + '
'; setPortalIndicators(d); - var img = d.imageByUrl && d.imageByUrl.imageUrl - ? d.imageByUrl.imageUrl - : DEFAULT_PORTAL_IMG; - + var img = d.imageByUrl.imageUrl; var lat = d.locationE6.latE6; var lng = d.locationE6.lngE6; var perma = '/intel?latE6='+lat+'&lngE6='+lng+'&z=17&pguid='+guid; From 07a07b0e24e29844a32b80aca64391b8e8c9817c Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Thu, 18 Apr 2013 15:39:17 +0100 Subject: [PATCH 22/46] mapquest map tiles support for https access --- code/boot.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/boot.js b/code/boot.js index 130f9265..59e54a7f 100644 --- a/code/boot.js +++ b/code/boot.js @@ -118,8 +118,9 @@ window.setupMap = function() { //MapQuest offer tiles - http://developer.mapquest.com/web/products/open/map //their usage policy has no limits (except required notification above 4000 tiles/sec - we're perhaps at 50 tiles/sec based on CloudMade stats) var mqSubdomains = [ 'otile1','otile2', 'otile3', 'otile4' ]; + var mqTileUrlPrefix = window.location.protocol !== 'https:' ? 'http://{s}.mqcdn.com' : 'https://{s}-s.mqcdn.com'; var mqMapOpt = {attribution: osmAttribution+', Tiles Courtesy of MapQuest', mazZoom: 18, detectRetena: true, subdomains: mqSubdomains}; - var mqMap = new L.TileLayer('http://{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpg',mqMapOpt); + var mqMap = new L.TileLayer(mqTileUrlPrefix+'/tiles/1.0.0/map/{z}/{x}/{y}.jpg',mqMapOpt); //MapQuest satellite coverage outside of the US is rather limited - so not really worth having as we have google as an option //var mqSatOpt = {attribution: 'Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency', mazZoom: 18, detectRetena: true, subdomains: mqSubdomains}; //var mqSat = new L.TileLayer('http://{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg',mqSatOpt); From f56f802d2c456cfe8bea5375052b88d909ca7f77 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Thu, 18 Apr 2013 15:46:52 +0100 Subject: [PATCH 23/46] additional fix #175 - should be ok now --- mobile/smartphone.css | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mobile/smartphone.css b/mobile/smartphone.css index fa7e937a..804f6a29 100644 --- a/mobile/smartphone.css +++ b/mobile/smartphone.css @@ -19,12 +19,12 @@ body { } -#geosearch{ - width:301px; +#geosearch { + width: 100%; } -#geosearchwrapper img{ - display:none; +#geosearchwrapper img { + display: none; } #chatcontrols { From 92bfd70eb042e07b584942b2442f04a8b23682d8 Mon Sep 17 00:00:00 2001 From: Xelio Date: Sat, 20 Apr 2013 02:39:10 +0800 Subject: [PATCH 24/46] Plugin AP List: Update description to reflect function changes --- plugins/ap-list.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/ap-list.user.js b/plugins/ap-list.user.js index c8a4d575..9bf1c09a 100644 --- a/plugins/ap-list.user.js +++ b/plugins/ap-list.user.js @@ -1,11 +1,11 @@ // ==UserScript== // @id iitc-plugin-ap-list@xelio // @name IITC plugin: AP List -// @version 0.5.1.@@DATETIMEVERSION@@ +// @version 0.5.2.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ -// @description [@@BUILDNAME@@-@@BUILDDATE@@] List top 10 portals by AP of either faction. Other functions and controls please refer to the Userguide. +// @description [@@BUILDNAME@@-@@BUILDDATE@@] List portals by AP of either faction or by effective level. Other functions and controls please refer to the Userguide. // @include https://www.ingress.com/intel* // @include http://www.ingress.com/intel* // @match https://www.ingress.com/intel* From d9f968a4bbbc29682e03bd2ce2a646cb1ac44d7f Mon Sep 17 00:00:00 2001 From: Peter Dietrich Date: Sat, 20 Apr 2013 00:28:15 +0200 Subject: [PATCH 25/46] Update ipas plugin to pass shield info --- plugins/ipas-link.user.js | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/plugins/ipas-link.user.js b/plugins/ipas-link.user.js index 50f7c994..814c6b6a 100644 --- a/plugins/ipas-link.user.js +++ b/plugins/ipas-link.user.js @@ -30,16 +30,34 @@ window.plugin.ipasLink.addLink = function(d) { $('.linkdetails').append(''); } -window.plugin.ipasLink.getHash = function(d) { - var hashParts=[]; - $.each(d.resonatorArray.resonators, function(ind, reso) { - if (reso) { - hashParts.push(reso.level + "," + reso.distanceToPortal + "," + reso.energyTotal); - } else { - hashParts.push(1 + "," + 35 + "," + 0); // Dummy values, the only important one is energy=0 - } - }); - return hashParts.join(";")+"|" + "0,0,0,0"; //shields not implemented yet +window.plugin.ipasLink.getHash = function (d) { + var hashParts = []; + $.each(d.resonatorArray.resonators, function (ind, reso) { + if (reso) { + hashParts.push(reso.level + "," + reso.distanceToPortal + "," + reso.energyTotal); + } else { + hashParts.push("1,20,0"); + } + }); + var resos = hashParts.join(";"); + + hashParts = []; + $.each(d.portalV2.linkedModArray, function (ind, mod) { + //shields only, so far... + var s = "0"; + if (mod) { + if (mod.type === "RES_SHIELD") { + s = mod.rarity.charAt(0).toLowerCase(); + } + } + hashParts.push(s); + }); + var shields = hashParts.join(","); + return resos + "|" + shields; +} + +var setup = function () { + window.plugin.ipasLink.setupCallback(); } var setup = function() { From 4b7a3103079c90d947c2d0c3eb08d453a24bbfcd Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Sat, 20 Apr 2013 03:09:31 +0100 Subject: [PATCH 26/46] bump ipas plugin version number --- plugins/ipas-link.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ipas-link.user.js b/plugins/ipas-link.user.js index 814c6b6a..ac158c10 100644 --- a/plugins/ipas-link.user.js +++ b/plugins/ipas-link.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @id iitc-plugin-ipas-link@graphracer // @name IITC Plugin: simulate an attack on portal -// @version 0.1.1.@@DATETIMEVERSION@@ +// @version 0.2.0.@@DATETIMEVERSION@@ // @namespace https://github.com/xosofox/IPAS // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ From 5eb7344895ae0991b4b3cac12ffe765c62a0e2f4 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Sun, 21 Apr 2013 02:13:52 +0100 Subject: [PATCH 27/46] increase maxZoom of google satellite/hybrid modes by two levels, so it matches max zoom of google maps --- code/boot.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/boot.js b/code/boot.js index 59e54a7f..caaad95f 100644 --- a/code/boot.js +++ b/code/boot.js @@ -129,8 +129,8 @@ window.setupMap = function() { /*0*/ mqMap, /*1*/ new L.Google('INGRESS'), /*2*/ new L.Google('ROADMAP'), - /*3*/ new L.Google('SATELLITE'), - /*4*/ new L.Google('HYBRID') + /*3*/ new L.Google('SATELLITE',{maxZoom:20}), + /*4*/ new L.Google('HYBRID',{maxZoom:20}) ]; From e5079bc991ab50fd101cfc29af7feb2e89e59554 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Sun, 21 Apr 2013 14:38:54 +0100 Subject: [PATCH 28/46] increase length of scale bar --- plugins/scale-bar.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/scale-bar.user.js b/plugins/scale-bar.user.js index 5e784c12..23329456 100644 --- a/plugins/scale-bar.user.js +++ b/plugins/scale-bar.user.js @@ -28,7 +28,7 @@ window.plugin.scaleBar.setup = function() { // Before you ask: yes, I explicitely turned off imperial units. Imperial units // are worse than Internet Explorer 6 whirring fans combined. Upgrade to the metric // system already. - window.map.addControl(new L.Control.Scale({position: 'topleft', imperial: false})); + window.map.addControl(new L.Control.Scale({position: 'topleft', imperial: false, maxWidth: 200})); }; var setup = window.plugin.scaleBar.setup; From c3f37f949fc29be4c706209ffcac204c8fa21bba Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Mon, 22 Apr 2013 11:03:26 +0200 Subject: [PATCH 29/46] handle internal clicked poslinks correctly --- mobile/AndroidManifest.xml | 4 ++-- mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mobile/AndroidManifest.xml b/mobile/AndroidManifest.xml index d3fa4d8f..d032ca5d 100644 --- a/mobile/AndroidManifest.xml +++ b/mobile/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="10" + android:versionName="0.2.8.1" > Date: Mon, 22 Apr 2013 02:08:51 -0700 Subject: [PATCH 30/46] Build script fixes to work on both python 2 and 3 --- build.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/build.py b/build.py index 41ea60e8..a3d78b57 100755 --- a/build.py +++ b/build.py @@ -9,10 +9,13 @@ import sys import os import shutil import json -import urllib2 import shelve import hashlib +try: + import urllib2 +except ImportError: + import urllib.request as urllib2 # load settings file from buildsettings import buildSettings @@ -72,23 +75,25 @@ def loaderRaw(var): def loaderMD(var): fn = var.group(1) - db = shelve.open('build/MD.dat') - if db.has_key('files'): + # use different MD.dat's for python 2 vs 3 incase user switches versions, as they are not compatible + db = shelve.open('build/MDv' + str(sys.version_info.major) + '.dat') + if 'files' in db: files = db['files'] else: files = {} file = readfile(fn) - filemd5 = hashlib.md5(file).hexdigest() + filemd5 = hashlib.md5(file.encode('utf8')).hexdigest() # check if file has already been parsed by the github api if fn in files and filemd5 in files[fn]: # use the stored copy if nothing has changed to avoid hiting the api more then the 60/hour when not signed in + db.close() return files[fn][filemd5] else: url = 'https://api.github.com/markdown' payload = {'text': file, 'mode': 'markdown'} - req = urllib2.Request(url) - req.add_header('Content-Type', 'application/json') - md = urllib2.urlopen(req, json.dumps(payload)).read().replace('\n', '').replace('\'', '\\\'') + headers = {'Content-Type': 'application/json'} + req = urllib2.Request(url, json.dumps(payload).encode('utf8'), headers) + md = urllib2.urlopen(req).read().decode('utf8').replace('\n', '').replace('\'', '\\\'') files[fn] = {} files[fn][filemd5] = md db['files'] = files From 99a18444bf4226ffb218c8ff6b25cbb0dcd02203 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Mon, 22 Apr 2013 16:35:15 +0200 Subject: [PATCH 31/46] added plugin functionality for iitc mobile --- build.py | 15 ++++++- mobile/AndroidManifest.xml | 4 +- mobile/res/values/strings.xml | 2 + mobile/res/xml/preferences.xml | 4 ++ .../com/cradle/iitc_mobile/IITC_Settings.java | 39 ++++++++++++++++++- .../iitc_mobile/IITC_SettingsFragment.java | 8 +++- .../iitc_mobile/IITC_WebViewClient.java | 35 +++++++++++++++++ 7 files changed, 102 insertions(+), 5 deletions(-) diff --git a/build.py b/build.py index 42b1e4bf..05017116 100755 --- a/build.py +++ b/build.py @@ -156,6 +156,14 @@ for fn in glob.glob("plugins/*.user.js"): metafn = fn.replace('.user.js', '.meta.js') saveScriptAndMeta(script, os.path.join(outDir,fn), os.path.join(outDir,metafn)) +def copytree(src, dst, symlinks=False, ignore=None): + for item in os.listdir(src): + s = os.path.join(src, item) + d = os.path.join(dst, item) + if os.path.isdir(s): + shutil.copytree(s, d, symlinks, ignore) + else: + shutil.copy2(s, d) # if we're building mobile too if buildMobile: @@ -169,7 +177,12 @@ if buildMobile: pass shutil.copy(os.path.join(outDir,"total-conversion-build.user.js"), "mobile/assets/iitc.js") - # TODO? also copy plugins - once the mobile app supports plugins, that is + # also copy plugins + try: + os.makedirs("mobile/assets/plugins") + except: + pass + copytree(os.path.join(outDir,"plugins"), "mobile/assets/plugins") # now launch 'ant' to build the mobile project diff --git a/mobile/AndroidManifest.xml b/mobile/AndroidManifest.xml index d032ca5d..844d7462 100644 --- a/mobile/AndroidManifest.xml +++ b/mobile/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="11" + android:versionName="0.3" > UI + Plugins + Available plugins Force desktop mode Nice for tablets, looks awful on smartphones Developer options diff --git a/mobile/res/xml/preferences.xml b/mobile/res/xml/preferences.xml index fd50c037..2d72b3e1 100644 --- a/mobile/res/xml/preferences.xml +++ b/mobile/res/xml/preferences.xml @@ -17,6 +17,10 @@ android:title="@string/pref_force_desktop" android:summary="@string/pref_force_desktop_sum" android:defaultValue="false" /> + asset_list = new ArrayList(Arrays.asList(asset_array)); + ArrayList asset_values = new ArrayList(); + + for (int i = 0; i < asset_list.size();) { + try { + if (asset_list.get(i).endsWith("user.js")) { + asset_values.add(am.open("plugins/" + asset_list.get(i)).toString()); + i++; + } + else { + asset_list.remove(i); + asset_values.add(am.open("plugins/" + asset_list.get(i)).toString()); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + Bundle bundle = getIntent().getExtras(); + bundle.putStringArray("ASSETS", (String[]) asset_list.toArray(new String[0])); + bundle.putStringArray("ASSETS_VAL", (String[]) asset_values.toArray(new String[0])); + settings.setArguments(bundle); // Display the fragment as the main content. getFragmentManager().beginTransaction() diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java b/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java index 34e3c0c0..702f59db 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java @@ -6,6 +6,7 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.os.Bundle; import android.preference.EditTextPreference; import android.preference.ListPreference; +import android.preference.MultiSelectListPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.PreferenceFragment; @@ -21,7 +22,12 @@ public class IITC_SettingsFragment extends PreferenceFragment { iitc_version = getArguments().getString("iitc_version"); addPreferencesFromResource(R.xml.preferences); - + + //plugins + MultiSelectListPreference pref_plugins = (MultiSelectListPreference) findPreference("pref_plugins"); + pref_plugins.setEntries(getArguments().getStringArray("ASSETS")); + pref_plugins.setEntryValues(getArguments().getStringArray("ASSETS")); + // set build version ListPreference pref_build_version = (ListPreference) findPreference("pref_build_version"); PackageManager pm = getActivity().getPackageManager(); diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java index 74e75c1b..15873a28 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java @@ -3,6 +3,7 @@ package com.cradle.iitc_mobile; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.AssetManager; import android.net.Uri; import android.net.http.SslError; import android.preference.PreferenceManager; @@ -17,6 +18,7 @@ import java.io.InputStream; import java.io.IOException; import java.net.URL; import java.util.Scanner; +import java.util.Set; public class IITC_WebViewClient extends WebViewClient { private static final ByteArrayInputStream style = new ByteArrayInputStream( @@ -91,6 +93,39 @@ public class IITC_WebViewClient extends WebViewClient { handler.proceed() ; }; + // plugins should be loaded after the main script is injected + @Override + public void onPageFinished(WebView view, String url) { + super.onPageFinished(view, url); + + // get the plugin preferences + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context); + Set plugin_list = sharedPref.getStringSet("pref_plugins", null); + + // iterate through all enabled plugins and load them + if (plugin_list != null) { + AssetManager am = context.getAssets(); + String[] plugin_array = plugin_list.toArray(new String[0]); + + for(int i = 0; i < plugin_list.size(); i++) { + if (plugin_array[i].endsWith("user.js")); + { + Log.d("iitcm", "adding plugin " + plugin_array[i]); + Scanner s = null; + String src = ""; + try { + s = new Scanner(am.open("plugins/" + plugin_array[i])).useDelimiter("\\A"); + } catch (IOException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + if (s != null) src = s.hasNext() ? s.next() : ""; + view.loadUrl("javascript:" + src); + } + } + } + } + // Check every external resource if it’s okay to load it and maybe replace it // with our own content. This is used to block loading Niantic resources // which aren’t required and to inject IITC early into the site. From 0f04acbc368359d49ce0128af9ecec5cc8b5b03d Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Mon, 22 Apr 2013 20:35:01 +0200 Subject: [PATCH 32/46] show plugin name instead of file name --- .../com/cradle/iitc_mobile/IITC_Settings.java | 39 ++++++++++++------- .../iitc_mobile/IITC_SettingsFragment.java | 2 +- .../iitc_mobile/IITC_WebViewClient.java | 2 +- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Settings.java b/mobile/src/com/cradle/iitc_mobile/IITC_Settings.java index 6a72c476..a5684005 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Settings.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Settings.java @@ -2,7 +2,7 @@ package com.cradle.iitc_mobile; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Scanner; import android.app.Activity; import android.content.res.AssetManager; @@ -25,22 +25,35 @@ public class IITC_Settings extends Activity { e.printStackTrace(); } - ArrayList asset_list = new ArrayList(Arrays.asList(asset_array)); + ArrayList asset_list = new ArrayList(); ArrayList asset_values = new ArrayList(); - for (int i = 0; i < asset_list.size();) { - try { - if (asset_list.get(i).endsWith("user.js")) { - asset_values.add(am.open("plugins/" + asset_list.get(i)).toString()); - i++; + for (int i = 0; i < asset_array.length ; i++) { + if (asset_array[i].endsWith("user.js")) { + // find user plugin name for user readable entries + Scanner s = null; + String src = ""; + try { + s = new Scanner(am.open("plugins/" + asset_array[i])).useDelimiter("\\A"); + } catch (IOException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); } - else { - asset_list.remove(i); - asset_values.add(am.open("plugins/" + asset_list.get(i)).toString()); + if (s != null) src = s.hasNext() ? s.next() : ""; + String header = src.substring(src.indexOf("==UserScript=="), src.indexOf("==/UserScript==")); + // remove new line comments and replace with space + // this way we get double spaces instead of newline + double slash + header = header.replace("\n//", " "); + // get a list of key-value...split on multiple spaces + String[] attributes = header.split(" +"); + String plugin_name = "not found"; + for (int j = 0; j < attributes.length; j++) { + // search for name and use the value + if (attributes[j].equals("@name")) plugin_name = attributes[j+1]; } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + asset_list.add(plugin_name); + // real value + asset_values.add(asset_array[i]); } } diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java b/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java index 702f59db..5a68f307 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_SettingsFragment.java @@ -26,7 +26,7 @@ public class IITC_SettingsFragment extends PreferenceFragment { //plugins MultiSelectListPreference pref_plugins = (MultiSelectListPreference) findPreference("pref_plugins"); pref_plugins.setEntries(getArguments().getStringArray("ASSETS")); - pref_plugins.setEntryValues(getArguments().getStringArray("ASSETS")); + pref_plugins.setEntryValues(getArguments().getStringArray("ASSETS_VAL")); // set build version ListPreference pref_build_version = (ListPreference) findPreference("pref_build_version"); diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java index 15873a28..caa42e89 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java @@ -46,7 +46,7 @@ public class IITC_WebViewClient extends WebViewClient { String[] attributes = header.split(" +"); String iitc_version = "not found"; for (int i = 0; i < attributes.length; i++) { - // search vor version and use the value + // search for version and use the value if (attributes[i].equals("@version")) iitc_version = attributes[i+1]; } return iitc_version; From 4a9c10f04435adcdbb85413404297fb891d7ae6b Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 23 Apr 2013 17:29:13 +0200 Subject: [PATCH 33/46] bugfix: http2https --- mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java index 700a8745..4da3cd1a 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java @@ -56,7 +56,7 @@ public class IITC_Mobile extends Activity { if (Intent.ACTION_VIEW.equals(action)) { Uri uri = intent.getData(); String url = uri.toString(); - if (intent.getScheme().equals("http://")) + if (intent.getScheme().equals("http")) url = url.replace("http://", "https://"); Log.d("iitcm", "intent received url: " + url); if (url.contains("ingress.com")) { From 959c031f37a42208e2d7357efc6d3183b1df258b Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 23 Apr 2013 17:29:41 +0200 Subject: [PATCH 34/46] updated internal poslink click handle (see #149) --- mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java | 3 ++- 1 file changed, 2 insertions(+), 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 caa42e89..f05dc044 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java @@ -154,7 +154,8 @@ public class IITC_WebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.contains("ingress.com")) { - if (url.contains("ingress.com/intel") && url.contains("latE6") && url.contains("lngE6")) { + // reload iitc if an poslink clicked inside the app + if (url.contains("intel?ll=") || (url.contains("latE6") && url.contains("lngE6"))) { Log.d("iitcm", "should be an internal clicked position link...reload script for: " + url); ((IITC_Mobile) context).loadUrl(url); } From c1dcd588adeab027c2cda992ca973a2fab03f05c Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Tue, 23 Apr 2013 17:38:42 +0200 Subject: [PATCH 35/46] fixed typo --- 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 f05dc044..d2a62897 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java @@ -154,7 +154,7 @@ public class IITC_WebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.contains("ingress.com")) { - // reload iitc if an poslink clicked inside the app + // reload iitc if a poslink is clicked inside the app if (url.contains("intel?ll=") || (url.contains("latE6") && url.contains("lngE6"))) { Log.d("iitcm", "should be an internal clicked position link...reload script for: " + url); ((IITC_Mobile) context).loadUrl(url); From 13448ca786a19bee0e761ce3369f0fae73b05880 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Tue, 23 Apr 2013 21:32:02 +0100 Subject: [PATCH 36/46] add assets/plugins/ to mobile .gitignore - they're copied there in the build process --- mobile/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/mobile/.gitignore b/mobile/.gitignore index a56e372f..42222e62 100644 --- a/mobile/.gitignore +++ b/mobile/.gitignore @@ -7,3 +7,4 @@ libs/ proguard-project.txt local.properties assets/iitc.js +assets/plugins/ From 59094e48bcedfeef2bdd5bfae89b62ba7baff52c Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Tue, 23 Apr 2013 21:45:01 +0100 Subject: [PATCH 37/46] looks like ingress.com/intel is in the process of changing the protocol. passing in zoom level rather than minLevelOfDetail parameters when requesting entities --- code/map_data.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/map_data.js b/code/map_data.js index 317d7877..91c6b4f0 100644 --- a/code/map_data.js +++ b/code/map_data.js @@ -47,7 +47,7 @@ window.requestData = function() { portalRenderLimit.init(); // finally send ajax requests $.each(tiles, function(ind, tls) { - data = { minLevelOfDetail: -1 }; + data = { zoom: map.getZoom() }; data.boundsParamsList = tls; window.requests.add(window.postAjax('getThinnedEntitiesV2', data, window.handleDataResponse, window.handleFailedRequest)); }); From d58306ec06b31257307f3da7fb6dde2e26c0e220 Mon Sep 17 00:00:00 2001 From: goodsoft Date: Wed, 24 Apr 2013 03:40:53 +0300 Subject: [PATCH 38/46] Updated quadkey calculations for new protocol --- code/map_data_calc_tools.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/code/map_data_calc_tools.js b/code/map_data_calc_tools.js index 2f383197..c464d277 100644 --- a/code/map_data_calc_tools.js +++ b/code/map_data_calc_tools.js @@ -1,5 +1,4 @@ - // MAP DATA REQUEST CALCULATORS ////////////////////////////////////// // Ingress Intel splits up requests for map data (portals, links, // fields) into tiles. To get data for the current viewport (i.e. what @@ -23,9 +22,9 @@ window.calculateR = function(convCenterLat) { } window.convertLatLngToPoint = function(latlng, magic, R) { - var x = (magic/2 + latlng.lng * magic / 360)*R; + var x = (magic + latlng.lng * magic / 180)*R; var l = Math.sin(latlng.lat * DEG2RAD); - var y = (magic/2 + 0.5*Math.log((1+l)/(1-l)) * -(magic / (2*Math.PI)))*R; + var y = (magic + Math.log((1+l)/(1-l)) * -(magic / (2*Math.PI)))*R; return {x: Math.floor(x/magic), y: Math.floor(y/magic)}; } @@ -35,13 +34,13 @@ window.convertPointToLatLng = function(x, y, magic, R) { // orig function put together from all over the place // lat: (2 * Math.atan(Math.exp((((y + 1) * magic / R) - (magic/ 2)) / (-1*(magic / (2 * Math.PI))))) - Math.PI / 2) / (Math.PI / 180), // shortened version by your favorite algebra program. - lat: (360*Math.atan(Math.exp(Math.PI - 2*Math.PI*(y+1)/R)))/Math.PI - 90, - lng: 360*x/R-180 + lat: (360*Math.atan(Math.exp(Math.PI - Math.PI*(y+1)/R)))/Math.PI - 90, + lng: 180*x/R-180 }; e.ne = { //lat: (2 * Math.atan(Math.exp(((y * magic / R) - (magic/ 2)) / (-1*(magic / (2 * Math.PI))))) - Math.PI / 2) / (Math.PI / 180), - lat: (360*Math.atan(Math.exp(Math.PI - 2*Math.PI*y/R)))/Math.PI - 90, - lng: 360*(x+1)/R-180 + lat: (360*Math.atan(Math.exp(Math.PI - Math.PI*y/R)))/Math.PI - 90, + lng: 180*(x+1)/R-180 }; return e; } @@ -49,7 +48,8 @@ window.convertPointToLatLng = function(x, y, magic, R) { // calculates the quad key for a given point. The point is not(!) in // lat/lng format. window.pointToQuadKey = function(x, y) { - var quadkey = []; + return window.map.getZoom() + "_" + x + "_" + y; + /*var quadkey = []; for(var c = window.map.getZoom(); c > 0; c--) { // +-------+ quadrants are probably ordered like this // | 0 | 1 | @@ -62,7 +62,7 @@ window.pointToQuadKey = function(x, y) { (y & e) != 0 && (quadrant++, quadrant++); // push down quadkey.push(quadrant); } - return quadkey.join(""); + return quadkey.join("");*/ } // given quadkey and bounds, returns the format as required by the From 2df9bdc5a742651bfd751f2ff225ebd1782952ac Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Wed, 24 Apr 2013 02:15:55 +0100 Subject: [PATCH 39/46] remove commented out code --- code/map_data_calc_tools.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/code/map_data_calc_tools.js b/code/map_data_calc_tools.js index c464d277..eca1b7e9 100644 --- a/code/map_data_calc_tools.js +++ b/code/map_data_calc_tools.js @@ -49,20 +49,6 @@ window.convertPointToLatLng = function(x, y, magic, R) { // lat/lng format. window.pointToQuadKey = function(x, y) { return window.map.getZoom() + "_" + x + "_" + y; - /*var quadkey = []; - for(var c = window.map.getZoom(); c > 0; c--) { - // +-------+ quadrants are probably ordered like this - // | 0 | 1 | - // |---|---| - // | 2 | 3 | - // |---|---| - var quadrant = 0; - var e = 1 << c - 1; - (x & e) != 0 && quadrant++; // push right - (y & e) != 0 && (quadrant++, quadrant++); // push down - quadkey.push(quadrant); - } - return quadkey.join("");*/ } // given quadkey and bounds, returns the format as required by the From 8f45a2a8842fbed0d804875e1672d4a3e030a3ba Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Wed, 24 Apr 2013 02:16:29 +0100 Subject: [PATCH 40/46] bump version number to 0.11.0 --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index 42da45b7..f87807ad 100644 --- a/main.js +++ b/main.js @@ -1,7 +1,7 @@ // ==UserScript== // @id ingress-intel-total-conversion@jonatkins // @name IITC: Ingress intel map total conversion -// @version 0.10.5.@@DATETIMEVERSION@@ +// @version 0.11.0.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ From 4a16668c6ac49154a5c5a109cee374272f913e6d Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Wed, 24 Apr 2013 02:40:53 +0100 Subject: [PATCH 41/46] change player tracker display for unknown plyaer levels, to match that used in the guess player levels plugin --- plugins/player-tracker.user.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/player-tracker.user.js b/plugins/player-tracker.user.js index 864a006a..7f20df6c 100644 --- a/plugins/player-tracker.user.js +++ b/plugins/player-tracker.user.js @@ -266,12 +266,13 @@ window.plugin.playerTracker.drawData = function() { if(window.plugin.guessPlayerLevels !== undefined && window.plugin.guessPlayerLevels.fetchLevelByPlayer !== undefined) { var playerLevel = window.plugin.guessPlayerLevels.fetchLevelByPlayer(pguid); - if (playerLevel === undefined) playerLevel = 1; //if player level unknown, assume level 1 if(playerLevel !== undefined) { title += 'Level ' + playerLevel + (playerLevel < (window.MAX_XM_PER_LEVEL.length - 1) ? ' (guessed)' : '') + ''; + } else { + title += 'Level unknown' } } From 0010626c916077b475a347f80a84692485c9ceaa Mon Sep 17 00:00:00 2001 From: goodsoft Date: Wed, 24 Apr 2013 06:17:36 +0300 Subject: [PATCH 42/46] Recreate links omitted from Niantic data See #192 --- code/map_data.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/code/map_data.js b/code/map_data.js index 91c6b4f0..76d72e89 100644 --- a/code/map_data.js +++ b/code/map_data.js @@ -78,7 +78,7 @@ window.handleDataResponse = function(data, textStatus, jqXHR) { // portals can be brought to front, this costs extra time. They need // to be in the foreground, or they cannot be clicked. See // https://github.com/Leaflet/Leaflet/issues/185 - var ppp = []; + var ppp = {}; var p2f = {}; $.each(m, function(qk, val) { $.each(val.deletedGameEntityGuids || [], function(ind, guid) { @@ -115,7 +115,7 @@ window.handleDataResponse = function(data, textStatus, jqXHR) { ent[2].imageByUrl = {'imageUrl': DEFAULT_PORTAL_IMG}; } - ppp.push(ent); // delay portal render + ppp[ent[0]] = ent; // delay portal render } else if(ent[2].edge !== undefined) { renderLink(ent); } else if(ent[2].capturedRegion !== undefined) { @@ -132,6 +132,25 @@ window.handleDataResponse = function(data, textStatus, jqXHR) { }); $.each(ppp, function(ind, portal) { + if ('portalV2' in portal[2] && 'linkedEdges' in portal[2].portalV2) { + $.each(portal[2].portalV2.linkedEdges, function (ind, edge) { + if (!ppp[edge.otherPortalGuid]) + return; + renderLink([ + edge.edgeGuid, + portal[1], + { + "controllingTeam": portal[2].controllingTeam, + "edge": { + "destinationPortalGuid": edge.isOrigin ? ppp[edge.otherPortalGuid][0] : portal[0], + "destinationPortalLocation": edge.isOrigin ? ppp[edge.otherPortalGuid][2].locationE6 : portal[2].locationE6, + "originPortalGuid": !edge.isOrigin ? ppp[edge.otherPortalGuid][0] : portal[0], + "originPortalLocation": !edge.isOrigin ? ppp[edge.otherPortalGuid][2].locationE6 : portal[2].locationE6 + } + } + ]); + }); + } if(portal[2].portalV2['linkedFields'] === undefined) { portal[2].portalV2['linkedFields'] = []; } From f7f8e1ca94efad9e008e4a861ec404f512906117 Mon Sep 17 00:00:00 2001 From: Paul Tsupikoff Date: Wed, 24 Apr 2013 12:58:31 +0300 Subject: [PATCH 43/46] Rewritten tile request calculation --- code/map_data.js | 40 ++++++++++------------ code/map_data_calc_tools.js | 68 +++++++++++++------------------------ 2 files changed, 42 insertions(+), 66 deletions(-) diff --git a/code/map_data.js b/code/map_data.js index 76d72e89..89e8eeb2 100644 --- a/code/map_data.js +++ b/code/map_data.js @@ -12,34 +12,30 @@ window.requestData = function() { requests.abort(); cleanUp(); - var magic = convertCenterLat(map.getCenter().lat); - var R = calculateR(magic); - var bounds = map.getBounds(); - // convert to point values - topRight = convertLatLngToPoint(bounds.getNorthEast(), magic, R); - bottomLeft = convertLatLngToPoint(bounds.getSouthWest() , magic, R); - // how many quadrants intersect the current view? - quadsX = Math.abs(bottomLeft.x - topRight.x); - quadsY = Math.abs(bottomLeft.y - topRight.y); + + var x1 = lngToTile(bounds.getNorthWest().lng, map.getZoom()); + var x2 = lngToTile(bounds.getNorthEast().lng, map.getZoom()); + var y1 = latToTile(bounds.getNorthWest().lat, map.getZoom()); + var y2 = latToTile(bounds.getSouthWest().lat, map.getZoom()); // will group requests by second-last quad-key quadrant tiles = {}; // walk in x-direction, starts right goes left - for(var i = 0; i <= quadsX; i++) { - var x = Math.abs(topRight.x - i); - var qk = pointToQuadKey(x, topRight.y); - var bnds = convertPointToLatLng(x, topRight.y, magic, R); - if(!tiles[qk.slice(0, -1)]) tiles[qk.slice(0, -1)] = []; - tiles[qk.slice(0, -1)].push(generateBoundsParams(qk, bnds)); - - // walk in y-direction, starts top, goes down - for(var j = 1; j <= quadsY; j++) { - var qk = pointToQuadKey(x, topRight.y + j); - var bnds = convertPointToLatLng(x, topRight.y + j, magic, R); - if(!tiles[qk.slice(0, -1)]) tiles[qk.slice(0, -1)] = []; - tiles[qk.slice(0, -1)].push(generateBoundsParams(qk, bnds)); + for (var x = x1; x <= x2; x++) { + for (var y = y1; y <= y2; y++) { + var tile_id = pointToTileId(map.getZoom(), x, y); + var bucket = Math.floor(x / 2) + "" + Math.floor(y / 2); + if (!tiles[bucket]) + tiles[bucket] = []; + tiles[bucket].push(generateBoundsParams( + tile_id, + tileToLat(y + 1, map.getZoom()), + tileToLng(x, map.getZoom()), + tileToLat(y, map.getZoom()), + tileToLng(x + 1, map.getZoom()) + )); } } diff --git a/code/map_data_calc_tools.js b/code/map_data_calc_tools.js index eca1b7e9..98535759 100644 --- a/code/map_data_calc_tools.js +++ b/code/map_data_calc_tools.js @@ -1,65 +1,45 @@ - // MAP DATA REQUEST CALCULATORS ////////////////////////////////////// // Ingress Intel splits up requests for map data (portals, links, // fields) into tiles. To get data for the current viewport (i.e. what // is currently visible) it first calculates which tiles intersect. // For all those tiles, it then calculates the lat/lng bounds of that // tile and a quadkey. Both the bounds and the quadkey are “somewhat” -// required to get complete data. No idea how the projection between -// lat/lng and tiles works. -// What follows now are functions that allow conversion between tiles -// and lat/lng as well as calculating the quad key. The variable names -// may be misleading. -// The minified source for this code was in gen_dashboard.js after the -// “// input 89” line (alternatively: the class was called “Xe”). +// required to get complete data. +// +// Convertion functions courtesy of +// http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames -window.convertCenterLat = function(centerLat) { - return Math.round(256 * 0.9999 * Math.abs(1 / Math.cos(centerLat * DEG2RAD))); +window.lngToTile = function(lng, zoom) { + return Math.floor((lng + 180) / 360 * Math.pow(2, zoom)); } -window.calculateR = function(convCenterLat) { - return 1 << window.map.getZoom() - (convCenterLat / 256 - 1); +window.latToTile = function(lat, zoom) { + return Math.floor((1 - Math.log(Math.tan(lat * Math.PI / 180) + + 1 / Math.cos(lat * Math.PI / 180)) / Math.PI) / 2 * Math.pow(2, zoom)); } -window.convertLatLngToPoint = function(latlng, magic, R) { - var x = (magic + latlng.lng * magic / 180)*R; - var l = Math.sin(latlng.lat * DEG2RAD); - var y = (magic + Math.log((1+l)/(1-l)) * -(magic / (2*Math.PI)))*R; - return {x: Math.floor(x/magic), y: Math.floor(y/magic)}; +window.tileToLng = function(x, zoom) { + return x / Math.pow(2, zoom) * 360 - 180; } -window.convertPointToLatLng = function(x, y, magic, R) { - var e = {}; - e.sw = { - // orig function put together from all over the place - // lat: (2 * Math.atan(Math.exp((((y + 1) * magic / R) - (magic/ 2)) / (-1*(magic / (2 * Math.PI))))) - Math.PI / 2) / (Math.PI / 180), - // shortened version by your favorite algebra program. - lat: (360*Math.atan(Math.exp(Math.PI - Math.PI*(y+1)/R)))/Math.PI - 90, - lng: 180*x/R-180 - }; - e.ne = { - //lat: (2 * Math.atan(Math.exp(((y * magic / R) - (magic/ 2)) / (-1*(magic / (2 * Math.PI))))) - Math.PI / 2) / (Math.PI / 180), - lat: (360*Math.atan(Math.exp(Math.PI - Math.PI*y/R)))/Math.PI - 90, - lng: 180*(x+1)/R-180 - }; - return e; +window.tileToLat = function(y, zoom) { + var n = Math.PI - 2 * Math.PI * y / Math.pow(2, zoom); + return 180 / Math.PI * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n))); } -// calculates the quad key for a given point. The point is not(!) in -// lat/lng format. -window.pointToQuadKey = function(x, y) { - return window.map.getZoom() + "_" + x + "_" + y; +window.pointToTileId = function(zoom, x, y) { + return zoom + "_" + x + "_" + y; } -// given quadkey and bounds, returns the format as required by the +// given tile id and bounds, returns the format as required by the // Ingress API to request map data. -window.generateBoundsParams = function(quadkey, bounds) { +window.generateBoundsParams = function(tile_id, minLat, minLng, maxLat, maxLng) { return { - id: quadkey, - qk: quadkey, - minLatE6: Math.round(bounds.sw.lat * 1E6), - minLngE6: Math.round(bounds.sw.lng * 1E6), - maxLatE6: Math.round(bounds.ne.lat * 1E6), - maxLngE6: Math.round(bounds.ne.lng * 1E6) + id: tile_id, + qk: tile_id, + minLatE6: Math.round(minLat * 1E6), + minLngE6: Math.round(minLng * 1E6), + maxLatE6: Math.round(maxLat * 1E6), + maxLngE6: Math.round(maxLng * 1E6) }; } From 395c27a9d28a6f0ec46090179e88d94f78031d9a Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Wed, 24 Apr 2013 13:32:15 +0100 Subject: [PATCH 44/46] bump version number for fixed coordinate calculations --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index f87807ad..c14497e5 100644 --- a/main.js +++ b/main.js @@ -1,7 +1,7 @@ // ==UserScript== // @id ingress-intel-total-conversion@jonatkins // @name IITC: Ingress intel map total conversion -// @version 0.11.0.@@DATETIMEVERSION@@ +// @version 0.11.1.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ From be957b3435dfc8f19abb12f10ac2928b0d1bc333 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Wed, 24 Apr 2013 13:54:16 +0100 Subject: [PATCH 45/46] change zoom levels for portal level display to match stock intel site - this seems to be enforced by the backend now fix #199 --- code/utils_misc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/utils_misc.js b/code/utils_misc.js index 4d12fcd9..267a1c06 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -201,8 +201,8 @@ window.renderLimitReached = function(ratio) { window.getMinPortalLevel = function() { var z = map.getZoom(); - if(z >= 16) return 0; - var conv = ['impossible', 8,7,7,6,6,5,5,4,4,3,3,2,2,1,1]; + if(z >= 17) return 0; + var conv = ['impossible', 8,8,8,7,7,6,6,5,4,4,3,3,2,2,1,1]; var minLevelByRenderLimit = portalRenderLimit.getMinLevel(); var result = minLevelByRenderLimit > conv[z] ? minLevelByRenderLimit From 494d388329520455d32711eab9eafda03e5da48d Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Wed, 24 Apr 2013 13:55:16 +0100 Subject: [PATCH 46/46] bump version number in preperation for next release --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index c14497e5..3bebd816 100644 --- a/main.js +++ b/main.js @@ -1,7 +1,7 @@ // ==UserScript== // @id ingress-intel-total-conversion@jonatkins // @name IITC: Ingress intel map total conversion -// @version 0.11.1.@@DATETIMEVERSION@@ +// @version 0.11.2.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@