Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Jack Miner 2013-12-17 07:50:23 +00:00
commit e655bb6585
22 changed files with 421 additions and 143 deletions

BIN
assets/prefer-iitc.psd Normal file

Binary file not shown.

View File

@ -247,7 +247,10 @@ window.artifact.showArtifactList = function() {
} }
if (data[type].fragments) { if (data[type].fragments) {
row += '<span class="fragments">Shard: #'+data[type].fragments.join(', #')+'</span> '; if (data[type].target) {
row += '<br>';
}
row += '<span class="fragments'+(data[type].target?' '+TEAM_TO_CSS[data[type].target]:'')+'">Shard: #'+data[type].fragments.join(', #')+'</span> ';
sortVal = Math.min.apply(null, data[type].fragments); // use min shard number at portal as sort key sortVal = Math.min.apply(null, data[type].fragments); // use min shard number at portal as sort key
} }

View File

@ -228,12 +228,12 @@ window.chat.renderCompact = function(oldMsgsWereAdded) {
$.each(chat._public.data, function(guid, entry) { $.each(chat._public.data, function(guid, entry) {
// skip player msgs // skip player msgs
if(!entry[1]) return true; if(!entry[1]) return true;
var pguid = entry[3]; var nick = entry[3];
// ignore if player has newer data // ignore if player has newer data
if(data[pguid] && data[pguid][0] > entry[0]) return true; if(data[nick] && data[nick][0] > entry[0]) return true;
data[pguid] = entry; data[nick] = entry;
}); });
// data keys are now player guids instead of message guids. However, // data keys are now player nicks instead of message guids. However,
// it is all the same to renderData. // it is all the same to renderData.
chat.renderData(data, 'chatcompact', oldMsgsWereAdded); chat.renderData(data, 'chatcompact', oldMsgsWereAdded);
} }
@ -350,7 +350,7 @@ window.chat.writeDataToHash = function(newData, storageHash, isPublicChannel, is
// format: timestamp, autogenerated, HTML message // format: timestamp, autogenerated, HTML message
storageHash.data[json[0]] = [json[1], auto, chat.renderMsg(msg, nick, time, team, msgToPlayer, systemNarrowcast)]; storageHash.data[json[0]] = [json[1], auto, chat.renderMsg(msg, nick, time, team, msgToPlayer, systemNarrowcast), nick];
}); });
} }

View File

@ -89,6 +89,7 @@ window.runHooks = function(event, data) {
window.addHook = function(event, callback) { window.addHook = function(event, callback) {
if(VALID_HOOKS.indexOf(event) === -1) { if(VALID_HOOKS.indexOf(event) === -1) {
console.error('addHook: Unknown event type: ' + event + ' - ignoring'); console.error('addHook: Unknown event type: ' + event + ' - ignoring');
debugger;
return; return;
} }

View File

@ -16,8 +16,9 @@ window.MapDataRequest = function() {
// no more than this many requests in parallel. stock site seems to rely on browser limits (6, usually), sending // no more than this many requests in parallel. stock site seems to rely on browser limits (6, usually), sending
// all requests at once. using our own queue limit ensures that other requests (e.g. chat) don't get postponed for too long // many requests at once.
this.MAX_REQUESTS = 6; // using our own queue limit ensures that other requests (e.g. chat, portal details) don't get delayed
this.MAX_REQUESTS = 5;
// no more than this many tiles in one request // no more than this many tiles in one request
// as of 2013-11-11, or possibly the release before that, the stock site was changed to only request four tiles at a time // as of 2013-11-11, or possibly the release before that, the stock site was changed to only request four tiles at a time
@ -28,7 +29,7 @@ window.MapDataRequest = function() {
this.MIN_TILES_PER_REQUEST = 4; this.MIN_TILES_PER_REQUEST = 4;
// number of times to retry a tile after a 'bad' error (i.e. not a timeout) // number of times to retry a tile after a 'bad' error (i.e. not a timeout)
this.MAX_TILE_RETRIES = 1; this.MAX_TILE_RETRIES = 2;
// refresh timers // refresh timers
this.MOVE_REFRESH = 1; //time, after a map move (pan/zoom) before starting the refresh processing this.MOVE_REFRESH = 1; //time, after a map move (pan/zoom) before starting the refresh processing

View File

@ -109,7 +109,7 @@ window.renderPortalDetails = function(guid) {
} else { } else {
// non-android - a permalink for the portal // non-android - a permalink for the portal
var permaHtml = $('<div>').html( $('<a>').attr({href:permalinkUrl, target:'_blank', title:'Create a URL link to this portal'}).text('Portal link') ).html(); var permaHtml = $('<div>').html( $('<a>').attr({href:permalinkUrl, title:'Create a URL link to this portal'}).text('Portal link') ).html();
linkDetails.push ( '<aside>'+permaHtml+'</aside>' ); linkDetails.push ( '<aside>'+permaHtml+'</aside>' );
// and a map link popup dialog // and a map link popup dialog

View File

@ -68,22 +68,23 @@ window.getLinkAmpRangeBoost = function(d) {
// (at the time of writing, only rare link amps have been seen in the wild, so there's a little guesswork at how // (at the time of writing, only rare link amps have been seen in the wild, so there's a little guesswork at how
// the stats work and combine - jon 2013-06-26) // the stats work and combine - jon 2013-06-26)
// link amps scale: first is full, second half, the last two a quarter // link amps scale: first is full, second a quarter, the last two an eigth
var scale = [1.0, 0.5, 0.25, 0.25]; var scale = [1.0, 0.25, 0.125, 0.125];
var boost = 1.0; // initial boost is 1.0 (i.e. no boost over standard range) var boost = 0.0; // initial boost is 0.0 (i.e. no boost over standard range)
var count = 0; var count = 0;
$.each(d.portalV2.linkedModArray, function(ind, mod) { var linkAmps = getPortalModsByType(d, 'LINK_AMPLIFIER');
if(mod && mod.type === 'LINK_AMPLIFIER' && mod.stats && mod.stats.LINK_RANGE_MULTIPLIER) {
// link amp stat LINK_RANGE_MULTIPLIER is 2000 for rare, and gives 2x boost to the range $.each(linkAmps, function(ind, mod) {
var baseMultiplier = mod.stats.LINK_RANGE_MULTIPLIER/1000; // link amp stat LINK_RANGE_MULTIPLIER is 2000 for rare, and gives 2x boost to the range
boost += (baseMultiplier-1)*scale[count]; // and very-rare is 7000 and gives 7x the range
count++; var baseMultiplier = mod.stats.LINK_RANGE_MULTIPLIER/1000;
} boost += baseMultiplier*scale[count];
count++;
}); });
return boost; return (count > 0) ? boost : 1.0;
} }

View File

@ -58,19 +58,23 @@ Modified by qnstie 2013-07-17 to maintain compatibility with Leaflet.draw
// loop ends before 'segments' is reached - we don't add the very last point here but outside the loop // loop ends before 'segments' is reached - we don't add the very last point here but outside the loop
// (this was to fix a bug - https://github.com/jonatkins/ingress-intel-total-conversion/issues/471 // (this was to fix a bug - https://github.com/jonatkins/ingress-intel-total-conversion/issues/471
// rounding errors? maths bug? not sure - but it solves the issue! and is a slight optimisation) // rounding errors? maths bug? not sure - but it solves the issue! and is a slight optimisation)
for (i = 1; i < segments; i++) { // UPDATE: there still seem to be rounding errors on relatively short links - but only on mobile.
// http://williams.best.vwh.net/avform.htm#Intermediate // let's only add intermediate points if there's two or more
// modified to handle longitude above +-180 degrees if (segments >= 3) {
f = i / segments; for (i = 1; i < segments; i++) {
A = Math.sin((1-f)*d) / Math.sin(d); // http://williams.best.vwh.net/avform.htm#Intermediate
B = Math.sin(f*d) / Math.sin(d); // modified to handle longitude above +-180 degrees
x = A * Math.cos(lat1) * Math.cos(0) + B * Math.cos(lat2) * Math.cos(dLng); f = i / segments;
y = A * Math.cos(lat1) * Math.sin(0) + B * Math.cos(lat2) * Math.sin(dLng); A = Math.sin((1-f)*d) / Math.sin(d);
z = A * Math.sin(lat1) + B * Math.sin(lat2); B = Math.sin(f*d) / Math.sin(d);
fLat = r2d * Math.atan2(z, Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))); x = A * Math.cos(lat1) * Math.cos(0) + B * Math.cos(lat2) * Math.cos(dLng);
fLng = r2d * (Math.atan2(y, x)+lng1); y = A * Math.cos(lat1) * Math.sin(0) + B * Math.cos(lat2) * Math.sin(dLng);
z = A * Math.sin(lat1) + B * Math.sin(lat2);
fLat = r2d * Math.atan2(z, Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)));
fLng = r2d * (Math.atan2(y, x)+lng1);
convertedPoints.push(L.latLng([fLat, fLng])); convertedPoints.push(L.latLng([fLat, fLng]));
}
} }
// push the final point unmodified // push the final point unmodified
convertedPoints.push(L.latLng(endLatlng)); convertedPoints.push(L.latLng(endLatlng));

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 848 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -6,6 +6,7 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnDismissListener; import android.content.DialogInterface.OnDismissListener;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
@ -166,7 +167,7 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
} }
} }
if (mDrawerLayout.isDrawerOpen(mDrawerLeft)) { if (mDrawerLayout.isDrawerOpen(mDrawerLeft) || mPane == Pane.MAP) {
mActionBar.setTitle(mIitc.getString(R.string.app_name)); mActionBar.setTitle(mIitc.getString(R.string.app_name));
} else { } else {
mActionBar.setTitle(mPane.label); mActionBar.setTitle(mPane.label);
@ -184,7 +185,16 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
public void addPane(String name, String label, String icon) { public void addPane(String name, String label, String icon) {
showNotice(NOTICE_PANES); showNotice(NOTICE_PANES);
int resId = mIitc.getResources().getIdentifier(icon, "drawable", mIitc.getPackageName()); Resources res = mIitc.getResources();
String packageName = res.getResourcePackageName(R.string.app_name);
/*
* since the package name is overridden in test builds
* we can't use context.getPackageName() to get the package name
* because the resources were processed before the package name was finally updated.
* so we have to retrieve the package name of another resource with Resources.getResourcePackageName()
* see http://www.piwai.info/renaming-android-manifest-package/
*/
int resId = mIitc.getResources().getIdentifier(icon, "drawable", packageName);
mNavigationAdapter.add(new Pane(name, label, resId)); mNavigationAdapter.add(new Pane(name, label, resId));
} }
@ -341,7 +351,7 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
public static final Pane FACTION = new Pane("faction", "Faction", R.drawable.ic_action_cc_bcc); public static final Pane FACTION = new Pane("faction", "Faction", R.drawable.ic_action_cc_bcc);
public static final Pane FULL = new Pane("full", "Full", R.drawable.ic_action_view_as_list); public static final Pane FULL = new Pane("full", "Full", R.drawable.ic_action_view_as_list);
public static final Pane INFO = new Pane("info", "Info", R.drawable.ic_action_about); public static final Pane INFO = new Pane("info", "Info", R.drawable.ic_action_about);
public static final Pane MAP = new Pane("map", "IITC Mobile", R.drawable.ic_action_map); public static final Pane MAP = new Pane("map", "Map", R.drawable.ic_action_map);
public static final Pane PUBLIC = new Pane("public", "Public", R.drawable.ic_action_group); public static final Pane PUBLIC = new Pane("public", "Public", R.drawable.ic_action_group);
private int icon; private int icon;

View File

@ -38,7 +38,7 @@ window.plugin.drawResonators.portalSelected = function(data) {
} }
} }
window.plugin.drawResonators.portalDetailsLoaded = function(data) { window.plugin.drawResonators.portalDetailLoaded = function(data) {
// the detailed data for a portal was just loaded - if this is the selected portal, draw them // the detailed data for a portal was just loaded - if this is the selected portal, draw them
if (data.guid == window.selectedPortal) { if (data.guid == window.selectedPortal) {
@ -117,6 +117,13 @@ window.plugin.drawResonators.zoomListener = function() {
ctrl.addClass('disabled').attr('title', 'Zoom in to show those.'); ctrl.addClass('disabled').attr('title', 'Zoom in to show those.');
} else { } else {
ctrl.removeClass('disabled').attr('title', 'Select a portal to draw resos'); ctrl.removeClass('disabled').attr('title', 'Select a portal to draw resos');
window.plugin.drawResonators.levelLayerGroup.clearLayers();
if (window.selectedPortal) {
var details = portalDetail.get(window.selectedPortal);
if (details) {
window.plugin.drawResonators.drawData(details);
}
}
}; };
} }
@ -127,7 +134,7 @@ var setup = function() {
window.addLayerGroup('Resonators', window.plugin.drawResonators.levelLayerGroup, true); window.addLayerGroup('Resonators', window.plugin.drawResonators.levelLayerGroup, true);
window.addHook('portalSelected', window.plugin.drawResonators.portalSelected); window.addHook('portalSelected', window.plugin.drawResonators.portalSelected);
window.addHook('portalDetailsLoaded', window.plugin.drawResonators.portalDetailsLoaded); window.addHook('portalDetailLoaded', window.plugin.drawResonators.portalDetailLoaded);
window.map.on('zoomend', function() { window.map.on('zoomend', function() {
window.plugin.drawResonators.zoomListener(); window.plugin.drawResonators.zoomListener();

View File

@ -0,0 +1,26 @@
// ==UserScript==
// @id iitc-digital-bumper-sticker
// @name IITC Digital Bumper Sticker
// @category Stock
// @version 0.1.0.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Adds a "I'd rather be using IITC" logo to the standard intel map.
// @include https://www.ingress.com/intel*
// @include http://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
// @grant none
// ==/UserScript==
var logoDiv = document.createElement('div');
logoDiv.setAttribute('style', "position: fixed; left: 20px; top: 130px; z-index: auto; pointer-events: none;");
var img = document.createElement('img');
img.setAttribute('src', 'http://iitc.jonatkins.com/assets/img/prefer-iitc-200.png');
logoDiv.appendChild(img);
var targetContainer = document.getElementById('dashboard_container');
targetContainer.appendChild(logoDiv);

View File

@ -2,7 +2,7 @@
// @id iitc-plugin-portals-count@yenky // @id iitc-plugin-portals-count@yenky
// @name IITC plugin: Show total counts of portals // @name IITC plugin: Show total counts of portals
// @category Info // @category Info
// @version 0.0.9.@@DATETIMEVERSION@@ // @version 0.1.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@@
@ -19,95 +19,303 @@
// PLUGIN START //////////////////////////////////////////////////////// // PLUGIN START ////////////////////////////////////////////////////////
/* whatsnew /* whatsnew
* 0.0.8 : use dialog() instead of alert() * 0.1.0 : display graphs
* 0.0.6 : ignoring outside bounds portals (even if close to) * 0.0.10 : show in nav drawer on mobile devices
* 0.0.5 : changed table layout, added some colors * 0.0.9 : fix for new intel map
* 0.0.4 : reverse show order of portals, using MAX_PORTAL_LEVEL now for array, changed table layout to be more compact, cleaned up code * 0.0.8 : use dialog() instead of alert()
* 0.0.3 : fixed incorrect rounded portal levels, adjusted viewport * 0.0.6 : ignoring outside bounds portals (even if close to)
* 0.0.2 : fixed counts to be reset after scrolling * 0.0.5 : changed table layout, added some colors
* 0.0.1 : initial release, show count of portals * 0.0.4 : reverse show order of portals, using MAX_PORTAL_LEVEL now for array, changed table layout to be more compact, cleaned up code
* todo : * 0.0.3 : fixed incorrect rounded portal levels, adjusted viewport
*/ * 0.0.2 : fixed counts to be reset after scrolling
* 0.0.1 : initial release, show count of portals
*/
// use own namespace for plugin // use own namespace for plugin
window.plugin.portalcounts = function() {}; window.plugin.portalcounts = {
BAR_TOP: 20,
BAR_HEIGHT: 180,
BAR_WIDTH: 25,
BAR_PADDING: 5,
RADIUS_INNER: 70,
RADIUS_OUTER: 100,
CENTER_X: 200,
CENTER_Y: 100,
};
//count portals for each level available on the map //count portals for each level available on the map
window.plugin.portalcounts.getPortals = function(){ window.plugin.portalcounts.getPortals = function (){
//console.log('** getPortals'); //console.log('** getPortals');
var retval=false; var self = window.plugin.portalcounts;
var displayBounds = map.getBounds(); var displayBounds = map.getBounds();
window.plugin.portalcounts.enlP = 0; self.enlP = 0;
window.plugin.portalcounts.resP = 0; self.resP = 0;
window.plugin.portalcounts.neuP = 0; self.neuP = 0;
window.plugin.portalcounts.PortalsEnl = new Array(); self.PortalsEnl = new Array();
window.plugin.portalcounts.PortalsRes = new Array(); self.PortalsRes = new Array();
for(var level = window.MAX_PORTAL_LEVEL; level > 0; level--){ for(var level = window.MAX_PORTAL_LEVEL; level > 0; level--){
window.plugin.portalcounts.PortalsEnl[level] = 0; self.PortalsEnl[level] = 0;
window.plugin.portalcounts.PortalsRes[level] = 0; self.PortalsRes[level] = 0;
} }
$.each(window.portals, function(i, portal) { $.each(window.portals, function(i, portal) {
retval=true;
var level = portal.options.level; var level = portal.options.level;
var team = portal.options.team; var team = portal.options.team;
// just count portals in viewport // just count portals in viewport
if(!displayBounds.contains(portal.getLatLng())) return true; if(!displayBounds.contains(portal.getLatLng())) return true;
switch (team){ switch (team){
case 1 : case 1 :
window.plugin.portalcounts.resP++; self.resP++;
window.plugin.portalcounts.PortalsRes[level]++; self.PortalsRes[level]++;
break; break;
case 2 : case 2 :
window.plugin.portalcounts.enlP++; self.enlP++;
window.plugin.portalcounts.PortalsEnl[level]++; self.PortalsEnl[level]++;
break; break;
default: default:
window.plugin.portalcounts.neuP++; self.neuP++;
break; break;
} }
}); });
//get portals informations from IITC //get portals informations from IITC
var minlvl = getMinPortalLevel(); var minlvl = getMinPortalLevel();
var total = self.neuP + self.enlP + self.resP;
var counts = '<table>'; var counts = '';
if(retval) { if(total > 0) {
counts += '<tr><th></th><th class="enl">Enlightened</th><th class="res">Resistance</th></tr>'; //'+window.plugin.portalcounts.enlP+' Portal(s)</th></tr>'; counts += '<table><tr><th></th><th class="enl">Enlightened</th><th class="res">Resistance</th></tr>'; //'+self.enlP+' Portal(s)</th></tr>';
for(var level = window.MAX_PORTAL_LEVEL; level > 0; level--){ for(var level = window.MAX_PORTAL_LEVEL; level > 0; level--){
counts += '<tr><td class="L'+level+'">Level '+level+'</td>'; counts += '<tr><td class="L'+level+'">Level '+level+'</td>';
if(minlvl > level) if(minlvl > level)
counts += '<td colspan="2">zoom in to see portals in this level</td>'; counts += '<td colspan="2">zoom in to see portals in this level</td>';
else else
counts += '<td class="enl">'+window.plugin.portalcounts.PortalsEnl[level]+'</td><td class="res">'+window.plugin.portalcounts.PortalsRes[level]+'</td>'; counts += '<td class="enl">'+self.PortalsEnl[level]+'</td><td class="res">'+self.PortalsRes[level]+'</td>';
counts += '</tr>'; counts += '</tr>';
} }
counts += '<tr><th>Total:</th><td class="enl">'+window.plugin.portalcounts.enlP+'</td><td class="res">'+window.plugin.portalcounts.resP+'</td></tr>'; counts += '<tr><th>Total:</th><td class="enl">'+self.enlP+'</td><td class="res">'+self.resP+'</td></tr>';
counts += '<tr><td>Neutral:</td><td colspan="2">'; counts += '<tr><td>Neutral:</td><td colspan="2">';
if(minlvl > 0) if(minlvl > 0)
counts += 'zoom in to see unclaimed portals'; counts += 'zoom in to see unclaimed portals';
else else
counts += window.plugin.portalcounts.neuP; counts += self.neuP;
counts += '</td></tr>'; counts += '</td></tr></table>';
var svg = $('<svg width="300" height="200">').css("margin-top", 10);
var all = self.PortalsRes.map(function(val,i){return val+self.PortalsEnl[i]});
all[0] = self.neuP;
// bar graphs
self.makeBar(self.PortalsEnl, "Enl", COLORS[2], 0 ).appendTo(svg);
self.makeBar(all , "All", "#FFFFFF", 1*(self.BAR_WIDTH + self.BAR_PADDING)).appendTo(svg);
self.makeBar(self.PortalsRes, "Res", COLORS[1], 2*(self.BAR_WIDTH + self.BAR_PADDING)).appendTo(svg);
// pie graph
var g = $("<g>")
.attr("transform", self.format("translate(%s,%s)", self.CENTER_X, self.CENTER_Y))
.appendTo(svg);
// inner parts - factions
self.makePie(0, self.resP/total, COLORS[1]).appendTo(g);
self.makePie(self.resP/total, (self.neuP + self.resP)/total, COLORS[0]).appendTo(g);
self.makePie((self.neuP + self.resP)/total, 1, COLORS[2]).appendTo(g);
// outer part - levels
var angle = 0;
for(var i=self.PortalsRes.length-1;i>=0;i--) {
if(!self.PortalsRes[i])
continue;
var diff = self.PortalsRes[i] / total;
self.makeRing(angle, angle+diff, COLORS_LVL[i]).appendTo(g);
angle += diff;
}
var diff = self.neuP / total;
self.makeRing(angle, angle+diff, COLORS_LVL[0]).appendTo(g);
angle += diff;
for(var i=0;i<self.PortalsEnl.length;i++) {
if(!self.PortalsEnl[i])
continue;
var diff = self.PortalsEnl[i] / total;
self.makeRing(angle, angle+diff, COLORS_LVL[i]).appendTo(g);
angle += diff;
}
// black line from center to top
$("<line>")
.attr({
x1: self.resP<self.enlP ? 0.5 : -0.5,
y1: 0,
x2: self.resP<self.enlP ? 0.5 : -0.5,
y2: -self.RADIUS_OUTER,
stroke: "#000",
"stroke-width": 1
})
.appendTo(g);
// if there are no neutral portals, draw a black line between res and enl
if(self.neuP == 0) {
var x = Math.sin((0.5 - self.resP/total) * 2 * Math.PI) * self.RADIUS_OUTER;
var y = Math.cos((0.5 - self.resP/total) * 2 * Math.PI) * self.RADIUS_OUTER;
$("<line>")
.attr({
x1: self.resP<self.enlP ? 0.5 : -0.5,
y1: 0,
x2: x,
y2: y,
stroke: "#000",
"stroke-width": 1
})
.appendTo(g);
}
counts += $("<div>").append(svg).html();
} else } else
counts += '<tr><td>No Portals in range!</td></tr>'; counts += '<p>No Portals in range!</p>';
counts += '</table>';
var total = self.enlP + self.resP + self.neuP;
var title = total + ' ' + (total == 1 ? 'portal' : 'portals');
var total = window.plugin.portalcounts.enlP + window.plugin.portalcounts.resP + window.plugin.portalcounts.neuP; if(typeof android !== 'undefined' && android && android.addPane) {
dialog({ $('<div id="portalcounts" class="mobile">'
html: '<div id="portalcounts">' + counts + '</div>', + '<div class="ui-dialog-titlebar"><span class="ui-dialog-title ui-dialog-title-active">' + title + '</span></div>'
title: 'Portal counts: ' + total + ' ' + (total == 1 ? 'portal' : 'portals'), + counts
}); + '</div>').appendTo(document.body);
} else {
dialog({
html: '<div id="portalcounts">' + counts + '</div>',
title: 'Portal counts: ' + title,
width: 'auto'
});
}
} }
window.plugin.portalcounts.makeBar = function(portals, text, color, shift) {
var self = window.plugin.portalcounts;
var g = $("<g>").attr("transform", "translate("+shift+",0)");
var sum = portals.reduce(function(a,b){ return a+b });
var top = self.BAR_TOP;
if(sum != 0) {
for(var i=portals.length-1;i>=0;i--) {
if(!portals[i])
continue;
var height = self.BAR_HEIGHT * portals[i] / sum;
$("<rect>")
.attr({
x: 0,
y: top,
width: self.BAR_WIDTH,
height: height,
fill: COLORS_LVL[i]
})
.appendTo(g);
top += height;
}
}
$('<text>')
.html(text)
.attr({
x: self.BAR_WIDTH * 0.5,
y: self.BAR_TOP * 0.75,
fill: color,
"text-anchor": "middle"
})
.appendTo(g);
return g;
};
window.plugin.portalcounts.makePie = function(startAngle, endAngle, color) {
var self = window.plugin.portalcounts;
var large_arc = (endAngle - startAngle) > 0.5 ? 1 : 0;
startAngle = 0.5 - startAngle;
endAngle = 0.5 - endAngle;
var p1x = Math.sin(startAngle * 2 * Math.PI) * self.RADIUS_INNER;
var p1y = Math.cos(startAngle * 2 * Math.PI) * self.RADIUS_INNER;
var p2x = Math.sin(endAngle * 2 * Math.PI) * self.RADIUS_INNER;
var p2y = Math.cos(endAngle * 2 * Math.PI) * self.RADIUS_INNER;
// for a full circle, both coordinates would be identical, so no circle would be drawn
if(startAngle == 0.5 && endAngle == -0.5)
p2x -= 1E-5;
return $("<path>")
.attr({
fill: color,
d: self.format("M %s,%s A %s,%s 0 %s 1 %s,%s L 0,0 z", p1x,p1y, self.RADIUS_INNER,self.RADIUS_INNER, large_arc, p2x,p2y)
});
};
window.plugin.portalcounts.makeRing = function(startAngle, endAngle, color) {
var self = window.plugin.portalcounts;
var large_arc = (endAngle - startAngle) > 0.5 ? 1 : 0;
startAngle = 0.5 - startAngle;
endAngle = 0.5 - endAngle;
var p1x = Math.sin(startAngle * 2 * Math.PI) * self.RADIUS_OUTER;
var p1y = Math.cos(startAngle * 2 * Math.PI) * self.RADIUS_OUTER;
var p2x = Math.sin(endAngle * 2 * Math.PI) * self.RADIUS_OUTER;
var p2y = Math.cos(endAngle * 2 * Math.PI) * self.RADIUS_OUTER;
var p3x = Math.sin(endAngle * 2 * Math.PI) * self.RADIUS_INNER;
var p3y = Math.cos(endAngle * 2 * Math.PI) * self.RADIUS_INNER;
var p4x = Math.sin(startAngle * 2 * Math.PI) * self.RADIUS_INNER;
var p4y = Math.cos(startAngle * 2 * Math.PI) * self.RADIUS_INNER;
// for a full circle, both coordinates would be identical, so no circle would be drawn
if(startAngle == 0.5 && endAngle == -0.5) {
p2x -= 1E-5;
p3x -= 1E-5;
}
return $("<path>")
.attr({
fill: color,
d: self.format("M %s,%s ", p1x, p1y)
+ self.format("A %s,%s 0 %s 1 %s,%s ", self.RADIUS_OUTER,self.RADIUS_OUTER, large_arc, p2x,p2y)
+ self.format("L %s,%s ", p3x,p3y)
+ self.format("A %s,%s 0 %s 0 %s,%s ", self.RADIUS_INNER,self.RADIUS_INNER, large_arc, p4x,p4y)
+ "Z"
});
};
window.plugin.portalcounts.format = function(str) {
var re = /%s/;
for(var i = 1; i < arguments.length; i++) {
str = str.replace(re, arguments[i]);
}
return str;
}
window.plugin.portalcounts.onPaneChanged = function(pane) {
if(pane == "plugin-portalcounts")
window.plugin.portalcounts.getPortals();
else
$("#portalcounts").remove()
};
var setup = function() { var setup = function() {
$('#toolbox').append(' <a onclick="window.plugin.portalcounts.getPortals()" title="Display a summary of portals in the current view">Portal counts</a>'); if(typeof android !== 'undefined' && android && android.addPane) {
$('head').append('<style>' + android.addPane("plugin-portalcounts", "Portal counts", "ic_action_data_usage");
addHook("paneChanged", window.plugin.portalcounts.onPaneChanged);
} else {
$('#toolbox').append(' <a onclick="window.plugin.portalcounts.getPortals()" title="Display a summary of portals in the current view">Portal counts</a>');
}
$('head').append('<style>' +
'#portalcounts.mobile {background: transparent; border: 0 none !important; height: 100% !important; width: 100% !important; left: 0 !important; top: 0 !important; position: absolute; overflow: auto; z-index: 9000 !important; }' +
'#portalcounts table {margin-top:5px; border-collapse: collapse; empty-cells: show; width:100%; clear: both;}' + '#portalcounts table {margin-top:5px; border-collapse: collapse; empty-cells: show; width:100%; clear: both;}' +
'#portalcounts table td, #portalcounts table th {border-bottom: 1px solid #0b314e; padding:3px; color:white; background-color:#1b415e}' + '#portalcounts table td, #portalcounts table th {border-bottom: 1px solid #0b314e; padding:3px; color:white; background-color:#1b415e}' +
'#portalcounts table tr.res th { background-color: #005684; }' + '#portalcounts table tr.res th { background-color: #005684; }' +
@ -122,7 +330,7 @@ var setup = function() {
'#portalcounts table td.L5 { background-color: #FD2992 !important;}' + '#portalcounts table td.L5 { background-color: #FD2992 !important;}' +
'#portalcounts table td.L6 { background-color: #EB26CD !important;}' + '#portalcounts table td.L6 { background-color: #EB26CD !important;}' +
'#portalcounts table td.L7 { background-color: #C124E0 !important;}' + '#portalcounts table td.L7 { background-color: #C124E0 !important;}' +
'#portalcounts table td.L8 { background-color: #9627F4 !important;}' + '#portalcounts table td.L8 { background-color: #9627F4 !important;}' +
'#portalcounts table td:nth-child(1) { text-align: left;}' + '#portalcounts table td:nth-child(1) { text-align: left;}' +
'#portalcounts table th:nth-child(1) { text-align: left;}' + '#portalcounts table th:nth-child(1) { text-align: left;}' +
'</style>'); '</style>');

View File

@ -45,10 +45,11 @@
window.plugin.portalslist = function() {}; window.plugin.portalslist = function() {};
window.plugin.portalslist.listPortals = []; window.plugin.portalslist.listPortals = [];
window.plugin.portalslist.sortOrder=-1; window.plugin.portalslist.sortBy = 'level';
window.plugin.portalslist.sortOrder = -1;
window.plugin.portalslist.enlP = 0; window.plugin.portalslist.enlP = 0;
window.plugin.portalslist.resP = 0; window.plugin.portalslist.resP = 0;
window.plugin.portalslist.filter=0; window.plugin.portalslist.filter = 0;
//fill the listPortals array with portals avaliable on the map (level filtered portals will not appear in the table) //fill the listPortals array with portals avaliable on the map (level filtered portals will not appear in the table)
window.plugin.portalslist.getPortals = function() { window.plugin.portalslist.getPortals = function() {
@ -64,16 +65,14 @@ window.plugin.portalslist.getPortals = function() {
retval=true; retval=true;
var d = portal.options.data; var d = portal.options.data;
var teamN = window.TEAM_NONE; var teamN = portal.options.team;
switch (d.team){ switch (teamN) {
case 'RESISTANCE' : case TEAM_RES:
window.plugin.portalslist.resP++; window.plugin.portalslist.resP++;
teamN = window.TEAM_RES
break; break;
case 'ENLIGHTENED' : case TEAM_ENL:
window.plugin.portalslist.enlP++; window.plugin.portalslist.enlP++;
teamN = window.TEAM_ENL;
break; break;
} }
var l = window.getPortalLinks(i); var l = window.getPortalLinks(i);
@ -84,6 +83,7 @@ window.plugin.portalslist.getPortals = function() {
'guid': i, 'guid': i,
'teamN': teamN, 'teamN': teamN,
'name': d.title, 'name': d.title,
'nameLower': d.title.toLowerCase(),
'team': d.team, 'team': d.team,
'level': portal.options.level, 'level': portal.options.level,
'health': d.health, 'health': d.health,
@ -102,12 +102,14 @@ window.plugin.portalslist.getPortals = function() {
window.plugin.portalslist.displayPL = function() { window.plugin.portalslist.displayPL = function() {
var html = ''; var html = '';
window.plugin.portalslist.sortOrder=-1; window.plugin.portalslist.sortBy = 'level';
window.plugin.portalslist.sortOrder = -1;
window.plugin.portalslist.enlP = 0; window.plugin.portalslist.enlP = 0;
window.plugin.portalslist.resP = 0; window.plugin.portalslist.resP = 0;
window.plugin.portalslist.filter = 0;
if (window.plugin.portalslist.getPortals()) { if (window.plugin.portalslist.getPortals()) {
html += window.plugin.portalslist.portalTable('level', window.plugin.portalslist.sortOrder,window.plugin.portalslist.filter); html += window.plugin.portalslist.portalTable(window.plugin.portalslist.sortBy, window.plugin.portalslist.sortOrder,window.plugin.portalslist.filter);
} else { } else {
html = '<table><tr><td>Nothing to show!</td></tr></table>'; html = '<table><tr><td>Nothing to show!</td></tr></table>';
}; };
@ -123,84 +125,94 @@ window.plugin.portalslist.displayPL = function() {
width: 700 width: 700
}); });
} }
//run the name resolving process
//resolvePlayerNames();
} }
window.plugin.portalslist.portalTable = function(sortBy, sortOrder, filter) { window.plugin.portalslist.portalTable = function(sortBy, sortOrder, filter) {
// sortOrder <0 ==> desc, >0 ==> asc, i use sortOrder * -1 to change the state // save the sortBy/sortOrder/filter
window.plugin.portalslist.filter=filter; window.plugin.portalslist.sortBy = sortBy;
window.plugin.portalslist.sortOrder = sortOrder;
window.plugin.portalslist.filter = filter;
var portals=window.plugin.portalslist.listPortals; var portals=window.plugin.portalslist.listPortals;
//Array sort //Array sort
window.plugin.portalslist.listPortals.sort(function(a, b) { window.plugin.portalslist.listPortals.sort(function(a, b) {
var retVal = 0; var retVal = 0;
switch (sortBy) {
case 'names': var aComp = a[sortBy];
retVal = a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1; var bComp = b[sortBy];
break;
default: if (aComp < bComp) {
retVal = b[sortBy] - a[sortBy]; retVal = -1;
break; } else if (aComp > bComp) {
retVal = 1;
} else {
// equal - compare GUIDs to ensure consistant (but arbitary) order
retVal = a.guid < b.guid ? -1 : 1;
} }
if (sortOrder > 0) retVal = -retVal; //thx @jonatkins
// sortOrder is 1 (normal) or -1 (reversed)
retVal = retVal * sortOrder;
return retVal; return retVal;
}); });
var sort = window.plugin.portalslist.portalTableSort; var sortAttr = window.plugin.portalslist.portalTableHeaderSortAttr;
var html = window.plugin.portalslist.stats(); var html = window.plugin.portalslist.stats();
html += '<table>' html += '<table>'
+ '<tr><th ' + sort('names', sortBy, -1) + '>Portal</th>' + '<tr>'
+ '<th ' + sort('level', sortBy, -1) + '>Level</th>' + '<th>#</th>'
+ '<th title="Team" ' + sort('teamN', sortBy, -1) + '>Team</th>' + '<th ' + sortAttr('nameLower', sortBy, 1, 'portalTitle') + '>Portal Name</th>'
+ '<th ' + sort('health', sortBy, -1) + '>Health</th>' + '<th ' + sortAttr('level', sortBy, -1) + '>Level</th>'
+ '<th ' + sort('resCount', sortBy, -1) + '>Resonator Count</th>' + '<th ' + sortAttr('teamN', sortBy, 1) + '>Team</th>'
+ '<th ' + sort('linkCount', sortBy, -1) + '>Link Count</th>' + '<th ' + sortAttr('health', sortBy, -1) + '>Health</th>'
+ '<th ' + sort('fieldCount', sortBy, -1) + '>Field Count</th>' + '<th ' + sortAttr('resCount', sortBy, -1) + '>Resonators</th>'
+ '<th ' + sortAttr('linkCount', sortBy, -1) + '>Links</th>'
+ '<th ' + sortAttr('fieldCount', sortBy, -1) + '>Fields</th>'
var rowNum = 1;
$.each(portals, function(ind, portal) { $.each(portals, function(ind, portal) {
if (filter === TEAM_NONE || filter === portal.teamN) { if (filter === TEAM_NONE || filter === portal.teamN) {
html += '<tr class="' + (portal.teamN === window.TEAM_RES ? 'res' : (portal.teamN === window.TEAM_ENL ? 'enl' : 'neutral')) + '">' html += '<tr class="' + (portal.teamN === window.TEAM_RES ? 'res' : (portal.teamN === window.TEAM_ENL ? 'enl' : 'neutral')) + '">'
+ '<td style="">' + window.plugin.portalslist.getPortalLink(portal, portal.guid) + '</td>' + '<td>'+rowNum+'</td>'
+ '<td class="L' + Math.floor(portal.level) +'">' + portal.level + '</td>' + '<td class="portalTitle" style="">' + window.plugin.portalslist.getPortalLink(portal, portal.guid) + '</td>'
+ '<td style="text-align:center;">' + portal.team + '</td>'; + '<td class="L' + portal.level +'" style="background-color: '+COLORS_LVL[portal.level]+'">' + portal.level + '</td>'
+ '<td style="text-align:center;">' + portal.team.substr(0,3) + '</td>';
html += '<td style="cursor:help" title="'+ portal.health +'">' + portal.health + '</td>' html += '<td style="cursor:help" title="'+ portal.health +'">' + portal.health + '</td>'
+ '<td>' + portal.resCount + '</td>' + '<td>' + portal.resCount + '</td>'
+ '<td title="In: ' + portal.link.in.length + ' Out: ' + portal.link.out.length + '">' + portal.linkCount + '</td>' + '<td title="In: ' + portal.link.in.length + ' Out: ' + portal.link.out.length + '">' + (portal.linkCount?portal.linkCount:'-') + '</td>'
+ '<td>' + portal.fieldCount + '</td>'; + '<td>' + (portal.fieldCount?portal.fieldCount:'-') + '</td>';
html+= '</tr>'; html+= '</tr>';
rowNum++;
} }
}); });
html += '</table>'; html += '</table>';
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, Resistance Portals, Enlightened Portals</b> to filter<br>' + 'Click on <b>All Portals, Resistance Portals, Enlightened Portals</b> to filter</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>';
window.plugin.portalslist.sortOrder = window.plugin.portalslist.sortOrder*-1;
return html; return html;
} }
window.plugin.portalslist.stats = function(sortBy) { window.plugin.portalslist.stats = function(sortBy) {
var html = '<table><tr>' var html = '<table><tr>'
+ '<td class="filterAll" style="cursor:pointer" onclick="window.plugin.portalslist.portalTable(\'level\',-1,0)"><a href=""></a>All Portals : (click to filter)</td><td class="filterAll">' + window.plugin.portalslist.listPortals.length + '</td>' + '<td class="filterAll" style="cursor:pointer"><a href=""></a>All Portals : (click to filter)</td><td class="filterAll">' + window.plugin.portalslist.listPortals.length + '</td>'
+ '<td class="filterRes" style="cursor:pointer" class="sorted" onclick="window.plugin.portalslist.portalTable(\'level\',-1,1)">Resistance Portals : </td><td class="filterRes">' + window.plugin.portalslist.resP +' (' + Math.floor(window.plugin.portalslist.resP/window.plugin.portalslist.listPortals.length*100) + '%)</td>' + '<td class="filterRes" style="cursor:pointer" class="sorted">Resistance Portals : </td><td class="filterRes">' + window.plugin.portalslist.resP +' (' + Math.floor(window.plugin.portalslist.resP/window.plugin.portalslist.listPortals.length*100) + '%)</td>'
+ '<td class="filterEnl" style="cursor:pointer" class="sorted" onclick="window.plugin.portalslist.portalTable(\'level\',-1,2)">Enlightened Portals : </td><td class="filterEnl">'+ window.plugin.portalslist.enlP +' (' + Math.floor(window.plugin.portalslist.enlP/window.plugin.portalslist.listPortals.length*100) + '%)</td>' + '<td class="filterEnl" style="cursor:pointer" class="sorted">Enlightened Portals : </td><td class="filterEnl">'+ window.plugin.portalslist.enlP +' (' + Math.floor(window.plugin.portalslist.enlP/window.plugin.portalslist.listPortals.length*100) + '%)</td>'
+ '</tr>' + '</tr>'
+ '</table>'; + '</table>';
return html; return html;
} }
// A little helper function so the above isn't so messy // A little helper function so the above isn't so messy
window.plugin.portalslist.portalTableSort = function(name, by) { window.plugin.portalslist.portalTableHeaderSortAttr = function(name, by, defOrder, extraClass) {
var retVal = 'data-sort="' + name + '"'; // data-sort attr: used by jquery .data('sort') below
if(name === by) { var retVal = 'data-sort="'+name+'" data-defaultorder="'+defOrder+'" class="'+(extraClass?extraClass+' ':'')+'sortable'+(name==by?' sorted':'')+'"';
retVal += ' class="sorted"';
}
return retVal; return retVal;
}; };
@ -224,7 +236,7 @@ window.plugin.portalslist.getPortalLink = function(portal,guid) {
onClick: jsSingleClick, onClick: jsSingleClick,
onDblClick: jsDoubleClick onDblClick: jsDoubleClick
})[0].outerHTML; })[0].outerHTML;
var div = '<div class="portalTitle">'+a+'</div>'; var div = '<div class="portalTitleTruncate">'+a+'</div>';
return div; return div;
} }
@ -252,28 +264,33 @@ var setup = function() {
'#portalslist table tr.neutral td { background-color: #000000; }' + '#portalslist table tr.neutral td { background-color: #000000; }' +
'#portalslist table th { text-align: center;}' + '#portalslist table th { text-align: center;}' +
'#portalslist table td { text-align: center;}' + '#portalslist table td { text-align: center;}' +
'#portalslist table td:nth-child(1) { text-align: left;}' + '#portalslist table td.portalTitle { text-align: left;}' +
'#portalslist table th { cursor:pointer;}' + '#portalslist table th.sortable { cursor:pointer;}' +
'#portalslist table th:nth-child(1) { text-align: left;}' + '#portalslist table th.portalTitle { text-align: left;}' +
'#portalslist table th.sorted { color:#FFCE00; }' + '#portalslist .sorted { color:#FFCE00; }' +
'#portalslist .filterAll { margin-top: 10px;}' + '#portalslist .filterAll { margin-top: 10px;}' +
'#portalslist .filterRes { margin-top: 10px; background-color: #005684 }' + '#portalslist .filterRes { margin-top: 10px; background-color: #005684 }' +
'#portalslist .filterEnl { margin-top: 10px; background-color: #017f01 }' + '#portalslist .filterEnl { margin-top: 10px; background-color: #017f01 }' +
'#portalslist .disclaimer { margin-top: 10px; font-size:10px; }' + '#portalslist .disclaimer { margin-top: 10px; font-size:10px; }' +
'#portalslist .portalTitle { display: inline-block; width: 160px !important; min-width: 160px !important; max-width: 160px !important; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }' + '#portalslist .portalTitleTruncate { display: inline-block; width: 240px !important; min-width: 240px !important; max-width: 160px !important; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }' +
'</style>'); '</style>');
// Setup sorting // Setup sorting
$(document).on('click.portalslist', '#portalslist table th', function() { $(document).on('click.portalslist', '#portalslist table th.sortable', function() {
$('#portalslist').html(window.plugin.portalslist.portalTable($(this).data('sort'),window.plugin.portalslist.sortOrder,window.plugin.portalslist.filter)); var sortBy = $(this).data('sort');
// if this is the currently selected column, toggle the sort order - otherwise use the columns default sort order
var sortOrder = sortBy == window.plugin.portalslist.sortBy ? window.plugin.portalslist.sortOrder*-1 : parseInt($(this).data('defaultorder'));
$('#portalslist').html(window.plugin.portalslist.portalTable(sortBy,sortOrder,window.plugin.portalslist.filter));
}); });
$(document).on('click.portalslist', '#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(window.plugin.portalslist.sortBy,window.plugin.portalslist.sortOrder,0));
}); });
$(document).on('click.portalslist', '#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(window.plugin.portalslist.sortBy,window.plugin.portalslist.sortOrder,1));
}); });
$(document).on('click.portalslist', '#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(window.plugin.portalslist.sortBy,window.plugin.portalslist.sortOrder,2));
}); });
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

View File

@ -9,7 +9,7 @@ Occasionally the Niantic servers give this misleading message - what it should u
"Failed to check account status - please reload to try again". IITC will, in most cases, retry for you. "Failed to check account status - please reload to try again". IITC will, in most cases, retry for you.
</p> </p>
<p> <p>
Sometimes this is caused by server issues, and no ammount of reloading will fix it. Come back later and try again. Sometimes this is caused by server issues, and no amount of reloading will fix it. Come back later and try again.
</p> </p>
<p> <p>
However, another reason for this message is your account being blocked/suspended by Niantic. There However, another reason for this message is your account being blocked/suspended by Niantic. There