Merge git://github.com/jonatkins/ingress-intel-total-conversion into dev

This commit is contained in:
Morgan Jones 2013-04-23 20:26:07 -05:00
commit 7600c7a40d
11 changed files with 88 additions and 43 deletions

View File

@ -8,7 +8,14 @@ import base64
import sys
import os
import shutil
import json
import shelve
import hashlib
try:
import urllib2
except ImportError:
import urllib.request as urllib2
# load settings file
from buildsettings import buildSettings
@ -66,6 +73,33 @@ def loaderRaw(var):
fn = var.group(1)
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):
fn = var.group(1)
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('@@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 = script.replace('@@BUILDDATE@@', buildDate)

View File

@ -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));
});

View File

@ -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,20 +48,7 @@ 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 = [];
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("");
return window.map.getZoom() + "_" + x + "_" + y;
}
// given quadkey and bounds, returns the format as required by the

View File

@ -1,7 +1,8 @@
// UTILS + MISC ///////////////////////////////////////////////////////
window.aboutIITC = function(){
var v = '@@BUILDNAME@@-@@BUILDDATE@@'
var v = '@@BUILDNAME@@-@@BUILDDATE@@';
var attrib = '@@INCLUDEMD:ATTRIBUTION.md@@';
var a = ''
+ ' <div><b>About IITC</b></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">'
+ ' </div>'
+ ' <hr>'
+ ' <div>Version: ' + v + '</div>';
alert(a);
+ ' <div>Version: ' + v + '</div>'
+ ' <hr>'
+ ' <div>' + attrib + '</div>';
alert(a, true, function() {$('.ui-dialog').removeClass('ui-dialog-aboutIITC');});
$('.ui-dialog').addClass('ui-dialog-aboutIITC');
}

View File

@ -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@@

1
mobile/.gitignore vendored
View File

@ -7,3 +7,4 @@ libs/
proguard-project.txt
local.properties
assets/iitc.js
assets/plugins/

View File

@ -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")) {

View File

@ -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<String> asset_list = new ArrayList<String>(Arrays.asList(asset_array));
ArrayList<String> asset_list = 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 {
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) {
s = new Scanner(am.open("plugins/" + asset_array[i])).useDelimiter("\\A");
} catch (IOException e2) {
// 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]);
}
}

View File

@ -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");

View File

@ -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;
@ -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 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);
}

View File

@ -766,6 +766,11 @@ h3 {
text-decoration: underline;
}
.ui-dialog-aboutIITC {
max-width: 600px !important;
width: 600px !important;
}
td {
padding: 0;
vertical-align: top;