Merge branch 'gh-pages' of github.com:breunigs/ingress-intel-total-conversion into gh-pages
This commit is contained in:
commit
939006281d
@ -152,6 +152,8 @@ window.chat.handleFaction = function(data, textStatus, jqXHR) {
|
||||
chat.writeDataToHash(data, chat._factionData, false);
|
||||
var oldMsgsWereAdded = old !== chat.getOldestTimestamp(true);
|
||||
|
||||
runHooks('factionChatDataAvailable', {raw: data, processed: chat._factionData});
|
||||
|
||||
window.chat.renderFaction(oldMsgsWereAdded);
|
||||
|
||||
if(data.result.length >= CHAT_FACTION_ITEMS) chat.needMoreMessages();
|
||||
|
@ -30,6 +30,11 @@
|
||||
// yet been displayed. The data hash contains both the un-
|
||||
// processed raw ajax response as well as the processed
|
||||
// chat data that is going to be used for display.
|
||||
// factionChatDataAvailable: this hook runs after data for the faction
|
||||
// chat has been received and processed, but not yet been
|
||||
// displayed. The data hash contains both the unprocessed
|
||||
// raw ajax response as well as the processed chat data
|
||||
// that is going to be used for display.
|
||||
// portalDataLoaded: callback is passed the argument of
|
||||
// {portals : [portal, portal, ...]} where "portal" is the
|
||||
// data element and not the leaflet object. "portal" is an
|
||||
@ -53,8 +58,8 @@
|
||||
|
||||
window._hooks = {}
|
||||
window.VALID_HOOKS = ['portalAdded', 'portalDetailsUpdated',
|
||||
'publicChatDataAvailable', 'portalDataLoaded', 'beforePortalReRender',
|
||||
'checkRenderLimit', 'requestFinished'];
|
||||
'publicChatDataAvailable', 'factionChatDataAvailable', 'portalDataLoaded',
|
||||
'beforePortalReRender', 'checkRenderLimit', 'requestFinished'];
|
||||
|
||||
window.runHooks = function(event, data) {
|
||||
if(VALID_HOOKS.indexOf(event) === -1) throw('Unknown event type: ' + event);
|
||||
|
@ -30,6 +30,7 @@
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<data android:host="www.ingress.com" android:scheme="https" android:pathPrefix="/intel"></data>
|
||||
<data android:host="www.ingress.com" android:scheme="http" android:pathPrefix="/intel"></data>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
@ -1,6 +1,7 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item android:id="@+id/reload_button"
|
||||
android:orderInCategory="100"
|
||||
android:icon="@drawable/ic_menu_refresh"
|
||||
android:orderInCategory="90"
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/reload"></item>
|
||||
|
||||
@ -10,11 +11,12 @@
|
||||
android:title="@string/version"></item>
|
||||
|
||||
<item android:id="@+id/cache_clear"
|
||||
android:orderInCategory="90"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/cache_clear"></item>
|
||||
|
||||
<item android:id="@+id/locate"
|
||||
android:icon="@android:drawable/ic_menu_mylocation"
|
||||
android:orderInCategory="80"
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/locate"></item>
|
||||
|
@ -14,9 +14,6 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnTouchListener;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class IITC_Mobile extends Activity {
|
||||
@ -42,6 +39,9 @@ public class IITC_Mobile extends Activity {
|
||||
if (Intent.ACTION_VIEW.equals(action)) {
|
||||
Uri uri = intent.getData();
|
||||
String url = uri.toString();
|
||||
// TODO Why does "if(intent.getScheme() == "http")" not work?
|
||||
if (url.contains("http://"))
|
||||
url = url.replace("http://", "https://");
|
||||
Log.d("Intent received", "url: " + url);
|
||||
if (url.contains("ingress.com")) {
|
||||
Log.d("Intent received", "loading url...");
|
||||
@ -52,17 +52,6 @@ public class IITC_Mobile extends Activity {
|
||||
Log.d("No Intent call", "loading https://www.ingress.com/intel");
|
||||
iitc_view.loadUrl("https://www.ingress.com/intel");
|
||||
}
|
||||
|
||||
// listen to touches (think we need this)
|
||||
iitc_view.setOnTouchListener(new OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
back_button_pressed = false;
|
||||
// return false to indicate, that we don't consumed this event. this leads
|
||||
// to the execution of our touch event
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,13 +61,6 @@ public class IITC_Mobile extends Activity {
|
||||
iitc_view.saveState(outState);
|
||||
}
|
||||
|
||||
// we want a self defined behavior on resume
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
this.back_button_pressed = false;
|
||||
}
|
||||
|
||||
// we want a self defined behavior for the back button
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
|
@ -1,11 +1,11 @@
|
||||
// ==UserScript==
|
||||
// @id iitc-plugin-ap-list@xelio
|
||||
// @name iitc: AP List
|
||||
// @version 0.3
|
||||
// @version 0.4
|
||||
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
|
||||
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/ap-list.user.js
|
||||
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/ap-list.user.js
|
||||
// @description List top 10 portals by AP of either faction. Hover over AP will show breakdown of AP. Click on portal name will select the portal. Double click on portal name will zoom to and select portal. Portals before zooming in will be cached and count in top portal. They will be cleared if you click the "↻ R" or move out of the area.
|
||||
// @description List top 10 portals by AP of either faction. Other functions and controls please refer to the Userguide. (https://github.com/breunigs/ingress-intel-total-conversion/wiki/Userguide-%28Main-Vanilla-IITC%29#wiki-pluginsAPListUserGuide)
|
||||
// @include https://www.ingress.com/intel*
|
||||
// @match https://www.ingress.com/intel*
|
||||
// ==/UserScript==
|
||||
@ -36,6 +36,8 @@ window.plugin.apList.useCachedPortals = false;
|
||||
window.plugin.apList.cacheBounds;
|
||||
window.plugin.apList.cacheActiveZoomLevel;
|
||||
|
||||
window.plugin.apList.destroyPortalsGuid = new Array();
|
||||
|
||||
|
||||
window.plugin.apList.handleUpdate = function() {
|
||||
if(!requests.isLastRequest('getThinnedEntitiesV2')) return;
|
||||
@ -45,22 +47,66 @@ window.plugin.apList.handleUpdate = function() {
|
||||
|
||||
// Generate html table from top portals
|
||||
window.plugin.apList.updatePortalTable = function(side) {
|
||||
var displayEnemy = (plugin.apList.displaySide === window.plugin.apList.SIDE_ENEMY);
|
||||
|
||||
var content = '<table style="width: 100%; table-layout:fixed">';
|
||||
for(var i = 0; i < plugin.apList.topMaxCount; i++) {
|
||||
var portal = plugin.apList.sortedPortals[side][i];
|
||||
content += '<tr>'
|
||||
+ '<td style="width: 85%; overflow:hidden; white-space:nowrap">'
|
||||
+ (portal ? plugin.apList.getPortalLink(portal) : ' ')
|
||||
+ '</td>'
|
||||
+ '<td>'
|
||||
+ (portal ? plugin.apList.getPortalApText(portal) : ' ')
|
||||
+ '</td>'
|
||||
+ '</tr>';
|
||||
content += '<tr>';
|
||||
// Only enemy portal list will display destroy checkbox
|
||||
if(displayEnemy) {
|
||||
content += '<td style="width: 5%; height: 1px">'
|
||||
+ (portal ? plugin.apList.getPortalDestroyCheckbox(portal) : ' ')
|
||||
+ '</td>';
|
||||
}
|
||||
content += '<td style="width: ' + (displayEnemy ? '80%' : '85%')
|
||||
+ '; overflow:hidden; white-space:nowrap">'
|
||||
+ (portal ? plugin.apList.getPortalLink(portal) : ' ')
|
||||
+ '</td>'
|
||||
+ '<td>'
|
||||
+ (portal ? plugin.apList.getPortalApText(portal) : ' ')
|
||||
+ '</td>'
|
||||
+ '</tr>';
|
||||
}
|
||||
content += "</table>";
|
||||
$('div#ap-list-table').html(content);
|
||||
}
|
||||
|
||||
window.plugin.apList.getPortalDestroyCheckbox = function(portal) {
|
||||
// Change background color to border color if portal selected for destroy
|
||||
var style = 'width: 10px; height: 10px; border: 1px solid rgb(32, 168, 177); margin: 0 auto; '
|
||||
+ (plugin.apList.destroyPortalIndex(portal.guid) >= 0
|
||||
? 'background-color: rgb(32, 168, 177);'
|
||||
: '');
|
||||
var onClick = 'window.plugin.apList.destroyPortal(\'' + portal.guid + '\');';
|
||||
// 3 div for centering checkbox horizontally and vertically,
|
||||
// click event on outest div for people with not so good aiming
|
||||
var div = '<div style="display: table; height: 100%; width: 100%;" onclick="' + onClick + '">'
|
||||
+ '<div style="display: table-cell; vertical-align: middle;">'
|
||||
+ '<div style="' + style + '"/>'
|
||||
+ '</div>'
|
||||
+ '</div>';
|
||||
return div;
|
||||
}
|
||||
|
||||
window.plugin.apList.destroyPortal = function(guid) {
|
||||
// Add to destroyPortalsGuid if not yet added, remove if already added
|
||||
var portalIndex = plugin.apList.destroyPortalIndex(guid);
|
||||
if(portalIndex >= 0) {
|
||||
plugin.apList.destroyPortalsGuid.splice(portalIndex, 1);
|
||||
} else {
|
||||
plugin.apList.destroyPortalsGuid.push(guid);
|
||||
}
|
||||
|
||||
plugin.apList.updateSortedPortals();
|
||||
plugin.apList.updatePortalTable(plugin.apList.displaySide);
|
||||
}
|
||||
|
||||
// Return the index of portal in destroyPortalsGuid
|
||||
window.plugin.apList.destroyPortalIndex = function(guid) {
|
||||
return $.inArray(guid, plugin.apList.destroyPortalsGuid);
|
||||
}
|
||||
|
||||
// Combine title and test
|
||||
window.plugin.apList.getPortalApText = function(portal) {
|
||||
var title = plugin.apList.getPortalApTitle(portal);
|
||||
@ -83,6 +129,7 @@ window.plugin.apList.getPortalApTitle = function(portal) {
|
||||
t += 'Sum: ' + digits(playerApGain.totalAp) + ' AP';
|
||||
} else {
|
||||
t = 'Destroy & Capture:\n'
|
||||
+ 'R:' + playerApGain.resoCount + ' L:' + playerApGain.linkCount + ' CF:' + playerApGain.fieldCount + '\n'
|
||||
+ 'Destroy AP\t=\t' + digits(playerApGain.destroyAp) + '\n'
|
||||
+ 'Capture AP\t=\t' + digits(playerApGain.captureAp) + '\n'
|
||||
+ 'Sum: ' + digits(playerApGain.totalAp) + ' AP';
|
||||
@ -99,9 +146,13 @@ window.plugin.apList.getPortalLink = function(portal) {
|
||||
var jsDoubleClick = 'window.zoomToAndShowPortal(\''+portal.guid+'\', ['+latlng+']);return false';
|
||||
var perma = 'https://ingress.com/intel?latE6='+portal.locationE6.latE6
|
||||
+'&lngE6='+portal.locationE6.lngE6+'&z=17&pguid='+portal.guid;
|
||||
var style = plugin.apList.destroyPortalIndex(portal.guid) >= 0
|
||||
? 'font-style:italic'
|
||||
: '';
|
||||
//Use Jquery to create the link, which escape characters in TITLE and ADDRESS of portal
|
||||
var a = $('<a>',{
|
||||
"class": 'help',
|
||||
style: style,
|
||||
text: portal.portalV2.descriptiveText.TITLE,
|
||||
title: portal.portalV2.descriptiveText.ADDRESS,
|
||||
href: perma,
|
||||
@ -155,6 +206,81 @@ window.plugin.apList.updateSortedPortals = function() {
|
||||
return b.playerApGain.totalAp - a.playerApGain.totalAp;
|
||||
});
|
||||
});
|
||||
|
||||
// Modify sortedPortals if any portal selected for destroy
|
||||
if(plugin.apList.destroyPortalsGuid.length > 0) {
|
||||
plugin.apList.handleDestroyPortal()
|
||||
}
|
||||
}
|
||||
|
||||
// This function will make AP gain of field and link only count once if
|
||||
// one of the connected portal is selected for destroy
|
||||
window.plugin.apList.handleDestroyPortal = function() {
|
||||
var enemy = window.plugin.apList.SIDE_ENEMY;
|
||||
var destroyedLinks = {};
|
||||
var destroyedFields = {};
|
||||
|
||||
// Clean up portal selected for destroy, remove from destroyPortalsGuid
|
||||
// if portal not exist or change to friendly side
|
||||
plugin.apList.destroyPortalsGuid = $.grep(plugin.apList.destroyPortalsGuid, function(portalGuid,ind) {
|
||||
var portal = plugin.apList.cachedPortals[portalGuid];
|
||||
if(!portal || plugin.apList.portalSide(portal) !== enemy) return false;
|
||||
return true;
|
||||
});
|
||||
|
||||
// Loop through portals from highest AP to lowest AP, matching links and fields to the
|
||||
// portal only if the portal is selected for destroy and have highest AP.
|
||||
// Matching info stores in "destroyedLinks" and "destroyedFields"
|
||||
$.each(plugin.apList.sortedPortals[enemy], function(ind, portal) {
|
||||
if(plugin.apList.destroyPortalIndex(portal.guid) < 0) return true;
|
||||
|
||||
$.each(portal.portalV2.linkedEdges || [], function(ind,link) {
|
||||
// Skip if the link already matched with a portal
|
||||
if(destroyedLinks[link.edgeGuid]) return true;
|
||||
belongTo = {portalGuid: portal.guid};
|
||||
destroyedLinks[link.edgeGuid] = belongTo;
|
||||
});
|
||||
$.each(portal.portalV2.linkedFields || [], function(ind,field) {
|
||||
// Skip if the field already matched with a portal
|
||||
if(destroyedFields[field]) return true;
|
||||
belongTo = {portalGuid: portal.guid};
|
||||
destroyedFields[field] = belongTo;
|
||||
});
|
||||
});
|
||||
|
||||
// Remove the link and field which was matched with another portal
|
||||
var getApGainFunc = plugin.apList.playerApGainFunc[enemy];
|
||||
$.each(plugin.apList.sortedPortals[enemy], function(ind, portal) {
|
||||
// Filter out links which was matched with another portal
|
||||
var newLinkedEdges = $.grep(portal.portalV2.linkedEdges || [], function(link,ind) {
|
||||
if(!destroyedLinks[link.edgeGuid]) return true;
|
||||
return (destroyedLinks[link.edgeGuid].portalGuid === portal.guid);
|
||||
});
|
||||
// Filter out fields which was matched with another portal
|
||||
var newLinkedFields = $.grep(portal.portalV2.linkedFields || [], function(field,ind) {
|
||||
if(!destroyedFields[field]) return true;
|
||||
return (destroyedFields[field].portalGuid === portal.guid);
|
||||
});
|
||||
|
||||
// Skip modifying portal if no link and field changed
|
||||
if(newLinkedEdges.length === (portal.portalV2.linkedEdges || []).length
|
||||
&& newLinkedFields.length === (portal.portalV2.linkedFields || []).length)
|
||||
return true;
|
||||
|
||||
// Clone the portal to avoid modifying original data in cachedPortal
|
||||
var newPortal = $.extend(true, {}, portal);
|
||||
// Assign new links and fields and calculate new playerApGain
|
||||
if(portal.portalV2.linkedEdges) newPortal.portalV2.linkedEdges = newLinkedEdges;
|
||||
if(portal.portalV2.linkedFields) newPortal.portalV2.linkedFields = newLinkedFields;
|
||||
newPortal.playerApGain = getApGainFunc(newPortal);
|
||||
|
||||
plugin.apList.sortedPortals[enemy][ind] = newPortal;
|
||||
});
|
||||
|
||||
// Sorting portals with updated AP
|
||||
plugin.apList.sortedPortals[enemy].sort(function(a, b) {
|
||||
return b.playerApGain.totalAp - a.playerApGain.totalAp;
|
||||
});
|
||||
}
|
||||
|
||||
window.plugin.apList.enableCache = function() {
|
||||
@ -271,7 +397,10 @@ window.plugin.apList.getAttackApGain = function(d) {
|
||||
return {
|
||||
totalAp: totalAp,
|
||||
destroyAp: destroyAp,
|
||||
captureAp: captureAp
|
||||
captureAp: captureAp,
|
||||
resoCount: resoCount,
|
||||
linkCount: linkCount,
|
||||
fieldCount: fieldCount
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user