Plugin AP List: Add comments and reordering code
This commit is contained in:
parent
810092dc3c
commit
3220099449
@ -44,13 +44,15 @@ window.plugin.apList.destroyPortalsGuid = new Array();
|
|||||||
window.plugin.apList.portalLocationIndicator;
|
window.plugin.apList.portalLocationIndicator;
|
||||||
window.plugin.apList.animTimeout;
|
window.plugin.apList.animTimeout;
|
||||||
|
|
||||||
|
// ENTRY POINT ///////////////////////////////////////////////////////////////////
|
||||||
window.plugin.apList.handleUpdate = function() {
|
window.plugin.apList.handleUpdate = function() {
|
||||||
if(!requests.isLastRequest('getThinnedEntitiesV2')) return;
|
if(!requests.isLastRequest('getThinnedEntitiesV2')) return;
|
||||||
plugin.apList.updateSortedPortals();
|
plugin.apList.updateSortedPortals();
|
||||||
plugin.apList.updatePortalTable(plugin.apList.displaySide);
|
plugin.apList.updatePortalTable(plugin.apList.displaySide);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CONTENT GENERATION ////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Generate html table from top portals
|
// Generate html table from top portals
|
||||||
window.plugin.apList.updatePortalTable = function(side) {
|
window.plugin.apList.updatePortalTable = function(side) {
|
||||||
var table = '<table id="ap-list-table">'
|
var table = '<table id="ap-list-table">'
|
||||||
@ -116,25 +118,7 @@ window.plugin.apList.getPortalDestroyCheckbox = function(portal) {
|
|||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.plugin.apList.destroyPortal = function(guid) {
|
// Combine ap title and test
|
||||||
// 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) {
|
window.plugin.apList.getPortalApText = function(portal) {
|
||||||
var title = plugin.apList.getPortalApTitle(portal);
|
var title = plugin.apList.getPortalApTitle(portal);
|
||||||
return '<div class="help" title="' + title + '">' + digits(portal.playerApGain.totalAp) + '</div>';
|
return '<div class="help" title="' + title + '">' + digits(portal.playerApGain.totalAp) + '</div>';
|
||||||
@ -210,6 +194,8 @@ window.plugin.apList.getPortalLink = function(portal) {
|
|||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MAIN LOGIC FUNCTIONS //////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Loop through portals and get playerApGain, then put in sortedPortals by side and sort them by AP.
|
// Loop through portals and get playerApGain, then put in sortedPortals by side and sort them by AP.
|
||||||
window.plugin.apList.updateSortedPortals = function() {
|
window.plugin.apList.updateSortedPortals = function() {
|
||||||
plugin.apList.sortedPortals[plugin.apList.SIDE_FRIENDLY] = new Array();
|
plugin.apList.sortedPortals[plugin.apList.SIDE_FRIENDLY] = new Array();
|
||||||
@ -331,19 +317,6 @@ window.plugin.apList.handleDestroyPortal = function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
window.plugin.apList.enableCache = function() {
|
|
||||||
plugin.apList.useCachedPortals = true;
|
|
||||||
plugin.apList.updateSortedPortals();
|
|
||||||
plugin.apList.updatePortalTable(plugin.apList.displaySide);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.plugin.apList.disableCache = function() {
|
|
||||||
plugin.apList.useCachedPortals = false;
|
|
||||||
plugin.apList.cachedPortals = {};
|
|
||||||
plugin.apList.updateSortedPortals();
|
|
||||||
plugin.apList.updatePortalTable(plugin.apList.displaySide);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.plugin.apList.isSamePortal = function(a,b) {
|
window.plugin.apList.isSamePortal = function(a,b) {
|
||||||
if(!a || !b) return false;
|
if(!a || !b) return false;
|
||||||
if(a.team !== b.team) return false;
|
if(a.team !== b.team) return false;
|
||||||
@ -548,6 +521,21 @@ window.plugin.apList.getShieldsMitigation = function(portal) {
|
|||||||
return shieldsMitigation;
|
return shieldsMitigation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FEATURE TOGGLES AND INTERACTION HANDLER ///////////////////////////////////////
|
||||||
|
|
||||||
|
window.plugin.apList.enableCache = function() {
|
||||||
|
plugin.apList.useCachedPortals = true;
|
||||||
|
plugin.apList.updateSortedPortals();
|
||||||
|
plugin.apList.updatePortalTable(plugin.apList.displaySide);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.plugin.apList.disableCache = function() {
|
||||||
|
plugin.apList.useCachedPortals = false;
|
||||||
|
plugin.apList.cachedPortals = {};
|
||||||
|
plugin.apList.updateSortedPortals();
|
||||||
|
plugin.apList.updatePortalTable(plugin.apList.displaySide);
|
||||||
|
}
|
||||||
|
|
||||||
window.plugin.apList.selectPortal = function(guid) {
|
window.plugin.apList.selectPortal = function(guid) {
|
||||||
renderPortalDetails(guid);
|
renderPortalDetails(guid);
|
||||||
plugin.apList.setPortalLocationIndicator(guid);
|
plugin.apList.setPortalLocationIndicator(guid);
|
||||||
@ -592,6 +580,24 @@ window.plugin.apList.animPortalLocationIndicator = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
// Change display table to friendly portals
|
// Change display table to friendly portals
|
||||||
window.plugin.apList.displayFriendly = function() {
|
window.plugin.apList.displayFriendly = function() {
|
||||||
plugin.apList.changeDisplaySide(plugin.apList.SIDE_FRIENDLY);
|
plugin.apList.changeDisplaySide(plugin.apList.SIDE_FRIENDLY);
|
||||||
@ -631,6 +637,8 @@ window.plugin.apList.showReloadLabel = function() {
|
|||||||
$('#ap-list-reload').show();
|
$('#ap-list-reload').show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SETUP /////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
window.plugin.apList.setupVar = function() {
|
window.plugin.apList.setupVar = function() {
|
||||||
plugin.apList.sides[plugin.apList.SIDE_FRIENDLY] = plugin.apList.SIDE_FRIENDLY;
|
plugin.apList.sides[plugin.apList.SIDE_FRIENDLY] = plugin.apList.SIDE_FRIENDLY;
|
||||||
plugin.apList.sides[plugin.apList.SIDE_ENEMY] = plugin.apList.SIDE_ENEMY;
|
plugin.apList.sides[plugin.apList.SIDE_ENEMY] = plugin.apList.SIDE_ENEMY;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user