Merge branch 'upstream' into plugin

Conflicts:
	plugins/README.md
This commit is contained in:
boombuler
2013-02-23 15:50:12 +01:00
38 changed files with 2217 additions and 264 deletions

View File

@ -9,19 +9,23 @@ Plugins are installed the same way the total conversion script is. Please see th
Available Plugins
-----------------
- [**Draw Tools**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/draw-tools.user.js) allows to draw circles and lines on the map to aid you with planning your next big field.
- [**Compute AP Stats**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/compute-ap-stats.user.js) Shows the potential AP an agent could obtain by destroying and rebuilding all the portals in the current zoom area.
- [**Draw Tools**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/draw-tools.user.js) allows to draw circles and lines on the map to aid you with planning your next big field. [View screenshot](http://breunigs.github.com/ingress-intel-total-conversion/screenshots/plugin_draw_tools.png)
- [**Guess Player Level**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/guess-player-levels.user.js) looks for the highest placed resonator per player in the current view to guess the player level.
- [**Highlight Weakened Portals**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/show-portal-weakness.user.js) fill portals with red to indicate portal's state of disrepair. The brighter the color the more attention needed (recharge, shields, resonators). A dashed portal means a resonator is missing.
- [**Player Tracker**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/player-tracker.user.js) Draws trails for user actions in the last hour. At the last known location theres a tooltip that shows the data in a table. [View screenshot](http://breunigs.github.com/ingress-intel-total-conversion/screenshots/plugin_player_tracker.png).
- [**Render Limit Increase**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/render-limit-increase.user.js) increases render limits. Good for high density areas (e.g. London, UK) and faster PCs.
- [**Resonator Display Zoom Level Decrease**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/resonator-display-zoom-level-decrease.user.js) Resonator start displaying earlier.
- [**Max-Links**]((https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/rmax-links.user.js) Calculates how to link the portals to create the maximum number of fields.
- [**Show Portal Address**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/show-address.user.js) Shows portal address in the side panel.
- [**Max-Links**]((https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/max-links.user.js) Calculates how to link the portals to create the maximum number of fields.
### available only with the development version
The development version is not available publicly, you need to build it yourself. See [HACKING.md](https://github.com/breunigs/ingress-intel-total-conversion/blob/gh-pages/HACKING.md#hacking) for guides.
[Read HACKING.md file](https://github.com/breunigs/ingress-intel-total-conversion/blob/gh-pages/HACKING.md#hacking) to learn how to build the development version yourself. If **and only if** [you have read how to report bugs](https://github.com/breunigs/ingress-intel-total-conversion/blob/gh-pages/HACKING.md#how-do-i-report-bugs), you may beta test the [nightly](https://www.dropbox.com/sh/lt9p0s40kt3cs6m/3xzpyiVBnF) version.
- [**Player Tracker**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/player-tracker.user.js) Draws trails for user actions in the last hour. At the last known location theres a tooltip that shows the data in a table. [View screenshot](http://breunigs.github.com/ingress-intel-total-conversion/screenshots/plugin_player_tracker.png). **REQUIRES 2013-02-19+**
- [**Compute AP Stats**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/compute-ap-stats.user.js) Shows the potential AP an agent could obtain by destroying and rebuilding all the portals in the current zoom area. **REQUIRES 2013-02-22+**
Hacking
-------

View File

@ -1,7 +1,7 @@
// ==UserScript==
// @id iitc-plugin-compute-ap-stats@Hollow011
// @name iitc: Compute AP statistics
// @version 0.1
// @version 0.2
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/compute-ap-stats.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/compute-ap-stats.user.js
@ -21,35 +21,59 @@ if(typeof window.plugin !== 'function') window.plugin = function() {};
window.plugin.compAPStats = function() {};
window.plugin.compAPStats.setupCallback = function() {
$('#toolbox').append('<a onclick="window.plugin.compAPStats.guess()">Compute AP Stats</a> ');
// add a new div to the bottom of the sidebar and style it
$('#sidebar').append('<div id="available_ap_display"></div>');
$('#available_ap_display').css({'color':'#ffce00', 'font-size':'90%', 'padding':'4px 2px'});
// do an initial calc for sidebar sizing purposes
window.plugin.compAPStats.onPositionMove();
// make the value update when the map data updates
var handleDataResponseOrig = window.handleDataResponse;
window.handleDataResponse = function(data, textStatus, jqXHR) {
handleDataResponseOrig(data, textStatus, jqXHR);
window.plugin.compAPStats.onPositionMove();
}
}
window.plugin.compAPStats.onPositionMove = function() {
var result = window.plugin.compAPStats.compAPStats();
$('#available_ap_display').html('Available AP in this area:<table>'
+ '<tr><td>Enlightened:</td><td style="text-align:right">' + digits(result[1]) + '</td></tr>'
+ '<tr><td>Resistance:</td><td style="text-align:right">' + digits(result[0]) + '</td></tr>'
+ '</table>');
}
window.plugin.compAPStats.compAPStats = function() {
var totalAP_RES = 0;
var totalAP_ENL = 0;
var allResEdges = [];
var allResFields = [];
var allEnlEdges = [];
var allEnlFields = [];
var displayBounds = map.getBounds();
// Grab every portal in the viewable area and compute individual AP stats
$.each(window.portals, function(ind, portal) {
var d = portal.options.details;
// eliminate offscreen portals (selected, and in padding)
if(!displayBounds.contains(portal.getLatLng())) return true;
var portalStats = getAttackApGain(d);
var portalSum = portalStats.resoAp + portalStats.captureAp;
if (getTeam(d) === TEAM_ENL) {
totalAP_RES += portalSum;
$.each(d.portalV2.linkedEdges, function(ind, edge) {
if(!edge) return true;
allEnlEdges.push(edge.edgeGuid);
if(!edge) return true;
allEnlEdges.push(edge.edgeGuid);
});
$.each(d.portalV2.linkedFields, function(ind, field) {
if(!field) return true;
allEnlFields.push(field);
@ -57,50 +81,38 @@ window.plugin.compAPStats.compAPStats = function() {
}
else if (getTeam(d) === TEAM_RES) {
totalAP_ENL += portalSum;
$.each(d.portalV2.linkedEdges, function(ind, edge) {
if(!edge) return true;
allResEdges.push(edge.edgeGuid);
});
$.each(d.portalV2.linkedFields, function(ind, field) {
if(!field) return true;
allResFields.push(field);
});
} else {
} else {
// it's a neutral portal, potential for both teams. by definition no fields or edges
totalAP_ENL += portalSum;
totalAP_RES += portalSum;
}
});
// Compute team field AP
allResFields = uniqueArray(allResFields);
totalAP_ENL += (allResFields.length * DESTROY_FIELD);
allEnlFields = uniqueArray(allEnlFields);
totalAP_RES += (allEnlFields.length * DESTROY_FIELD);
// Compute team Link AP
allResEdges = uniqueArray(allResEdges);
totalAP_ENL += (allResEdges.length * DESTROY_LINK);
allEnlEdges = uniqueArray(allEnlEdges);
totalAP_RES += (allEnlEdges.length * DESTROY_LINK);
return [totalAP_RES, totalAP_ENL];
}
window.plugin.compAPStats.guess = function() {
var res = window.plugin.compAPStats.compAPStats();
var totalAP_RES = res[0];
var totalAP_ENL = res[1];
var s = 'Calculated AP gain potential:\n\n';
s += 'Available Resistance AP:\t' + digits(totalAP_RES) + '\n';
s += 'Available Enlightened AP:\t' + digits(totalAP_ENL) + '\n';
alert(s);
}
var setup = function() {
window.plugin.compAPStats.setupCallback();
}

View File

@ -1,7 +1,7 @@
// ==UserScript==
// @id iitc-plugin-player-tracker@breunigs
// @name iitc: player tracker
// @version 0.4
// @version 0.5
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/player-tracker.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/player-tracker.user.js
@ -76,10 +76,11 @@ window.plugin.playerTracker.processNewData = function(data) {
$.each(json[2].plext.markup, function(ind, markup) {
switch(markup[0]) {
case 'TEXT':
// Destroy link messages depend on how the link was originally
// created. Therefore its not clear which portal the player is
// at, so ignore it.
if(markup[1].plain.indexOf('destroyed the Link') !== -1) {
// Destroy link and field messages depend on where the link or
// field was originally created. Therefore its not clear which
// portal the player is at, so ignore it.
if(markup[1].plain.indexOf('destroyed the Link') !== -1
|| markup[1].plain.indexOf('destroyed a Control Field') !== -1) {
skipThisMessage = true;
return false;
}

View File

@ -0,0 +1,55 @@
// ==UserScript==
// @id iitc-plugin-show-address@vita10gy
// @name iitc: show portal address in sidebar
// @version 0.2
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/show-address.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/show-address.user.js
// @description Portal address will show in the sidebar.
// @include http://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
// ==/UserScript==
function wrapper() {
// ensure plugin framework is there, even if iitc is not yet loaded
if(typeof window.plugin !== 'function') window.plugin = function() {};
// PLUGIN START ////////////////////////////////////////////////////////
// use own namespace for plugin
window.plugin.portalAddress = function() {};
window.plugin.portalAddress.portalDetail = function(data) {
// If there's 4 sets of comma delimieted info the last one is the
// country, so get rid of it. If the country is in the [2] then it
// doesn't matter because address is usually short enough to fit.
var d = data.portalDetails.portalV2;
var address = d.descriptiveText.ADDRESS.split(',').splice(0,3).join(',');
$('.imgpreview').append('<div id="address">'+address+'</div>');
}
var setup = function() {
window.addHook('portalDetailsUpdated', window.plugin.portalAddress.portalDetail);
$('head').append('<style>' +
'.res #address { border: 1px solid #0076b6; }' +
'.enl #address { border: 1px solid #017f01; }' +
'#address { margin:5px; padding:3px; margin-top:120px; margin-right:8px; font-size:11px; background-color:rgba(0, 0, 0, 0.7); text-align:center; white-space:nowrap; overflow:hidden; }' +
'</style>');
}
// PLUGIN END //////////////////////////////////////////////////////////
if(window.iitcLoaded && typeof setup === 'function') {
setup();
} else {
if(window.bootPlugins)
window.bootPlugins.push(setup);
else
window.bootPlugins = [setup];
}
} // wrapper end
// inject code into site context
var script = document.createElement('script');
script.appendChild(document.createTextNode('('+ wrapper +')();'));
(document.body || document.head || document.documentElement).appendChild(script);