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

This commit is contained in:
Morgan Jones 2013-04-27 13:09:00 -05:00
commit 992c0edacb
13 changed files with 427 additions and 445 deletions

BIN
assets/IITC.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

64
assets/IITC.svg Executable file
View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="134.333px" height="207.581px" viewBox="0 0 134.333 207.581" enable-background="new 0 0 134.333 207.581"
xml:space="preserve">
<g>
<g>
<radialGradient id="SVGID_1_" cx="65.6543" cy="81.3018" r="81.8284" gradientUnits="userSpaceOnUse">
<stop offset="0" style="stop-color:#57A2D9"/>
<stop offset="1" style="stop-color:#004A8E"/>
</radialGradient>
<polygon fill="url(#SVGID_1_)" points="98.581,110.958 98.581,129.814 114.91,120.385 "/>
<radialGradient id="SVGID_2_" cx="65.6494" cy="81.2998" r="81.8353" gradientUnits="userSpaceOnUse">
<stop offset="0" style="stop-color:#57A2D9"/>
<stop offset="1" style="stop-color:#004A8E"/>
</radialGradient>
<path fill="url(#SVGID_2_)" d="M83.27,96.306l10.275,5.932V65.707c0-0.899,0.48-1.73,1.258-2.18l28.654-16.542L89.868,27.593
l-6.599,3.81V96.306z"/>
<radialGradient id="SVGID_3_" cx="65.6489" cy="81.3003" r="81.8332" gradientUnits="userSpaceOnUse">
<stop offset="0" style="stop-color:#D9DADA"/>
<stop offset="1" style="stop-color:#ADADAD"/>
</radialGradient>
<polygon fill="url(#SVGID_3_)" points="35.752,96.307 35.752,58.133 13.66,45.377 9.374,47.852 9.374,111.538 "/>
<radialGradient id="SVGID_4_" cx="65.6543" cy="81.3003" r="81.8301" gradientUnits="userSpaceOnUse">
<stop offset="0" style="stop-color:#D9DADA"/>
<stop offset="1" style="stop-color:#ADADAD"/>
</radialGradient>
<polygon fill="url(#SVGID_4_)" points="98.581,67.16 98.581,105.146 119.944,117.481 124.959,114.585 124.959,51.93 "/>
<radialGradient id="SVGID_5_" cx="65.6499" cy="81.2183" r="81.9199" gradientUnits="userSpaceOnUse">
<stop offset="0" style="stop-color:#57A2D9"/>
<stop offset="1" style="stop-color:#004A8E"/>
</radialGradient>
<path fill="url(#SVGID_5_)" d="M93.545,108.051l-14.05-8.113c-0.78-0.449-1.259-1.281-1.259-2.179V29.949
c0-0.899,0.479-1.731,1.259-2.179l5.339-3.084l-17.668-10.2L40.772,29.724c0.007,0.074,0.015,0.149,0.015,0.225v25.278
l14.374,8.299c0.778,0.449,1.259,1.281,1.259,2.18v67.81c0,0.9-0.481,1.731-1.259,2.182l-4.61,2.661l16.614,9.593l26.379-15.229
V108.051z"/>
<radialGradient id="SVGID_6_" cx="65.6489" cy="81.3013" r="81.8339" gradientUnits="userSpaceOnUse">
<stop offset="0" style="stop-color:#57A2D9"/>
<stop offset="1" style="stop-color:#004A8E"/>
</radialGradient>
<polygon fill="url(#SVGID_6_)" points="35.752,52.321 35.752,32.622 18.694,42.47 "/>
<radialGradient id="SVGID_7_" cx="65.6499" cy="81.2998" r="81.8327" gradientUnits="userSpaceOnUse">
<stop offset="0" style="stop-color:#57A2D9"/>
<stop offset="1" style="stop-color:#004A8E"/>
</radialGradient>
<path fill="url(#SVGID_7_)" d="M51.386,67.16l-10.599-6.12v36.72c0,0.899-0.481,1.73-1.259,2.179l-27.761,16.03l33.75,19.482
l5.869-3.389V67.16z"/>
</g>
<g>
<path d="M102.767,188.545l-8.822-5.094v-8.778l8.822-5.094c1.168-0.676,1.566-2.164,0.893-3.333
c-0.673-1.166-2.163-1.563-3.33-0.892l-10.041,5.8c-0.755,0.433-1.219,1.238-1.219,2.11v11.592c0,0.872,0.464,1.678,1.219,2.114
l10.041,5.796c0.383,0.223,0.803,0.328,1.217,0.328c0.843,0,1.662-0.439,2.113-1.221
C104.333,190.709,103.935,189.218,102.767,188.545z"/>
<path d="M53.21,165.029c-1.346,0-2.438,1.091-2.438,2.438v23.189c0,1.347,1.092,2.439,2.438,2.439
c1.348,0,2.439-1.093,2.439-2.439v-23.189C55.649,166.12,54.558,165.029,53.21,165.029z"/>
<path d="M81.501,165.029H66.366c-1.346,0-2.438,1.091-2.438,2.438c0,1.346,1.091,2.438,2.438,2.438h5.13v20.751
c0,1.347,1.092,2.439,2.438,2.439c1.348,0,2.439-1.093,2.439-2.439v-20.751h5.128c1.348,0,2.439-1.093,2.439-2.438
C83.94,166.12,82.849,165.029,81.501,165.029z"/>
<path d="M32.785,165.029c-1.346,0-2.438,1.091-2.438,2.438v23.189c0,1.347,1.091,2.439,2.438,2.439
c1.348,0,2.439-1.093,2.439-2.439v-23.189C35.224,166.12,34.132,165.029,32.785,165.029z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -119,7 +119,7 @@ window.setupMap = function() {
//their usage policy has no limits (except required notification above 4000 tiles/sec - we're perhaps at 50 tiles/sec based on CloudMade stats) //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 mqSubdomains = [ 'otile1','otile2', 'otile3', 'otile4' ];
var mqTileUrlPrefix = window.location.protocol !== 'https:' ? 'http://{s}.mqcdn.com' : 'https://{s}-s.mqcdn.com'; 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 mqMapOpt = {attribution: osmAttribution+', Tiles Courtesy of MapQuest', maxZoom: 18, detectRetena: true, subdomains: mqSubdomains};
var mqMap = new L.TileLayer(mqTileUrlPrefix+'/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 //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 mqSatOpt = {attribution: 'Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency', mazZoom: 18, detectRetena: true, subdomains: mqSubdomains};
@ -127,10 +127,11 @@ window.setupMap = function() {
var views = [ var views = [
/*0*/ mqMap, /*0*/ mqMap,
/*1*/ new L.Google('INGRESS'), /*1*/ new L.Google('INGRESS',{maxZoom:20}),
/*2*/ new L.Google('ROADMAP'), /*2*/ new L.Google('ROADMAP',{maxZoom:20}),
/*3*/ new L.Google('SATELLITE',{maxZoom:20}), /*3*/ new L.Google('SATELLITE',{maxZoom:20}),
/*4*/ new L.Google('HYBRID',{maxZoom:20}) /*4*/ new L.Google('HYBRID',{maxZoom:20}),
/*5*/ new L.Google('TERRAIN',{maxZoom:15})
]; ];
@ -161,7 +162,8 @@ window.setupMap = function() {
'Default Ingress Map': views[1], 'Default Ingress Map': views[1],
'Google Roads': views[2], 'Google Roads': views[2],
'Google Satellite': views[3], 'Google Satellite': views[3],
'Google Hybrid': views[4] 'Google Hybrid': views[4],
'Google Terrain': views[5]
}, addLayers); }, addLayers);
map.addControl(window.layerChooser); map.addControl(window.layerChooser);

View File

@ -12,34 +12,30 @@ window.requestData = function() {
requests.abort(); requests.abort();
cleanUp(); cleanUp();
var magic = convertCenterLat(map.getCenter().lat);
var R = calculateR(magic);
var bounds = map.getBounds(); var bounds = map.getBounds();
// convert to point values
topRight = convertLatLngToPoint(bounds.getNorthEast(), magic, R); var x1 = lngToTile(bounds.getNorthWest().lng, map.getZoom());
bottomLeft = convertLatLngToPoint(bounds.getSouthWest() , magic, R); var x2 = lngToTile(bounds.getNorthEast().lng, map.getZoom());
// how many quadrants intersect the current view? var y1 = latToTile(bounds.getNorthWest().lat, map.getZoom());
quadsX = Math.abs(bottomLeft.x - topRight.x); var y2 = latToTile(bounds.getSouthWest().lat, map.getZoom());
quadsY = Math.abs(bottomLeft.y - topRight.y);
// will group requests by second-last quad-key quadrant // will group requests by second-last quad-key quadrant
tiles = {}; tiles = {};
// walk in x-direction, starts right goes left // walk in x-direction, starts right goes left
for(var i = 0; i <= quadsX; i++) { for (var x = x1; x <= x2; x++) {
var x = Math.abs(topRight.x - i); for (var y = y1; y <= y2; y++) {
var qk = pointToQuadKey(x, topRight.y); var tile_id = pointToTileId(map.getZoom(), x, y);
var bnds = convertPointToLatLng(x, topRight.y, magic, R); var bucket = Math.floor(x / 2) + "" + Math.floor(y / 2);
if(!tiles[qk.slice(0, -1)]) tiles[qk.slice(0, -1)] = []; if (!tiles[bucket])
tiles[qk.slice(0, -1)].push(generateBoundsParams(qk, bnds)); tiles[bucket] = [];
tiles[bucket].push(generateBoundsParams(
// walk in y-direction, starts top, goes down tile_id,
for(var j = 1; j <= quadsY; j++) { tileToLat(y + 1, map.getZoom()),
var qk = pointToQuadKey(x, topRight.y + j); tileToLng(x, map.getZoom()),
var bnds = convertPointToLatLng(x, topRight.y + j, magic, R); tileToLat(y, map.getZoom()),
if(!tiles[qk.slice(0, -1)]) tiles[qk.slice(0, -1)] = []; tileToLng(x + 1, map.getZoom())
tiles[qk.slice(0, -1)].push(generateBoundsParams(qk, bnds)); ));
} }
} }
@ -78,7 +74,7 @@ window.handleDataResponse = function(data, textStatus, jqXHR) {
// portals can be brought to front, this costs extra time. They need // portals can be brought to front, this costs extra time. They need
// to be in the foreground, or they cannot be clicked. See // to be in the foreground, or they cannot be clicked. See
// https://github.com/Leaflet/Leaflet/issues/185 // https://github.com/Leaflet/Leaflet/issues/185
var ppp = []; var ppp = {};
var p2f = {}; var p2f = {};
$.each(m, function(qk, val) { $.each(m, function(qk, val) {
$.each(val.deletedGameEntityGuids || [], function(ind, guid) { $.each(val.deletedGameEntityGuids || [], function(ind, guid) {
@ -115,7 +111,7 @@ window.handleDataResponse = function(data, textStatus, jqXHR) {
ent[2].imageByUrl = {'imageUrl': DEFAULT_PORTAL_IMG}; 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) { } else if(ent[2].edge !== undefined) {
renderLink(ent); renderLink(ent);
} else if(ent[2].capturedRegion !== undefined) { } else if(ent[2].capturedRegion !== undefined) {
@ -132,6 +128,25 @@ window.handleDataResponse = function(data, textStatus, jqXHR) {
}); });
$.each(ppp, function(ind, portal) { $.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) { if(portal[2].portalV2['linkedFields'] === undefined) {
portal[2].portalV2['linkedFields'] = []; portal[2].portalV2['linkedFields'] = [];
} }

View File

@ -1,65 +1,45 @@
// 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
// is currently visible) it first calculates which tiles intersect. // is currently visible) it first calculates which tiles intersect.
// For all those tiles, it then calculates the lat/lng bounds of that // 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” // tile and a quadkey. Both the bounds and the quadkey are “somewhat”
// required to get complete data. No idea how the projection between // required to get complete data.
// lat/lng and tiles works. //
// What follows now are functions that allow conversion between tiles // Convertion functions courtesy of
// and lat/lng as well as calculating the quad key. The variable names // http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
// 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”).
window.convertCenterLat = function(centerLat) { window.lngToTile = function(lng, zoom) {
return Math.round(256 * 0.9999 * Math.abs(1 / Math.cos(centerLat * DEG2RAD))); return Math.floor((lng + 180) / 360 * Math.pow(2, zoom));
} }
window.calculateR = function(convCenterLat) { window.latToTile = function(lat, zoom) {
return 1 << window.map.getZoom() - (convCenterLat / 256 - 1); 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) { window.tileToLng = function(x, zoom) {
var x = (magic + latlng.lng * magic / 180)*R; return x / Math.pow(2, zoom) * 360 - 180;
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.convertPointToLatLng = function(x, y, magic, R) { window.tileToLat = function(y, zoom) {
var e = {}; var n = Math.PI - 2 * Math.PI * y / Math.pow(2, zoom);
e.sw = { return 180 / Math.PI * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
// 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;
} }
// calculates the quad key for a given point. The point is not(!) in window.pointToTileId = function(zoom, x, y) {
// lat/lng format. return zoom + "_" + x + "_" + y;
window.pointToQuadKey = function(x, y) {
return window.map.getZoom() + "_" + 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. // Ingress API to request map data.
window.generateBoundsParams = function(quadkey, bounds) { window.generateBoundsParams = function(tile_id, minLat, minLng, maxLat, maxLng) {
return { return {
id: quadkey, id: tile_id,
qk: quadkey, qk: tile_id,
minLatE6: Math.round(bounds.sw.lat * 1E6), minLatE6: Math.round(minLat * 1E6),
minLngE6: Math.round(bounds.sw.lng * 1E6), minLngE6: Math.round(minLng * 1E6),
maxLatE6: Math.round(bounds.ne.lat * 1E6), maxLatE6: Math.round(maxLat * 1E6),
maxLngE6: Math.round(bounds.ne.lng * 1E6) maxLngE6: Math.round(maxLng * 1E6)
}; };
} }

View File

@ -137,7 +137,7 @@ window.showPortalPosLinks = function(lat, lng, name) {
portal_name = encodeURIComponent(' (' + name + ')'); portal_name = encodeURIComponent(' (' + name + ')');
} }
if (typeof android !== 'undefined' && android && android.intentPosLink) { if (typeof android !== 'undefined' && android && android.intentPosLink) {
android.intentPosLink(window.location.protocol + '//maps.google.com/?q='+lat+','+lng); android.intentPosLink(lat, lng, portal_name);
} else { } else {
var qrcode = '<div id="qrcode"></div>'; var qrcode = '<div id="qrcode"></div>';
var script = '<script>$(\'#qrcode\').qrcode({text:\'GEO:'+lat+','+lng+'\'});</script>'; var script = '<script>$(\'#qrcode\').qrcode({text:\'GEO:'+lat+','+lng+'\'});</script>';
@ -202,8 +202,8 @@ window.renderLimitReached = function(ratio) {
window.getMinPortalLevel = function() { window.getMinPortalLevel = function() {
var z = map.getZoom(); var z = map.getZoom();
if(z >= 16) return 0; if(z >= 17) return 0;
var conv = ['impossible', 8,7,7,6,6,5,5,4,4,3,3,2,2,1,1]; var conv = ['impossible', 8,8,8,7,7,6,6,5,4,4,3,3,2,2,1,1];
var minLevelByRenderLimit = portalRenderLimit.getMinLevel(); var minLevelByRenderLimit = portalRenderLimit.getMinLevel();
var result = minLevelByRenderLimit > conv[z] var result = minLevelByRenderLimit > conv[z]
? minLevelByRenderLimit ? minLevelByRenderLimit
@ -233,6 +233,7 @@ window.getTypeByGuid = function(guid) {
// portals end in “.11” or “.12“, links in “.9", fields in “.b” // portals end in “.11” or “.12“, links in “.9", fields in “.b”
// .11 == portals // .11 == portals
// .12 == portals // .12 == portals
// .16 == portals
// .9 == links // .9 == links
// .b == fields // .b == fields
// .c == player/creator // .c == player/creator
@ -246,6 +247,7 @@ window.getTypeByGuid = function(guid) {
switch(guid.slice(33)) { switch(guid.slice(33)) {
case '11': case '11':
case '12': case '12':
case '16':
return TYPE_PORTAL; return TYPE_PORTAL;
case '9': case '9':

View File

@ -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.11.0.@@DATETIMEVERSION@@ // @version 0.11.2.@@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@@

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cradle.iitc_mobile" package="com.cradle.iitc_mobile"
android:versionCode="11" android:versionCode="12"
android:versionName="0.3" > android:versionName="0.3.1" >
<uses-sdk <uses-sdk
android:minSdkVersion="14" android:minSdkVersion="14"

View File

@ -18,11 +18,12 @@ public class IITC_JSInterface {
context = c; context = c;
} }
// send intent for gmaps link // send geo intent for navigation apps like gmaps or waze etc...
@JavascriptInterface @JavascriptInterface
public void intentPosLink(String s) { public void intentPosLink(String lat, String lng, String portal_name) {
String uri = "geo:" + lat + "," + lng + "?q=" + lat + "," + lng + portal_name;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse(s)); Uri.parse(uri));
context.startActivity(intent); context.startActivity(intent);
} }

View File

@ -22,6 +22,7 @@ public class IITC_WebView extends WebView {
settings.setDomStorageEnabled(true); settings.setDomStorageEnabled(true);
settings.setAllowFileAccess(true); settings.setAllowFileAccess(true);
settings.setGeolocationEnabled(true); settings.setGeolocationEnabled(true);
settings.setDatabasePath(this.getContext().getApplicationInfo().dataDir + "/databases/");
this.js_interface = new IITC_JSInterface(c); this.js_interface = new IITC_JSInterface(c);
this.addJavascriptInterface(js_interface, "android"); this.addJavascriptInterface(js_interface, "android");

View File

@ -266,12 +266,13 @@ window.plugin.playerTracker.drawData = function() {
if(window.plugin.guessPlayerLevels !== undefined && if(window.plugin.guessPlayerLevels !== undefined &&
window.plugin.guessPlayerLevels.fetchLevelByPlayer !== undefined) { window.plugin.guessPlayerLevels.fetchLevelByPlayer !== undefined) {
var playerLevel = window.plugin.guessPlayerLevels.fetchLevelByPlayer(pguid); var playerLevel = window.plugin.guessPlayerLevels.fetchLevelByPlayer(pguid);
if (playerLevel === undefined) playerLevel = 1; //if player level unknown, assume level 1
if(playerLevel !== undefined) { if(playerLevel !== undefined) {
title += '<span style="font-weight:bold;margin-left:10px;">Level ' title += '<span style="font-weight:bold;margin-left:10px;">Level '
+ playerLevel + playerLevel
+ (playerLevel < (window.MAX_XM_PER_LEVEL.length - 1) ? ' (guessed)' : '') + (playerLevel < (window.MAX_XM_PER_LEVEL.length - 1) ? ' (guessed)' : '')
+ '</span>'; + '</span>';
} else {
title += '<span style="font-weight:bold;margin-left:10px;">Level unknown</span>'
} }
} }
@ -370,7 +371,8 @@ window.plugin.playerTracker.centerMapOnUser = function(nick) {
return false; return false;
} }
map.setView(position, map.getZoom()); if(window.isSmartphone()) window.smartphone.mapButton.click();
window.map.setView(position, map.getZoom());
} }
window.plugin.playerTracker.onNicknameClicked = function(info) { window.plugin.playerTracker.onNicknameClicked = function(info) {

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @id iitc-plugin-portals-list@teo96 // @id iitc-plugin-portals-list@teo96
// @name IITC plugin: show list of portals // @name IITC plugin: show list of portals
// @version 0.0.10.@@DATETIMEVERSION@@ // @version 0.0.11.@@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@@
@ -13,6 +13,8 @@
// ==/UserScript== // ==/UserScript==
/* whatsnew /* whatsnew
* 0.0.11: Add nominal energy column and # links, fix sort bug when opened even amounts of times, nits
* 0.0.10: Fixed persistent css problem with alert
* 0.0.9 : bugs hunt * 0.0.9 : bugs hunt
* 0.0.8 : Aborted to avoid problems with Niantic (export portals informations as csv or kml file) * 0.0.8 : Aborted to avoid problems with Niantic (export portals informations as csv or kml file)
* 0.0.7 : more informations avalaible via tooltips (who deployed, energy, ...), new E/AP column * 0.0.7 : more informations avalaible via tooltips (who deployed, energy, ...), new E/AP column
@ -89,15 +91,16 @@ window.plugin.portalslist.getPortals = function(){
//get shield informations //get shield informations
var shields = []; var shields = [];
$.each(d.portalV2.linkedModArray, function(ind, mod) { $.each(d.portalV2.linkedModArray, function(ind, mod) {
if (mod) if (mod) {
//shields[ind] = mod.rarity.capitalize().replace('_', ' '); //shields[ind] = mod.rarity.capitalize().replace('_', ' ');
shields[ind] = [mod.rarity.substr(0,1).capitalize(), getPlayerName(mod.installingUser)] ; shields[ind] = [mod.rarity.substr(0,1).capitalize(), getPlayerName(mod.installingUser)] ;
else } else {
shields[ind] = ['', '']; shields[ind] = ['', ''];
}
}); });
var APgain= getAttackApGain(d).enemyAp; var APgain= getAttackApGain(d).enemyAp;
var thisPortal = {'portal':d,'name':name,'team':team,'level':level,'guid':guid, 'resonators':resonators,'energyratio' : Math.floor(energy/maxenergy*100), 'shields':shields, 'APgain':APgain, 'EAP' : (energy/APgain).toFixed(2), 'energy': energy, 'maxenergy':maxenergy, 'lat':portal._latlng.lat, 'lng':portal._latlng.lng, 'address': address, 'img' : img}; var thisPortal = {'portal': d, 'name': name, 'team': team, 'level': level, 'guid': guid, 'resonators': resonators, 'energyratio': maxenergy ? Math.floor(energy/maxenergy*100) : 0, 'shields': shields, 'APgain': APgain, 'EAP': (energy/APgain).toFixed(2), 'energy': energy, 'maxenergy': maxenergy, 'links': d.portalV2.linkedEdges.length, 'lat': portal._latlng.lat, 'lng': portal._latlng.lng, 'address': address, 'img': img};
window.plugin.portalslist.listPortals.push(thisPortal); window.plugin.portalslist.listPortals.push(thisPortal);
}); });
@ -119,20 +122,23 @@ window.plugin.portalslist.displayPL = function() {
} else { } else {
html = '<table><tr><td>Nothing to Show !</td></tr></table>'; html = '<table><tr><td>Nothing to Show !</td></tr></table>';
}; };
alert('<div id="portalslist">' + html + '</div>', true, function() {$(".ui-dialog").removeClass('ui-dialog-portalslist');}); alert('<div id="portalslist">' + html + '</div>', true, function() {
$(".ui-dialog").removeClass('ui-dialog-portalslist');
$(document).off('.portalslist');
});
$(".ui-dialog").addClass('ui-dialog-portalslist'); $(".ui-dialog").addClass('ui-dialog-portalslist');
// Setup sorting // Setup sorting
$(document).on('click', '#portalslist table th', function() { $(document).on('click.portalslist', '#portalslist table th', function() {
$('#portalslist').html(window.plugin.portalslist.portalTable($(this).data('sort'),window.plugin.portalslist.sortOrder,window.plugin.portalslist.filter)); $('#portalslist').html(window.plugin.portalslist.portalTable($(this).data('sort'),window.plugin.portalslist.sortOrder,window.plugin.portalslist.filter));
}); });
$(document).on('click', '#portalslist .filterAll', function() { $(document).on('click.portalslist', '#portalslist .filterAll', function() {
$('#portalslist').html(window.plugin.portalslist.portalTable($(this).data('sort'),window.plugin.portalslist.sortOrder,0)); $('#portalslist').html(window.plugin.portalslist.portalTable($(this).data('sort'),window.plugin.portalslist.sortOrder,0));
}); });
$(document).on('click', '#portalslist .filterRes', function() { $(document).on('click.portalslist', '#portalslist .filterRes', function() {
$('#portalslist').html(window.plugin.portalslist.portalTable($(this).data('sort'),window.plugin.portalslist.sortOrder,1)); $('#portalslist').html(window.plugin.portalslist.portalTable($(this).data('sort'),window.plugin.portalslist.sortOrder,1));
}); });
$(document).on('click', '#portalslist .filterEnl', function() { $(document).on('click.portalslist', '#portalslist .filterEnl', function() {
$('#portalslist').html(window.plugin.portalslist.portalTable($(this).data('sort'),window.plugin.portalslist.sortOrder,2)); $('#portalslist').html(window.plugin.portalslist.portalTable($(this).data('sort'),window.plugin.portalslist.sortOrder,2));
}); });
@ -193,7 +199,7 @@ window.plugin.portalslist.portalTable = function(sortBy, sortOrder, filter) {
retVal = b[sortBy] - a[sortBy]; retVal = b[sortBy] - a[sortBy];
break; break;
} }
if (sortOrder > 0) { retVal = -retVal} //thx @jonatkins if (sortOrder > 0) retVal = -retVal; //thx @jonatkins
return retVal; return retVal;
}); });
@ -211,7 +217,9 @@ window.plugin.portalslist.portalTable = function(sortBy, sortOrder, filter) {
+ '<th ' + sort('r6', sortBy, -1) + '>R6</th>' + '<th ' + sort('r6', sortBy, -1) + '>R6</th>'
+ '<th ' + sort('r7', sortBy, -1) + '>R7</th>' + '<th ' + sort('r7', sortBy, -1) + '>R7</th>'
+ '<th ' + sort('r8', sortBy, -1) + '>R8</th>' + '<th ' + sort('r8', sortBy, -1) + '>R8</th>'
+ '<th ' + sort('energyratio', sortBy, -1) + '>Energy</th>' + '<th ' + sort('energy', sortBy, -1) + '>Energy</th>'
+ '<th ' + sort('energyratio', sortBy, -1) + '>%</th>'
+ '<th ' + sort('links', sortBy, -1) + '>Links</th>'
+ '<th ' + sort('s1', sortBy, -1) + '>S1</th>' + '<th ' + sort('s1', sortBy, -1) + '>S1</th>'
+ '<th ' + sort('s2', sortBy, -1) + '>S2</th>' + '<th ' + sort('s2', sortBy, -1) + '>S2</th>'
+ '<th ' + sort('s3', sortBy, -1) + '>S3</th>' + '<th ' + sort('s3', sortBy, -1) + '>S3</th>'
@ -228,17 +236,21 @@ window.plugin.portalslist.portalTable = function(sortBy, sortOrder, filter) {
+ '<td class="L' + Math.floor(portal.level) +'">' + portal.level + '</td>' + '<td class="L' + Math.floor(portal.level) +'">' + portal.level + '</td>'
+ '<td style="text-align:center;">' + portal.team + '</td>'; + '<td style="text-align:center;">' + portal.team + '</td>';
var title;
var percent;
$.each([0, 1, 2, 3 ,4 ,5 ,6 ,7], function(ind, slot) { $.each([0, 1, 2, 3 ,4 ,5 ,6 ,7], function(ind, slot) {
percent = portal.resonators[slot][4] ? Math.floor(portal.resonators[slot][3]/portal.resonators[slot][4]*100) : 0;
var title = 'title="owner: <b>' + portal.resonators[slot][1] + '</b><br>' title = 'title="owner: <b>' + portal.resonators[slot][1] + '</b><br>'
+ 'energy: ' + portal.resonators[slot][3] + ' / ' + portal.resonators[slot][4] + ' (' + Math.floor(portal.resonators[slot][3]/portal.resonators[slot][4]*100) + '%)<br>' + 'energy: ' + portal.resonators[slot][3] + ' / ' + portal.resonators[slot][4] + ' (' + percent + '%)<br>'
+ 'distance: ' + portal.resonators[slot][2] + 'm'; + 'distance: ' + portal.resonators[slot][2] + 'm';
html += '<td class="L' + portal.resonators[slot][0] +'" ' + title + '">' + portal.resonators[slot][0] + '</td>'; html += '<td class="L' + portal.resonators[slot][0] +'" ' + title + '">' + portal.resonators[slot][0] + '</td>';
}); });
html += '<td style="cursor:help" title="' + portal.energy + ' / ' + portal.maxenergy +'">' + portal.energyratio + '%</td>' html += '<td style="cursor:help" title="'+ portal.energy +'">' + prettyEnergy(portal.energy) + '</td>'
+ '<td style="cursor:help" title="' + portal.energy + ' / ' + portal.maxenergy +'">' + portal.energyratio + '%</td>'
+ '<td style="cursor:help" title="' + portal.links + '">' + portal.links + '</td>'
+ '<td style="cursor:help" title="'+ portal.shields[0][1] +'">' + portal.shields[0][0] + '</td>' + '<td style="cursor:help" title="'+ portal.shields[0][1] +'">' + portal.shields[0][0] + '</td>'
+ '<td style="cursor:help" title="'+ portal.shields[1][1] +'">' + portal.shields[1][0] + '</td>' + '<td style="cursor:help" title="'+ portal.shields[1][1] +'">' + portal.shields[1][0] + '</td>'
+ '<td style="cursor:help" title="'+ portal.shields[2][1] +'">' + portal.shields[2][0] + '</td>' + '<td style="cursor:help" title="'+ portal.shields[2][1] +'">' + portal.shields[2][0] + '</td>'
@ -251,8 +263,6 @@ window.plugin.portalslist.portalTable = function(sortBy, sortOrder, filter) {
}); });
html += '</table>'; html += '</table>';
//html += window.plugin.portalslist.exportLinks();
html += '<div class="disclaimer">Click on portals table headers to sort by that column. ' html += '<div class="disclaimer">Click on portals table headers to sort by that column. '
+ 'Click on <b>All Portals, Resistant Portals, Enlightened Portals</b> to filter<br>' + 'Click on <b>All Portals, Resistant Portals, Enlightened Portals</b> to filter<br>'
+ 'Thanks to @vita10gy & @xelio for their IITC plugins who inspired me. A <a href="https://plus.google.com/113965246471577467739">@teo96</a> production. Vive la Résistance !</div>'; + 'Thanks to @vita10gy & @xelio for their IITC plugins who inspired me. A <a href="https://plus.google.com/113965246471577467739">@teo96</a> production. Vive la Résistance !</div>';
@ -272,103 +282,6 @@ window.plugin.portalslist.stats = function(sortBy) {
return html; return html;
} }
//return Html generated to export links
window.plugin.portalslist.exportLinks = function(){
var html='';
var stamp = new Date().getTime();
html+='<div><aside><a download="Ingress Export.csv" href="' + window.plugin.portalslist.export('csv') + '">Export as .csv</a></aside>'
+ '<aside><a download="Ingress Export.kml" href="' + window.plugin.portalslist.export('kml') + '">Export as .kml</a></aside>'
+ '</div>';
return html;
}
window.plugin.portalslist.export = function(fileformat){
//alert('format :' + fileformat);
var file = '';
var uri = '';
switch (fileformat) {
case 'csv':
file = window.plugin.portalslist.exportCSV();
break;
case 'kml':
file = window.plugin.portalslist.exportKML();
break;
}
if (file !== '') {
//http://stackoverflow.com/questions/4639372/export-to-csv-in-jquery
var uri = 'data:application/' + fileformat + 'csv;charset=UTF-8,' + encodeURIComponent(file);
//window.open(uri);
}
return uri;
}
window.plugin.portalslist.exportCSV = function(){
var csv = '';
var filter = window.plugin.portalslist.filter;
var portals = window.plugin.portalslist.listPortals;
//headers
csv += 'Portal\tLevel\tTeam\tR1\tR2\tR3\tR4\tR5\tR6\tR7\tR8\tEnergy\tS1\tS2\tS3\tS4\tAP Gain\tE/AP\tlat\tlong\n';
$.each(portals, function(ind, portal) {
if (filter === 0 || filter === portal.team){
csv += portal.name + '\t'
+ portal.level + '\t'
+ portal.team + '\t';
$.each([0, 1, 2, 3 ,4 ,5 ,6 ,7], function(ind, slot) {
csv += portal.resonators[slot][0] + '\t';
});
csv += portal.energyratio + '\t' + portal.shields[0][0] + '\t' + portal.shields[1][0] + '\t' + portal.shields[2][0] + '\t' + portal.shields[3][0] + '\t' + portal.APgain + '\t' + portal.EAP + '\t';
csv += portal.lat + '\t' + portal.lng;
csv += '\n';
}
});
return csv;
}
window.plugin.portalslist.exportKML = function(){
var kml = '';
var filter = window.plugin.portalslist.filter;
// all portals informations are avalaible in the listPortals array
var portals = window.plugin.portalslist.listPortals;
//headers
kml = '<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2"><Document>\n'
+ '<name>Ingress Export</name><description><![CDATA[Ingress Portals\nExported from IITC using the Portals-list plugin\n' + new Date().toLocaleString() + ']]></description>';
// define colored markers as style0 (neutral), style1 (Resistance), style2 (Enlight)
kml += '<Style id="style1"><IconStyle><Icon><href>http://maps.gstatic.com/mapfiles/ms2/micons/blue-dot.png</href></Icon></IconStyle></Style>'
+ '<Style id="style2"><IconStyle><Icon><href>http://maps.gstatic.com/mapfiles/ms2/micons/green-dot.png</href></Icon></IconStyle></Style>'
+ '<Style id="style0"><IconStyle><Icon><href>http://maps.gstatic.com/mapfiles/ms2/micons/pink-dot.png</href></Icon></IconStyle></Style>\n';
$.each(portals, function(ind, portal) {
// add the portal in the kml file only if part of the filter choice
if (filter === 0 || filter === portal.team){
// description contain picture of the portal, address and link to the Intel map
var description = '<![CDATA['
+ '<div><table><tr><td><img style="width:100px" src="' + portal.img + '"></td><td>' + portal.address
+ '<br><a href="https://www.ingress.com/intel?latE6=' + portal.lat*1E6 + '&lngE6=' + portal.lng*1E6 + '&z=17">Link to Intel Map</a></td></tr></table>'
+ ']]>';
kml += '<Placemark><name>L' + Math.floor(portal.level) + ' - ' + portal.name + '</name>'
+ '<description>' + description + '</description>'
+ '<styleUrl>#style' + portal.team + '</styleUrl>';
//coordinates
kml += '<Point><coordinates>' + portal.lng + ',' + portal.lat + ',0</coordinates></Point>';
kml += '</Placemark>\n';
}
});
kml += '</Document></kml>';
return kml;
}
// A little helper functon so the above isn't so messy // A little helper functon so the above isn't so messy
window.plugin.portalslist.portalTableSort = function(name, by) { window.plugin.portalslist.portalTableSort = function(name, by) {
var retVal = 'data-sort="' + name + '"'; var retVal = 'data-sort="' + name + '"';
@ -403,9 +316,9 @@ window.plugin.portalslist.getPortalLink = function(portal,guid) {
} }
var setup = function() { var setup = function() {
$('#toolbox').append(' <a onclick="window.plugin.portalslist.displayPL(0)" title="Display a list of portals in the current view">Portals list</a>'); $('#toolbox').append(' <a onclick="window.plugin.portalslist.displayPL()" title="Display a list of portals in the current view">Portals list</a>');
$('head').append('<style>' + $('head').append('<style>' +
'.ui-dialog-portalslist {position: absolute !important; top: 10px !important; left: 30px !important;max-width:800px !important; width:733px !important;}' + '.ui-dialog-portalslist {position: absolute !important; top: 10px !important; left: 30px !important;max-width:800px !important; width:auto !important;}' +
'#portalslist table {margin-top:5px; border-collapse: collapse; empty-cells: show; width:100%; clear: both;}' + '#portalslist table {margin-top:5px; border-collapse: collapse; empty-cells: show; width:100%; clear: both;}' +
'#portalslist table td, #portalslist table th {border-bottom: 1px solid #0b314e; padding:3px; color:white; background-color:#1b415e}' + '#portalslist table td, #portalslist table th {border-bottom: 1px solid #0b314e; padding:3px; color:white; background-color:#1b415e}' +
'#portalslist table tr.res td { background-color: #005684; }' + '#portalslist table tr.res td { background-color: #005684; }' +

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @id iitc-plugin-scoreboard@vita10gy // @id iitc-plugin-scoreboard@vita10gy
// @name IITC plugin: show a localized scoreboard. // @name IITC plugin: show a localized scoreboard.
// @version 0.1.6.@@DATETIMEVERSION@@ // @version 0.1.7.@@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@@
@ -69,7 +69,6 @@ window.plugin.scoreboard.compileStats = function() {
var team = getTeam(val.options.data); var team = getTeam(val.options.data);
var player = val.options.data.creator.creatorGuid; var player = val.options.data.creator.creatorGuid;
window.plugin.scoreboard.initPlayer(player,team); window.plugin.scoreboard.initPlayer(player,team);
// Google sends fields long since dead in the data. This makes sure it's still actually up. // Google sends fields long since dead in the data. This makes sure it's still actually up.
@ -109,6 +108,7 @@ window.plugin.scoreboard.compileStats = function() {
$.each(window.links, function(qk, link) { $.each(window.links, function(qk, link) {
somethingInView = true; somethingInView = true;
var team = getTeam(link.options.data); var team = getTeam(link.options.data);
if(link.options.data.creator !== undefined) {
var player = link.options.data.creator.creatorGuid; var player = link.options.data.creator.creatorGuid;
window.plugin.scoreboard.initPlayer(player, team); window.plugin.scoreboard.initPlayer(player, team);
scores['team'][team]['count_links']++; scores['team'][team]['count_links']++;
@ -131,7 +131,7 @@ window.plugin.scoreboard.compileStats = function() {
// largestLink = linkLength; // largestLink = linkLength;
//} //}
//scores['player'][player]['largest']['link'] = largestLink; //scores['player'][player]['largest']['link'] = largestLink;
}
}); });
$.each(window.portals, function(qk, portal) { $.each(window.portals, function(qk, portal) {
somethingInView = true; somethingInView = true;
@ -204,6 +204,7 @@ window.plugin.scoreboard.fieldInfo = function(field) {
+ window.digits(field.options.data.entityScore.entityScore) + window.digits(field.options.data.entityScore.entityScore)
+ ' - ' + window.getPlayerName(field.options.data.creator.creatorGuid) + ' - ' + window.getPlayerName(field.options.data.creator.creatorGuid)
+ '</div>'; + '</div>';
} else { } else {
retVal = 'N/A'; retVal = 'N/A';
} }
@ -224,6 +225,7 @@ window.plugin.scoreboard.fieldInfoArea = function(field) {
+ window.digits(Math.round(field.options.data.fieldArea)) + window.digits(Math.round(field.options.data.fieldArea))
+ ' - ' + window.getPlayerName(field.options.data.creator.creatorGuid) + ' - ' + window.getPlayerName(field.options.data.creator.creatorGuid)
+ '</div>'; + '</div>';
} else { } else {
retVal = 'N/A'; retVal = 'N/A';
} }