Merge git://github.com/jonatkins/ingress-intel-total-conversion into dialog
This commit is contained in:
18
code/boot.js
18
code/boot.js
@ -139,10 +139,10 @@ 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)
|
||||
var mqSubdomains = [ 'otile1','otile2', 'otile3', 'otile4' ];
|
||||
var mqTileUrlPrefix = window.location.protocol !== 'https:' ? 'http://{s}.mqcdn.com' : 'https://{s}-s.mqcdn.com';
|
||||
var mqMapOpt = {attribution: osmAttribution+', Tiles Courtesy of MapQuest', maxZoom: 18, detectRetena: true, subdomains: mqSubdomains};
|
||||
var mqMapOpt = {attribution: osmAttribution+', Tiles Courtesy of MapQuest', maxZoom: 18, subdomains: mqSubdomains};
|
||||
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
|
||||
//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, subdomains: mqSubdomains};
|
||||
//var mqSat = new L.TileLayer('http://{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg',mqSatOpt);
|
||||
|
||||
var views = [
|
||||
@ -203,7 +203,8 @@ window.setupMap = function() {
|
||||
// layers. This likely leads to broken layer selection because the
|
||||
// views/cookie order does not match the layer chooser order.
|
||||
try {
|
||||
map.addLayer(views[readCookie('ingress.intelmap.type')]);
|
||||
convertCookieToLocalStorage('ingress.intelmap.type');
|
||||
map.addLayer(views[localStorage['ingress.intelmap.type']]);
|
||||
} catch(e) { map.addLayer(views[0]); }
|
||||
|
||||
map.attributionControl.setPrefix('');
|
||||
@ -228,7 +229,7 @@ window.setupMap = function() {
|
||||
|
||||
map.on('baselayerchange', function () {
|
||||
var selInd = $('[name=leaflet-base-layers]:checked').parent().index();
|
||||
writeCookie('ingress.intelmap.type', selInd);
|
||||
localStorage['ingress.intelmap.type']=selInd;
|
||||
});
|
||||
|
||||
// map update status handling
|
||||
@ -405,7 +406,13 @@ function boot() {
|
||||
$('#sidebar').show();
|
||||
|
||||
if(window.bootPlugins)
|
||||
$.each(window.bootPlugins, function(ind, ref) { ref(); });
|
||||
$.each(window.bootPlugins, function(ind, ref) {
|
||||
try {
|
||||
ref();
|
||||
} catch(err) {
|
||||
console.log("error starting plugin: index "+ind+", error: "+err);
|
||||
}
|
||||
});
|
||||
|
||||
window.runOnSmartphonesAfterBoot();
|
||||
|
||||
@ -413,6 +420,7 @@ function boot() {
|
||||
setTimeout('window.map.invalidateSize(false);', 500);
|
||||
|
||||
window.iitcLoaded = true;
|
||||
window.runHooks('iitcLoaded');
|
||||
}
|
||||
|
||||
// this is the minified load.js script that allows us to easily load
|
||||
|
@ -24,6 +24,6 @@ window.setupGeosearch = function() {
|
||||
e.preventDefault();
|
||||
});
|
||||
$('#geosearchwrapper img').click(function(){
|
||||
map.locate({setView : true});;
|
||||
map.locate({setView : true, maxZoom: 13});;
|
||||
});
|
||||
}
|
||||
|
@ -53,14 +53,14 @@
|
||||
// set reached to true.
|
||||
// requestFinished: called after each request finished. Argument is
|
||||
// {success: boolean} indicated the request success or fail.
|
||||
|
||||
// iitcLoaded: called after IITC and all plugins loaded
|
||||
|
||||
|
||||
window._hooks = {}
|
||||
window.VALID_HOOKS = ['portalAdded', 'portalDetailsUpdated',
|
||||
'publicChatDataAvailable', 'factionChatDataAvailable', 'portalDataLoaded',
|
||||
'beforePortalReRender', 'checkRenderLimit', 'requestFinished', 'nicknameClicked',
|
||||
'geoSearch'];
|
||||
'geoSearch', 'iitcLoaded'];
|
||||
|
||||
window.runHooks = function(event, data) {
|
||||
if(VALID_HOOKS.indexOf(event) === -1) throw('Unknown event type: ' + event);
|
||||
|
@ -173,16 +173,17 @@ window.handlePortalsRender = function(portals) {
|
||||
// Preserve selectedPortal because it will get lost on re-rendering
|
||||
// the portal
|
||||
var oldSelectedPortal = selectedPortal;
|
||||
|
||||
runHooks('portalDataLoaded', {portals : portals});
|
||||
$.each(portals, function(ind, portal) {
|
||||
//~ if(selectedPortal === portal[0]) portalUpdateAvailable = true;
|
||||
if(urlPortal && portal[0] === urlPortal) portalInUrlAvailable = true;
|
||||
if(urlPortalLL && urlPortalLL[0] === portal[2].locationE6.latE6/1E6 && urlPortalLL[1] === portal[2].locationE6.lngE6/1E6) {
|
||||
urlPortal = portal[0];
|
||||
portalInUrlAvailable = true;
|
||||
urlPortalLL = null;
|
||||
}
|
||||
if(window.portals[portal[0]]) {
|
||||
highlightPortal(window.portals[portal[0]]);
|
||||
}
|
||||
renderPortal(portal);
|
||||
});
|
||||
|
||||
@ -285,7 +286,7 @@ window.renderPortal = function(ent) {
|
||||
// do nothing if portal did not change
|
||||
var layerGroup = portalsLayers[parseInt(portalLevel)];
|
||||
var old = findEntityInLeaflet(layerGroup, window.portals, ent[0]);
|
||||
if(old) {
|
||||
if(!changing_highlighters && old) {
|
||||
var oo = old.options;
|
||||
|
||||
// Default checks to see if a portal needs to be re-rendered
|
||||
@ -333,6 +334,7 @@ window.renderPortal = function(ent) {
|
||||
clickable: true,
|
||||
level: portalLevel,
|
||||
team: team,
|
||||
ent: ent,
|
||||
details: ent[2],
|
||||
guid: ent[0]});
|
||||
|
||||
@ -370,7 +372,7 @@ window.renderPortal = function(ent) {
|
||||
});
|
||||
|
||||
window.renderResonators(ent, null);
|
||||
|
||||
highlightPortal(p);
|
||||
window.runHooks('portalAdded', {portal: p});
|
||||
p.addTo(layerGroup);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// created to start cleaning up "window" interaction
|
||||
//
|
||||
window.show = function(id) {
|
||||
window.hideall();
|
||||
switch(id) {
|
||||
case 'full':
|
||||
window.chat.show('full');
|
||||
@ -19,6 +20,7 @@ window.show = function(id) {
|
||||
break;
|
||||
case 'map':
|
||||
window.smartphone.mapButton.click();
|
||||
$('#portal_highlight_select').show();
|
||||
break;
|
||||
case 'info':
|
||||
window.smartphone.sideButton.click();
|
||||
@ -28,3 +30,8 @@ window.show = function(id) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
window.hideall = function() {
|
||||
$('#chatcontrols, #chat, #chatinput, #sidebartoggle, #scrollwrapper, #updatestatus, #portal_highlight_select').hide();
|
||||
$('#map').css('visibility', 'hidden');
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ window.renderPortalDetails = function(guid) {
|
||||
var lng = d.locationE6.lngE6/1E6;
|
||||
var perma = '/intel?ll='+lat+','+lng+'&z=17&pll='+lat+','+lng;
|
||||
var imgTitle = 'title="'+getPortalDescriptionFromDetails(d)+'\n\nClick to show full image."';
|
||||
var poslinks = 'window.showPortalPosLinks('+lat+','+lng+',\'' + d.portalV2.descriptiveText.TITLE + '\')';
|
||||
var poslinks = 'window.showPortalPosLinks('+lat+','+lng+',\''+escapeJavascriptString(d.portalV2.descriptiveText.TITLE)+'\')';
|
||||
|
||||
$('#portaldetails')
|
||||
.attr('class', TEAM_TO_CSS[getTeam(d)])
|
||||
|
64
code/portal_highlighter.js
Normal file
64
code/portal_highlighter.js
Normal file
@ -0,0 +1,64 @@
|
||||
// Portal Highlighter //////////////////////////////////////////////////////////
|
||||
// these functions handle portal highlighters
|
||||
|
||||
|
||||
window._highlighters = null;
|
||||
window._current_highlighter = localStorage.portal_highlighter;
|
||||
window.changing_highlighters = false;
|
||||
window._no_highlighter = 'No Highlights';
|
||||
|
||||
window.addPortalHighlighter = function(name, callback) {
|
||||
if(_highlighters === null) {
|
||||
_highlighters = {};
|
||||
}
|
||||
_highlighters[name] = callback;
|
||||
if(localStorage.portal_highlighter === undefined) {
|
||||
_current_highlighter = name;
|
||||
localStorage.portal_highlighter = name;
|
||||
}
|
||||
portalHighlighterControl();
|
||||
}
|
||||
|
||||
window.portalHighlighterControl = function() {
|
||||
if(_highlighters !== null) {
|
||||
if($('#portal_highlight_select').length === 0) {
|
||||
$("body").append("<select id='portal_highlight_select'></select>");
|
||||
}
|
||||
$("#portal_highlight_select").html('');
|
||||
$("#portal_highlight_select").append($("<option>").attr('value',_no_highlighter).text(_no_highlighter));
|
||||
var h_names = Object.keys(_highlighters).sort();
|
||||
|
||||
$.each(h_names, function(i, name) {
|
||||
$("#portal_highlight_select").append($("<option>").attr('value',name).text(name));
|
||||
});
|
||||
$("#portal_highlight_select").val(_current_highlighter);
|
||||
$("#portal_highlight_select").change(function(){ changePortalHighlights($(this).val());});
|
||||
$(".leaflet-top.leaflet-left").css('padding-top', '20px');
|
||||
$(".leaflet-control-scale-line").css('margin-top','25px');
|
||||
}
|
||||
}
|
||||
|
||||
window.changePortalHighlights = function(name) {
|
||||
changing_highlighters = true;
|
||||
_current_highlighter = name;
|
||||
resetHighlightedPortals();
|
||||
changing_highlighters = false;
|
||||
localStorage.portal_highlighter = name;
|
||||
}
|
||||
|
||||
window.highlightPortal = function(p) {
|
||||
|
||||
if(_highlighters !== null && _highlighters[_current_highlighter] !== undefined) {
|
||||
p.options.highligher = _current_highlighter;
|
||||
_highlighters[_current_highlighter]({portal: p});
|
||||
}
|
||||
}
|
||||
|
||||
window.resetHighlightedPortals = function() {
|
||||
$.each(portals, function(ind, portal) {
|
||||
try {
|
||||
renderPortal(portal.options.ent);
|
||||
}
|
||||
catch(e) {}
|
||||
});
|
||||
}
|
@ -117,3 +117,43 @@ window.getAttackApGain = function(d) {
|
||||
captureAp: captureAp
|
||||
};
|
||||
}
|
||||
|
||||
//This function will return the potential level a player can upgrade it to
|
||||
window.potentialPortalLevel = function(d) {
|
||||
var current_level = getPortalLevel(d);
|
||||
var potential_level = current_level;
|
||||
|
||||
if(PLAYER.team === d.controllingTeam.team) {
|
||||
var resonators_on_portal = d.resonatorArray.resonators;
|
||||
var resonator_levels = new Array();
|
||||
// figure out how many of each of these resonators can be placed by the player
|
||||
var player_resontators = new Array();
|
||||
for(var i=1;i<=MAX_PORTAL_LEVEL; i++) {
|
||||
player_resontators[i] = i > PLAYER.level ? 0 : MAX_RESO_PER_PLAYER[i];
|
||||
}
|
||||
$.each(resonators_on_portal, function(ind, reso) {
|
||||
if(reso !== null && reso.ownerGuid === window.PLAYER.guid) {
|
||||
player_resontators[reso.level]--;
|
||||
}
|
||||
resonator_levels.push(reso === null ? 0 : reso.level);
|
||||
});
|
||||
|
||||
resonator_levels.sort(function(a, b) {
|
||||
return(a - b);
|
||||
});
|
||||
|
||||
// Max out portal
|
||||
var install_index = 0;
|
||||
for(var i=MAX_PORTAL_LEVEL;i>=1; i--) {
|
||||
for(var install = player_resontators[i]; install>0; install--) {
|
||||
if(resonator_levels[install_index] < i) {
|
||||
resonator_levels[install_index] = i;
|
||||
install_index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
//console.log(resonator_levels);
|
||||
potential_level = resonator_levels.reduce(function(a, b) {return a + b;}) / 8;
|
||||
}
|
||||
return(potential_level);
|
||||
}
|
||||
|
@ -77,8 +77,6 @@ window.runOnSmartphonesAfterBoot = function() {
|
||||
// disable img full view
|
||||
$('#portaldetails').off('click', '**');
|
||||
|
||||
$('.leaflet-right').addClass('leaflet-left').removeClass('leaflet-right');
|
||||
|
||||
// make buttons in action bar flexible
|
||||
var l = $('#chatcontrols a:visible');
|
||||
l.css('width', 100/l.length + '%');
|
||||
|
@ -72,6 +72,22 @@ window.writeCookie = function(name, val) {
|
||||
document.cookie = name + "=" + val + '; expires=Thu, 31 Dec 2020 23:59:59 GMT; path=/';
|
||||
}
|
||||
|
||||
window.eraseCookie = function(name) {
|
||||
document.cookie = name + '=; expires=Thu, 1 Jan 1970 00:00:00 GMT; path=/';
|
||||
}
|
||||
|
||||
//certain values were stored in cookies, but we're better off using localStorage instead - make it easy to convert
|
||||
window.convertCookieToLocalStorage = function(name) {
|
||||
var cookie=readCookie(name);
|
||||
if(cookie !== undefined) {
|
||||
console.log('converting cookie '+name+' to localStorage');
|
||||
if(localStorage[name] === undefined) {
|
||||
localStorage[name] = cookie;
|
||||
}
|
||||
eraseCookie(name);
|
||||
}
|
||||
}
|
||||
|
||||
// add thousand separators to given number.
|
||||
// http://stackoverflow.com/a/1990590/1684530 by Doug Neiner.
|
||||
window.digits = function(d) {
|
||||
@ -289,6 +305,12 @@ if (typeof String.prototype.startsWith !== 'function') {
|
||||
};
|
||||
}
|
||||
|
||||
// escape a javascript string, so quotes and backslashes are escaped with a backslash
|
||||
// (for strings passed as parameters to html onclick="..." for example)
|
||||
window.escapeJavascriptString = function(str) {
|
||||
return (str+'').replace(/[\\"']/g,'\\$&');
|
||||
}
|
||||
|
||||
window.prettyEnergy = function(nrg) {
|
||||
return nrg> 1000 ? Math.round(nrg/1000) + ' k': nrg;
|
||||
}
|
||||
@ -358,10 +380,10 @@ window.calcTriArea = function(p) {
|
||||
return Math.abs((p[0].lat*(p[1].lng-p[2].lng)+p[1].lat*(p[2].lng-p[0].lng)+p[2].lat*(p[0].lng-p[1].lng))/2);
|
||||
}
|
||||
|
||||
// Update layerGroups display status to window.overlayStatus and cookie 'ingress.intelmap.layergroupdisplayed'
|
||||
// Update layerGroups display status to window.overlayStatus and localStorage 'ingress.intelmap.layergroupdisplayed'
|
||||
window.updateDisplayedLayerGroup = function(name, display) {
|
||||
overlayStatus[name] = display;
|
||||
writeCookie('ingress.intelmap.layergroupdisplayed', JSON.stringify(overlayStatus));
|
||||
localStorage['ingress.intelmap.layergroupdisplayed'] = JSON.stringify(overlayStatus);
|
||||
}
|
||||
|
||||
// Read layerGroup status from window.overlayStatus if it was added to map,
|
||||
@ -370,7 +392,8 @@ window.updateDisplayedLayerGroup = function(name, display) {
|
||||
window.isLayerGroupDisplayed = function(name, defaultDisplay) {
|
||||
if(typeof(overlayStatus[name]) !== 'undefined') return overlayStatus[name];
|
||||
|
||||
var layersJSON = readCookie('ingress.intelmap.layergroupdisplayed');
|
||||
convertCookieToLocalStorage('ingress.intelmap.layergroupdisplayed');
|
||||
var layersJSON = localStorage['ingress.intelmap.layergroupdisplayed'];
|
||||
if(!layersJSON) return defaultDisplay;
|
||||
|
||||
var layers = JSON.parse(layersJSON);
|
||||
|
Reference in New Issue
Block a user