From 1d2eec7f8042843a41b84118ed40768bd99dd202 Mon Sep 17 00:00:00 2001
From: vita10gy
Date: Tue, 3 Sep 2013 18:42:45 -0700
Subject: [PATCH 01/67] Feedback when geosearch finds nothing
Subtle, but it's driven me crazy in the past where seemingly reasonable
searches do nothing and "worked - but found nothing" and "maybe it's
just taking a second to work" aren't apparent.
---
code/geosearch.js | 6 +++++-
style.css | 6 ++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/code/geosearch.js b/code/geosearch.js
index ab67a56c..0a3165c8 100644
--- a/code/geosearch.js
+++ b/code/geosearch.js
@@ -14,6 +14,7 @@ window.setupGeosearch = function() {
$('#geosearchwrapper img').click(function(){
map.locate({setView : true, maxZoom: 13});
});
+ $('#geosearch').keyup(function(){$(this).removeClass('search_not_found')});
}
window.search = function(search) {
@@ -22,7 +23,10 @@ window.search = function(search) {
}
$.getJSON(NOMINATIM + encodeURIComponent(search), function(data) {
- if(!data || !data[0]) return true;
+ if(!data || !data[0]) {
+ $('#geosearch').addClass('search_not_found');
+ return true;
+ }
var b = data[0].boundingbox;
if(!b) return true;
var southWest = new L.LatLng(b[0], b[2]),
diff --git a/style.css b/style.css
index 532bc501..c72baec6 100644
--- a/style.css
+++ b/style.css
@@ -469,6 +469,12 @@ input {
margin-bottom: 2px;
cursor: pointer;
}
+
+.search_not_found{
+ color:red;
+ font-style: italic;
+}
+
::-webkit-input-placeholder {
font-style: italic;
}
From dfd91de6dca0c107fb09abc741d7eb203a91e195 Mon Sep 17 00:00:00 2001
From: Xelio
Date: Fri, 20 Sep 2013 13:40:26 +0800
Subject: [PATCH 02/67] New hook: playerNameResolved Called when unresolved
player name get resolved. Argument is {names: object} which names[guid] is
the resolved player name
---
code/hooks.js | 5 ++++-
code/player_names.js | 5 +++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/code/hooks.js b/code/hooks.js
index f415fe62..b6a7ef6c 100644
--- a/code/hooks.js
+++ b/code/hooks.js
@@ -15,6 +15,9 @@
// required to successfully boot the plugin.
//
// Here’s more specific information about each event:
+// playerNameResolved: called when unresolved player name get resolved.
+// Argument is {names: object} which names[guid] is the
+// resolved player name.
// portalSelected: called when portal on map is selected/unselected.
// Provide guid of selected and unselected portal.
// mapDataRefreshStart: called when we start refreshing map data
@@ -49,7 +52,7 @@
window._hooks = {}
window.VALID_HOOKS = [
- 'portalSelected',
+ 'playerNameResolved', 'portalSelected',
'mapDataRefreshStart', 'mapDataRefreshEnd',
'portalAdded', 'linkAdded', 'fieldAdded',
'portalDetailsUpdated',
diff --git a/code/player_names.js b/code/player_names.js
index d8bfda37..0f895d53 100644
--- a/code/player_names.js
+++ b/code/player_names.js
@@ -68,9 +68,11 @@ window.resolvePlayerNames = function() {
window.playersInResolving = window.playersInResolving.concat(p);
postAjax('getPlayersByGuids', d, function(dat) {
+ var resolvedName = {};
if(dat.result) {
$.each(dat.result, function(ind, player) {
window.setPlayerName(player.guid, player.nickname);
+ resolvedName[player.guid] = player.nickname;
// remove from array
window.playersInResolving.splice(window.playersInResolving.indexOf(player.guid), 1);
});
@@ -82,6 +84,9 @@ window.resolvePlayerNames = function() {
//therefore, not a good idea to automatically retry by adding back to the playersToResolve list
}
+ // Run hook 'playerNameResolved' with the resolved player names
+ window.runHooks('playerNameResolved', {names: resolvedName});
+
//TODO: have an event triggered for this instead of hard-coded single function call
if(window.selectedPortal)
window.renderPortalDetails(window.selectedPortal);
From ca8c8bb806947e2b8f83a061fb72d133f90bc029 Mon Sep 17 00:00:00 2001
From: Nihal Mirpuri
Date: Tue, 24 Sep 2013 13:26:35 +1000
Subject: [PATCH 03/67] Added KML plugin
---
external/KML.js | 336 ++++++++++++++++++++++++++++++++++
external/leaflet.filelayer.js | 168 +++++++++++++++++
external/togeojson.js | 224 +++++++++++++++++++++++
plugins/kml_plugin.user.js | 62 +++++++
4 files changed, 790 insertions(+)
create mode 100755 external/KML.js
create mode 100755 external/leaflet.filelayer.js
create mode 100755 external/togeojson.js
create mode 100755 plugins/kml_plugin.user.js
diff --git a/external/KML.js b/external/KML.js
new file mode 100755
index 00000000..22659777
--- /dev/null
+++ b/external/KML.js
@@ -0,0 +1,336 @@
+/*global L: true */
+
+L.KML = L.FeatureGroup.extend({
+ options: {
+ async: true
+ },
+
+ initialize: function(kml, options) {
+ L.Util.setOptions(this, options);
+ this._kml = kml;
+ this._layers = {};
+
+ if (kml) {
+ this.addKML(kml, options, this.options.async);
+ }
+ },
+
+ loadXML: function(url, cb, options, async) {
+ if (async == undefined) async = this.options.async;
+ if (options == undefined) options = this.options;
+
+ var req = new window.XMLHttpRequest();
+ req.open('GET', url, async);
+ try {
+ req.overrideMimeType('text/xml'); // unsupported by IE
+ } catch(e) {}
+ req.onreadystatechange = function() {
+ if (req.readyState != 4) return;
+ if(req.status == 200) cb(req.responseXML, options);
+ };
+ req.send(null);
+ },
+
+ addKML: function(url, options, async) {
+ var _this = this;
+ var cb = function(gpx, options) { _this._addKML(gpx, options) };
+ this.loadXML(url, cb, options, async);
+ },
+
+ _addKML: function(xml, options) {
+ var layers = L.KML.parseKML(xml);
+ if (!layers || !layers.length) return;
+ for (var i = 0; i < layers.length; i++)
+ {
+ this.fire('addlayer', {
+ layer: layers[i]
+ });
+ this.addLayer(layers[i]);
+ }
+ this.latLngs = L.KML.getLatLngs(xml);
+ this.fire("loaded");
+ },
+
+ latLngs: []
+});
+
+L.Util.extend(L.KML, {
+
+ parseKML: function (xml) {
+ var style = this.parseStyle(xml);
+ var el = xml.getElementsByTagName("Folder");
+ var layers = [], l;
+ for (var i = 0; i < el.length; i++) {
+ if (!this._check_folder(el[i])) { continue; }
+ l = this.parseFolder(el[i], style);
+ if (l) { layers.push(l); }
+ }
+ el = xml.getElementsByTagName('Placemark');
+ for (var j = 0; j < el.length; j++) {
+ if (!this._check_folder(el[j])) { continue; }
+ l = this.parsePlacemark(el[j], xml, style);
+ if (l) { layers.push(l); }
+ }
+ return layers;
+ },
+
+ // Return false if e's first parent Folder is not [folder]
+ // - returns true if no parent Folders
+ _check_folder: function (e, folder) {
+ e = e.parentElement;
+ while (e && e.tagName !== "Folder")
+ {
+ e = e.parentElement;
+ }
+ return !e || e === folder;
+ },
+
+ parseStyle: function (xml) {
+ var style = {};
+ var sl = xml.getElementsByTagName("Style");
+
+ //for (var i = 0; i < sl.length; i++) {
+ var attributes = {color: true, width: true, Icon: true, href: true,
+ hotSpot: true};
+
+ function _parse(xml) {
+ var options = {};
+ for (var i = 0; i < xml.childNodes.length; i++) {
+ var e = xml.childNodes[i];
+ var key = e.tagName;
+ if (!attributes[key]) { continue; }
+ if (key === 'hotSpot')
+ {
+ for (var j = 0; j < e.attributes.length; j++) {
+ options[e.attributes[j].name] = e.attributes[j].nodeValue;
+ }
+ } else {
+ var value = e.childNodes[0].nodeValue;
+ if (key === 'color') {
+ options.opacity = parseInt(value.substring(0, 2), 16) / 255.0;
+ options.color = "#" + value.substring(6, 8) + value.substring(4, 6) + value.substring(2, 4);
+ } else if (key === 'width') {
+ options.weight = value;
+ } else if (key === 'Icon') {
+ ioptions = _parse(e);
+ if (ioptions.href) { options.href = ioptions.href; }
+ } else if (key === 'href') {
+ options.href = value;
+ }
+ }
+ }
+ return options;
+ }
+
+ for (var i = 0; i < sl.length; i++) {
+ var e = sl[i], el;
+ var options = {}, poptions = {}, ioptions = {};
+ el = e.getElementsByTagName("LineStyle");
+ if (el && el[0]) { options = _parse(el[0]); }
+ el = e.getElementsByTagName("PolyStyle");
+ if (el && el[0]) { poptions = _parse(el[0]); }
+ if (poptions.color) { options.fillColor = poptions.color; }
+ if (poptions.opacity) { options.fillOpacity = poptions.opacity; }
+ el = e.getElementsByTagName("IconStyle");
+ if (el && el[0]) { ioptions = _parse(el[0]); }
+ if (ioptions.href) {
+ // save anchor info until the image is loaded
+ options.icon = new L.KMLIcon({
+ iconUrl: ioptions.href,
+ shadowUrl: null,
+ iconAnchorRef: {x: ioptions.x, y: ioptions.y},
+ iconAnchorType: {x: ioptions.xunits, y: ioptions.yunits}
+ });
+ }
+ style['#' + e.getAttribute('id')] = options;
+ }
+ return style;
+ },
+
+ parseFolder: function (xml, style) {
+ var el, layers = [], l;
+ el = xml.getElementsByTagName('Folder');
+ for (var i = 0; i < el.length; i++) {
+ if (!this._check_folder(el[i], xml)) { continue; }
+ l = this.parseFolder(el[i], style);
+ if (l) { layers.push(l); }
+ }
+ el = xml.getElementsByTagName('Placemark');
+ for (var j = 0; j < el.length; j++) {
+ if (!this._check_folder(el[j], xml)) { continue; }
+ l = this.parsePlacemark(el[j], xml, style);
+ if (l) { layers.push(l); }
+ }
+ if (!layers.length) { return; }
+ if (layers.length === 1) { return layers[0]; }
+ return new L.FeatureGroup(layers);
+ },
+
+ parsePlacemark: function (place, xml, style) {
+ var i, j, el, options = {};
+ el = place.getElementsByTagName('styleUrl');
+ for (i = 0; i < el.length; i++) {
+ var url = el[i].childNodes[0].nodeValue;
+ for (var a in style[url])
+ {
+ // for jshint
+ if (true)
+ {
+ options[a] = style[url][a];
+ }
+ }
+ }
+ var layers = [];
+
+ var parse = ['LineString', 'Polygon', 'Point'];
+ for (j in parse) {
+ // for jshint
+ if (true)
+ {
+ var tag = parse[j];
+ el = place.getElementsByTagName(tag);
+ for (i = 0; i < el.length; i++) {
+ var l = this["parse" + tag](el[i], xml, options);
+ if (l) { layers.push(l); }
+ }
+ }
+ }
+
+ if (!layers.length) {
+ return;
+ }
+ var layer = layers[0];
+ if (layers.length > 1) {
+ layer = new L.FeatureGroup(layers);
+ }
+
+ var name, descr = "";
+ el = place.getElementsByTagName('name');
+ if (el.length) {
+ name = el[0].childNodes[0].nodeValue;
+ }
+ el = place.getElementsByTagName('description');
+ for (i = 0; i < el.length; i++) {
+ for (j = 0; j < el[i].childNodes.length; j++) {
+ descr = descr + el[i].childNodes[j].nodeValue;
+ }
+ }
+
+ if (name) {
+ layer.bindPopup("
" + name + "
" + descr);
+ }
+
+ return layer;
+ },
+
+ parseCoords: function (xml) {
+ var el = xml.getElementsByTagName('coordinates');
+ return this._read_coords(el[0]);
+ },
+
+ parseLineString: function (line, xml, options) {
+ var coords = this.parseCoords(line);
+ if (!coords.length) { return; }
+ return new L.Polyline(coords, options);
+ },
+
+ parsePoint: function (line, xml, options) {
+ var el = line.getElementsByTagName('coordinates');
+ if (!el.length) {
+ return;
+ }
+ var ll = el[0].childNodes[0].nodeValue.split(',');
+ return new L.KMLMarker(new L.LatLng(ll[1], ll[0]), options);
+ },
+
+ parsePolygon: function (line, xml, options) {
+ var el, polys = [], inner = [], i, coords;
+ el = line.getElementsByTagName('outerBoundaryIs');
+ for (i = 0; i < el.length; i++) {
+ coords = this.parseCoords(el[i]);
+ if (coords) {
+ polys.push(coords);
+ }
+ }
+ el = line.getElementsByTagName('innerBoundaryIs');
+ for (i = 0; i < el.length; i++) {
+ coords = this.parseCoords(el[i]);
+ if (coords) {
+ inner.push(coords);
+ }
+ }
+ if (!polys.length) {
+ return;
+ }
+ if (options.fillColor) {
+ options.fill = true;
+ }
+ if (polys.length === 1) {
+ return new L.Polygon(polys.concat(inner), options);
+ }
+ return new L.MultiPolygon(polys, options);
+ },
+
+ getLatLngs: function (xml) {
+ var el = xml.getElementsByTagName('coordinates');
+ var coords = [];
+ for (var j = 0; j < el.length; j++) {
+ // text might span many childnodes
+ coords = coords.concat(this._read_coords(el[j]));
+ }
+ return coords;
+ },
+
+ _read_coords: function (el) {
+ var text = "", coords = [], i;
+ for (i = 0; i < el.childNodes.length; i++) {
+ text = text + el.childNodes[i].nodeValue;
+ }
+ text = text.split(/[\s\n]+/);
+ for (i = 0; i < text.length; i++) {
+ var ll = text[i].split(',');
+ if (ll.length < 2) {
+ continue;
+ }
+ coords.push(new L.LatLng(ll[1], ll[0]));
+ }
+ return coords;
+ }
+
+});
+
+L.KMLIcon = L.Icon.extend({
+
+ createIcon: function () {
+ var img = this._createIcon('icon');
+ img.onload = function () {
+ var i = new Image();
+ i.src = this.src;
+ this.style.width = i.width + 'px';
+ this.style.height = i.height + 'px';
+
+ if (this.anchorType.x === 'UNITS_FRACTION' || this.anchorType.x === 'fraction') {
+ img.style.marginLeft = (-this.anchor.x * i.width) + 'px';
+ }
+ if (this.anchorType.y === 'UNITS_FRACTION' || this.anchorType.x === 'fraction') {
+ img.style.marginTop = (-(1 - this.anchor.y) * i.height) + 'px';
+ }
+ this.style.display = "";
+ };
+ return img;
+ },
+
+ _setIconStyles: function (img, name) {
+ L.Icon.prototype._setIconStyles.apply(this, [img, name])
+ // save anchor information to the image
+ img.anchor = this.options.iconAnchorRef;
+ img.anchorType = this.options.iconAnchorType;
+ }
+});
+
+
+L.KMLMarker = L.Marker.extend({
+ options: {
+ icon: new L.KMLIcon.Default()
+ }
+});
\ No newline at end of file
diff --git a/external/leaflet.filelayer.js b/external/leaflet.filelayer.js
new file mode 100755
index 00000000..7eab6a50
--- /dev/null
+++ b/external/leaflet.filelayer.js
@@ -0,0 +1,168 @@
+/*
+ * Load files *locally* (GeoJSON, KML, GPX) into the map
+ * using the HTML5 File API.
+ *
+ * Requires Pavel Shramov's GPX.js
+ * https://github.com/shramov/leaflet-plugins/blob/d74d67/layer/vector/GPX.js
+ */
+var FileLoader = L.Class.extend({
+ includes: L.Mixin.Events,
+ options: {
+ layerOptions: {}
+ },
+
+ initialize: function (map, options) {
+ this._map = map;
+ L.Util.setOptions(this, options);
+
+ this._parsers = {
+ 'geojson': this._loadGeoJSON,
+ 'gpx': this._convertToGeoJSON,
+ 'kml': this._convertToGeoJSON
+ };
+ },
+
+ load: function (file /* File */) {
+ // Check file extension
+ var ext = file.name.split('.').pop(),
+ parser = this._parsers[ext];
+ if (!parser) {
+ window.alert("Unsupported file type " + file.type + '(' + ext + ')');
+ return;
+ }
+ // Read selected file using HTML5 File API
+ var reader = new FileReader();
+ reader.onload = L.Util.bind(function (e) {
+ this.fire('data:loading', {filename: file.name, format: ext});
+ var layer = parser.call(this, e.target.result, ext);
+ this.fire('data:loaded', {layer: layer, filename: file.name, format: ext});
+ }, this);
+ reader.readAsText(file);
+ },
+
+ _loadGeoJSON: function (content) {
+ if (typeof content == 'string') {
+ content = JSON.parse(content);
+ }
+ return L.geoJson(content, this.options.layerOptions).addTo(this._map);
+ },
+
+ _convertToGeoJSON: function (content, format) {
+ // Format is either 'gpx' or 'kml'
+ if (typeof content == 'string') {
+ content = ( new window.DOMParser() ).parseFromString(content, "text/xml");
+ }
+ var geojson = toGeoJSON[format](content);
+ return this._loadGeoJSON(geojson);
+ }
+});
+
+
+L.Control.FileLayerLoad = L.Control.extend({
+ statics: {
+ TITLE: 'Load local file (GPX, KML, GeoJSON)',
+ LABEL: '⌅'
+ },
+ options: {
+ position: 'topleft',
+ fitBounds: true,
+ layerOptions: {}
+ },
+
+ initialize: function (options) {
+ L.Util.setOptions(this, options);
+ this.loader = null;
+ },
+
+ onAdd: function (map) {
+ this.loader = new FileLoader(map, {layerOptions: this.options.layerOptions});
+
+ this.loader.on('data:loaded', function (e) {
+ // Fit bounds after loading
+ if (this.options.fitBounds) {
+ window.setTimeout(function () {
+ map.fitBounds(e.layer.getBounds()).zoomOut();
+ }, 500);
+ }
+ }, this);
+
+ // Initialize Drag-and-drop
+ this._initDragAndDrop(map);
+
+ // Initialize map control
+ return this._initContainer();
+ },
+
+ _initDragAndDrop: function (map) {
+ var fileLoader = this.loader,
+ dropbox = map._container;
+
+ var callbacks = {
+ dragenter: function () {
+ map.scrollWheelZoom.disable();
+ },
+ dragleave: function () {
+ map.scrollWheelZoom.enable();
+ },
+ dragover: function (e) {
+ e.stopPropagation();
+ e.preventDefault();
+ },
+ drop: function (e) {
+ e.stopPropagation();
+ e.preventDefault();
+
+ var files = Array.prototype.slice.apply(e.dataTransfer.files),
+ i = files.length;
+ setTimeout(function(){
+ fileLoader.load(files.shift());
+ if (files.length > 0) {
+ setTimeout(arguments.callee, 25);
+ }
+ }, 25);
+ map.scrollWheelZoom.enable();
+ }
+ };
+ for (var name in callbacks)
+ dropbox.addEventListener(name, callbacks[name], false);
+ },
+
+ _initContainer: function () {
+ // Create an invisible file input
+ var fileInput = L.DomUtil.create('input', 'hidden', container);
+ fileInput.type = 'file';
+ fileInput.accept = '.gpx,.kml,.geojson';
+ fileInput.style.display = 'none';
+ // Load on file change
+ var fileLoader = this.loader;
+ fileInput.addEventListener("change", function (e) {
+ fileLoader.load(this.files[0]);
+ }, false);
+
+ // Create a button, and bind click on hidden file input
+ var zoomName = 'leaflet-control-filelayer leaflet-control-zoom',
+ barName = 'leaflet-bar',
+ partName = barName + '-part',
+ container = L.DomUtil.create('div', zoomName + ' ' + barName);
+ var link = L.DomUtil.create('a', zoomName + '-in ' + partName, container);
+ link.innerHTML = L.Control.FileLayerLoad.LABEL;
+ link.href = '#';
+ link.title = L.Control.FileLayerLoad.TITLE;
+
+ var stop = L.DomEvent.stopPropagation;
+ L.DomEvent
+ .on(link, 'click', stop)
+ .on(link, 'mousedown', stop)
+ .on(link, 'dblclick', stop)
+ .on(link, 'click', L.DomEvent.preventDefault)
+ .on(link, 'click', function (e) {
+ fileInput.click();
+ e.preventDefault();
+ });
+ return container;
+ }
+});
+
+L.Control.fileLayerLoad = function (options) {
+ return new L.Control.FileLayerLoad(options);
+};
\ No newline at end of file
diff --git a/external/togeojson.js b/external/togeojson.js
new file mode 100755
index 00000000..cd980b92
--- /dev/null
+++ b/external/togeojson.js
@@ -0,0 +1,224 @@
+toGeoJSON = (function() {
+ 'use strict';
+
+ var removeSpace = (/\s*/g),
+ trimSpace = (/^\s*|\s*$/g),
+ splitSpace = (/\s+/);
+ // generate a short, numeric hash of a string
+ function okhash(x) {
+ if (!x || !x.length) return 0;
+ for (var i = 0, h = 0; i < x.length; i++) {
+ h = ((h << 5) - h) + x.charCodeAt(i) | 0;
+ } return h;
+ }
+ // all Y children of X
+ function get(x, y) { return x.getElementsByTagName(y); }
+ function attr(x, y) { return x.getAttribute(y); }
+ function attrf(x, y) { return parseFloat(attr(x, y)); }
+ // one Y child of X, if any, otherwise null
+ function get1(x, y) { var n = get(x, y); return n.length ? n[0] : null; }
+ // https://developer.mozilla.org/en-US/docs/Web/API/Node.normalize
+ function norm(el) { if (el.normalize) { el.normalize(); } return el; }
+ // cast array x into numbers
+ function numarray(x) {
+ for (var j = 0, o = []; j < x.length; j++) o[j] = parseFloat(x[j]);
+ return o;
+ }
+ function clean(x) {
+ var o = {};
+ for (var i in x) if (x[i]) o[i] = x[i];
+ return o;
+ }
+ // get the content of a text node, if any
+ function nodeVal(x) { if (x) {norm(x);} return x && x.firstChild && x.firstChild.nodeValue; }
+ // get one coordinate from a coordinate array, if any
+ function coord1(v) { return numarray(v.replace(removeSpace, '').split(',')); }
+ // get all coordinates from a coordinate array as [[],[]]
+ function coord(v) {
+ var coords = v.replace(trimSpace, '').split(splitSpace),
+ o = [];
+ for (var i = 0; i < coords.length; i++) {
+ o.push(coord1(coords[i]));
+ }
+ return o;
+ }
+ function coordPair(x) { return [attrf(x, 'lon'), attrf(x, 'lat')]; }
+
+ // create a new feature collection parent object
+ function fc() {
+ return {
+ type: 'FeatureCollection',
+ features: []
+ };
+ }
+
+ var serializer;
+ if (typeof XMLSerializer !== 'undefined') {
+ serializer = new XMLSerializer();
+ } else if (typeof require !== 'undefined') {
+ serializer = new (require('xmldom').XMLSerializer)();
+ }
+ function xml2str(str) { return serializer.serializeToString(str); }
+
+ var t = {
+ kml: function(doc, o) {
+ o = o || {};
+
+ var gj = fc(),
+ // styleindex keeps track of hashed styles in order to match features
+ styleIndex = {},
+ // atomic geospatial types supported by KML - MultiGeometry is
+ // handled separately
+ geotypes = ['Polygon', 'LineString', 'Point', 'Track'],
+ // all root placemarks in the file
+ placemarks = get(doc, 'Placemark'),
+ styles = get(doc, 'Style');
+
+ for (var k = 0; k < styles.length; k++) {
+ styleIndex['#' + attr(styles[k], 'id')] = okhash(xml2str(styles[k])).toString(16);
+ }
+ for (var j = 0; j < placemarks.length; j++) {
+ gj.features = gj.features.concat(getPlacemark(placemarks[j]));
+ }
+ function gxCoord(v) { return numarray(v.split(' ')); }
+ function gxCoords(root) {
+ var elems = get(root, 'coord', 'gx'), coords = [];
+ for (var i = 0; i < elems.length; i++) coords.push(gxCoord(nodeVal(elems[i])));
+ return coords;
+ }
+ function getGeometry(root) {
+ var geomNode, geomNodes, i, j, k, geoms = [];
+ if (get1(root, 'MultiGeometry')) return getGeometry(get1(root, 'MultiGeometry'));
+ if (get1(root, 'MultiTrack')) return getGeometry(get1(root, 'MultiTrack'));
+ for (i = 0; i < geotypes.length; i++) {
+ geomNodes = get(root, geotypes[i]);
+ if (geomNodes) {
+ for (j = 0; j < geomNodes.length; j++) {
+ geomNode = geomNodes[j];
+ if (geotypes[i] == 'Point') {
+ geoms.push({
+ type: 'Point',
+ coordinates: coord1(nodeVal(get1(geomNode, 'coordinates')))
+ });
+ } else if (geotypes[i] == 'LineString') {
+ geoms.push({
+ type: 'LineString',
+ coordinates: coord(nodeVal(get1(geomNode, 'coordinates')))
+ });
+ } else if (geotypes[i] == 'Polygon') {
+ var rings = get(geomNode, 'LinearRing'),
+ coords = [];
+ for (k = 0; k < rings.length; k++) {
+ coords.push(coord(nodeVal(get1(rings[k], 'coordinates'))));
+ }
+ geoms.push({
+ type: 'Polygon',
+ coordinates: coords
+ });
+ } else if (geotypes[i] == 'Track') {
+ geoms.push({
+ type: 'LineString',
+ coordinates: gxCoords(geomNode)
+ });
+ }
+ }
+ }
+ }
+ return geoms;
+ }
+ function getPlacemark(root) {
+ var geoms = getGeometry(root), i, properties = {},
+ name = nodeVal(get1(root, 'name')),
+ styleUrl = nodeVal(get1(root, 'styleUrl')),
+ description = nodeVal(get1(root, 'description')),
+ extendedData = get1(root, 'ExtendedData');
+
+ if (!geoms.length) return [];
+ if (name) properties.name = name;
+ if (styleUrl && styleIndex[styleUrl]) {
+ properties.styleUrl = styleUrl;
+ properties.styleHash = styleIndex[styleUrl];
+ }
+ if (description) properties.description = description;
+ if (extendedData) {
+ var datas = get(extendedData, 'Data'),
+ simpleDatas = get(extendedData, 'SimpleData');
+
+ for (i = 0; i < datas.length; i++) {
+ properties[datas[i].getAttribute('name')] = nodeVal(get1(datas[i], 'value'));
+ }
+ for (i = 0; i < simpleDatas.length; i++) {
+ properties[simpleDatas[i].getAttribute('name')] = nodeVal(simpleDatas[i]);
+ }
+ }
+ return [{
+ type: 'Feature',
+ geometry: (geoms.length === 1) ? geoms[0] : {
+ type: 'GeometryCollection',
+ geometries: geoms
+ },
+ properties: properties
+ }];
+ }
+ return gj;
+ },
+ gpx: function(doc, o) {
+ var i,
+ tracks = get(doc, 'trk'),
+ routes = get(doc, 'rte'),
+ waypoints = get(doc, 'wpt'),
+ // a feature collection
+ gj = fc();
+ for (i = 0; i < tracks.length; i++) {
+ gj.features.push(getLinestring(tracks[i], 'trkpt'));
+ }
+ for (i = 0; i < routes.length; i++) {
+ gj.features.push(getLinestring(routes[i], 'rtept'));
+ }
+ for (i = 0; i < waypoints.length; i++) {
+ gj.features.push(getPoint(waypoints[i]));
+ }
+ function getLinestring(node, pointname) {
+ var j, pts = get(node, pointname), line = [];
+ for (j = 0; j < pts.length; j++) {
+ line.push(coordPair(pts[j]));
+ }
+ return {
+ type: 'Feature',
+ properties: getProperties(node),
+ geometry: {
+ type: 'LineString',
+ coordinates: line
+ }
+ };
+ }
+ function getPoint(node) {
+ var prop = getProperties(node);
+ prop.ele = nodeVal(get1(node, 'ele'));
+ prop.sym = nodeVal(get1(node, 'sym'));
+ return {
+ type: 'Feature',
+ properties: prop,
+ geometry: {
+ type: 'Point',
+ coordinates: coordPair(node)
+ }
+ };
+ }
+ function getProperties(node) {
+ var meta = ['name', 'desc', 'author', 'copyright', 'link',
+ 'time', 'keywords'],
+ prop = {},
+ k;
+ for (k = 0; k < meta.length; k++) {
+ prop[meta[k]] = nodeVal(get1(node, meta[k]));
+ }
+ return clean(prop);
+ }
+ return gj;
+ }
+ };
+ return t;
+})();
+
+if (typeof module !== 'undefined') module.exports = toGeoJSON;
diff --git a/plugins/kml_plugin.user.js b/plugins/kml_plugin.user.js
new file mode 100755
index 00000000..d87199a3
--- /dev/null
+++ b/plugins/kml_plugin.user.js
@@ -0,0 +1,62 @@
+// ==UserScript==
+// @id overlay-kml@danielatkins
+// @name IITC plugin: overlay KML
+// @category Info
+// @version 0.1.@@DATETIMEVERSION@@
+// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
+// @updateURL @@UPDATEURL@@
+// @downloadURL @@DOWNLOADURL@@
+// @description [@@BUILDNAME@@-@@BUILDDATE@@] Allows users to overlay their own KML / GPX files on top of IITC
+// @include https://www.ingress.com/intel*
+// @include http://www.ingress.com/intel*
+// @match https://www.ingress.com/intel*
+// @match http://www.ingress.com/intel*
+// @grant none
+// ==/UserScript==
+
+@@PLUGINSTART@@
+
+// PLUGIN START ////////////////////////////////////////////////////////
+
+// use own namespace for plugin
+window.plugin.overlayKML = function() {};
+
+window.plugin.overlayKML.loadExternals = function() {
+ try { console.log('Loading leaflet.filelayer JS now'); } catch(e) {}
+ @@INCLUDERAW:external/leaflet.filelayer.js@@
+ try { console.log('done loading leaflet.filelayer JS'); } catch(e) {}
+
+ try { console.log('Loading KML JS now'); } catch(e) {}
+ @@INCLUDERAW:external/KML.js@@
+ try { console.log('done loading KML JS'); } catch(e) {}
+
+ try { console.log('Loading togeojson JS now'); } catch(e) {}
+ @@INCLUDERAW:external/togeojson.js@@
+ try { console.log('done loading togeojson JS'); } catch(e) {}
+
+ window.plugin.overlayKML.load();
+}
+
+// window.plugin.overlayKML.setupCallback = function() {
+// $('#toolbox').append(' Overlay KML');
+// }
+
+window.plugin.overlayKML.load = function() {
+ // Provide popup window allow user to select KML to overlay
+L.Control.FileLayerLoad.LABEL = 'O';
+L.Control.fileLayerLoad({
+ fitBounds: true,
+ layerOptions: {
+ pointToLayer: function (data, latlng) {
+ return L.marker(latlng);
+ }},
+}).addTo(map);
+}
+
+var setup = function() {
+ window.plugin.overlayKML.loadExternals();
+}
+
+// PLUGIN END //////////////////////////////////////////////////////////
+
+@@PLUGINEND@@
\ No newline at end of file
From 24eb531ef081af60776f567b3b32b352efe496fb Mon Sep 17 00:00:00 2001
From: Nihal Mirpuri
Date: Tue, 24 Sep 2013 13:45:07 +1000
Subject: [PATCH 04/67] Added KML plugin
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index 509ecd94..adde0f02 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,5 @@
+Forked to test a plugin to add a KML overlay over the map, chosen by file
+
ingress intel total conversion (IITC)
=====================================
From d008e37200f07d0ed220b7856acced38f6ef98c5 Mon Sep 17 00:00:00 2001
From: Nihal Mirpuri
Date: Tue, 24 Sep 2013 14:29:58 +1000
Subject: [PATCH 05/67] Modified KML Plugin to work with points
---
plugins/{kml_plugin.user.js => add-kml.user.js} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename plugins/{kml_plugin.user.js => add-kml.user.js} (100%)
diff --git a/plugins/kml_plugin.user.js b/plugins/add-kml.user.js
similarity index 100%
rename from plugins/kml_plugin.user.js
rename to plugins/add-kml.user.js
From bac7ef7d2212eae1d2b43a3612fcbf87422f1938 Mon Sep 17 00:00:00 2001
From: Nihal Mirpuri
Date: Tue, 24 Sep 2013 15:13:56 +1000
Subject: [PATCH 06/67] Shifted point anchors to be on top of portals
---
plugins/add-kml.user.js | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/plugins/add-kml.user.js b/plugins/add-kml.user.js
index d87199a3..5a24ea41 100755
--- a/plugins/add-kml.user.js
+++ b/plugins/add-kml.user.js
@@ -29,28 +29,34 @@ window.plugin.overlayKML.loadExternals = function() {
try { console.log('Loading KML JS now'); } catch(e) {}
@@INCLUDERAW:external/KML.js@@
try { console.log('done loading KML JS'); } catch(e) {}
-
+
try { console.log('Loading togeojson JS now'); } catch(e) {}
@@INCLUDERAW:external/togeojson.js@@
try { console.log('done loading togeojson JS'); } catch(e) {}
window.plugin.overlayKML.load();
}
-
-// window.plugin.overlayKML.setupCallback = function() {
-// $('#toolbox').append(' Overlay KML');
-// }
window.plugin.overlayKML.load = function() {
// Provide popup window allow user to select KML to overlay
-L.Control.FileLayerLoad.LABEL = 'O';
-L.Control.fileLayerLoad({
- fitBounds: true,
- layerOptions: {
- pointToLayer: function (data, latlng) {
- return L.marker(latlng);
- }},
-}).addTo(map);
+
+ L.Icon.Default.imagePath = '@@INCLUDEIMAGE:images/marker-icon.png@@';
+ var KMLIcon = L.icon({
+ iconUrl: '@@INCLUDEIMAGE:images/marker-icon.png@@',
+
+ iconSize: [16, 24], // size of the icon
+ iconAnchor: [8, 24], // point of the icon which will correspond to marker's location
+ popupAnchor: [-3, 16] // point from which the popup should open relative to the iconAnchor
+ });
+
+ L.Control.FileLayerLoad.LABEL = 'O';
+ L.Control.fileLayerLoad({
+ fitBounds: true,
+ layerOptions: {
+ pointToLayer: function (data, latlng) {
+ return L.marker(latlng, {icon: KMLIcon});
+ }},
+ }).addTo(map);
}
var setup = function() {
@@ -59,4 +65,4 @@ var setup = function() {
// PLUGIN END //////////////////////////////////////////////////////////
-@@PLUGINEND@@
\ No newline at end of file
+@@PLUGINEND@@
From 841497f53b44c1957cc788611762367501c2c4a3 Mon Sep 17 00:00:00 2001
From: Nihal Mirpuri
Date: Tue, 24 Sep 2013 15:36:08 +1000
Subject: [PATCH 07/67] Added folder icon for opening KML files
---
images/open-folder-icon_sml.png | Bin 0 -> 345 bytes
plugins/add-kml.user.js | 6 +++---
2 files changed, 3 insertions(+), 3 deletions(-)
create mode 100644 images/open-folder-icon_sml.png
diff --git a/images/open-folder-icon_sml.png b/images/open-folder-icon_sml.png
new file mode 100644
index 0000000000000000000000000000000000000000..afeda49e6c66e8f5a643ab7c8aed41ed8214a2e7
GIT binary patch
literal 345
zcmeAS@N?(olHy`uVBq!ia0vp^5|
zgW!U_%O?XxI14-?iy0WWg+Z8+Vb&aw0qiB7zOL+dIVD&{C2rhi`3V%d>FMGaVsZNF
z6@RZLM~UMf{gYVM-qGBWAl!}Y`p5Tu#q)Dp43DY^
z1;nYAd=xECQ+#!$H26zXXo+r&>XJQe(Kg2!-miEdxZj##+QV}^*9{K{@E^4E&Y1VF
zDljZ6q2-y}uFc}iHSK?vW_6ucI&f5uLHW-ShU5_Eg+X5eStJ&0JZg}8DSP7MPZyfa
l4huiyym
Date: Tue, 24 Sep 2013 22:23:43 +1000
Subject: [PATCH 08/67] Replaced folder icon with 'O'
---
plugins/add-kml.user.js | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/plugins/add-kml.user.js b/plugins/add-kml.user.js
index dc7ff2e3..98784036 100755
--- a/plugins/add-kml.user.js
+++ b/plugins/add-kml.user.js
@@ -49,8 +49,10 @@ window.plugin.overlayKML.load = function() {
popupAnchor: [-3, 16] // point from which the popup should open relative to the iconAnchor
});
- L.Control.FileLayerLoad.LABEL = '';
- L.Control.fileLayerLoad({
+// Implementing a folder icon instead of default 'O' icon to open KML. Not yet useable
+// L.Control.FileLayerLoad.LABEL = '';
+L.Control.FileLayerLoad.LABEL = 'O';
+L.Control.fileLayerLoad({
fitBounds: true,
layerOptions: {
pointToLayer: function (data, latlng) {
From 39ea0a4a854a3492cf6c08c965970bbbe81c9ea5 Mon Sep 17 00:00:00 2001
From: Nihal Mirpuri
Date: Tue, 24 Sep 2013 23:10:49 +1000
Subject: [PATCH 09/67] Added clickable folder icon
---
plugins/add-kml.user.js | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/plugins/add-kml.user.js b/plugins/add-kml.user.js
index 98784036..3a549f92 100755
--- a/plugins/add-kml.user.js
+++ b/plugins/add-kml.user.js
@@ -42,17 +42,15 @@ window.plugin.overlayKML.load = function() {
L.Icon.Default.imagePath = '@@INCLUDEIMAGE:images/marker-icon.png@@';
var KMLIcon = L.icon({
- iconUrl: '@@INCLUDEIMAGE:images/marker-icon.png@@';,
+ iconUrl: '@@INCLUDEIMAGE:images/marker-icon.png@@',
iconSize: [16, 24], // size of the icon
iconAnchor: [16, 8], // point of the icon which will correspond to marker's location
popupAnchor: [-3, 16] // point from which the popup should open relative to the iconAnchor
});
-// Implementing a folder icon instead of default 'O' icon to open KML. Not yet useable
-// L.Control.FileLayerLoad.LABEL = '';
-L.Control.FileLayerLoad.LABEL = 'O';
-L.Control.fileLayerLoad({
+ L.Control.FileLayerLoad.LABEL = '';
+ L.Control.fileLayerLoad({
fitBounds: true,
layerOptions: {
pointToLayer: function (data, latlng) {
From 773c7d4a6fcc0b2d18dbbcc5ece5020e197ed514 Mon Sep 17 00:00:00 2001
From: Nihal Mirpuri
Date: Tue, 24 Sep 2013 23:36:17 +1000
Subject: [PATCH 10/67] Updated README.md file
---
README.md | 53 ++++-------------------------------------
plugins/add-kml.user.js | 2 +-
2 files changed, 6 insertions(+), 49 deletions(-)
diff --git a/README.md b/README.md
index adde0f02..0fd79e86 100644
--- a/README.md
+++ b/README.md
@@ -1,50 +1,7 @@
-Forked to test a plugin to add a KML overlay over the map, chosen by file
+Forked to test a plugin to add a KML, GPX or GeoJSON overlay over the map, chosen by file.
-ingress intel total conversion (IITC)
-=====================================
+Run the ```build.py local``` script to build the code, as per jonatkins' fork.
-Since the [breunigs](https://github.com/breunigs/ingress-intel-total-conversion) IITC branch was deleted,
-I've created this one to continue some development.
-
-## Users
-
-Just want to download/install IITC? Go to http://iitc.jonatkins.com/
-
-For keeping up with the latest news, release announcements, etc, Follow IITC on G+
-https://plus.google.com/105383756361375410867/posts
-
-If you have questions, need help or advice with IITC, the Google+ community is a good place to start.
-https://plus.google.com/communities/105647403088015055797
-
-Want to report a bug? Post it to the issues page
-https://github.com/jonatkins/ingress-intel-total-conversion/issues
-
-## Developers
-
-This Github page is for those interested in developing IITC further.
-
-### Quickstart
-
-To build the browser scripts from source you will need Python (either a late version 2.x, or 3.0+). It should
-build correctly on Linux and Windows (and, probably, Macs, FreeBSD, etc)
-
-Fork this project, clone to your local machine.
-
-Run the ```build.py local``` script to build the code.
-
-If all goes well, output of the build will end up in ```build/local``` subfolder.
-
-You can create a custom build settings file, ```localbuildsettings.py``` - look in the supplied
-```buildsettings.py``` for details.
-
-#### Mobile
-
-To build the mobile app, along with python, you will need
-
-- The Java JDK (development kit - the runtime JRE is not enough)
-- The Android SDK
-
-Run ``build.py mobile``` to build IITC Mobile in debug mode.
-
-Note that part of the build.py process includes copying the IITC script files into the ```mobile/res``` subfolder.
-If this isn't done (e.g. you build IITC Mobile directly from Eclipse) you will end up with a broken build.
+#Instructions
+If you just want to download the plugin to try it out: http://goo.gl/h0GmoT
+(Note: you have to download a new version of the original IITC script, there are some updated things in there)
diff --git a/plugins/add-kml.user.js b/plugins/add-kml.user.js
index 3a549f92..45c4ce2c 100755
--- a/plugins/add-kml.user.js
+++ b/plugins/add-kml.user.js
@@ -45,7 +45,7 @@ window.plugin.overlayKML.load = function() {
iconUrl: '@@INCLUDEIMAGE:images/marker-icon.png@@',
iconSize: [16, 24], // size of the icon
- iconAnchor: [16, 8], // point of the icon which will correspond to marker's location
+ iconAnchor: [8, 24], // point of the icon which will correspond to marker's location
popupAnchor: [-3, 16] // point from which the popup should open relative to the iconAnchor
});
From 0a4ad93472cce79e6def87f0f3460ad152a44371 Mon Sep 17 00:00:00 2001
From: Nihal Mirpuri
Date: Wed, 25 Sep 2013 02:40:46 +1000
Subject: [PATCH 11/67] reverted README changes
---
README.md | 51 ++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 46 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 0fd79e86..509ecd94 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,48 @@
-Forked to test a plugin to add a KML, GPX or GeoJSON overlay over the map, chosen by file.
+ingress intel total conversion (IITC)
+=====================================
-Run the ```build.py local``` script to build the code, as per jonatkins' fork.
+Since the [breunigs](https://github.com/breunigs/ingress-intel-total-conversion) IITC branch was deleted,
+I've created this one to continue some development.
-#Instructions
-If you just want to download the plugin to try it out: http://goo.gl/h0GmoT
-(Note: you have to download a new version of the original IITC script, there are some updated things in there)
+## Users
+
+Just want to download/install IITC? Go to http://iitc.jonatkins.com/
+
+For keeping up with the latest news, release announcements, etc, Follow IITC on G+
+https://plus.google.com/105383756361375410867/posts
+
+If you have questions, need help or advice with IITC, the Google+ community is a good place to start.
+https://plus.google.com/communities/105647403088015055797
+
+Want to report a bug? Post it to the issues page
+https://github.com/jonatkins/ingress-intel-total-conversion/issues
+
+## Developers
+
+This Github page is for those interested in developing IITC further.
+
+### Quickstart
+
+To build the browser scripts from source you will need Python (either a late version 2.x, or 3.0+). It should
+build correctly on Linux and Windows (and, probably, Macs, FreeBSD, etc)
+
+Fork this project, clone to your local machine.
+
+Run the ```build.py local``` script to build the code.
+
+If all goes well, output of the build will end up in ```build/local``` subfolder.
+
+You can create a custom build settings file, ```localbuildsettings.py``` - look in the supplied
+```buildsettings.py``` for details.
+
+#### Mobile
+
+To build the mobile app, along with python, you will need
+
+- The Java JDK (development kit - the runtime JRE is not enough)
+- The Android SDK
+
+Run ``build.py mobile``` to build IITC Mobile in debug mode.
+
+Note that part of the build.py process includes copying the IITC script files into the ```mobile/res``` subfolder.
+If this isn't done (e.g. you build IITC Mobile directly from Eclipse) you will end up with a broken build.
From c2912d97679ededdc5a350269b9716b46e41c4bf Mon Sep 17 00:00:00 2001
From: Nihal Mirpuri
Date: Wed, 25 Sep 2013 02:46:03 +1000
Subject: [PATCH 12/67] Added attributions for KML files
---
ATTRIBUTION.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md
index 81723e1f..edb3f828 100644
--- a/ATTRIBUTION.md
+++ b/ATTRIBUTION.md
@@ -10,5 +10,8 @@ This project is licensed under the permissive [ISC license](http://www.isc.org/d
- [taphold.js by Rich Adams; unknown](https://github.com/richadams/jquery-taphold)
- [L.Control.Pan.js by Kartena AB; same as Leaflet](https://github.com/kartena/Leaflet.Pancontrol)
- [L.Control.Zoomslider.js by Kartena AB; same as Leaflet](https://github.com/kartena/Leaflet.zoomslider)
+- [KML.js by shramov; same as Leaflet](https://github.com/shramov/leaflet-plugins)
+- [leaflet.filelayer.js by shramov; same as Leaflet](https://github.com/shramov/leaflet-plugins)
+- [togeojson.js by shramov; same as Leaflet](https://github.com/shramov/leaflet-plugins)
- StackOverflow-CopyPasta is attributed in the source; [CC-Wiki](https://creativecommons.org/licenses/by-sa/3.0/)
- all Ingress/Niantic related stuff obviously remains non-free and is still copyrighted by Niantic/Google
From a2064cc2fde4d11df64e3582756eac120a8c85fc Mon Sep 17 00:00:00 2001
From: Jon Atkins
Date: Wed, 16 Oct 2013 04:46:51 +0100
Subject: [PATCH 13/67] website update for 0.14.3
---
website/page/home.php | 48 +++++--------------------------------------
website/page/news.php | 8 ++++++++
2 files changed, 13 insertions(+), 43 deletions(-)
diff --git a/website/page/home.php b/website/page/home.php
index 768a5b5b..452161e2 100644
--- a/website/page/home.php
+++ b/website/page/home.php
@@ -13,50 +13,12 @@ offers many more features. It is available for
Latest news
-
1st October 2013
+
16th October 2013
-IITC 0.14.2 and IITC Mobile 0.7.1 have been released. This is a critical update required to work with changes made
-to the standard intel site. Additionally, a major update to the mobile app interface has been made, and a handful
-of tweaks and bugfixes to IITC and a few plugins.
+IITC 0.14.3 and IITC MObile 0.7.4 have just been released. This is a critical update required to work with the latest
+changes Niantic have made to the standard intel site. Additionally, the draw-tools plugin now snaps points to portals
+when creating lines/polygons/markers (was actually in 0.14.2 release), a bugfix relating to IITC not realising who
+'you' are, causing some highlighters to break, and a handful of other tweaks/bugfixes.
-
-The standard intel site now includes an 'alerts' chat tab. This will be coming to IITC in the future, but it's
-better to get this working version released without it than hold things up just for that.
-
-
-
22nd September 2013
-
-Update: IITC Mobile 0.6.5 replaces 0.6.4. This fixes a crash on entering plugin preferences on some tablets.
-
-
-IITC 0.14.1 and IITC Mobile 0.6.4 have been released. Changes in this version include:
-
-
Better performance when a very large number of portals are within view (country/continent level)
-
Add layer chooser options to hide resistance/enlightened portals/links/fields
-
Chat tab now remembers which was active when reloading IITC
-
Fix some shorter links not showing on the map
-
Add details of hack information (number/cooldown time, taking account of mods) and mitigation (from shields and links)
-to the portal information panel
-
Mobile
-
-
increase the size of various links on the info page to make them easier to tap
-
move the highlight selection dropdown to the native android app bar at the top
-
-
-And plugins:
-
-
Major update to bookmarks-by-zaso, including sync support
-
New features added to the resonators plugin
-
max-links plugin - start of rename to 'tidy links' - as this is a better description of what it does
-
show-linked-portals - indicate which are incoming/outgoing links in the tooltip
-
New Plugins
-
-
show-link-direction, to indicate visually which portal a link was created from
-
highlighter for portal mitigation - to show strength of defence from shields and links at a glance
-
-
-And, as always, numerous other bug fixes, tweaks and improvements.
-
+IITC 0.14.3 and IITC MObile 0.7.4 have just been released. This is a critical update required to work with the latest
+changes Niantic have made to the standard intel site. Additionally, the draw-tools plugin now snaps points to portals
+when creating lines/polygons/markers (was actually in 0.14.2 release), a bugfix relating to IITC not realising who
+'you' are, causing some highlighters to break, and a handful of other tweaks/bugfixes.
+
+
1st October 2013
IITC 0.14.2 and IITC Mobile 0.7.1 have been released. This is a critical update required to work with changes made
From 7681bd10cd149ddf0c94009e7d65ead4c043274c Mon Sep 17 00:00:00 2001
From: Jon Atkins
Date: Wed, 16 Oct 2013 04:47:13 +0100
Subject: [PATCH 14/67] bump version, ready for future release
---
main.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/main.js b/main.js
index d231360a..72f96f7e 100644
--- a/main.js
+++ b/main.js
@@ -1,7 +1,7 @@
// ==UserScript==
// @id ingress-intel-total-conversion@jonatkins
// @name IITC: Ingress intel map total conversion
-// @version 0.14.3.@@DATETIMEVERSION@@
+// @version 0.14.4.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
From 34410bd047ac846925f7724ba3c5b661f184395a Mon Sep 17 00:00:00 2001
From: Jon Atkins
Date: Wed, 16 Oct 2013 07:11:01 +0100
Subject: [PATCH 15/67] map data request handling - tweaks to the timers, and
immediate 'finished' processing when all data came from the cache
---
code/map_data_request.js | 37 +++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)
diff --git a/code/map_data_request.js b/code/map_data_request.js
index dc63370e..4355ef9e 100644
--- a/code/map_data_request.js
+++ b/code/map_data_request.js
@@ -37,16 +37,20 @@ window.MapDataRequest = function() {
// processing cache, etc) and actually sending the first network requests
this.DOWNLOAD_DELAY = 3; //delay after preparing the data download before tile requests are sent
- // a short delay between one request finishing and the queue being run for the next request
+
+ // a short delay between one request finishing and the queue being run for the next request.
+ // this gives a chance of other requests finishing, allowing better grouping of retries in new requests
this.RUN_QUEUE_DELAY = 0.5;
// delay before re-queueing tiles
- this.TILE_TIMEOUT_REQUEUE_DELAY = 0.5; // short delay before retrying a 'error==TIMEOUT' tile - as this is very common
- this.BAD_REQUEST_REQUEUE_DELAY = 4; // longer delay before retrying a completely failed request - as in this case the servers are struggling
+ this.TILE_TIMEOUT_REQUEUE_DELAY = 0.2; // short delay before retrying a 'error==TIMEOUT' tile. a common 'error', and the stock site has no delay in this case
+ this.BAD_REQUEST_REQUEUE_DELAY = 5; // longer delay before retrying a completely failed request - as in this case the servers are struggling
+
+ // a delay before processing the queue after requeueing tiles. this gives a chance for other requests to finish
+ // or other requeue actions to happen before the queue is processed, allowing better grouping of requests
+ // however, the queue may be processed sooner if a previous timeout was set
+ this.REQUEUE_DELAY = 1;
- // additionally, a delay before processing the queue after requeueing tiles
- // (this way, if multiple requeue delays finish within a short time of each other, they're all processed in one queue run)
- this.RERUN_QUEUE_DELAY = 1;
this.REFRESH_CLOSE = 120; // refresh time to use for close views z>12 when not idle and not moving
this.REFRESH_FAR = 600; // refresh time for far views z <= 12
@@ -90,8 +94,8 @@ window.MapDataRequest.prototype.mapMoveEnd = function() {
if (this.fetchedDataParams) {
// we have fetched (or are fetching) data...
- if (this.fetchedDataParams.zoom == zoom && this.fetchedDataParams.bounds.contains(bounds)) {
- // ... and the data zoom levels are the same, and the current bounds is inside the fetched bounds
+ if (this.fetchedDataParams.mapZoom == map.getZoom() && this.fetchedDataParams.bounds.contains(bounds)) {
+ // ... and the zoom level is the same and the current bounds is inside the fetched bounds
// so, no need to fetch data. if there's time left, restore the original timeout
var remainingTime = (this.timerExpectedTimeoutTime - new Date().getTime())/1000;
@@ -201,10 +205,10 @@ window.MapDataRequest.prototype.refresh = function() {
//setTimeout (function(){ map.removeLayer(debugrect2); }, 10*1000);
// store the parameters used for fetching the data. used to prevent unneeded refreshes after move/zoom
- this.fetchedDataParams = { bounds: dataBounds, zoom: zoom, minPortalLevel: minPortalLevel };
+ this.fetchedDataParams = { bounds: dataBounds, mapZoom: map.getZoom(), minPortalLevel: minPortalLevel };
- window.runHooks ('mapDataRefreshStart', {bounds: bounds, zoom: zoom, tileBounds: dataBounds});
+ window.runHooks ('mapDataRefreshStart', {bounds: bounds, zoom: zoom, minPortalLevel: minPortalLevel, tileBounds: dataBounds});
this.render.startRenderPass();
this.render.clearPortalsBelowLevel(minPortalLevel);
@@ -290,8 +294,13 @@ console.log('stale tile '+tile_id+': newest mtime '+lastTimestamp+(lastTimestamp
console.log ('done request preperation (cleared out-of-bounds and invalid for zoom, and rendered cached data)');
- // don't start processing the download queue immediately - start it after a short delay
- this.delayProcessRequestQueue (this.DOWNLOAD_DELAY,true);
+ if (Object.keys(this.tileBounds).length > 0) {
+ // queued requests - don't start processing the download queue immediately - start it after a short delay
+ this.delayProcessRequestQueue (this.DOWNLOAD_DELAY,true);
+ } else {
+ // all data was from the cache, nothing queued - run the queue 'immediately' so it handles the end request processing
+ this.delayProcessRequestQueue (0,true);
+ }
}
@@ -581,7 +590,7 @@ console.log('processed delta mapData request:'+id+': '+oldEntityCount+' original
delete savedContext.requestedTiles[id];
savedContext.requeueTile(id, false);
}
- savedContext.delayProcessRequestQueue(this.RERUN_QUEUE_DELAY);
+ savedContext.delayProcessRequestQueue(this.REQUEUE_DELAY);
}, this.TILE_TIMEOUT_REQUEUE_DELAY*1000);
}
@@ -592,7 +601,7 @@ console.log('processed delta mapData request:'+id+': '+oldEntityCount+' original
delete savedContext.requestedTiles[id];
savedContext.requeueTile(id, true);
}
- savedContext.delayProcessRequestQueue(this.RERUN_QUEUE_DELAY);
+ savedContext.delayProcessRequestQueue(this.REQUEUE_DELAY);
}, this.BAD_REQUEST_REQUEUE_DELAY*1000);
}
From 4883eb5a4e0c444c573a7a105df60662a27c22a0 Mon Sep 17 00:00:00 2001
From: Jon Atkins
Date: Wed, 16 Oct 2013 07:11:50 +0100
Subject: [PATCH 16/67] plugins: show-more/less portals updated to take account
of the new map data tile sizes - show-more-portals no longer causes
unfriendly request tile sizes. unclaimed are now visible one level further
out, but l1+ is no longer available one level further in (i.e. it jumps
directly from l2+ to all portals) - slow-less-portals-when-zoomed-out - major
reductions in portal visibility levels - works around the daft tile size/zoom
level combinations used in the current stock intel site
---
plugins/show-less-portals-zoomed-out.user.js | 30 +++++++-------
plugins/show-more-portals.user.js | 42 +++++++-------------
2 files changed, 28 insertions(+), 44 deletions(-)
diff --git a/plugins/show-less-portals-zoomed-out.user.js b/plugins/show-less-portals-zoomed-out.user.js
index c61f25bd..c701f7a7 100644
--- a/plugins/show-less-portals-zoomed-out.user.js
+++ b/plugins/show-less-portals-zoomed-out.user.js
@@ -2,11 +2,11 @@
// @id iitc-plugin-show-less-portals@jonatkins
// @name IITC plugin: Show less portals when zoomed out
// @category Tweaks
-// @version 0.1.3.@@DATETIMEVERSION@@
+// @version 0.1.4.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
-// @description [@@BUILDNAME@@-@@BUILDDATE@@] Decrease the portal detail level used when zoomed out. This can speed up map loading, decrease the amount of data used, and result in faster display. Only applies when zoomed out to show no closer than L3 portals. May stop display of the smaller links/fields.
+// @description [@@BUILDNAME@@-@@BUILDDATE@@] Decrease the portal detail level used when zoomed out. This can speed up map loading, decrease the amount of data used, and solve excessive request issues. Only applies when zoomed out to show no closer than L3 portals. May stop display of the smaller links/fields.
// @include https://www.ingress.com/intel*
// @include http://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
@@ -32,23 +32,21 @@ window.plugin.showLessPortals.setup = function() {
window.getPortalDataZoom = function() {
var mapZoom = map.getZoom();
- // this plugin only cares about close in zoom levels (zoom 13 and higher) - run the original
- // code when this isn't the case. (this way, multiple zoom-modifying plugins can exist at once - in theory)
- if (mapZoom >= 13) {
- return origGetPortalDataZoom();
+ // the latest intel site update, as of 2013-10-16, requests a silly number of map tiles at the larger zoom levels
+ // IITC matches the behaviour by default, but it makes sense to reduce the detail level sooner
+
+ // at the largest scale zooms - move back two levels
+ if (mapZoom <= 7) {
+ return Math.max(mapZoom-2,0);
}
- // make sure we're dealing with an integer here
- // (mobile: a float somehow gets through in some cases!)
- var z = parseInt(mapZoom);
+ // intermediate zoom levels - move back one
+ if (mapZoom <= 11) {
+ return Math.max(mapZoom-1,0);
+ }
- // reduce the portal zoom level by one
- z -= 1;
-
- // ensure we're not too far out
- if (z < 0) z=0;
-
- return z;
+ // otherwise revert to default behaviour
+ return origGetPortalDataZoom();
}
diff --git a/plugins/show-more-portals.user.js b/plugins/show-more-portals.user.js
index 0721cbbd..e119affb 100644
--- a/plugins/show-more-portals.user.js
+++ b/plugins/show-more-portals.user.js
@@ -2,11 +2,11 @@
// @id iitc-plugin-show-more-portals@jonatkins
// @name IITC plugin: Show more portals
// @category Tweaks
-// @version 0.1.4.@@DATETIMEVERSION@@
+// @version 0.1.5.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
-// @description [@@BUILDNAME@@-@@BUILDDATE@@] Boost the detail level of portals shown on the map by one zoom level when zoomed in close (L2+ portals or closer)
+// @description [@@BUILDNAME@@-@@BUILDDATE@@] Boost the detail level of portals shown so that unclaimed portals are visible when normally L1+ portals would be shown, and L2+ are visible when normally L3+ are shown
// @include https://www.ingress.com/intel*
// @include http://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
@@ -32,36 +32,22 @@ window.plugin.showMorePortals.setup = function() {
window.getPortalDataZoom = function() {
var mapZoom = map.getZoom();
- // this plugin only cares about close in zoom levels (zoom 12 and higher) - run the original
- // code when this isn't the case. (this way, multiple zoom-modifying plugins can exist at once - in theory)
- if (mapZoom < 12) {
- return origGetPortalDataZoom();
+ // as of 2013-10-16...
+
+ // the stock site uses the same tile size for both L1+ portals and all portals
+ // therefore, changing the L1+ zoom levels into all portals zoom level is not unfriendly to the servers
+ // (in some ways it's nicer, as IITC caches better)
+ if (mapZoom >= 15) {
+ return 17;
}
- // make sure we're dealing with an integer here
- // (mobile: a float somehow gets through in some cases!)
- var z = parseInt(mapZoom);
-
- // boost data zoom level by one
- z += 1;
-
- // not recommended on anything other than the very smallest of screens
-// // show unclaimed portals at an additional zoom level further than by default
-// if (mapZoom >= 15) z += 1;
-
-
- // limiting the mazimum zoom level for data retrieval reduces the number of requests at high zoom levels
- // (as all portal data is retrieved at z=17, why retrieve multiple z=18 tiles when fewer z=17 would do?)
- // very effective along with the new cache code
- if (z > 17) z=17;
-
- // if the data zoom is above the map zoom we can step back if the detail level is the same
- // with the new cache code this works rather well
- while (z > mapZoom && getMinPortalLevelForZoom(z) == getMinPortalLevelForZoom(z-1)) {
- z = z-1;
+ // and, the same scale for L2+ and L3+ portals. again, forcing the level down isn't unfriendly to the servers
+ // (ditto on the cacheing)
+ if (mapZoom >= 12) {
+ return 13;
}
- return z;
+ return origGetPortalDataZoom();
}
From fa969561e28a5e7d7ae67c3e559212293002368f Mon Sep 17 00:00:00 2001
From: fkloft
Date: Wed, 16 Oct 2013 15:42:16 +0200
Subject: [PATCH 17/67] Hide tab(s) if only one tab visible
---
.../com/cradle/iitc_mobile/share/ShareActivity.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java b/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java
index aeec04cc..9e23bb50 100644
--- a/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java
+++ b/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java
@@ -103,7 +103,6 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
mFragmentAdapter = new IntentFragmentAdapter(getSupportFragmentManager());
final ActionBar actionBar = getActionBar();
- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayHomeAsUpEnabled(true);
Intent intent = getIntent();
@@ -126,7 +125,8 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
- actionBar.setSelectedNavigationItem(position);
+ if (actionBar.getNavigationMode() != ActionBar.NAVIGATION_MODE_STANDARD)
+ actionBar.setSelectedNavigationItem(position);
setSelected(position);
}
});
@@ -141,11 +141,15 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
.setTabListener(this));
}
+ if (mFragmentAdapter.getCount() > 1)
+ actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+
mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
int selected = mSharedPrefs.getInt("pref_share_selected_tab", 0);
if (selected < mFragmentAdapter.getCount()) {
mViewPager.setCurrentItem(selected);
- actionBar.setSelectedNavigationItem(selected);
+ if (actionBar.getNavigationMode() != ActionBar.NAVIGATION_MODE_STANDARD)
+ actionBar.setSelectedNavigationItem(selected);
}
}
From 767275fdf5c364d20030ee6d9ba52e844f9acba4 Mon Sep 17 00:00:00 2001
From: fkloft
Date: Wed, 16 Oct 2013 17:24:20 +0200
Subject: [PATCH 18/67] Show detailed portal level in tooltip
---
code/portal_detail_display.js | 13 ++++++++++++-
style.css | 1 +
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/code/portal_detail_display.js b/code/portal_detail_display.js
index 5004ce1c..b2771d3f 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"
+ '
- IITC Mobile is an optimized mobile browser for the
+ IITCm Test is an optimized mobile browser for the
Ingress Intel Total Conversion (IITC) userscript by breunigs.
After Niantic asked the main developer to shut down his github project, development
is continued on a fork of jonatkins.
diff --git a/mobile/res/xml/preferences.xml b/mobile/res/xml/preferences.xml
index 11729aef..41baa5c0 100644
--- a/mobile/res/xml/preferences.xml
+++ b/mobile/res/xml/preferences.xml
@@ -48,7 +48,7 @@
android:title="@string/pref_plugins"
android:persistent="false">
Date: Tue, 22 Oct 2013 13:09:55 +0200
Subject: [PATCH 46/67] - removed test stuff from build.xml - added new
build-test.xml for test builds
---
mobile/build-test.xml | 205 ++++++++++++++++++++++++++++++++++++++++++
mobile/build.xml | 112 -----------------------
2 files changed, 205 insertions(+), 112 deletions(-)
create mode 100644 mobile/build-test.xml
diff --git a/mobile/build-test.xml b/mobile/build-test.xml
new file mode 100644
index 00000000..6584fcbd
--- /dev/null
+++ b/mobile/build-test.xml
@@ -0,0 +1,205 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ git.commits: ${git.commits}
+
+
+
+
+
+ git.version: ${git.version}
+
+
+
+ Creating backup of AndroidManifest.xml
+
+
+
+
+
+
+
+
+ Restoring backup of AndroidManifest.xml
+
+
+
+
+ Creating backup of strings.xml and preferences.xml
+
+
+
+
+
+
+
+ Restoring backup of strings.xml and preferences.xml
+
+
+
+
+
+
+
+
diff --git a/mobile/build.xml b/mobile/build.xml
index 6584fcbd..b8f279b5 100644
--- a/mobile/build.xml
+++ b/mobile/build.xml
@@ -87,118 +87,6 @@
in order to avoid having your file be overridden by tools such as "android update project"
-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- git.commits: ${git.commits}
-
-
-
-
-
- git.version: ${git.version}
-
-
-
- Creating backup of AndroidManifest.xml
-
-
-
-
-
-
-
-
- Restoring backup of AndroidManifest.xml
-
-
-
-
- Creating backup of strings.xml and preferences.xml
-
-
-
-
-
-
-
- Restoring backup of strings.xml and preferences.xml
-
-
-
-
From 6f159f6c71302aedbfe2eba2b565f7650e1dba5d Mon Sep 17 00:00:00 2001
From: Philipp Schaefer
Date: Tue, 22 Oct 2013 13:18:41 +0200
Subject: [PATCH 47/67] reverted wrong commited files
---
mobile/res/values/strings.xml | 8 ++++----
mobile/res/xml/preferences.xml | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/mobile/res/values/strings.xml b/mobile/res/values/strings.xml
index f7b2feaf..b7fc6d6c 100644
--- a/mobile/res/values/strings.xml
+++ b/mobile/res/values/strings.xml
@@ -1,8 +1,8 @@
- IITCm Test
- IITCm Test Settings
+ IITC Mobile
+ IITC Mobile SettingsIITC PluginsShare using…Copy to clipboard
@@ -20,13 +20,13 @@
IITC VersionAbout
- About IITCm Test
+ About IITC MobileIngress Intel Total Conversion Mobile
- IITCm Test is an optimized mobile browser for the
+ IITC Mobile is an optimized mobile browser for the
Ingress Intel Total Conversion (IITC) userscript by breunigs.
After Niantic asked the main developer to shut down his github project, development
is continued on a fork of jonatkins.
diff --git a/mobile/res/xml/preferences.xml b/mobile/res/xml/preferences.xml
index 41baa5c0..11729aef 100644
--- a/mobile/res/xml/preferences.xml
+++ b/mobile/res/xml/preferences.xml
@@ -48,7 +48,7 @@
android:title="@string/pref_plugins"
android:persistent="false">
Date: Tue, 22 Oct 2013 19:16:41 +0200
Subject: [PATCH 48/67] added fkloft and hastarin to contribs.md. both helped
me out on mobile side.
---
CONTRIBS.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CONTRIBS.md b/CONTRIBS.md
index 0cfccf65..5ab69b23 100644
--- a/CONTRIBS.md
+++ b/CONTRIBS.md
@@ -8,7 +8,9 @@ So far, these people have contributed:
[ccjon](https://github.com/ccjon),
[cmrn](https://github.com/cmrn),
[epf](https://github.com/epf),
+[fkloft](https://github.com/fkloft),
[Fragger](https://github.com/Fragger),
+[hastarin](https://github.com/hastarin),
[integ3r](https://github.com/integ3r),
[j16sdiz](https://github.com/j16sdiz),
[JasonMillward](https://github.com/JasonMillward),
From 3d7192ecd649797a78f34eb7b567c0b7e2d24777 Mon Sep 17 00:00:00 2001
From: Philipp Schaefer
Date: Tue, 22 Oct 2013 20:05:58 +0200
Subject: [PATCH 49/67] reformat code
---
build.py | 2 +-
.../iitc_mobile/IITC_DeviceAccountLogin.java | 6 ++-
.../cradle/iitc_mobile/IITC_MapSettings.java | 23 ++++++---
.../com/cradle/iitc_mobile/IITC_Mobile.java | 29 +++++++----
.../iitc_mobile/IITC_NavigationHelper.java | 49 ++++++++++++-------
.../IITC_PluginPreferenceActivity.java | 21 +++++---
.../com/cradle/iitc_mobile/IITC_WebView.java | 15 +++---
.../iitc_mobile/IITC_WebViewClient.java | 14 ++++--
.../iitc_mobile/fragments/MainSettings.java | 3 +-
.../iitc_mobile/share/IntentFragment.java | 3 +-
.../iitc_mobile/share/IntentListView.java | 6 ++-
.../iitc_mobile/share/ShareActivity.java | 15 ++++--
12 files changed, 120 insertions(+), 66 deletions(-)
diff --git a/build.py b/build.py
index 96212c5c..250e502f 100755
--- a/build.py
+++ b/build.py
@@ -263,7 +263,7 @@ if buildMobile:
if buildMobile != 'copyonly':
# now launch 'ant' to build the mobile project
- retcode = os.system("ant %s -buildfile mobile/build.xml %s" % (antOptions, buildMobile))
+ retcode = os.system("ant clean %s -buildfile mobile/build.xml %s" % (antOptions, buildMobile))
if retcode != 0:
print ("Error: mobile app failed to build. ant returned %d" % retcode)
diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_DeviceAccountLogin.java b/mobile/src/com/cradle/iitc_mobile/IITC_DeviceAccountLogin.java
index 11cf1518..fb8e1890 100644
--- a/mobile/src/com/cradle/iitc_mobile/IITC_DeviceAccountLogin.java
+++ b/mobile/src/com/cradle/iitc_mobile/IITC_DeviceAccountLogin.java
@@ -128,10 +128,12 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback {
*/
public void onActivityResult(int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK)
- // authentication activity succeeded, request token again
+ // authentication activity succeeded, request token again
+ {
startAuthentication();
- else
+ } else {
onLoginFailed();
+ }
}
/**
diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_MapSettings.java b/mobile/src/com/cradle/iitc_mobile/IITC_MapSettings.java
index 245aefd2..c683dce9 100644
--- a/mobile/src/com/cradle/iitc_mobile/IITC_MapSettings.java
+++ b/mobile/src/com/cradle/iitc_mobile/IITC_MapSettings.java
@@ -47,12 +47,13 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList
@Override
public int compare(String lhs, String rhs) {
// Move "No Highlights" on top. Sort the rest alphabetically
- if (lhs.equals("No Highlights"))
+ if (lhs.equals("No Highlights")) {
return -1000;
- else if (rhs.equals("No Highlights"))
+ } else if (rhs.equals("No Highlights")) {
return 1000;
- else
+ } else {
return lhs.compareTo(rhs);
+ }
}
}
@@ -77,8 +78,9 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList
Layer item = getItem(position);
View view = (TextView) super.getView(position, convertView, parent);
- if (view instanceof CheckedTextView)
+ if (view instanceof CheckedTextView) {
((CheckedTextView) view).setChecked(item.active);
+ }
return view;
}
}
@@ -128,9 +130,10 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList
}
private void setLayer(Layer layer) {
- if (!mLoading)
+ if (!mLoading) {
mIitc.getWebView().loadUrl(
"javascript: window.layerChooser.showLayer(" + layer.id + "," + layer.active + ");");
+ }
}
public void addPortalHighlighter(String name) {
@@ -208,8 +211,9 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList
mActiveHighlighter = name;
int position = mHighlighters.getPosition(mActiveHighlighter);
- if (position >= 0 && position < mHighlighters.getCount())
+ if (position >= 0 && position < mHighlighters.getCount()) {
mSpinnerHighlighter.setSelection(position);
+ }
mIitc.getNavigationHelper().setHighlighter(name);
}
@@ -245,8 +249,10 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList
layer.active = layerObj.getBoolean("active");
if (layer.active)
- // getCount() will be the index of the layer we are about to add
+ // getCount() will be the index of the layer we are about to add
+ {
mActiveLayer = mBaseLayers.getCount();
+ }
mBaseLayers.add(layer);
} catch (JSONException e) {
@@ -276,7 +282,8 @@ public class IITC_MapSettings implements OnItemSelectedListener, OnItemClickList
}
public void updateLayers() {
- if (!mLoading)
+ if (!mLoading) {
mIitc.getWebView().loadUrl("javascript: window.layerChooser.getLayers()");
+ }
}
}
diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java
index 06122fbd..043be0ec 100644
--- a/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java
+++ b/mobile/src/com/cradle/iitc_mobile/IITC_Mobile.java
@@ -133,8 +133,10 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis
|| key.equals("pref_share_selected_tab")
|| key.equals("pref_messages")
|| key.equals("pref_external_storage"))
- // no reload needed
+ // no reload needed
+ {
return;
+ }
mReloadNeeded = true;
}
@@ -233,8 +235,9 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis
// parts[0] may contain an 'uncertainty' parameter, delimited by a semicolon
String[] pos = parts[0].split(";", 2)[0].split(",", 2);
- if (pos.length != 2)
+ if (pos.length != 2) {
throw new URISyntaxException(uri.toString(), "URI does not contain a valid position");
+ }
try {
lat = Double.valueOf(pos[0]);
@@ -262,8 +265,9 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis
}
String url = "http://www.ingress.com/intel?ll=" + lat + "," + lon;
- if (z != null)
+ if (z != null) {
url += "&z=" + z;
+ }
this.loadUrl(url);
}
@@ -298,8 +302,9 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis
Log.d("iitcm", "stopping iitcm");
mIitcWebView.loadUrl("javascript: window.idleSet();");
- if (mIsLocEnabled)
+ if (mIsLocEnabled) {
mLocMngr.removeUpdates(this);
+ }
super.onStop();
}
@@ -383,10 +388,11 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis
// ensure no double adds
if (pane == mCurrentPane) return;
- if (mBackStackPush)
+ if (mBackStackPush) {
mBackStack.push(mCurrentPane);
- else
+ } else {
mBackStackPush = true;
+ }
mCurrentPane = pane;
mNavigationHelper.switchTo(pane);
@@ -433,8 +439,9 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- if (mNavigationHelper.onOptionsItemSelected(item))
+ if (mNavigationHelper.onOptionsItemSelected(item)) {
return true;
+ }
// Handle item selection
final int itemId = item.getItemId();
@@ -462,10 +469,11 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis
"window.map.locate({setView : true, maxZoom: 15});");
// if gps location is displayed we can use a better location without any costs
} else {
- if (mLastLocation != null)
+ if (mLastLocation != null) {
mIitcWebView.loadUrl("javascript: window.map.setView(new L.LatLng(" +
mLastLocation.getLatitude() + "," +
mLastLocation.getLongitude() + "), 15);");
+ }
}
return true;
case R.id.action_settings: // start settings activity
@@ -511,10 +519,11 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis
// vp=f enables mDesktopMode mode...vp=m is the defaul mobile view
private String addUrlParam(String url) {
- if (mDesktopMode)
+ if (mDesktopMode) {
return (url + "?vp=f");
- else
+ } else {
return (url + "?vp=m");
+ }
}
// inject the iitc-script and load the intel url
diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_NavigationHelper.java b/mobile/src/com/cradle/iitc_mobile/IITC_NavigationHelper.java
index 1c0af426..6e78db67 100644
--- a/mobile/src/com/cradle/iitc_mobile/IITC_NavigationHelper.java
+++ b/mobile/src/com/cradle/iitc_mobile/IITC_NavigationHelper.java
@@ -46,18 +46,20 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
add(Pane.PUBLIC);
add(Pane.FACTION);
- if (mPrefs.getBoolean("pref_advanced_menu", false))
+ if (mPrefs.getBoolean("pref_advanced_menu", false)) {
add(Pane.DEBUG);
+ }
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView view = (TextView) super.getView(position, convertView, parent);
Pane item = getItem(position);
- if (item == Pane.MAP)
+ if (item == Pane.MAP) {
view.setText("Map");
- else
+ } else {
view.setText(getPaneTitle(item));
+ }
int icon = 0;
switch (item) {
@@ -84,8 +86,9 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
break;
}
- if (icon != 0)
+ if (icon != 0) {
view.setCompoundDrawablesWithIntrinsicBounds(icon, 0, 0, 0);
+ }
return view;
}
@@ -140,8 +143,9 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
}
private void showNotice(final int which) {
- if ((mPrefs.getInt("pref_messages", 0) & which) != 0)
+ if ((mPrefs.getInt("pref_messages", 0) & which) != 0) {
return;
+ }
String text;
switch (which) {
@@ -186,8 +190,9 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
private void updateActionBar() {
int position = mNavigationAdapter.getPosition(mPane);
- if (position >= 0 && position < mNavigationAdapter.getCount())
+ if (position >= 0 && position < mNavigationAdapter.getCount()) {
mDrawerLeft.setItemChecked(position, true);
+ }
if (mDesktopMode) {
mActionBar.setDisplayHomeAsUpEnabled(false); // Hide "up" indicator
@@ -207,28 +212,32 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
mActionBar.setHomeButtonEnabled(true);// Make icon clickable
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
- if (mPane == Pane.MAP || mDrawerLayout.isDrawerOpen(mDrawerLeft))
+ if (mPane == Pane.MAP || mDrawerLayout.isDrawerOpen(mDrawerLeft)) {
setDrawerIndicatorEnabled(true);
- else
+ } else {
setDrawerIndicatorEnabled(false);
+ }
}
- if (mDrawerLayout.isDrawerOpen(mDrawerLeft))
+ if (mDrawerLayout.isDrawerOpen(mDrawerLeft)) {
mActionBar.setTitle(mIitc.getString(R.string.app_name));
- else
+ } else {
mActionBar.setTitle(getPaneTitle(mPane));
+ }
}
boolean mapVisible = mDesktopMode || mPane == Pane.MAP;
- if ("No Highlights".equals(mHighlighter) || isDrawerOpened() || mIsLoading || !mapVisible)
+ if ("No Highlights".equals(mHighlighter) || isDrawerOpened() || mIsLoading || !mapVisible) {
mActionBar.setSubtitle(null);
- else
+ } else {
mActionBar.setSubtitle(mHighlighter);
+ }
- if (mFullscreen && mHideInFullscreen)
+ if (mFullscreen && mHideInFullscreen) {
mActionBar.hide();
- else
+ } else {
mActionBar.show();
+ }
}
public void closeDrawers() {
@@ -289,16 +298,18 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
Pane item = mNavigationAdapter.getItem(position);
mIitc.switchToPane(item);
- if (item == Pane.INFO)
+ if (item == Pane.INFO) {
showNotice(NOTICE_INFO);
+ }
mDrawerLayout.closeDrawer(mDrawerLeft);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == android.R.id.home)
+ if (item.getItemId() == android.R.id.home) {
mDrawerLayout.closeDrawer(mDrawerRight);
+ }
return super.onOptionsItemSelected(item);
}
@@ -315,8 +326,9 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
}
public void openRightDrawer() {
- if (mDrawerLayout.getDrawerLockMode(mDrawerRight) == DrawerLayout.LOCK_MODE_UNLOCKED)
+ if (mDrawerLayout.getDrawerLockMode(mDrawerRight) == DrawerLayout.LOCK_MODE_UNLOCKED) {
mDrawerLayout.openDrawer(mDrawerRight);
+ }
}
public void reset() {
@@ -326,8 +338,9 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
public void setDebugMode(boolean enabled) {
mNavigationAdapter.remove(Pane.DEBUG); // avoid duplicates
- if (enabled)
+ if (enabled) {
mNavigationAdapter.add(Pane.DEBUG);
+ }
}
public void setFullscreen(boolean fullscreen) {
diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java b/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java
index b8909fca..02ac8ddd 100644
--- a/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java
+++ b/mobile/src/com/cradle/iitc_mobile/IITC_PluginPreferenceActivity.java
@@ -62,8 +62,10 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
- if (onIsMultiPane()) getIntent()
- .putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, PluginsFragment.class.getName());
+ if (onIsMultiPane()) {
+ getIntent()
+ .putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, PluginsFragment.class.getName());
+ }
super.onCreate(savedInstanceState);
}
@@ -162,8 +164,9 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity {
// TODO Auto-generated catch block
e2.printStackTrace();
}
- if (s != null)
+ if (s != null) {
src = s.hasNext() ? s.next() : "";
+ }
// now we have all stuff together and can build the pref screen
addPluginPreference(src, anAsset_array, false);
}
@@ -179,8 +182,9 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity {
e.printStackTrace();
Log.d("iitcm", "failed to parse file " + file);
}
- if (s != null)
+ if (s != null) {
src = s.hasNext() ? s.next() : "";
+ }
// now we have all stuff together and can build the pref screen
addPluginPreference(src, file.toString(), true);
@@ -202,12 +206,15 @@ public class IITC_PluginPreferenceActivity extends PreferenceActivity {
String plugin_cat = "Misc";
for (int j = 0; j < attributes.length; j++) {
// search for name and use the value
- if (attributes[j].equals("@name"))
+ if (attributes[j].equals("@name")) {
plugin_name = attributes[j + 1];
- if (attributes[j].equals("@description"))
+ }
+ if (attributes[j].equals("@description")) {
plugin_desc = attributes[j + 1];
- if (attributes[j].equals("@category"))
+ }
+ if (attributes[j].equals("@category")) {
plugin_cat = attributes[j + 1];
+ }
}
// remove IITC plugin prefix from plugin_name
diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java
index 3a9f29d9..f57069c7 100644
--- a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java
+++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java
@@ -33,7 +33,6 @@ public class IITC_WebView extends WebView {
" Gecko/20130810 Firefox/17.0 Iceweasel/17.0.8";
-
// init web view
private void iitc_init(Context c) {
if (isInEditMode()) return;
@@ -136,10 +135,11 @@ public class IITC_WebView extends WebView {
// force https if enabled in settings
SharedPreferences sharedPref = PreferenceManager
.getDefaultSharedPreferences(getContext());
- if (sharedPref.getBoolean("pref_force_https", true))
+ if (sharedPref.getBoolean("pref_force_https", true)) {
url = url.replace("http://", "https://");
- else
+ } else {
url = url.replace("https://", "http://");
+ }
// disable splash screen if a http error code is responded
new CheckHttpResponse(mJsInterface, mContext).execute(url);
@@ -157,7 +157,7 @@ public class IITC_WebView extends WebView {
}
public void updateCaching(boolean login) {
- switch(Integer.parseInt(mSharedPrefs.getString("pref_caching", "1"))) {
+ switch (Integer.parseInt(mSharedPrefs.getString("pref_caching", "1"))) {
case 0:
mSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
break;
@@ -173,8 +173,11 @@ public class IITC_WebView extends WebView {
Log.d("iitcm", "not connected to wifi...load tiles from cache");
mSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
} else {
- if (login) Log.d("iitcm", "login...load tiles from network");
- else Log.d("iitcm", "connected to wifi...load tiles from network");
+ if (login) {
+ Log.d("iitcm", "login...load tiles from network");
+ } else {
+ Log.d("iitcm", "connected to wifi...load tiles from network");
+ }
mSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
}
break;
diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java
index a41835ae..cd307a35 100644
--- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java
+++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java
@@ -50,9 +50,10 @@ public class IITC_WebViewClient extends WebViewClient {
public String getIITCVersion() {
String header = "";
- if (mIitcScript != null)
+ if (mIitcScript != null) {
header = mIitcScript.substring(mIitcScript.indexOf("==UserScript=="),
mIitcScript.indexOf("==/UserScript=="));
+ }
// remove new line comments
header = header.replace("\n//", "");
// get a list of key-value
@@ -60,8 +61,9 @@ public class IITC_WebViewClient extends WebViewClient {
String iitc_version = "not found";
for (int i = 0; i < attributes.length; i++) {
// search for version and use the value
- if (attributes[i].equals("@version"))
+ if (attributes[i].equals("@version")) {
iitc_version = attributes[i + 1];
+ }
}
return iitc_version;
}
@@ -201,10 +203,11 @@ public class IITC_WebViewClient extends WebViewClient {
// load it as javascript
public boolean loadJS(String file, boolean asset, WebView view) {
String js = fileToString(file, asset);
- if (js.equals("false"))
+ if (js.equals("false")) {
return false;
- else
+ } else {
view.loadUrl("javascript:" + js);
+ }
return true;
}
@@ -235,8 +238,9 @@ public class IITC_WebViewClient extends WebViewClient {
}
}
- if (s != null)
+ if (s != null) {
src = s.hasNext() ? s.next() : "";
+ }
return src;
}
diff --git a/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java b/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java
index 49af96ea..c904385a 100644
--- a/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java
+++ b/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java
@@ -75,8 +75,9 @@ public class MainSettings extends PreferenceFragment {
// thx to http://stackoverflow.com/a/16800527/2638486 !!
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
- if (preference.getTitle().toString().equals(getString(R.string.pref_advanced_options)))
+ if (preference.getTitle().toString().equals(getString(R.string.pref_advanced_options))) {
initializeActionBar((PreferenceScreen) preference);
+ }
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
diff --git a/mobile/src/com/cradle/iitc_mobile/share/IntentFragment.java b/mobile/src/com/cradle/iitc_mobile/share/IntentFragment.java
index b1b15682..5a181099 100644
--- a/mobile/src/com/cradle/iitc_mobile/share/IntentFragment.java
+++ b/mobile/src/com/cradle/iitc_mobile/share/IntentFragment.java
@@ -33,8 +33,9 @@ public class IntentFragment extends Fragment implements OnScrollListener, OnItem
mIntents = args.getParcelableArrayList("intents");
mListView = new IntentListView(getActivity());
mListView.setIntents(mIntents);
- if (mScrollIndex != -1 && mScrollTop != -1)
+ if (mScrollIndex != -1 && mScrollTop != -1) {
mListView.setSelectionFromTop(mScrollIndex, mScrollTop);
+ }
mListView.setOnScrollListener(this);
mListView.setOnItemClickListener(this);
diff --git a/mobile/src/com/cradle/iitc_mobile/share/IntentListView.java b/mobile/src/com/cradle/iitc_mobile/share/IntentListView.java
index 9c6b16c1..621f023c 100644
--- a/mobile/src/com/cradle/iitc_mobile/share/IntentListView.java
+++ b/mobile/src/com/cradle/iitc_mobile/share/IntentListView.java
@@ -60,8 +60,9 @@ public class IntentListView extends ListView {
private static final HashSet KNOWN_COPY_HANDLERS = new HashSet();
private static void setupKnownCopyHandlers() {
- if (!KNOWN_COPY_HANDLERS.isEmpty())
+ if (!KNOWN_COPY_HANDLERS.isEmpty()) {
return;
+ }
KNOWN_COPY_HANDLERS.add(new CopyHandler(
"com.google.android.apps.docs",
@@ -141,8 +142,9 @@ public class IntentListView extends ListView {
for (ResolveInfo resolveInfo : activityList) { // search for "Copy to clipboard" handler
CopyHandler handler = new CopyHandler(resolveInfo);
- if (KNOWN_COPY_HANDLERS.contains(handler))
+ if (KNOWN_COPY_HANDLERS.contains(handler)) {
hasCopyIntent = true;
+ }
}
// use traditional loop since list may change during iteration
diff --git a/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java b/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java
index 9e23bb50..fdb1d49f 100644
--- a/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java
+++ b/mobile/src/com/cradle/iitc_mobile/share/ShareActivity.java
@@ -45,15 +45,17 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
private String getUrl() {
String url = "http://www.ingress.com/intel?ll=" + mLl + "&z=" + mZoom;
- if (mIsPortal)
+ if (mIsPortal) {
url += "&pll=" + mLl;
+ }
return url;
}
private void setSelected(int position) {
// Activity not fully loaded yet (may occur during tab creation)
- if (mSharedPrefs == null)
+ if (mSharedPrefs == null) {
return;
+ }
mSharedPrefs
.edit()
@@ -125,8 +127,9 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
- if (actionBar.getNavigationMode() != ActionBar.NAVIGATION_MODE_STANDARD)
+ if (actionBar.getNavigationMode() != ActionBar.NAVIGATION_MODE_STANDARD) {
actionBar.setSelectedNavigationItem(position);
+ }
setSelected(position);
}
});
@@ -141,15 +144,17 @@ public class ShareActivity extends FragmentActivity implements ActionBar.TabList
.setTabListener(this));
}
- if (mFragmentAdapter.getCount() > 1)
+ if (mFragmentAdapter.getCount() > 1) {
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+ }
mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
int selected = mSharedPrefs.getInt("pref_share_selected_tab", 0);
if (selected < mFragmentAdapter.getCount()) {
mViewPager.setCurrentItem(selected);
- if (actionBar.getNavigationMode() != ActionBar.NAVIGATION_MODE_STANDARD)
+ if (actionBar.getNavigationMode() != ActionBar.NAVIGATION_MODE_STANDARD) {
actionBar.setSelectedNavigationItem(selected);
+ }
}
}
From 5198858b6cc2b579f23bcab29ebacb21b77968b7 Mon Sep 17 00:00:00 2001
From: fkloft
Date: Tue, 22 Oct 2013 20:12:59 +0200
Subject: [PATCH 50/67] New about dialog for IITCm
---
mobile/res/values/strings.xml | 29 ++--
mobile/res/xml/preferences.xml | 127 ++++++++----------
.../IITC_AboutDialogPreference.java | 51 ++++---
.../iitc_mobile/IITC_WebViewClient.java | 1 -
.../iitc_mobile/fragments/MainSettings.java | 49 +++----
5 files changed, 110 insertions(+), 147 deletions(-)
diff --git a/mobile/res/values/strings.xml b/mobile/res/values/strings.xml
index b1565352..21e99338 100644
--- a/mobile/res/values/strings.xml
+++ b/mobile/res/values/strings.xml
@@ -16,29 +16,29 @@
Get LocationlocalClose
- Build Version
- IITC Version
- About
-
About IITC Mobile
-
- Ingress Intel Total Conversion Mobile
+
+ Ingress Intel Total Conversion Mobile
+ Build Version: %1$s
+ IITC Version: %2$s
+ by cradle and contributors
IITC Mobile is an optimized mobile browser for the
Ingress Intel Total Conversion (IITC) userscript by breunigs.
After Niantic asked the main developer to shut down his github project, development
- is continued on a fork of jonatkins.
- Community:
+ is continued on a fork of jonatkins.
+
Community:
• Visit the IITC website for new releases and the desktop version.
• Follow the IITC Google+ page
for release announcements.
• Join the IITC Google+ community
- - a place to ask for help and discuss with other users.
Permission to use, copy, modify, and/or distribute this software for
@@ -53,7 +53,8 @@
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- PERFORMANCE OF THIS SOFTWARE.]]>
+ PERFORMANCE OF THIS SOFTWARE.
+ ]]>
@@ -67,7 +68,7 @@
• tap and hold a portal for a second
• tap on the left half of the status bar]]>
-
+
UIMiscDeveloper options
diff --git a/mobile/res/xml/preferences.xml b/mobile/res/xml/preferences.xml
index 4e743e35..289856d5 100644
--- a/mobile/res/xml/preferences.xml
+++ b/mobile/res/xml/preferences.xml
@@ -1,136 +1,115 @@
-
+
+
+
+ android:defaultValue="false"
+ android:key="pref_user_loc"
+ android:summary="@string/pref_user_loc_sum"
+ android:title="@string/pref_user_loc"/>
+ android:title="@string/pref_user_zoom"/>
+ android:title="@string/pref_fullscreen_actionbar"/>
+ android:title="@string/pref_force_desktop"/>
-
+
+ android:title="@string/pref_select_iitc"/>
+
+ android:persistent="false"
+ android:title="@string/pref_plugins">
+ android:targetClass="com.cradle.iitc_mobile.IITC_PluginPreferenceActivity"
+ android:targetPackage="com.cradle.iitc_mobile"/>
-
-
-
+
+
+
-
-
+ android:persistent="false"
+ android:title="@string/pref_advanced_options">
+ android:title="@string/pref_enable_dev_mode"/>
-
-
+ android:title="@string/pref_advanced_menu"/>
-
+ android:title="@string/pref_disable_splash"/>
-
-
+ android:entryValues="@array/pref_caching_array_vals"
+ android:key="pref_caching"
+ android:summary="@string/pref_caching_sum"
+ android:title="@string/pref_caching"/>
-
+ android:title="@string/pref_fake_user_agent"/>
-
-
-
-
-
-
\ No newline at end of file
diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_AboutDialogPreference.java b/mobile/src/com/cradle/iitc_mobile/IITC_AboutDialogPreference.java
index 54600070..1bfd0fbe 100644
--- a/mobile/src/com/cradle/iitc_mobile/IITC_AboutDialogPreference.java
+++ b/mobile/src/com/cradle/iitc_mobile/IITC_AboutDialogPreference.java
@@ -1,44 +1,41 @@
package com.cradle.iitc_mobile;
-import android.app.AlertDialog.Builder;
import android.content.Context;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnClickListener;
-import android.preference.DialogPreference;
+import android.preference.Preference;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
import android.widget.TextView;
-public class IITC_AboutDialogPreference extends DialogPreference {
-
- private final Context mContext;
+public class IITC_AboutDialogPreference extends Preference {
+ private String mBuildVersion = "";
+ private String mIitcVersion = "";
public IITC_AboutDialogPreference(Context context, AttributeSet attrs) {
super(context, attrs);
- this.mContext = context;
}
- /*
- * start an about-dialog...I found no better way for clickable
- * links in a TextView then using Html.fromHtml...Linkify is just broken and
- * does not understand html href tags...so let's tag the @string/about_msg
- * with CDATA and use Html.fromHtml(...) for clickable hrefs with tags.
- */
@Override
- protected void onPrepareDialogBuilder(Builder builder) {
- final TextView message = new TextView(mContext);
- String about_msg = mContext.getText(R.string.pref_about_msg).toString();
- message.setText(Html.fromHtml(about_msg));
- message.setMovementMethod(LinkMovementMethod.getInstance());
- builder.setView(message).setTitle(R.string.about)
- .setIcon(android.R.drawable.ic_dialog_info)
- .setNeutralButton(R.string.close, new OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.cancel();
- }
- });
- super.onPrepareDialogBuilder(builder);
+ public View getView(View convertView, ViewGroup parent) {
+ /*
+ * I found no better way for clickable links in a TextView then using Html.fromHtml(). Linkify
+ * is just broken and does not understand html href tags, so let's tag the @string/about_msg
+ * with CDATA and use Html.fromHtml() for clickable hrefs with tags.
+ */
+ final TextView tv = new TextView(getContext());
+ String text = getContext().getText(R.string.pref_about_text).toString();
+ text = String.format(text, mBuildVersion, mIitcVersion);
+
+ tv.setText(Html.fromHtml(text));
+ tv.setMovementMethod(LinkMovementMethod.getInstance());
+
+ return tv;
}
+ public void setVersions(String iitcVersion, String buildVersion) {
+ mIitcVersion = iitcVersion;
+ mBuildVersion = buildVersion;
+ }
}
diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java
index a41835ae..ef409706 100644
--- a/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java
+++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebViewClient.java
@@ -12,7 +12,6 @@ import android.preference.PreferenceManager;
import android.util.Log;
import android.webkit.SslErrorHandler;
import android.webkit.WebResourceResponse;
-import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
diff --git a/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java b/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java
index 49af96ea..71d26ed4 100644
--- a/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java
+++ b/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java
@@ -6,66 +6,53 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.preference.EditTextPreference;
-import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
-import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
+import com.cradle.iitc_mobile.IITC_AboutDialogPreference;
import com.cradle.iitc_mobile.R;
public class MainSettings extends PreferenceFragment {
-
- private String mIitcVersion;
-
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- mIitcVersion = getArguments().getString("iitc_version");
-
addPreferencesFromResource(R.xml.preferences);
- // set build version
- ListPreference pref_build_version = (ListPreference) findPreference("pref_build_version");
+ // set versions
+ String iitcVersion = getArguments().getString("iitc_version");
+ String buildVersion = "unknown";
+
PackageManager pm = getActivity().getPackageManager();
- String version = "unknown";
try {
- PackageInfo info = pm.getPackageInfo(
- getActivity().getPackageName(), 0);
- version = info.versionName;
+ PackageInfo info = pm.getPackageInfo(getActivity().getPackageName(), 0);
+ buildVersion = info.versionName;
} catch (NameNotFoundException e) {
e.printStackTrace();
}
- pref_build_version.setSummary(version);
- // set iitc version
- ListPreference pref_iitc_version = (ListPreference) findPreference("pref_iitc_version");
- pref_iitc_version.setSummary(mIitcVersion);
+ IITC_AboutDialogPreference pref_about = (IITC_AboutDialogPreference) findPreference("pref_about");
+ pref_about.setVersions(iitcVersion, buildVersion);
// set iitc source
EditTextPreference pref_iitc_source = (EditTextPreference) findPreference("pref_iitc_source");
- pref_iitc_source
- .setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(Preference preference,
- Object newValue) {
- preference.setSummary(getString(R.string.pref_select_iitc_sum) +
- " " + newValue);
- // TODO: update mIitcVersion when iitc source has
- // changed
- return true;
- }
- });
+ pref_iitc_source.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ preference.setSummary(getString(R.string.pref_select_iitc_sum) + " " + newValue);
+ // TODO: update mIitcVersion when iitc source has changed
+ return true;
+ }
+ });
// first init of summary
- String pref_iitc_source_sum = getString(R.string.pref_select_iitc_sum)
- + " " + pref_iitc_source.getText();
+ String pref_iitc_source_sum = getString(R.string.pref_select_iitc_sum) + " " + pref_iitc_source.getText();
pref_iitc_source.setSummary(pref_iitc_source_sum);
}
From 22ba06512e1a210514ea2e8bba033ada898ca070 Mon Sep 17 00:00:00 2001
From: Philipp Schaefer
Date: Tue, 22 Oct 2013 20:39:43 +0200
Subject: [PATCH 51/67] enable home button for about preference
---
mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java b/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java
index 71d26ed4..985a97dc 100644
--- a/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java
+++ b/mobile/src/com/cradle/iitc_mobile/fragments/MainSettings.java
@@ -62,7 +62,8 @@ public class MainSettings extends PreferenceFragment {
// thx to http://stackoverflow.com/a/16800527/2638486 !!
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
- if (preference.getTitle().toString().equals(getString(R.string.pref_advanced_options)))
+ if (preference.getTitle().toString().equals(getString(R.string.pref_advanced_options))
+ || preference.getTitle().toString().equals(getString(R.string.pref_about_title)))
initializeActionBar((PreferenceScreen) preference);
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
From ffe437968477485ad21cfd884981fdfb97cd8614 Mon Sep 17 00:00:00 2001
From: Philipp Schaefer
Date: Tue, 22 Oct 2013 20:45:48 +0200
Subject: [PATCH 52/67] removed ant clean in build script
---
build.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/build.py b/build.py
index 250e502f..96212c5c 100755
--- a/build.py
+++ b/build.py
@@ -263,7 +263,7 @@ if buildMobile:
if buildMobile != 'copyonly':
# now launch 'ant' to build the mobile project
- retcode = os.system("ant clean %s -buildfile mobile/build.xml %s" % (antOptions, buildMobile))
+ retcode = os.system("ant %s -buildfile mobile/build.xml %s" % (antOptions, buildMobile))
if retcode != 0:
print ("Error: mobile app failed to build. ant returned %d" % retcode)
From 1b1c850532852704f47948f65c7ee8ae56d437f2 Mon Sep 17 00:00:00 2001
From: Jon Atkins
Date: Tue, 22 Oct 2013 19:59:18 +0100
Subject: [PATCH 53/67] update build.py to support an option to specify the
build.xml filename - needed for new test builds
---
build.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/build.py b/build.py
index 96212c5c..5bc94a70 100755
--- a/build.py
+++ b/build.py
@@ -60,6 +60,8 @@ resourceUrlBase = settings.get('resourceUrlBase')
distUrlBase = settings.get('distUrlBase')
buildMobile = settings.get('buildMobile')
antOptions = settings.get('antOptions','')
+antBuildFile = settings.get('antBuildFile', 'mobile/build.xml');
+
# plugin wrapper code snippets. handled as macros, to ensure that
# 1. indentation caused by the "function wrapper()" doesn't apply to the plugin code body
@@ -263,7 +265,7 @@ if buildMobile:
if buildMobile != 'copyonly':
# now launch 'ant' to build the mobile project
- retcode = os.system("ant %s -buildfile mobile/build.xml %s" % (antOptions, buildMobile))
+ retcode = os.system("ant %s -buildfile %s %s" % (antOptions, antBuildFile, buildMobile))
if retcode != 0:
print ("Error: mobile app failed to build. ant returned %d" % retcode)
From 499ff6f09dc3a54ef931c222eebad1f3fced546a Mon Sep 17 00:00:00 2001
From: Philipp Schaefer
Date: Wed, 23 Oct 2013 09:05:35 +0200
Subject: [PATCH 54/67] xml formatting and comments for IITC_Application
---
mobile/build-test.xml | 87 +++++++++----------
.../cradle/iitc_mobile/IITC_Application.java | 6 ++
2 files changed, 49 insertions(+), 44 deletions(-)
diff --git a/mobile/build-test.xml b/mobile/build-test.xml
index 6584fcbd..94d78654 100644
--- a/mobile/build-test.xml
+++ b/mobile/build-test.xml
@@ -68,26 +68,7 @@
-->
-
-
-
+
-
-
-
-
- git.commits: ${git.commits}
-
-
-
-
-
- git.version: ${git.version}
+
+
+
+
+ git.commits: ${git.commits}
+
+
+
+
+
+ git.version: ${git.version}
- Creating backup of AndroidManifest.xml
-
+ Creating backup of AndroidManifest.xml
+
-
-
@@ -188,17 +169,35 @@
- Restoring backup of strings.xml and preferences.xml
-
-
+ Restoring backup of strings.xml and preferences.xml
+
+
+
diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_Application.java b/mobile/src/com/cradle/iitc_mobile/IITC_Application.java
index 312faab7..23327f58 100644
--- a/mobile/src/com/cradle/iitc_mobile/IITC_Application.java
+++ b/mobile/src/com/cradle/iitc_mobile/IITC_Application.java
@@ -5,6 +5,12 @@ import android.preference.PreferenceManager;
import java.io.File;
+/*
+ * To write the WebView cache to external storage we need to override the
+ * getCacheDir method of the main application. Some internal Android code seems
+ * to call getApplicationContext().getCacheDir(); instead of
+ * getContext().getCacheDir(); to decide where to store and read cached files.
+ */
public class IITC_Application extends Application {
@Override
public File getCacheDir() {
From c4990d31bd265d74b9f8ce57b12333528ea799fe Mon Sep 17 00:00:00 2001
From: Philipp Schaefer
Date: Wed, 23 Oct 2013 10:31:43 +0200
Subject: [PATCH 55/67] some project cleanups - removed gradle and proguard
files, because they are not used, tested or updated at the moment
---
mobile/.gitignore | 3 ++
mobile/.idea/.name | 2 +-
mobile/.idea/libraries/android_support_v4.xml | 9 +++++
mobile/.idea/misc.xml | 23 ++++++++++++
mobile/.idea/modules.xml | 2 +-
mobile/.idea/vcs.xml | 1 -
mobile/IITC-Mobile.iml | 34 ------------------
mobile/{mobile.iml => IITC_Mobile.iml} | 12 ++-----
mobile/build.gradle | 35 -------------------
mobile/proguard-project.txt | 16 ---------
10 files changed, 40 insertions(+), 97 deletions(-)
create mode 100644 mobile/.idea/libraries/android_support_v4.xml
delete mode 100644 mobile/IITC-Mobile.iml
rename mobile/{mobile.iml => IITC_Mobile.iml} (66%)
delete mode 100644 mobile/build.gradle
delete mode 100644 mobile/proguard-project.txt
diff --git a/mobile/.gitignore b/mobile/.gitignore
index 2f94c701..20b44cb9 100644
--- a/mobile/.gitignore
+++ b/mobile/.gitignore
@@ -18,6 +18,9 @@ bin/
gen/
out/
+# private ant configs
+ant.properties
+
# Local configuration file (sdk path, etc)
local.properties
diff --git a/mobile/.idea/.name b/mobile/.idea/.name
index d884b924..b4e0055b 100644
--- a/mobile/.idea/.name
+++ b/mobile/.idea/.name
@@ -1 +1 @@
-IITC-Mobile
\ No newline at end of file
+IITC_Mobile
\ No newline at end of file
diff --git a/mobile/.idea/libraries/android_support_v4.xml b/mobile/.idea/libraries/android_support_v4.xml
new file mode 100644
index 00000000..90805f27
--- /dev/null
+++ b/mobile/.idea/libraries/android_support_v4.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mobile/.idea/misc.xml b/mobile/.idea/misc.xml
index 3b54f562..31e23495 100644
--- a/mobile/.idea/misc.xml
+++ b/mobile/.idea/misc.xml
@@ -3,8 +3,31 @@
+
+
+
+
+
+
+
+ Android 4.3 Platform
+
+
+
+
+
+
+
diff --git a/mobile/.idea/modules.xml b/mobile/.idea/modules.xml
index c7429177..cbb8eea5 100644
--- a/mobile/.idea/modules.xml
+++ b/mobile/.idea/modules.xml
@@ -2,7 +2,7 @@
-
+
diff --git a/mobile/.idea/vcs.xml b/mobile/.idea/vcs.xml
index 2e0588cc..21cbaa60 100644
--- a/mobile/.idea/vcs.xml
+++ b/mobile/.idea/vcs.xml
@@ -1,7 +1,6 @@
-
diff --git a/mobile/IITC-Mobile.iml b/mobile/IITC-Mobile.iml
deleted file mode 100644
index 3da809e3..00000000
--- a/mobile/IITC-Mobile.iml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
- MANIFEST_FILE_PATH
- RESOURCES_DIR_PATH
- ASSETS_DIR_PATH
- NATIVE_LIBS_DIR_PATH
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/mobile/mobile.iml b/mobile/IITC_Mobile.iml
similarity index 66%
rename from mobile/mobile.iml
rename to mobile/IITC_Mobile.iml
index 25a68b77..7647439e 100644
--- a/mobile/mobile.iml
+++ b/mobile/IITC_Mobile.iml
@@ -2,24 +2,18 @@
-
-
- MANIFEST_FILE_PATH
- RESOURCES_DIR_PATH
- ASSETS_DIR_PATH
- NATIVE_LIBS_DIR_PATH
-
-
+
-
+
+
diff --git a/mobile/build.gradle b/mobile/build.gradle
deleted file mode 100644
index 2fa22689..00000000
--- a/mobile/build.gradle
+++ /dev/null
@@ -1,35 +0,0 @@
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.4'
- }
-}
-apply plugin: 'android'
-
-dependencies {
-}
-
-android {
- compileSdkVersion 17
- buildToolsVersion "17"
-
- defaultConfig {
- minSdkVersion 14
- targetSdkVersion 17
- }
- sourceSets {
- main {
- manifest.srcFile 'AndroidManifest.xml'
- java.srcDirs = ['src']
- resources.srcDirs = ['src']
- aidl.srcDirs = ['src']
- renderscript.srcDirs = ['src']
- res.srcDirs = ['res']
- assets.srcDirs = ['assets']
- }
-
- instrumentTest.setRoot('tests')
- }
-}
diff --git a/mobile/proguard-project.txt b/mobile/proguard-project.txt
deleted file mode 100644
index ff7f7030..00000000
--- a/mobile/proguard-project.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-# view res/xml/preferences.xml #generated:4
--keep class com.cradle.iitc_mobile.IITC_AboutDialogPreference { (...); }
-
-# view AndroidManifest.xml #generated:23
--keep class com.cradle.iitc_mobile.IITC_Mobile { (...); }
-
-# view AndroidManifest.xml #generated:56
--keep class com.cradle.iitc_mobile.IITC_SearchableActivity { (...); }
-
-# view AndroidManifest.xml #generated:50
--keep class com.cradle.iitc_mobile.IITC_PreferenceActivity { (...); }
-
-# view res/layout/activity_main.xml #generated:6
--keep class com.cradle.iitc_mobile.IITC_WebView { (...); }
-
--keep class com.cradle.iitc_mobile.IITC_JSInterface { (...); }
\ No newline at end of file
From 82708124068218cd51069891afba4f56d535433c Mon Sep 17 00:00:00 2001
From: Jon Atkins
Date: Fri, 25 Oct 2013 07:10:35 +0100
Subject: [PATCH 56/67] experimental change: render stale map data tiles before
downloading fresh data - should give a more responsive appearance of data
also increase cache expiry time to 15 mins
---
code/map_data_cache.js | 2 +-
code/map_data_request.js | 10 +++++++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/code/map_data_cache.js b/code/map_data_cache.js
index bdd18228..a04070fc 100644
--- a/code/map_data_cache.js
+++ b/code/map_data_cache.js
@@ -11,7 +11,7 @@ window.DataCache = function() {
// entries would grow indefinitely. an hour seems reasonable from experience with the data, so 55 mins max cache time
// this.REQUEST_CACHE_MAX_AGE = 55*60; // maximum cache age. entries are deleted from the cache after this time
//UPDATE: this timestampMs parameter doesn't work, so reduced max age to limit RAM usage
- this.REQUEST_CACHE_MAX_AGE = 5*60; // maximum cache age. entries are deleted from the cache after this time
+ this.REQUEST_CACHE_MAX_AGE = 15*60; // maximum cache age. entries are deleted from the cache after this time
if (L.Browser.mobile) {
// on mobile devices, smaller cache size
diff --git a/code/map_data_request.js b/code/map_data_request.js
index c118d23f..5e49a3f8 100644
--- a/code/map_data_request.js
+++ b/code/map_data_request.js
@@ -247,7 +247,15 @@ window.MapDataRequest.prototype.refresh = function() {
this.cachedTileCount += 1;
} else {
- // no fresh data - queue a request
+ // no fresh data
+
+ // render the cached stale data, if we have it. this ensures *something* appears quickly when possible
+ var old_data = this.cache && this.cache.get(tile_id);
+ if (old_data) {
+ this.render.processTileData (old_data);
+ }
+
+ // queue a request
var boundsParams = generateBoundsParams(
tile_id,
latSouth,
From d268b0a79f8cf61db4f81affda474c8c8f7d1e7e Mon Sep 17 00:00:00 2001
From: Jon Atkins
Date: Fri, 25 Oct 2013 08:01:45 +0100
Subject: [PATCH 57/67] remove the delay before requeueing 'error==TIMEOUT'
tiles. it's not needed (stock site has no delay), and the other delay (before
processing the queue again) has more than enough effect to batch multiple
retries together when it's useful
---
code/map_data_request.js | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/code/map_data_request.js b/code/map_data_request.js
index 5e49a3f8..84795404 100644
--- a/code/map_data_request.js
+++ b/code/map_data_request.js
@@ -42,8 +42,7 @@ window.MapDataRequest = function() {
// this gives a chance of other requests finishing, allowing better grouping of retries in new requests
this.RUN_QUEUE_DELAY = 0.5;
- // delay before re-queueing tiles
- this.TILE_TIMEOUT_REQUEUE_DELAY = 0.2; // short delay before retrying a 'error==TIMEOUT' tile. a common 'error', and the stock site has no delay in this case
+ // delay before re-queueing tiles in failed requests
this.BAD_REQUEST_REQUEUE_DELAY = 5; // longer delay before retrying a completely failed request - as in this case the servers are struggling
// a delay before processing the queue after requeueing tiles. this gives a chance for other requests to finish
@@ -513,7 +512,6 @@ window.MapDataRequest.prototype.handleResponse = function (data, tiles, success)
if (val.error == "TIMEOUT") {
// TIMEOUT errors for individual tiles are 'expected'(!) - and result in a silent unlimited retries
timeoutTiles.push (id);
- this.debugTiles.setState (id, 'tile-timeout');
} else {
console.warn('map data tile '+id+' failed: error=='+val.error);
errorTiles.push (id);
@@ -588,21 +586,20 @@ console.log('processed delta mapData request:'+id+': '+oldEntityCount+' original
console.log ('getThinnedEntities status: '+tiles.length+' tiles: '+successTiles.length+' successful, '+timeoutTiles.length+' timed out, '+errorTiles.length+' failed');
- //setTimeout has no way of passing the 'context' (aka 'this') to it's function
- var savedContext = this;
-
+ // requeue any 'timeout' tiles immediately
if (timeoutTiles.length > 0) {
- setTimeout (function() {
- for (var i in timeoutTiles) {
- var id = timeoutTiles[i];
- delete savedContext.requestedTiles[id];
- savedContext.requeueTile(id, false);
- }
- savedContext.delayProcessRequestQueue(this.REQUEUE_DELAY);
- }, this.TILE_TIMEOUT_REQUEUE_DELAY*1000);
+ for (var i in timeoutTiles) {
+ var id = timeoutTiles[i];
+ delete this.requestedTiles[id];
+ this.requeueTile(id, false);
+ }
}
+ // but for other errors, delay before retrying (as the server is having issues)
if (errorTiles.length > 0) {
+ //setTimeout has no way of passing the 'context' (aka 'this') to it's function
+ var savedContext = this;
+
setTimeout (function() {
for (var i in errorTiles) {
var id = errorTiles[i];
From 51bb866dc6250479aa4c0f9c4090445ab64e4916 Mon Sep 17 00:00:00 2001
From: Jon Atkins
Date: Sun, 27 Oct 2013 16:06:35 +0000
Subject: [PATCH 58/67] geodesic lines - improved handling of lines that cross
the antimeridian works fine as long as the longitude difference is under 180
degrees
---
external/L.Geodesic.js | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/external/L.Geodesic.js b/external/L.Geodesic.js
index b2bf8339..9d25b3b1 100644
--- a/external/L.Geodesic.js
+++ b/external/L.Geodesic.js
@@ -44,7 +44,7 @@ Modified by qnstie 2013-07-17 to maintain compatibility with Leaflet.draw
lat1, lat2, lng1, lng2, dLng, d, segments,
f, A, B, x, y, z, fLat, fLng;
- dLng = Math.abs(endLatlng.lng - startLatlng.lng) * d2r;
+ dLng = (endLatlng.lng - startLatlng.lng) * d2r;
lat1 = startLatlng.lat * d2r;
lat2 = endLatlng.lat * d2r;
lng1 = startLatlng.lng * d2r;
@@ -60,14 +60,15 @@ Modified by qnstie 2013-07-17 to maintain compatibility with Leaflet.draw
// rounding errors? maths bug? not sure - but it solves the issue! and is a slight optimisation)
for (i = 1; i < segments; i++) {
// http://williams.best.vwh.net/avform.htm#Intermediate
+ // modified to handle longitude above +-180 degrees
f = i / segments;
A = Math.sin((1-f)*d) / Math.sin(d);
B = Math.sin(f*d) / Math.sin(d);
- x = A * Math.cos(lat1) * Math.cos(lng1) + B * Math.cos(lat2) * Math.cos(lng2);
- y = A * Math.cos(lat1) * Math.sin(lng1) + B * Math.cos(lat2) * Math.sin(lng2);
- z = A * Math.sin(lat1) + B * Math.sin(lat2);
+ x = A * Math.cos(lat1) * Math.cos(0) + B * Math.cos(lat2) * Math.cos(dLng);
+ y = A * Math.cos(lat1) * Math.sin(0) + B * Math.cos(lat2) * Math.sin(dLng);
+ z = A * Math.sin(lat1) + B * Math.sin(lat2);
fLat = r2d * Math.atan2(z, Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)));
- fLng = r2d * Math.atan2(y, x);
+ fLng = r2d * (Math.atan2(y, x)+lng1);
convertedPoints.push(L.latLng([fLat, fLng]));
}
From 7230e2f44a83400ffe0ce5701f8d2dc80e495973 Mon Sep 17 00:00:00 2001
From: Jon Atkins
Date: Sun, 27 Oct 2013 16:33:42 +0000
Subject: [PATCH 59/67] run the requestFinished callback after updating
visibility/render of cached data technically, not a finished request, but
makes sense from the point of view of plugins
---
code/map_data_request.js | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/code/map_data_request.js b/code/map_data_request.js
index 84795404..07ee7e32 100644
--- a/code/map_data_request.js
+++ b/code/map_data_request.js
@@ -299,6 +299,10 @@ console.log('stale tile '+tile_id+': newest mtime '+lastTimestamp+(lastTimestamp
this.setStatus ('loading');
+ // technically a request hasn't actually finished - however, displayed portal data has been refreshed
+ // so as far as plugins are concerned, it should be treated as a finished request
+ window.runHooks('requestFinished', {success: true});
+
console.log ('done request preperation (cleared out-of-bounds and invalid for zoom, and rendered cached data)');
if (Object.keys(this.tileBounds).length > 0) {
From b6eebccca9383b283005c744d838f6029827afd2 Mon Sep 17 00:00:00 2001
From: Jon Atkins
Date: Mon, 28 Oct 2013 21:56:36 +0000
Subject: [PATCH 60/67] extract script version and other data from the
tampermonkey/greasemonkey GM_info and pass it through the wrapper function
modify the plugin template code to do the same for plugins - also include the
plugin base filename
this is the required data to allow version checks to be performed. it will also allow IITC to know which plugins are installed and active
---
build.py | 34 +++++++++++++++++++---------------
main.js | 10 ++++++++--
2 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/build.py b/build.py
index 5bc94a70..abde15f2 100755
--- a/build.py
+++ b/build.py
@@ -67,24 +67,24 @@ antBuildFile = settings.get('antBuildFile', 'mobile/build.xml');
# 1. indentation caused by the "function wrapper()" doesn't apply to the plugin code body
# 2. the wrapper is formatted correctly for removal by the IITC Mobile android app
pluginWrapperStart = """
-function wrapper() {
+function wrapper(plugin_info) {
// ensure plugin framework is there, even if iitc is not yet loaded
if(typeof window.plugin !== 'function') window.plugin = function() {};
"""
+
pluginWrapperEnd = """
-if(window.iitcLoaded && typeof setup === 'function') {
- setup();
-} else {
- if(window.bootPlugins)
- window.bootPlugins.push(setup);
- else
- window.bootPlugins = [setup];
-}
+setup.info = plugin_info; //add the script info data to the function as a property
+if(!window.bootPlugins) window.bootPlugins = [];
+window.bootPlugins.push(setup);
+// if IITC has already booted, immediately run the 'setup' function
+if(window.iitcLoaded && typeof setup === 'function') setup();
} // wrapper end
// inject code into site context
var script = document.createElement('script');
-script.appendChild(document.createTextNode('('+ wrapper +')();'));
+var info = { buildName: '@@BUILDNAME@@', dateTimeVersion: '@@DATETIMEVERSION@@', pluginId: '@@PLUGINNAME@@' };
+if (this.GM_info && this.GM_info.script) info.script = { version: GM_info.script.version, name: GM_info.script.name, description: GM_info.script.description };
+script.appendChild(document.createTextNode('('+ wrapper +')('+JSON.stringify(info)+');'));
(document.body || document.head || document.documentElement).appendChild(script);
"""
@@ -143,10 +143,13 @@ def extractUserScriptMeta(var):
-def doReplacements(script,updateUrl,downloadUrl):
+def doReplacements(script,updateUrl,downloadUrl,pluginName=None):
script = re.sub('@@INJECTCODE@@',loadCode,script)
+ script = script.replace('@@PLUGINSTART@@', pluginWrapperStart)
+ script = script.replace('@@PLUGINEND@@', pluginWrapperEnd)
+
script = re.sub('@@INCLUDERAW:([0-9a-zA-Z_./-]+)@@', loaderRaw, script)
script = re.sub('@@INCLUDESTRING:([0-9a-zA-Z_./-]+)@@', loaderString, script)
script = re.sub('@@INCLUDEMD:([0-9a-zA-Z_./-]+)@@', loaderMD, script)
@@ -166,8 +169,8 @@ def doReplacements(script,updateUrl,downloadUrl):
script = script.replace('@@UPDATEURL@@', updateUrl)
script = script.replace('@@DOWNLOADURL@@', downloadUrl)
- script = script.replace('@@PLUGINSTART@@', pluginWrapperStart)
- script = script.replace('@@PLUGINEND@@', pluginWrapperEnd)
+ if (pluginName):
+ script = script.replace('@@PLUGINNAME@@', pluginName);
return script
@@ -223,7 +226,8 @@ for fn in glob.glob("plugins/*.user.js"):
downloadUrl = distUrlBase and distUrlBase + '/' + fn.replace("\\","/") or 'none'
updateUrl = distUrlBase and downloadUrl.replace('.user.js', '.meta.js') or 'none'
- script = doReplacements(script, downloadUrl=downloadUrl, updateUrl=updateUrl)
+ pluginName = os.path.splitext(os.path.splitext(os.path.basename(fn))[0])[0]
+ script = doReplacements(script, downloadUrl=downloadUrl, updateUrl=updateUrl, pluginName=pluginName)
metafn = fn.replace('.user.js', '.meta.js')
saveScriptAndMeta(script, os.path.join(outDir,fn), os.path.join(outDir,metafn))
@@ -238,7 +242,7 @@ if buildMobile:
script = readfile("mobile/plugins/" + fn)
downloadUrl = distUrlBase and distUrlBase + '/' + fn.replace("\\","/") or 'none'
updateUrl = distUrlBase and downloadUrl.replace('.user.js', '.meta.js') or 'none'
- script = doReplacements(script, downloadUrl=downloadUrl, updateUrl=updateUrl)
+ script = doReplacements(script, downloadUrl=downloadUrl, updateUrl=updateUrl, pluginName='user-location')
metafn = fn.replace('.user.js', '.meta.js')
saveScriptAndMeta(script, os.path.join(outDir,fn), os.path.join(outDir,metafn))
diff --git a/main.js b/main.js
index 4e5a6ebf..c51ff443 100644
--- a/main.js
+++ b/main.js
@@ -107,7 +107,11 @@ document.getElementsByTagName('body')[0].innerHTML = ''
// 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
// instead of in the Greasemonkey/Extension/etc. context.
-function wrapper() {
+function wrapper(info) {
+// a cut-down version of GM_info is passed as a parameter to the script
+// (not the full GM_info - it contains the ENTIRE script source!)
+window.script_info = info;
+
// LEAFLET PREFER CANVAS ///////////////////////////////////////////////
// Set to true if Leaflet should draw things using Canvas instead of SVG
@@ -240,5 +244,7 @@ if(typeof window.plugin !== 'function') window.plugin = function() {};
// inject code into site context
var script = document.createElement('script');
-script.appendChild(document.createTextNode('('+ wrapper +')();'));
+var info = { buildName: '@@BUILDNAME@@', dateTimeVersion: '@@DATETIMEVERSION@@' };
+if (this.GM_info && this.GM_info.script) info.script = { version: GM_info.script.version, name: GM_info.script.name, description: GM_info.script.description };
+script.appendChild(document.createTextNode('('+ wrapper +')('+JSON.stringify(info)+');'));
(document.body || document.head || document.documentElement).appendChild(script);
From 8d1eb6e0b77fd8ee4687ad27beeaa69801a8b1a3 Mon Sep 17 00:00:00 2001
From: Philipp Schaefer
Date: Mon, 28 Oct 2013 20:14:25 +0100
Subject: [PATCH 61/67] first version of custom fullscreen preference (fix for
#594)
---
mobile/res/values/strings.xml | 22 +++-
mobile/res/xml/preferences.xml | 11 +-
.../com/cradle/iitc_mobile/IITC_Mobile.java | 38 +++---
.../iitc_mobile/IITC_NavigationHelper.java | 34 ++----
.../com/cradle/iitc_mobile/IITC_WebView.java | 111 ++++++++++++++++--
5 files changed, 153 insertions(+), 63 deletions(-)
diff --git a/mobile/res/values/strings.xml b/mobile/res/values/strings.xml
index 5980c01b..1babb023 100644
--- a/mobile/res/values/strings.xml
+++ b/mobile/res/values/strings.xml
@@ -79,14 +79,16 @@
Show users position on mapShow zoom controlShows +/- buttons even on multitouch capable devices.
- Hide Action Bar in fullscreen mode
- Nice for screenshots. Note: IITCm can still be controlled via the Navigation Drawers
+ Hide in fullscreen mode
+ Which elements should be hidden in fullscreen mode.
+ Note: IITCm can still be controlled via the Navigation DrawersForce desktop modeNice for tablets, looks awful on smartphonesForce httpsDisabling may improve performanceMove cache to external storage
- Restart required! Write cache to sdCard. Saves internal storage. External storage has to be mounted.
+ Restart required! Write cache to sdCard. Saves internal storage.
+ External storage has to be mounted.Press back button twice to exitAvoids accidental exitsAdvanced settings
@@ -106,6 +108,20 @@
Aggressive CachingPrefer cached values even if they are expired…saves traffic but
may result in login issues
+
+
+ System Bar
+ Action Bar
+ IITC Status Bar
+ Navigation Bar
+
+
+ 2
+ 4
+ 8
+ 16
+
+
AlwaysMobile data only (default)
diff --git a/mobile/res/xml/preferences.xml b/mobile/res/xml/preferences.xml
index 8a137c51..ab91e41b 100644
--- a/mobile/res/xml/preferences.xml
+++ b/mobile/res/xml/preferences.xml
@@ -24,11 +24,12 @@
android:key="pref_user_zoom"
android:summary="@string/pref_user_zoom_sum"
android:title="@string/pref_user_zoom"/>
-
+ entries = mSharedPrefs.getStringSet("pref_fullscreen", new HashSet());
+ mFullscreenStatus &= FS_ENABLED;
+
+ // default values...android has no nice way to add default values to multiSelectListPreferences
+ if (entries.isEmpty()) {
+ mFullscreenStatus += FS_ACTIONBAR | FS_SYSBAR;
+ }
+ for (String entry : entries) {
+ mFullscreenStatus += Integer.parseInt(entry);
+ }
+ }
+
+ int getFullscreenStatus() {
+ return mFullscreenStatus;
+ }
+
+ public boolean isInFullscreen() {
+ return (mFullscreenStatus & FS_ENABLED) != 0;
+ }
+
public IITC_WebViewClient getWebViewClient() {
return mIitcWebViewClient;
}
@@ -210,5 +306,4 @@ public class IITC_WebView extends WebView {
Log.d("iitcm", "setting user agent to: " + ua);
mSettings.setUserAgentString(ua);
}
-
}
From 318cea2e9a03d8e8fea14ec9b8122aff5c8749fc Mon Sep 17 00:00:00 2001
From: Jon Atkins
Date: Tue, 29 Oct 2013 02:09:41 +0000
Subject: [PATCH 62/67] add a list of the active plugins to the about dialog,
listing the version, etc from the new plugin interface changes also use the
new versin data supplied by grease/tampermonkey for the main script version
display
---
code/utils_misc.js | 35 +++++++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/code/utils_misc.js b/code/utils_misc.js
index fa34ee5e..762e5fa1 100644
--- a/code/utils_misc.js
+++ b/code/utils_misc.js
@@ -1,9 +1,38 @@
// UTILS + MISC ///////////////////////////////////////////////////////
-window.aboutIITC = function(){
- var v = '@@BUILDNAME@@-@@BUILDDATE@@';
+window.aboutIITC = function() {
+ var v = (script_info.script && script_info.script.version || script_info.dateTimeVersion) + ' ['+script_info.buildName+']';
+ if (typeof android !== 'undefined' && android && android.getVersionCode) {
+ v += '[IITC Mobile '+android.getVersionCode()+']';
+ }
+
+ var plugins = '
';
+ for (var i in bootPlugins) {
+ var info = bootPlugins[i].info;
+ if (info) {
+ var pname = info.script && info.script.name || info.pluginId;
+ if (pname.substr(0,13) == 'IITC plugin: ' || pname.substr(0,13) == 'IITC Plugin: ') {
+ pname = pname.substr(13);
+ }
+ var pvers = info.script && info.script.version || info.dateTimeVersion;
+
+ var ptext = pname + ' - ' + pvers;
+ if (info.buildName != script_info.buildName) {
+ ptext += ' ['+info.buildName+']';
+ }
+
+ plugins += '
'+ptext+'
';
+ } else {
+ // no 'info' property of the plugin setup function - old plugin wrapper code
+ // could attempt to find the "window.plugin.NAME = function() {};" line it's likely to have..?
+ plugins += '
(unknown plugin: index '+i+')
';
+ }
+ }
+ plugins += '
';
+
var attrib = '@@INCLUDEMD:ATTRIBUTION.md@@';
var contrib = '@@INCLUDEMD:CONTRIBS.md@@'
+
var a = ''
+ '
';
+
dialog({
title: 'IITC ' + v,
html: a,
From 9dabc33770d6d85629c85fbf271186be1e341efd Mon Sep 17 00:00:00 2001
From: Jon Atkins
Date: Tue, 29 Oct 2013 02:43:56 +0000
Subject: [PATCH 63/67] modify plugin wrapper, so build-script injected macros
in the wrapper are in a more obvious place, so 3rd party plugin authors are
less likely to make mistakes here when working outside the build.py
environment tweak the about screen to display non-standard plugins using the
new interface better
---
build.py | 11 +++++++++--
code/utils_misc.js | 2 +-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/build.py b/build.py
index abde15f2..f81f6245 100755
--- a/build.py
+++ b/build.py
@@ -71,6 +71,13 @@ function wrapper(plugin_info) {
// ensure plugin framework is there, even if iitc is not yet loaded
if(typeof window.plugin !== 'function') window.plugin = function() {};
+//PLUGIN AUTHORS: writing a plugin outside of the IITC build environment? if so, delete these lines!!
+//(leaving them in place might break the 'About IITC' page or break update checks)
+plugin_info.buildName = '@@BUILDNAME@@';
+plugin_info.dateTimeVersion: '@@DATETIMEVERSION@@';
+plugin_info.pluginId = '@@PLUGINNAME@@';
+//END PLUGIN AUTHORS NOTE
+
"""
pluginWrapperEnd = """
@@ -82,8 +89,8 @@ if(window.iitcLoaded && typeof setup === 'function') setup();
} // wrapper end
// inject code into site context
var script = document.createElement('script');
-var info = { buildName: '@@BUILDNAME@@', dateTimeVersion: '@@DATETIMEVERSION@@', pluginId: '@@PLUGINNAME@@' };
-if (this.GM_info && this.GM_info.script) info.script = { version: GM_info.script.version, name: GM_info.script.name, description: GM_info.script.description };
+var info = {};
+if (typeof GM_info !== 'undefined' && GM_info && GM_info.script) info.script = { version: GM_info.script.version, name: GM_info.script.name, description: GM_info.script.description };
script.appendChild(document.createTextNode('('+ wrapper +')('+JSON.stringify(info)+');'));
(document.body || document.head || document.documentElement).appendChild(script);
diff --git a/code/utils_misc.js b/code/utils_misc.js
index 762e5fa1..f41755e5 100644
--- a/code/utils_misc.js
+++ b/code/utils_misc.js
@@ -18,7 +18,7 @@ window.aboutIITC = function() {
var ptext = pname + ' - ' + pvers;
if (info.buildName != script_info.buildName) {
- ptext += ' ['+info.buildName+']';
+ ptext += ' ['+(info.buildName||'non-standard plugin')+']';
}
plugins += '
'+ptext+'
';
From c52d657864977c1ad915c9bea565a18aed423787 Mon Sep 17 00:00:00 2001
From: Jon Atkins
Date: Tue, 29 Oct 2013 02:48:03 +0000
Subject: [PATCH 64/67] fix syntax error in
9dabc33770d6d85629c85fbf271186be1e341efd - it broke all plugins (oops!)
---
build.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/build.py b/build.py
index f81f6245..921f0d0a 100755
--- a/build.py
+++ b/build.py
@@ -74,7 +74,7 @@ if(typeof window.plugin !== 'function') window.plugin = function() {};
//PLUGIN AUTHORS: writing a plugin outside of the IITC build environment? if so, delete these lines!!
//(leaving them in place might break the 'About IITC' page or break update checks)
plugin_info.buildName = '@@BUILDNAME@@';
-plugin_info.dateTimeVersion: '@@DATETIMEVERSION@@';
+plugin_info.dateTimeVersion = '@@DATETIMEVERSION@@';
plugin_info.pluginId = '@@PLUGINNAME@@';
//END PLUGIN AUTHORS NOTE
From a8f3a281e738ce1f621f7f2f3de7000f33600e11 Mon Sep 17 00:00:00 2001
From: Jon Atkins
Date: Tue, 29 Oct 2013 18:35:08 +0000
Subject: [PATCH 65/67] work in progress on version check server side script
---
website/versioncheck/index.php | 135 +++++++++++++++++++++++++++++++++
1 file changed, 135 insertions(+)
create mode 100644 website/versioncheck/index.php
diff --git a/website/versioncheck/index.php b/website/versioncheck/index.php
new file mode 100644
index 00000000..831e199f
--- /dev/null
+++ b/website/versioncheck/index.php
@@ -0,0 +1,135 @@
+ Array ( # live release
+ 'path' => 'release',
+ 'name' => 'Stable release build',
+ ),
+ 'jonatkins-test' => Array ( # public test builds
+ 'path' => 'test',
+ 'name' => 'Test build',
+ ),
+
+ 'jonatkins-experimental' => Array ( # rarely used, for features not quite ready for 'test'
+ 'path' => 'experimental',
+ 'name' => 'Experimental build',
+ ),
+
+ 'jonatkins-dev' => Array ( # personal
+ 'path' => 'dev',
+ 'name' => 'Development builds - not for public use',
+ ),
+
+ 'local' => Array ( # not a real build, but often the default for local development
+ 'path' => NULL,
+ 'name' => 'Local build - no update check available',
+ ),
+);
+
+if ( array_key_exists ( $build, $details ) )
+{
+ $info = $details[$build];
+
+ $response['buildPath'] = $info['path'];
+ $response['name'] = $info['name'];
+
+
+}
+else
+{
+ $response['error'] = 'Unsupported build for version check';
+}
+
+
+$data = json_encode ( $response );
+$data = indent($data);
+
+
+# send the response - allow either jsonp (using a 'callback' parameter), or regular json
+if ( array_key_exists ( 'callback', $_GET ) )
+{
+ header('Content-Type: text/javascript; charset=utf8');
+ header('Access-Control-Allow-Origin: *');
+ header('Access-Control-Max-Age: 3628800');
+ header('Access-Control-Allow-Methods: GET, POST');
+
+ $callback = $_GET['callback'];
+ echo $callback.'('.$data.');';
+
+}
+else
+{
+ // normal JSON string
+ header('Content-Type: application/json; charset=utf8');
+
+ echo $data;
+}
+
+
+// http://www.daveperrett.com/articles/2008/03/11/format-json-with-php/
+/**
+ * Indents a flat JSON string to make it more human-readable.
+ *
+ * @param string $json The original JSON string to process.
+ *
+ * @return string Indented version of the original JSON string.
+ */
+function indent($json) {
+
+ $result = '';
+ $pos = 0;
+ $strLen = strlen($json);
+ $indentStr = ' ';
+ $newLine = "\n";
+ $prevChar = '';
+ $outOfQuotes = true;
+
+ for ($i=0; $i<=$strLen; $i++) {
+
+ // Grab the next character in the string.
+ $char = substr($json, $i, 1);
+
+ // Are we inside a quoted string?
+ if ($char == '"' && $prevChar != '\\') {
+ $outOfQuotes = !$outOfQuotes;
+
+ // If this character is the end of an element,
+ // output a new line and indent the next line.
+ } else if(($char == '}' || $char == ']') && $outOfQuotes) {
+ $result .= $newLine;
+ $pos --;
+ for ($j=0; $j<$pos; $j++) {
+ $result .= $indentStr;
+ }
+ }
+
+ // Add the character to the result string.
+ $result .= $char;
+
+ // If the last character was the beginning of an element,
+ // output a new line and indent the next line.
+ if (($char == ',' || $char == '{' || $char == '[') && $outOfQuotes) {
+ $result .= $newLine;
+ if ($char == '{' || $char == '[') {
+ $pos ++;
+ }
+
+ for ($j = 0; $j < $pos; $j++) {
+ $result .= $indentStr;
+ }
+ }
+
+ $prevChar = $char;
+ }
+
+ return $result;
+}
+
+?>
From e7fe4bb1dddc7fefc4b197642afcda31193787e9 Mon Sep 17 00:00:00 2001
From: Jon Atkins
Date: Tue, 29 Oct 2013 20:29:08 +0000
Subject: [PATCH 66/67] first pass at a fix for protocol changes - #618
---
code/map_data_debug.js | 3 +-
code/map_data_request.js | 120 +++++-------------------------
code/utils_misc.js | 154 +++++++++++++--------------------------
3 files changed, 72 insertions(+), 205 deletions(-)
diff --git a/code/map_data_debug.js b/code/map_data_debug.js
index dcede257..4ecc27a8 100644
--- a/code/map_data_debug.js
+++ b/code/map_data_debug.js
@@ -37,8 +37,7 @@ window.RenderDebugTiles.prototype.setState = function(id,state) {
var col = '#f0f';
var fill = '#f0f';
switch(state) {
- case 'ok': col='#080'; fill='#080'; break;
- case 'ok-delta': col='#0f0'; fill='#0f0'; break;
+ case 'ok': col='#0f0'; fill='#0f0'; break;
case 'error': col='#f00'; fill='#f00'; break;
case 'cache-fresh': col='#0f0'; fill='#ff0'; break;
case 'cache-stale': col='#f00'; fill='#ff0'; break;
diff --git a/code/map_data_request.js b/code/map_data_request.js
index 07ee7e32..1c112a88 100644
--- a/code/map_data_request.js
+++ b/code/map_data_request.js
@@ -11,7 +11,6 @@ window.MapDataRequest = function() {
this.activeRequestCount = 0;
this.requestedTiles = {};
- this.staleTileData = {};
this.idle = false;
@@ -173,11 +172,8 @@ window.MapDataRequest.prototype.refresh = function() {
// a 'set' to keep track of hard failures for tiles
this.tileErrorCount = {};
- // fill tileBounds with the data needed to request each tile
- this.tileBounds = {};
-
- // clear the stale tile data
- this.staleTileData = {};
+ // the 'set' of requested tile QKs
+ this.queuedTiles = {};
var bounds = clampLatLngBounds(map.getBounds());
@@ -255,43 +251,7 @@ window.MapDataRequest.prototype.refresh = function() {
}
// queue a request
- var boundsParams = generateBoundsParams(
- tile_id,
- latSouth,
- lngWest,
- latNorth,
- lngEast
- );
-
-/* After some testing, this doesn't seem to actually work. The server returns the same data with and without the parameter
- * Also, closer study of the stock site code shows the parameter isn't actually set anywhere.
- * so, disabling for now...
- // however, the server does support delta requests - only returning the entities changed since a particular timestamp
- // retrieve the stale cache entry and use it, if possible
- var stale = (this.cache && this.cache.get(tile_id));
- var lastTimestamp = undefined;
- if (stale) {
- // find the timestamp of the latest entry in the stale records. the stock site appears to use the browser
- // clock, but this isn't reliable. ideally the data set should include it's retrieval timestamp, set by the
- // server, for use here. a good approximation is the highest timestamp of all entities
-
- for (var i in stale.gameEntities) {
- var ent = stale.gameEntities[i];
- if (lastTimestamp===undefined || ent[1] > lastTimestamp) {
- lastTimestamp = ent[1];
- }
- }
-
-console.log('stale tile '+tile_id+': newest mtime '+lastTimestamp+(lastTimestamp?' '+new Date(lastTimestamp).toString():''));
- if (lastTimestamp) {
- // we can issue a useful delta request - store the previous data, as we can't rely on the cache still having it later
- this.staleTileData[tile_id] = stale;
- boundsParams.timestampMs = lastTimestamp;
- }
- }
-*/
-
- this.tileBounds[tile_id] = boundsParams;
+ this.queuedTiles[tile_id] = tile_id;
this.requestedTileCount += 1;
}
}
@@ -305,7 +265,7 @@ console.log('stale tile '+tile_id+': newest mtime '+lastTimestamp+(lastTimestamp
console.log ('done request preperation (cleared out-of-bounds and invalid for zoom, and rendered cached data)');
- if (Object.keys(this.tileBounds).length > 0) {
+ if (Object.keys(this.queuedTiles).length > 0) {
// queued requests - don't start processing the download queue immediately - start it after a short delay
this.delayProcessRequestQueue (this.DOWNLOAD_DELAY,true);
} else {
@@ -326,7 +286,7 @@ window.MapDataRequest.prototype.delayProcessRequestQueue = function(seconds,isFi
window.MapDataRequest.prototype.processRequestQueue = function(isFirstPass) {
// if nothing left in the queue, end the render. otherwise, send network requests
- if (Object.keys(this.tileBounds).length == 0) {
+ if (Object.keys(this.queuedTiles).length == 0) {
this.render.endRenderPass();
@@ -354,7 +314,7 @@ window.MapDataRequest.prototype.processRequestQueue = function(isFirstPass) {
// create a list of tiles that aren't requested over the network
var pendingTiles = [];
- for (var id in this.tileBounds) {
+ for (var id in this.queuedTiles) {
if (!(id in this.requestedTiles) ) {
pendingTiles.push(id);
}
@@ -404,24 +364,23 @@ window.MapDataRequest.prototype.processRequestQueue = function(isFirstPass) {
window.MapDataRequest.prototype.sendTileRequest = function(tiles) {
- var boundsParamsList = [];
+ var tilesList = [];
for (var i in tiles) {
var id = tiles[i];
this.debugTiles.setState (id, 'requested');
- this.requestedTiles[id] = { staleData: this.staleTileData[id] };
+ this.requestedTiles[id] = true;
- var boundsParams = this.tileBounds[id];
- if (boundsParams) {
- boundsParamsList.push (boundsParams);
+ if (id in this.queuedTiles) {
+ tilesList.push (id);
} else {
- console.warn('failed to find bounds for tile id '+id);
+ console.warn('no queue entry for tile id '+id);
}
}
- var data = { boundsParamsList: boundsParamsList };
+ var data = { quadKeys: tilesList };
this.activeRequestCount += 1;
@@ -435,7 +394,7 @@ window.MapDataRequest.prototype.sendTileRequest = function(tiles) {
}
window.MapDataRequest.prototype.requeueTile = function(id, error) {
- if (id in this.tileBounds) {
+ if (id in this.queuedTiles) {
// tile is currently wanted...
// first, see if the error can be ignored due to retry counts
@@ -461,7 +420,7 @@ window.MapDataRequest.prototype.requeueTile = function(id, error) {
this.failedTileCount += 1;
}
// and delete from the pending requests...
- delete this.tileBounds[id];
+ delete this.queuedTiles[id];
} else {
// if false, was a 'timeout' or we're retrying, so unlimited retries (as the stock site does)
@@ -471,9 +430,8 @@ window.MapDataRequest.prototype.requeueTile = function(id, error) {
// proper queue, just an object with guid as properties. Javascript standards don't guarantee the order of properties
// within an object. however, all current browsers do keep property order, and new properties are added at the end.
// therefore, delete and re-add the requeued tile and it will be added to the end of the queue
- var boundsData = this.tileBounds[id];
- delete this.tileBounds[id];
- this.tileBounds[id] = boundsData;
+ delete this.queuedTiles[id];
+ this.queuedTiles[id] = id;
}
} // else the tile wasn't currently wanted (an old non-cancelled request) - ignore
@@ -525,57 +483,17 @@ window.MapDataRequest.prototype.handleResponse = function (data, tiles, success)
// no error for this data tile - process it
successTiles.push (id);
- var stale = this.requestedTiles[id].staleData;
- if (stale) {
-//NOTE: currently this code path won't be used, as we never set the staleData to anything other than 'undefined'
- // we have stale data. therefore, a delta request was made for this tile. we need to merge the results with
- // the existing stale data before proceeding
-
- var dataObj = {};
- // copy all entities from the stale data...
- for (var i in stale.gameEntities||[]) {
- var ent = stale.gameEntities[i];
- dataObj[ent[0]] = { timestamp: ent[1], data: ent[2] };
- }
-var oldEntityCount = Object.keys(dataObj).length;
- // and remove any entities in the deletedEntnties list
- for (var i in val.deletedEntities||[]) {
- var guid = val.deletedEntities[i];
- delete dataObj[guid];
- }
-var oldEntityCount2 = Object.keys(dataObj).length;
- // then add all entities from the new data
- for (var i in val.gameEntities||[]) {
- var ent = val.gameEntities[i];
- dataObj[ent[0]] = { timestamp: ent[1], data: ent[2] };
- }
-var newEntityCount = Object.keys(dataObj).length;
-console.log('processed delta mapData request:'+id+': '+oldEntityCount+' original entities, '+oldEntityCount2+' after deletion, '+val.gameEntities.length+' entities in the response');
-
- // now reconstruct a new gameEntities array in val, with the updated data
- val.gameEntities = [];
- for (var guid in dataObj) {
- var ent = [guid, dataObj[guid].timestamp, dataObj[guid].data];
- val.gameEntities.push(ent);
- }
-
- // we can leave the returned 'deletedEntities' data unmodified - it's not critial to how IITC works anyway
-
- // also delete any staleTileData entries for this tile - no longer required
- delete this.staleTileData[id];
- }
-
// store the result in the cache
this.cache && this.cache.store (id, val);
// if this tile was in the render list, render it
// (requests aren't aborted when new requests are started, so it's entirely possible we don't want to render it!)
- if (id in this.tileBounds) {
- this.debugTiles.setState (id, stale?'ok-delta':'ok');
+ if (id in this.queuedTiles) {
+ this.debugTiles.setState (id, 'ok');
this.render.processTileData (val);
- delete this.tileBounds[id];
+ delete this.queuedTiles[id];
this.successTileCount += 1;
} // else we don't want this tile (from an old non-cancelled request) - ignore
diff --git a/code/utils_misc.js b/code/utils_misc.js
index f41755e5..5ca68549 100644
--- a/code/utils_misc.js
+++ b/code/utils_misc.js
@@ -129,104 +129,46 @@ window.digits = function(d) {
window.requestParameterMunges = [
// now obsolete (they don't have some of the new parameters) munge sets deleted
-
- // set 3 - in the update of 2013-09-30 (addition of 'alerts' chat tab)
+ // set 6 - 2013-10-29
{
- 'dashboard.getGameScore': 'fhlzntzkl5v7hcfh', // GET_GAME_SCORE
- 'dashboard.getPaginatedPlextsV2': 'wzuitnswoda7w028', // GET_PAGINATED_PLEXTS
- 'dashboard.getThinnedEntitiesV4': 'scgrm4lf2371esgw', // GET_THINNED_ENTITIES
- 'dashboard.getPlayersByGuids': '81l6usczczoi3lfi', // LOOKUP_PLAYERS
- 'dashboard.redeemReward': '8kop2koeld9b4c26', // REDEEM_REWARD
- 'dashboard.sendInviteEmail': 't0ccodsm1nuo5uso', // SEND_INVITE_EMAIL
- 'dashboard.sendPlext': 'k04cfjwwsg3h3827', // SEND_PLEXT
+ 'dashboard.getGameScore': 'vzjhib746rvkre04', // GET_GAME_SCORE
+ 'dashboard.getPaginatedPlextsV2': 'gqa96zhqpddtfmkl', // GET_PAGINATED_PLEXTS
+ 'dashboard.getThinnedEntitiesV4': '18lmw7lytgxji0dk', // GET_THINNED_ENTITIES
+ 'dashboard.getPlayersByGuids': 'emb5xrj8rav1i0be', // LOOKUP_PLAYERS
+ 'dashboard.redeemReward': '4xqof5pldqab63rb', // REDEEM_REWARD
+ 'dashboard.sendInviteEmail': 'yq5wxjlnud0tj6hu', // SEND_INVITE_EMAIL
+ 'dashboard.sendPlext': 'e1ipqdxjlwd3l7zb', // SEND_PLEXT
- method: '22ux2z96jwq5zn78',
- version: 'kf6hgl9yau03ws0o', //guessed parameter name - only seen munged
- version_parameter: '4608f4356a6f55690f127fb542f557f98de66169', // passed as the value to the above parameter
- boundsParamsList: '29t16cmsn6l3r2xg',
- id: '7rogqhp5pzcqobcw',
- minLatE6: 'yzbnp7z9bd28p0yr',
- minLngE6: '2pdhntvo85cd90bw',
- maxLatE6: 'c4ivr013h4dr68pd',
- maxLngE6: '4p8oorcrwalc1mzf',
- timestampMs: 'vd2rsa9v6f8q606s',
- qk: 'cblh9xe0bgwjy5ij',
- desiredNumItems: '3ymaq7slb165porj',
- minTimestampMs: 's9jf2seni33y3gyu',
- maxTimestampMs: '2kh3vti98rhp3g29',
- chatTab: '7n7ocqfq1p18352b', //guessed parameter name - only seen munged
- ascendingTimestampOrder: 'p88a2ztchtjhiazl',
- message: 'e8qm0kptw2trrcrw',
- latE6: 'fja1phtsqxm71dqm',
- lngE6: 'iut1tb7c0x726hwn',
- guids: '5hyiwhwc0jyljvro',
- inviteeEmailAddress: 's9z6zt03eymzxhkj',
- },
+ // common parameters
+ method: 'wg7gyxoanqc1si5r',
+ version: 'adlo9o4kjvho5q94', //guessed parameter name - only seen munged
+ version_parameter: '56036a6497ea344a9fffa38b171a77c092c1f220', // passed as the value to the above parameter
- // set 4 - second update of 2013-09-30
- {
- 'dashboard.getGameScore': 'ija9jgrf5hj7wm9r', // GET_GAME_SCORE
- 'dashboard.getPaginatedPlextsV2': '0elftx739mkbzi1b', // GET_PAGINATED_PLEXTS
- 'dashboard.getThinnedEntitiesV4': 'prv0ez8cbsykh63g', // GET_THINNED_ENTITIES
- 'dashboard.getPlayersByGuids': 'i0lxy6nc695z9ka3', // LOOKUP_PLAYERS
- 'dashboard.redeemReward': '376oivna8rf8qbfj', // REDEEM_REWARD
- 'dashboard.sendInviteEmail': '96y930v5q96nrcrw', // SEND_INVITE_EMAIL
- 'dashboard.sendPlext': 'c04kceytofuqvyqg', // SEND_PLEXT
+ // GET_THINNED_ENTITIES
+ quadKeys: '6vcl0ivqz4aj5sfu', //guessed parameter name - only seen munged
- method: '9we4b31i48ui4sdm',
- version: 'q402kn5zqisuo1ym', //guessed parameter name - only seen munged
- version_parameter: 'dbad4485024d446ae946e3d287b5d640029ef3e3', // passed as the value to the above parameter
- boundsParamsList: '3r5ctyvc2f653zjd',
- id: 'izey8ciqg2dz2oqc',
- minLatE6: 'cein0n4jrifa7ui2',
- minLngE6: 'lbd1juids3johtdo',
- maxLatE6: 'h4kyot9kmvd3g284',
- maxLngE6: 'sbci6jjc2d5g9uy4',
- timestampMs: '2wurn9giagbvv6bt',
- qk: 'hq73mwpjqyvcp6ul',
- desiredNumItems: 'kyo6vh5n58hmrnua',
- minTimestampMs: 'hu4swdftcp7mvkdi',
- maxTimestampMs: 'ly6ylae5lv1z9072',
- chatTab: 'q5kxut5rmbtlqbf9', //guessed parameter name - only seen munged
- ascendingTimestampOrder: 'hvfd0io35rahwjgr',
- message: 'z4hf7tzl27o14455',
- latE6: 'zyzh3bdxyd47vk1x',
- lngE6: 'n5d1f8pql51t641x',
- guids: 'gl16ehqoc3i3oi07',
- inviteeEmailAddress: 'orc9ufg7rp7g1y9j',
- },
+ // GET_PAGINATED_PLEXTS
+ desiredNumItems: '6jd5b49wn748diye',
+ minLatE6: '891ebsryg45b8cxb',
+ minLngE6: 'mvepdcx1k6noya15',
+ maxLatE6: 's3rh3fhji5mcjlof',
+ maxLngE6: 'yqdgfuukrxj8byzj',
+ minTimestampMs: 'btf0kpztxrkt6sl6',
+ maxTimestampMs: 'hg8vhtehxf53n5cu',
+ chatTab: '6bk9rmebtk1ux6da', //guessed parameter name - only seen munged
+ ascendingTimestampOrder: '4zw3v6xwp117r47w',
- // set 5 - second update of 2013-10-16
- {
- 'dashboard.getGameScore': '3b48kl956b33brrl', // GET_GAME_SCORE
- 'dashboard.getPaginatedPlextsV2': 'h785pmet6wrx6xoa', // GET_PAGINATED_PLEXTS
- 'dashboard.getThinnedEntitiesV4': '4gux7b0n3euu7e8y', // GET_THINNED_ENTITIES
- 'dashboard.getPlayersByGuids': 'nqm1kocgzspecpzv', // LOOKUP_PLAYERS
- 'dashboard.redeemReward': 'g618n6peb74u2ae9', // REDEEM_REWARD
- 'dashboard.sendInviteEmail': 'bsl4280bm39bkl3a', // SEND_INVITE_EMAIL
- 'dashboard.sendPlext': 'jym2hbw15i6uru7g', // SEND_PLEXT
+ // SEND_PLEXT
+ message: '55vpsci0hji0ai5x',
+ latE6: 'lyhrt4miuwc7w29d',
+ lngE6: 'c1yl2qmzfu5j23ao',
+// chatTab: '6bk9rmebtk1ux6da', //guessed parameter name - only seen munged
- method: 'g9cmy5g6vpxpmcxz',
- version: 'blq7574e6kkg0fig', //guessed parameter name - only seen munged
- version_parameter: '465c62b22b3bc9ecae01e08b30703752186a1dc9', // passed as the value to the above parameter
- boundsParamsList: '45k478vh10jt1ik7',
- id: '3eh1ynwxjy8c8rd5',
- minLatE6: 'krpywcgq1voq71z3',
- minLngE6: 'yo6lte88zvoneqi6',
- maxLatE6: 'dncli54tfafmtk6y',
- maxLngE6: '76pq437r7vm3osx9',
- timestampMs: '2zlgpsg1x6i9720s',
- qk: 'pzejivoj28p6kkry',
- desiredNumItems: 'u3uxpkqd4pn37ydn',
- minTimestampMs: 'msw5gcxhuuk46rb2',
- maxTimestampMs: 'bps0ekgdzakdfvr0',
- chatTab: 'pm4fm8bjvotjm30h', //guessed parameter name - only seen munged
- ascendingTimestampOrder: '7qp8gv50ogelh7cs',
- message: 'y599irwyfs45adp4',
- latE6: '19ko11fmx32sjfqk',
- lngE6: 'i8yjq6v2mjhze29d',
- guids: 'szebfshb9f3uo2h9',
- inviteeEmailAddress: 'qq4t7lhqphq7wqvh',
+ // LOOKUP_PLAYERS
+ guids: 'k76phw8ey9z21z7c',
+
+ // SEND_INVITE_EMAIL
+ inviteeEmailAddress: 'x16pe9u4i8bidbi2',
},
];
@@ -234,22 +176,30 @@ window.activeRequestMungeSet = undefined;
// attempt to guess the munge set in use, by looking therough the functions of the stock intel page for one of the munged params
window.detectActiveMungeSet = function() {
- if (window.requestParameterMunges.length == 1) {
- // no point in searching through the code when there's only one set in use
- window.activeRequestMungeSet = 0;
- return;
- }
// try and find the stock page functions
// FIXME? revert to searching through all the code? is that practical?
- var stockFunc = nemesis.dashboard.network.DataFetcher.prototype.sendRequest_.toString()
- for (var i in window.requestParameterMunges) {
- if (stockFunc.indexOf (window.requestParameterMunges[i]['method']) >= 0) {
- console.log('IITC: found request munge set index '+i+' in stock intel function nemesis.dashboard.network.DataFetcher.prototype.sendRequest_');
- window.activeRequestMungeSet = i;
+ var stockFunc;
+ try {
+ stockFunc = nemesis.dashboard.network.XhrController.prototype.sendRequest.toString();
+ } catch(e) {
+ try {
+ stockFunc = nemesis.dashboard.network.DataFetcher.prototype.sendRequest_.toString();
+ } catch(e) {
}
}
+ if(stockFunc) {
+ for (var i in window.requestParameterMunges) {
+ if (stockFunc.indexOf (window.requestParameterMunges[i]['method']) >= 0) {
+ console.log('IITC: found request munge set index '+i+' in stock intel site');
+ window.activeRequestMungeSet = i;
+ }
+ }
+ } else {
+ console.error('IITC: failed to find the stock site function for detecting munge set');
+ }
+
if (window.activeRequestMungeSet===undefined) {
console.error('IITC: failed to find request munge set - IITC will likely fail');
window.activeRequestMungeSet = 0;
From a428dcf54d72e9c51d5fd54d5e85831ff52aa8e4 Mon Sep 17 00:00:00 2001
From: Jon Atkins
Date: Tue, 29 Oct 2013 20:41:36 +0000
Subject: [PATCH 67/67] add comment about potential improvement to request
handling
---
code/map_data_request.js | 3 +++
1 file changed, 3 insertions(+)
diff --git a/code/map_data_request.js b/code/map_data_request.js
index 1c112a88..ae53421e 100644
--- a/code/map_data_request.js
+++ b/code/map_data_request.js
@@ -501,6 +501,9 @@ window.MapDataRequest.prototype.handleResponse = function (data, tiles, success)
}
+ // TODO? check for any requested tiles in 'tiles' not being mentioned in the response - and handle as if it's a 'timeout'?
+
+
window.runHooks('requestFinished', {success: true});
}