Merge branch 'gh-pages' into scoreboard
This commit is contained in:
46
code/boot.js
46
code/boot.js
@ -58,10 +58,6 @@ window.setupMap = function() {
|
||||
{zoomControl: !(localStorage['iitc.zoom.buttons'] === 'false')}
|
||||
));
|
||||
|
||||
try {
|
||||
map.addLayer(views[readCookie('ingress.intelmap.type')]);
|
||||
} catch(e) { map.addLayer(views[0]); }
|
||||
|
||||
var addLayers = {};
|
||||
|
||||
portalsLayers = [];
|
||||
@ -91,6 +87,14 @@ window.setupMap = function() {
|
||||
}, addLayers);
|
||||
|
||||
map.addControl(window.layerChooser);
|
||||
|
||||
// set the map AFTER adding the layer chooser, or Chrome reorders the
|
||||
// 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')]);
|
||||
} catch(e) { map.addLayer(views[0]); }
|
||||
|
||||
map.attributionControl.setPrefix('');
|
||||
// listen for changes and store them in cookies
|
||||
map.on('moveend', window.storeMapPosition);
|
||||
@ -227,13 +231,17 @@ window.setupDialogs = function() {
|
||||
}
|
||||
|
||||
|
||||
window.setupQRLoadLib = function() {
|
||||
@@INCLUDERAW:external/jquery.qrcode.min.js@@
|
||||
}
|
||||
|
||||
|
||||
// BOOTING ///////////////////////////////////////////////////////////
|
||||
|
||||
function boot() {
|
||||
window.debug.console.overwriteNativeIfRequired();
|
||||
|
||||
console.log('loading done, booting. Built: ' + window.iitcBuildDate);
|
||||
console.log('loading done, booting. Built: @@BUILDDATE@@');
|
||||
if(window.deviceID) console.log('Your device ID: ' + window.deviceID);
|
||||
window.runOnSmartphonesBeforeBoot();
|
||||
|
||||
@ -255,6 +263,7 @@ function boot() {
|
||||
window.setupPlayerStat();
|
||||
window.setupTooltips();
|
||||
window.chat.setup();
|
||||
window.setupQRLoadLib();
|
||||
// read here ONCE, so the URL is only evaluated one time after the
|
||||
// necessary data has been loaded.
|
||||
urlPortal = getURLParam('pguid');
|
||||
@ -287,26 +296,17 @@ function boot() {
|
||||
// Copyright (c) 2010 Chris O'Hara <cohara87@gmail.com>. MIT Licensed
|
||||
function asyncLoadScript(a){return function(b,c){var d=document.createElement("script");d.type="text/javascript",d.src=a,d.onload=b,d.onerror=c,d.onreadystatechange=function(){var a=this.readyState;if(a==="loaded"||a==="complete")d.onreadystatechange=null,b()},head.insertBefore(d,head.firstChild)}}(function(a){a=a||{};var b={},c,d;c=function(a,d,e){var f=a.halt=!1;a.error=function(a){throw a},a.next=function(c){c&&(f=!1);if(!a.halt&&d&&d.length){var e=d.shift(),g=e.shift();f=!0;try{b[g].apply(a,[e,e.length,g])}catch(h){a.error(h)}}return a};for(var g in b){if(typeof a[g]=="function")continue;(function(e){a[e]=function(){var g=Array.prototype.slice.call(arguments);if(e==="onError"){if(d)return b.onError.apply(a,[g,g.length]),a;var h={};return b.onError.apply(h,[g,g.length]),c(h,null,"onError")}return g.unshift(e),d?(a.then=a[e],d.push(g),f?a:a.next()):c({},[g],e)}})(g)}return e&&(a.then=a[e]),a.call=function(b,c){c.unshift(b),d.unshift(c),a.next(!0)},a.next()},d=a.addMethod=function(d){var e=Array.prototype.slice.call(arguments),f=e.pop();for(var g=0,h=e.length;g<h;g++)typeof e[g]=="string"&&(b[e[g]]=f);--h||(b["then"+d.substr(0,1).toUpperCase()+d.substr(1)]=f),c(a)},d("chain",function(a){var b=this,c=function(){if(!b.halt){if(!a.length)return b.next(!0);try{null!=a.shift().call(b,c,b.error)&&c()}catch(d){b.error(d)}}};c()}),d("run",function(a,b){var c=this,d=function(){c.halt||--b||c.next(!0)},e=function(a){c.error(a)};for(var f=0,g=b;!c.halt&&f<g;f++)null!=a[f].call(c,d,e)&&d()}),d("defer",function(a){var b=this;setTimeout(function(){b.next(!0)},a.shift())}),d("onError",function(a,b){var c=this;this.error=function(d){c.halt=!0;for(var e=0;e<b;e++)a[e].call(c,d)}})})(this);var head=document.getElementsByTagName("head")[0]||document.documentElement;addMethod("load",function(a,b){for(var c=[],d=0;d<b;d++)(function(b){c.push(asyncLoadScript(a[b]))})(d);this.call("run",c)})
|
||||
|
||||
|
||||
try { console.log('Loading included JS now'); } catch(e) {}
|
||||
@@INCLUDERAW:external/leaflet.js@@
|
||||
// modified version of https://github.com/shramov/leaflet-plugins. Also
|
||||
// contains the default Ingress map style.
|
||||
var LEAFLETGOOGLE = 'http://breunigs.github.com/ingress-intel-total-conversion/dist/leaflet_google.js';
|
||||
@@INCLUDERAW:external/leaflet_google.js@@
|
||||
@@INCLUDERAW:external/autolink.js@@
|
||||
|
||||
try { console.log('done loading included JS'); } catch(e) {}
|
||||
|
||||
var JQUERY = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js';
|
||||
var JQUERYUI = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js';
|
||||
var LEAFLET = 'http://cdn.leafletjs.com/leaflet-0.5/leaflet.js';
|
||||
var AUTOLINK = 'http://breunigs.github.com/ingress-intel-total-conversion/dist/autolink.js';
|
||||
var EMPTY = 'data:text/javascript;base64,';
|
||||
|
||||
// don’t download resources which have been injected already
|
||||
var ir = window && window.internalResources ? window.internalResources : [];
|
||||
if(ir.indexOf('jquery') !== -1) JQUERY = EMPTY;
|
||||
if(ir.indexOf('jqueryui') !== -1) JQUERYUI = EMPTY;
|
||||
if(ir.indexOf('leaflet') !== -1) LEAFLET = EMPTY;
|
||||
if(ir.indexOf('autolink') !== -1) AUTOLINK = EMPTY;
|
||||
if(ir.indexOf('leafletgoogle') !== -1) LEAFLETGOOGLE = EMPTY;
|
||||
|
||||
var JQUERYUI = 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js';
|
||||
|
||||
// after all scripts have loaded, boot the actual app
|
||||
load(JQUERY, LEAFLET, AUTOLINK).then(LEAFLETGOOGLE, JQUERYUI).onError(function (err) {
|
||||
alert('Could not all resources, the script likely won’t work.\n\nIf this happend the first time for you, it’s probably a temporary issue. Just wait a bit and try again.\n\nIf you installed the script for the first time and this happens:\n– try disabling NoScript if you have it installed\n– press CTRL+SHIFT+K in Firefox or CTRL+SHIFT+I in Chrome/Opera and reload the page. Additional info may be available in the console.\n– Open an issue at https://github.com/breunigs/ingress-intel-total-conversion/issues');
|
||||
}).thenRun(boot);
|
||||
load(JQUERY).then(JQUERYUI).thenRun(boot);
|
||||
|
@ -15,7 +15,7 @@ window.updateGameScore = function(data) {
|
||||
var es = '<span class="enl" style="width:'+ep+'%;"> '+Math.round(ep)+'%</span>';
|
||||
$('#gamestat').html(rs+es).one('click', function() { window.updateGameScore() });
|
||||
// help cursor via “#gamestat span”
|
||||
$('#gamestat').attr('title', 'Resistance:\t'+r+' MindUnits\nEnlightenment:\t'+e+' MindUnits');
|
||||
$('#gamestat').attr('title', 'Resistance:\t'+r+' MindUnits\nEnlightened:\t'+e+' MindUnits');
|
||||
|
||||
window.setTimeout('window.updateGameScore', REFRESH_GAME_SCORE*1000);
|
||||
}
|
||||
|
@ -43,13 +43,17 @@
|
||||
// redrawn. It is called early on in the
|
||||
// code/map_data.js#renderPortal as long as there was an
|
||||
// old portal for the guid.
|
||||
// checkRenderLimit: callback is passed the argument of
|
||||
// {reached : false} to indicate that the renderlimit is reached
|
||||
// set reached to true.
|
||||
|
||||
|
||||
|
||||
|
||||
window._hooks = {}
|
||||
window.VALID_HOOKS = ['portalAdded', 'portalDetailsUpdated',
|
||||
'publicChatDataAvailable', 'portalDataLoaded', 'beforePortalReRender'];
|
||||
'publicChatDataAvailable', 'portalDataLoaded', 'beforePortalReRender',
|
||||
'checkRenderLimit'];
|
||||
|
||||
window.runHooks = function(event, data) {
|
||||
if(VALID_HOOKS.indexOf(event) === -1) throw('Unknown event type: ' + event);
|
||||
|
@ -261,8 +261,11 @@ window.renderPortal = function(ent) {
|
||||
// pre-loads player names for high zoom levels
|
||||
loadPlayerNamesForPortal(ent[2]);
|
||||
|
||||
var lvWeight = Math.max(2, portalLevel / 1.5);
|
||||
var lvRadius = Math.max(portalLevel + 3, 5);
|
||||
var lvWeight = Math.max(2, Math.floor(portalLevel) / 1.5);
|
||||
var lvRadius = Math.floor(portalLevel) + 4;
|
||||
if(team === window.TEAM_NONE) {
|
||||
lvRadius = 7;
|
||||
}
|
||||
|
||||
var p = L.circleMarker(latlng, {
|
||||
radius: lvRadius + (L.Browser.mobile ? PORTAL_RADIUS_ENLARGE_MOBILE : 0),
|
||||
@ -481,9 +484,19 @@ window.renderLink = function(ent) {
|
||||
weight:2,
|
||||
clickable: false,
|
||||
guid: ent[0],
|
||||
smoothFactor: 10
|
||||
smoothFactor: 0 // doesn’t work for two points anyway, so disable
|
||||
});
|
||||
|
||||
// determine which links are very short and don’t render them at all.
|
||||
// in most cases this will go unnoticed, but improve rendering speed.
|
||||
poly._map = window.map;
|
||||
poly.projectLatlngs();
|
||||
var op = poly._originalPoints;
|
||||
var dist = Math.abs(op[0].x - op[1].x) + Math.abs(op[0].y - op[1].y);
|
||||
if(dist <= 10) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!getPaddedBounds().intersects(poly.getBounds())) return;
|
||||
|
||||
poly.on('remove', function() { delete window.links[this.options.guid]; });
|
||||
@ -512,17 +525,28 @@ window.renderField = function(ent) {
|
||||
[reg.vertexB.location.latE6/1E6, reg.vertexB.location.lngE6/1E6],
|
||||
[reg.vertexC.location.latE6/1E6, reg.vertexC.location.lngE6/1E6]
|
||||
];
|
||||
|
||||
var poly = L.polygon(latlngs, {
|
||||
fillColor: COLORS[team],
|
||||
fillOpacity: 0.25,
|
||||
stroke: false,
|
||||
clickable: false,
|
||||
smoothFactor: 10,
|
||||
vertices: ent[2].capturedRegion,
|
||||
smoothFactor: 0, // hiding small fields will be handled below
|
||||
vertices: reg,
|
||||
lastUpdate: ent[1],
|
||||
guid: ent[0],
|
||||
data: ent[2]});
|
||||
|
||||
// determine which fields are too small to be rendered and don’t
|
||||
// render them, so they don’t count towards the maximum fields limit.
|
||||
// This saves some DOM operations as well, but given the relatively
|
||||
// low amount of fields there isn’t much to gain.
|
||||
// The algorithm is the same as used by Leaflet.
|
||||
poly._map = window.map;
|
||||
poly.projectLatlngs();
|
||||
var count = L.LineUtil.simplify(poly._originalPoints, 6).length;
|
||||
if(count <= 2) return;
|
||||
|
||||
if(!getPaddedBounds().intersects(poly.getBounds())) return;
|
||||
|
||||
poly.on('remove', function() { delete window.fields[this.options.guid]; });
|
||||
|
@ -26,7 +26,10 @@ window.renderPortalDetails = function(guid) {
|
||||
: null;
|
||||
var playerText = player ? ['owner', player] : null;
|
||||
|
||||
var time = d.captured ? unixTimeToString(d.captured.capturedTime) : null;
|
||||
var time = d.captured
|
||||
? '<span title="' + unixTimeToString(d.captured.capturedTime, true) + '">'
|
||||
+ unixTimeToString(d.captured.capturedTime) + '</span>'
|
||||
: null;
|
||||
var sinceText = time ? ['since', time] : null;
|
||||
|
||||
var linkedFields = ['fields', d.portalV2.linkedFields.length];
|
||||
@ -41,13 +44,15 @@ window.renderPortalDetails = function(guid) {
|
||||
var resoDetails = '<table id="resodetails">' + getResonatorDetails(d) + '</table>';
|
||||
|
||||
setPortalIndicators(d);
|
||||
var img = d.imageByUrl && d.imageByUrl.imageUrl ? d.imageByUrl.imageUrl : DEFAULT_PORTAL_IMG;
|
||||
var img = d.imageByUrl && d.imageByUrl.imageUrl
|
||||
? d.imageByUrl.imageUrl.replace(/^http:/, 'https:')
|
||||
: DEFAULT_PORTAL_IMG;
|
||||
|
||||
var lat = d.locationE6.latE6;
|
||||
var lng = d.locationE6.lngE6;
|
||||
var perma = 'http://ingress.com/intel?latE6='+lat+'&lngE6='+lng+'&z=17&pguid='+guid;
|
||||
var imgTitle = 'title="'+getPortalDescriptionFromDetails(d)+'\n\nClick to show full image."';
|
||||
var gmaps = 'https://maps.google.com/?q='+lat/1E6+','+lng/1E6;
|
||||
var poslinks = 'window.showPortalPosLinks('+lat/1E6+','+lng/1E6+')';
|
||||
var postcard = 'Send in a postcard. Will put it online after receiving. Address:\\n\\nStefan Breunig\\nINF 305 – R045\\n69120 Heidelberg\\nGermany';
|
||||
|
||||
$('#portaldetails')
|
||||
@ -63,7 +68,7 @@ window.renderPortalDetails = function(guid) {
|
||||
+ randDetails
|
||||
+ resoDetails
|
||||
+ '<div class="linkdetails">'+ '<aside><a href="'+perma+'">portal link</a></aside>'
|
||||
+ '<aside><a href="'+gmaps+'" target="_blank">gmaps</a></aside>'
|
||||
+ '<aside><a onclick="'+poslinks+'">poslinks</a></aside>'
|
||||
+ '<aside><a onclick="alert(\''+postcard+'\');">donate</a></aside>'
|
||||
+ '<aside><a onclick="window.reportPortalIssue()">report issue</a></aside>'
|
||||
+ '</div>'
|
||||
|
@ -54,7 +54,7 @@ window.postAjax = function(action, data, success, error) {
|
||||
// use full URL to avoid issues depending on how people set their
|
||||
// slash. See:
|
||||
// https://github.com/breunigs/ingress-intel-total-conversion/issues/56
|
||||
url: 'http://www.ingress.com/rpc/dashboard.'+action,
|
||||
url: 'https://www.ingress.com/rpc/dashboard.'+action,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
@ -96,8 +96,16 @@ window.rangeLinkClick = function() {
|
||||
window.smartphone.mapButton.click();
|
||||
}
|
||||
|
||||
window.showPortalPosLinks = function(lat, lng) {
|
||||
var qrcode = '<div id="qrcode"></div>';
|
||||
var script = '<script>$(\'#qrcode\').qrcode({text:\'GEO:'+lat+','+lng+'\'});</script>';
|
||||
var gmaps = '<a href="https://maps.google.com/?q='+lat+','+lng+'">gmaps</a>';
|
||||
var osm = '<a href="http://www.openstreetmap.org/?mlat='+lat+'&mlon='+lng+'&zoom=16">OSM</a>';
|
||||
alert('<div style="text-align: center;">' + qrcode + script + gmaps + ' ' + osm + '</div>');
|
||||
}
|
||||
|
||||
window.reportPortalIssue = function(info) {
|
||||
var t = 'Redirecting you to a Google Help Page. Once there, click on “Contact Us” in the upper right corner.\n\nThe text box contains all necessary information. Press CTRL+C to copy it.';
|
||||
var t = 'Redirecting you to a Google Help Page.\n\nThe text box contains all necessary information. Press CTRL+C to copy it.';
|
||||
var d = window.portals[window.selectedPortal].options.details;
|
||||
|
||||
var info = 'Your Nick: ' + PLAYER.nickname + ' '
|
||||
@ -107,7 +115,7 @@ window.reportPortalIssue = function(info) {
|
||||
|
||||
//codename, approx addr, portalname
|
||||
if(prompt(t, info) !== null)
|
||||
location.href = 'https://support.google.com/ingress?hl=en';
|
||||
location.href = 'https://support.google.com/ingress?hl=en&contact=1';
|
||||
}
|
||||
|
||||
window._storedPaddedBounds = undefined;
|
||||
@ -117,6 +125,7 @@ window.getPaddedBounds = function() {
|
||||
window._storedPaddedBounds = null;
|
||||
});
|
||||
}
|
||||
if(renderLimitReached(0.7)) return window.map.getBounds();
|
||||
if(window._storedPaddedBounds) return window._storedPaddedBounds;
|
||||
|
||||
var p = window.map.getBounds().pad(VIEWPORT_PAD_RATIO);
|
||||
@ -124,11 +133,19 @@ window.getPaddedBounds = function() {
|
||||
return p;
|
||||
}
|
||||
|
||||
window.renderLimitReached = function() {
|
||||
if(Object.keys(portals).length >= MAX_DRAWN_PORTALS) return true;
|
||||
if(Object.keys(links).length >= MAX_DRAWN_LINKS) return true;
|
||||
if(Object.keys(fields).length >= MAX_DRAWN_FIELDS) return true;
|
||||
return false;
|
||||
// returns true if the render limit has been reached. The default ratio
|
||||
// is 1, which means it will tell you if there are more items drawn than
|
||||
// acceptable. A value of 0.9 will tell you if 90% of the amount of
|
||||
// acceptable entities have been drawn. You can use this to heuristi-
|
||||
// cally detect if the render limit will be hit.
|
||||
window.renderLimitReached = function(ratio) {
|
||||
ratio = ratio || 1;
|
||||
if(Object.keys(portals).length*ratio >= MAX_DRAWN_PORTALS) return true;
|
||||
if(Object.keys(links).length*ratio >= MAX_DRAWN_LINKS) return true;
|
||||
if(Object.keys(fields).length*ratio >= MAX_DRAWN_FIELDS) return true;
|
||||
var param = { 'reached': false };
|
||||
window.runHooks('checkRenderLimit', param);
|
||||
return param.reached;
|
||||
}
|
||||
|
||||
window.getMinPortalLevel = function() {
|
||||
|
Reference in New Issue
Block a user