Merge git://github.com/jonatkins/ingress-intel-total-conversion into dev
This commit is contained in:
commit
7600c7a40d
35
build.py
35
build.py
@ -8,7 +8,14 @@ import base64
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
import json
|
||||||
|
import shelve
|
||||||
|
import hashlib
|
||||||
|
|
||||||
|
try:
|
||||||
|
import urllib2
|
||||||
|
except ImportError:
|
||||||
|
import urllib.request as urllib2
|
||||||
|
|
||||||
# load settings file
|
# load settings file
|
||||||
from buildsettings import buildSettings
|
from buildsettings import buildSettings
|
||||||
@ -66,6 +73,33 @@ def loaderRaw(var):
|
|||||||
fn = var.group(1)
|
fn = var.group(1)
|
||||||
return readfile(fn)
|
return readfile(fn)
|
||||||
|
|
||||||
|
def loaderMD(var):
|
||||||
|
fn = var.group(1)
|
||||||
|
# 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.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'}
|
||||||
|
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
|
||||||
|
db.close()
|
||||||
|
return md
|
||||||
|
|
||||||
def loaderImage(var):
|
def loaderImage(var):
|
||||||
fn = var.group(1)
|
fn = var.group(1)
|
||||||
return 'data:image/png;base64,{0}'.format(base64.encodestring(open(fn, 'rb').read()).decode('utf8').replace('\n', ''))
|
return 'data:image/png;base64,{0}'.format(base64.encodestring(open(fn, 'rb').read()).decode('utf8').replace('\n', ''))
|
||||||
@ -86,6 +120,7 @@ def doReplacements(script,updateUrl,downloadUrl):
|
|||||||
|
|
||||||
script = re.sub('@@INCLUDERAW:([0-9a-zA-Z_./-]+)@@', loaderRaw, script)
|
script = re.sub('@@INCLUDERAW:([0-9a-zA-Z_./-]+)@@', loaderRaw, script)
|
||||||
script = re.sub('@@INCLUDESTRING:([0-9a-zA-Z_./-]+)@@', loaderString, script)
|
script = re.sub('@@INCLUDESTRING:([0-9a-zA-Z_./-]+)@@', loaderString, script)
|
||||||
|
script = re.sub('@@INCLUDEMD:([0-9a-zA-Z_./-]+)@@', loaderMD, script)
|
||||||
script = re.sub('@@INCLUDEIMAGE:([0-9a-zA-Z_./-]+)@@', loaderImage, script)
|
script = re.sub('@@INCLUDEIMAGE:([0-9a-zA-Z_./-]+)@@', loaderImage, script)
|
||||||
|
|
||||||
script = script.replace('@@BUILDDATE@@', buildDate)
|
script = script.replace('@@BUILDDATE@@', buildDate)
|
||||||
|
@ -47,7 +47,7 @@ window.requestData = function() {
|
|||||||
portalRenderLimit.init();
|
portalRenderLimit.init();
|
||||||
// finally send ajax requests
|
// finally send ajax requests
|
||||||
$.each(tiles, function(ind, tls) {
|
$.each(tiles, function(ind, tls) {
|
||||||
data = { minLevelOfDetail: -1 };
|
data = { zoom: map.getZoom() };
|
||||||
data.boundsParamsList = tls;
|
data.boundsParamsList = tls;
|
||||||
window.requests.add(window.postAjax('getThinnedEntitiesV2', data, window.handleDataResponse, window.handleFailedRequest));
|
window.requests.add(window.postAjax('getThinnedEntitiesV2', data, window.handleDataResponse, window.handleFailedRequest));
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
// MAP DATA REQUEST CALCULATORS //////////////////////////////////////
|
// MAP DATA REQUEST CALCULATORS //////////////////////////////////////
|
||||||
// Ingress Intel splits up requests for map data (portals, links,
|
// Ingress Intel splits up requests for map data (portals, links,
|
||||||
// fields) into tiles. To get data for the current viewport (i.e. what
|
// 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) {
|
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 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)};
|
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
|
// 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),
|
// 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.
|
// shortened version by your favorite algebra program.
|
||||||
lat: (360*Math.atan(Math.exp(Math.PI - 2*Math.PI*(y+1)/R)))/Math.PI - 90,
|
lat: (360*Math.atan(Math.exp(Math.PI - Math.PI*(y+1)/R)))/Math.PI - 90,
|
||||||
lng: 360*x/R-180
|
lng: 180*x/R-180
|
||||||
};
|
};
|
||||||
e.ne = {
|
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: (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,
|
lat: (360*Math.atan(Math.exp(Math.PI - Math.PI*y/R)))/Math.PI - 90,
|
||||||
lng: 360*(x+1)/R-180
|
lng: 180*(x+1)/R-180
|
||||||
};
|
};
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
@ -49,20 +48,7 @@ window.convertPointToLatLng = function(x, y, magic, R) {
|
|||||||
// calculates the quad key for a given point. The point is not(!) in
|
// calculates the quad key for a given point. The point is not(!) in
|
||||||
// lat/lng format.
|
// lat/lng format.
|
||||||
window.pointToQuadKey = function(x, y) {
|
window.pointToQuadKey = function(x, y) {
|
||||||
var quadkey = [];
|
return window.map.getZoom() + "_" + x + "_" + y;
|
||||||
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
|
// given quadkey and bounds, returns the format as required by the
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
// UTILS + MISC ///////////////////////////////////////////////////////
|
// UTILS + MISC ///////////////////////////////////////////////////////
|
||||||
|
|
||||||
window.aboutIITC = function(){
|
window.aboutIITC = function(){
|
||||||
var v = '@@BUILDNAME@@-@@BUILDDATE@@'
|
var v = '@@BUILDNAME@@-@@BUILDDATE@@';
|
||||||
|
var attrib = '@@INCLUDEMD:ATTRIBUTION.md@@';
|
||||||
var a = ''
|
var a = ''
|
||||||
+ ' <div><b>About IITC</b></div> '
|
+ ' <div><b>About IITC</b></div> '
|
||||||
+ ' <div>Ingress Intel Total Conversion</div> '
|
+ ' <div>Ingress Intel Total Conversion</div> '
|
||||||
@ -20,8 +21,11 @@ window.aboutIITC = function(){
|
|||||||
+ ' MapQuest OSM tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png">'
|
+ ' MapQuest OSM tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png">'
|
||||||
+ ' </div>'
|
+ ' </div>'
|
||||||
+ ' <hr>'
|
+ ' <hr>'
|
||||||
+ ' <div>Version: ' + v + '</div>';
|
+ ' <div>Version: ' + v + '</div>'
|
||||||
alert(a);
|
+ ' <hr>'
|
||||||
|
+ ' <div>' + attrib + '</div>';
|
||||||
|
alert(a, true, function() {$('.ui-dialog').removeClass('ui-dialog-aboutIITC');});
|
||||||
|
$('.ui-dialog').addClass('ui-dialog-aboutIITC');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
2
main.js
2
main.js
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @id ingress-intel-total-conversion@jonatkins
|
// @id ingress-intel-total-conversion@jonatkins
|
||||||
// @name IITC: Ingress intel map total conversion
|
// @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
|
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||||
// @updateURL @@UPDATEURL@@
|
// @updateURL @@UPDATEURL@@
|
||||||
// @downloadURL @@DOWNLOADURL@@
|
// @downloadURL @@DOWNLOADURL@@
|
||||||
|
1
mobile/.gitignore
vendored
1
mobile/.gitignore
vendored
@ -7,3 +7,4 @@ libs/
|
|||||||
proguard-project.txt
|
proguard-project.txt
|
||||||
local.properties
|
local.properties
|
||||||
assets/iitc.js
|
assets/iitc.js
|
||||||
|
assets/plugins/
|
||||||
|
@ -56,7 +56,7 @@ public class IITC_Mobile extends Activity {
|
|||||||
if (Intent.ACTION_VIEW.equals(action)) {
|
if (Intent.ACTION_VIEW.equals(action)) {
|
||||||
Uri uri = intent.getData();
|
Uri uri = intent.getData();
|
||||||
String url = uri.toString();
|
String url = uri.toString();
|
||||||
if (intent.getScheme().equals("http://"))
|
if (intent.getScheme().equals("http"))
|
||||||
url = url.replace("http://", "https://");
|
url = url.replace("http://", "https://");
|
||||||
Log.d("iitcm", "intent received url: " + url);
|
Log.d("iitcm", "intent received url: " + url);
|
||||||
if (url.contains("ingress.com")) {
|
if (url.contains("ingress.com")) {
|
||||||
|
@ -2,7 +2,7 @@ package com.cradle.iitc_mobile;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
@ -25,22 +25,35 @@ public class IITC_Settings extends Activity {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<String> asset_list = new ArrayList<String>(Arrays.asList(asset_array));
|
ArrayList<String> asset_list = new ArrayList<String>();
|
||||||
ArrayList<String> asset_values = new ArrayList<String>();
|
ArrayList<String> asset_values = new ArrayList<String>();
|
||||||
|
|
||||||
for (int i = 0; i < asset_list.size();) {
|
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 {
|
try {
|
||||||
if (asset_list.get(i).endsWith("user.js")) {
|
s = new Scanner(am.open("plugins/" + asset_array[i])).useDelimiter("\\A");
|
||||||
asset_values.add(am.open("plugins/" + asset_list.get(i)).toString());
|
} catch (IOException e2) {
|
||||||
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
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e2.printStackTrace();
|
||||||
|
}
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
asset_list.add(plugin_name);
|
||||||
|
// real value
|
||||||
|
asset_values.add(asset_array[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ public class IITC_SettingsFragment extends PreferenceFragment {
|
|||||||
//plugins
|
//plugins
|
||||||
MultiSelectListPreference pref_plugins = (MultiSelectListPreference) findPreference("pref_plugins");
|
MultiSelectListPreference pref_plugins = (MultiSelectListPreference) findPreference("pref_plugins");
|
||||||
pref_plugins.setEntries(getArguments().getStringArray("ASSETS"));
|
pref_plugins.setEntries(getArguments().getStringArray("ASSETS"));
|
||||||
pref_plugins.setEntryValues(getArguments().getStringArray("ASSETS"));
|
pref_plugins.setEntryValues(getArguments().getStringArray("ASSETS_VAL"));
|
||||||
|
|
||||||
// set build version
|
// set build version
|
||||||
ListPreference pref_build_version = (ListPreference) findPreference("pref_build_version");
|
ListPreference pref_build_version = (ListPreference) findPreference("pref_build_version");
|
||||||
|
@ -46,7 +46,7 @@ public class IITC_WebViewClient extends WebViewClient {
|
|||||||
String[] attributes = header.split(" +");
|
String[] attributes = header.split(" +");
|
||||||
String iitc_version = "not found";
|
String iitc_version = "not found";
|
||||||
for (int i = 0; i < attributes.length; i++) {
|
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];
|
if (attributes[i].equals("@version")) iitc_version = attributes[i+1];
|
||||||
}
|
}
|
||||||
return iitc_version;
|
return iitc_version;
|
||||||
@ -154,7 +154,8 @@ public class IITC_WebViewClient extends WebViewClient {
|
|||||||
@Override
|
@Override
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||||
if (url.contains("ingress.com")) {
|
if (url.contains("ingress.com")) {
|
||||||
if (url.contains("ingress.com/intel") && url.contains("latE6") && url.contains("lngE6")) {
|
// 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);
|
Log.d("iitcm", "should be an internal clicked position link...reload script for: " + url);
|
||||||
((IITC_Mobile) context).loadUrl(url);
|
((IITC_Mobile) context).loadUrl(url);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user