diff --git a/code/chat.js b/code/chat.js index 71d0196c..fc88c670 100644 --- a/code/chat.js +++ b/code/chat.js @@ -680,7 +680,18 @@ window.chat.postMsg = function() { var msg = $.trim($('#chatinput input').val()); if(!msg || msg === '') return; - if(c === 'debug') return new Function (msg)(); + if(c === 'debug') { + var result; + try { + result = eval(msg); + } catch(e) { + if(e.stack) console.error(e.stack); + throw e; // to trigger native error message + } + if(result !== undefined) + console.log(result.toString()); + return result; + } var publik = c === 'public'; var latlng = map.getCenter(); diff --git a/code/debugging.js b/code/debugging.js index b1d2bbe8..c72b3163 100644 --- a/code/debugging.js +++ b/code/debugging.js @@ -84,10 +84,20 @@ window.debug.console.error = function(text) { window.debug.console.overwriteNative = function() { window.debug.console.create(); - window.console = function() {} - window.console.log = window.debug.console.log; - window.console.warn = window.debug.console.warn; - window.console.error = window.debug.console.error; + + var nativeConsole = window.console; + window.console = {}; + + function overwrite(which) { + window.console[which] = function() { + nativeConsole[which].apply(nativeConsole, arguments); + window.debug.console[which].apply(window.debug.console, arguments); + } + } + + overwrite("log"); + overwrite("warn"); + overwrite("error"); } window.debug.console.overwriteNativeIfRequired = function() { diff --git a/code/panes.js b/code/panes.js index 5fd037fe..4c3898d4 100644 --- a/code/panes.js +++ b/code/panes.js @@ -1,65 +1,45 @@ // created to start cleaning up "window" interaction // window.show = function(id) { - if (typeof android !== 'undefined' && android && android.switchToPane) { - android.switchToPane(id); - } - /* - * disable all map properties when switching to another pane - * because sometimes (bug?) touch events are passed to the map when - * other panes are focussed - */ - window.disableMapProperties(); - window.hideall(); + window.hideall(); - switch(id) { - case 'full': - window.chat.show('full'); - break; - case 'compact': - window.chat.show('compact'); - break; - case 'public': - window.chat.show('public'); - break; - case 'faction': - window.chat.show('faction'); - break; - case 'debug': - window.debug.console.show(); - break; - case 'map': - window.enableMapProperties(); - window.smartphone.mapButton.click(); - $('#portal_highlight_select').show(); - $('#farm_level_select').show(); - break; - case 'info': - window.smartphone.sideButton.click(); - break; - default: - window.smartphone.mapButton.click(); - break; - } -} + switch(id) { + case 'full': + window.chat.show('full'); + break; + case 'compact': + window.chat.show('compact'); + break; + case 'public': + window.chat.show('public'); + break; + case 'faction': + window.chat.show('faction'); + break; + case 'debug': + window.debug.console.show(); + break; + case 'map': + window.smartphone.mapButton.click(); + $('#portal_highlight_select').show(); + $('#farm_level_select').show(); + break; + case 'info': + window.smartphone.sideButton.click(); + break; + default: + window.smartphone.mapButton.click(); + break; + } -window.enableMapProperties = function() { - window.map.tap.enable(); - window.map.dragging.enable(); - window.map.touchZoom.enable(); - window.map.doubleClickZoom.enable(); -} - -window.disableMapProperties = function() { - window.map.tap.disable(); - window.map.dragging.disable(); - window.map.touchZoom.disable(); - window.map.doubleClickZoom.disable(); + if (typeof android !== 'undefined' && android && android.switchToPane) { + android.switchToPane(id); + } } window.hideall = function() { - $('#chatcontrols, #chat, #chatinput, #sidebartoggle, #scrollwrapper, #updatestatus, #portal_highlight_select').hide(); - $('#farm_level_select').hide(); - $('#map').css('visibility', 'hidden'); - $('.ui-tooltip').remove(); + $('#chatcontrols, #chat, #chatinput, #sidebartoggle, #scrollwrapper, #updatestatus, #portal_highlight_select').hide(); + $('#farm_level_select').hide(); + $('#map').css('visibility', 'hidden'); + $('.ui-tooltip').remove(); } diff --git a/code/portal_detail_display.js b/code/portal_detail_display.js index 5004ce1c..47967e57 100644 --- a/code/portal_detail_display.js +++ b/code/portal_detail_display.js @@ -90,6 +90,17 @@ window.renderPortalDetails = function(guid) { portalDetailedDescription += ''; } + var levelDetails = getPortalLevel(d); + if(levelDetails != 8) { + if(levelDetails==Math.ceil(levelDetails)) + levelDetails += "\n8"; + else + levelDetails += "\n" + (Math.ceil(levelDetails) - levelDetails)*8; + levelDetails += " resonator level(s) needed for next portal level"; + } else { + levelDetails += "\nfully upgraded"; + } + levelDetails = "Level " + levelDetails; $('#portaldetails') .attr('class', TEAM_TO_CSS[getTeam(d)]) @@ -98,7 +109,7 @@ window.renderPortalDetails = function(guid) { + 'X' // help cursor via ".imgpreview img" + '
' - + ''+Math.floor(getPortalLevel(d))+'' + + ''+Math.floor(getPortalLevel(d))+'' + '
'+ portalDetailedDescription + '
' + '
' + '' @@ -134,9 +145,14 @@ window.setPortalIndicators = function(d) { var range = getPortalRange(d); var coord = [d.locationE6.latE6/1E6, d.locationE6.lngE6/1E6]; - portalRangeIndicator = (range > 0 - ? L.geodesicCircle(coord, range, { fill: false, color: RANGE_INDICATOR_COLOR, weight: 3, clickable: false }) - : L.circle(coord, range, { fill: false, stroke: false, clickable: false }) + portalRangeIndicator = (range.range > 0 + ? L.geodesicCircle(coord, range.range, { + fill: false, + color: RANGE_INDICATOR_COLOR, + weight: 3, + dashArray: range.isLinkable ? undefined : "10,10", + clickable: false }) + : L.circle(coord, range.range, { fill: false, stroke: false, clickable: false }) ).addTo(map); portalAccessIndicator = L.circle(coord, HACK_RANGE, diff --git a/code/portal_detail_display_tools.js b/code/portal_detail_display_tools.js index a1196d60..353189d9 100644 --- a/code/portal_detail_display_tools.js +++ b/code/portal_detail_display_tools.js @@ -5,11 +5,20 @@ // returns displayable text+link about portal range window.getRangeText = function(d) { var range = getPortalRange(d); + + var title = 'Base range:\t' + digits(Math.floor(range.base))+'m' + + '\nLink amp boost:\t×'+range.boost + + '\nRange:\t'+digits(Math.floor(range.range))+'m'; + + if(!range.isLinkable) title += '\nPortal is missing resonators,\nno new links can be made'; + return ['range', - '' - + (range > 1000 - ? Math.floor(range/1000) + ' km' - : Math.floor(range) + ' m') + '' + + (range.range > 1000 + ? Math.floor(range.range/1000) + ' km' + : Math.floor(range.range) + ' m') + '']; } diff --git a/code/portal_info.js b/code/portal_info.js index a6a5bc01..569f8f0f 100644 --- a/code/portal_info.js +++ b/code/portal_info.js @@ -47,18 +47,20 @@ window.getPortalRange = function(d) { $.each(d.resonatorArray.resonators, function(ind, reso) { if(!reso) { resoMissing = true; - return false; + return; } lvl += parseInt(reso.level); }); - if(resoMissing) return 0; - var range = 160*Math.pow(getPortalLevel(d), 4); + var range = { + base: 160*Math.pow(getPortalLevel(d), 4), + boost: getLinkAmpRangeBoost(d) + }; - var boost = getLinkAmpRangeBoost(d); - - return range*boost; + range.range = range.boost * range.base; + range.isLinkable = !resoMissing; + return range; } window.getLinkAmpRangeBoost = function(d) { diff --git a/code/utils_misc.js b/code/utils_misc.js index a8f2048f..fa34ee5e 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -602,3 +602,22 @@ window.clampLatLng = function(latlng) { window.clampLatLngBounds = function(bounds) { return new L.LatLngBounds ( clampLatLng(bounds.getSouthWest()), clampLatLng(bounds.getNorthEast()) ); } + +// avoid error in stock JS +if(goog && goog.style) { + goog.style.showElement = function(a, b) { + if(a && a.style) + a.style.display = b ? "" : "none" + }; +} + +// Fix Leaflet: handle touchcancel events in Draggable +L.Draggable.prototype._onDownOrig = L.Draggable.prototype._onDown; +L.Draggable.prototype._onDown = function(e) { + L.Draggable.prototype._onDownOrig.apply(this, arguments); + + if(e.type === "touchstart") { + L.DomEvent.on(document, "touchcancel", this._onUp, this); + } +} + diff --git a/main.js b/main.js index 72f96f7e..4e5a6ebf 100644 --- a/main.js +++ b/main.js @@ -100,7 +100,9 @@ document.getElementsByTagName('body')[0].innerHTML = '' + ' ' + ' ' + '' - + '
'; + + '
' + // avoid error by stock JS + + '
'; // putting everything in a wrapper function that in turn is placed in a // script tag on the website allows us to execute in the site’s context diff --git a/mobile/AndroidManifest.xml b/mobile/AndroidManifest.xml index bfe5e003..2bf270c2 100644 --- a/mobile/AndroidManifest.xml +++ b/mobile/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="56" + android:versionName="0.7.6">