Merge branch 'gh-pages' of https://github.com/breunigs/ingress-intel-total-conversion into gh-pages
This commit is contained in:
22
NEWS.md
22
NEWS.md
@ -1,6 +1,26 @@
|
|||||||
CHANGES IN 0.3
|
CHANGES in 0.4
|
||||||
==============
|
==============
|
||||||
|
|
||||||
|
- Feature: display resonator charge percentage in tooltip (by Xelio)
|
||||||
|
- Feature: display resonator level in reso bar (by JasonMillward)
|
||||||
|
- Feature: portals may be filtered by level (using the layer switcher)
|
||||||
|
- Feature: build script in Python (by epf)
|
||||||
|
- Feature: plugins
|
||||||
|
- Change: Portal mods are colored according to their rare-ness (by OshiHidra)
|
||||||
|
- Change: nick highlight in chat now case-insensitive
|
||||||
|
- Change: +/- zoom buttons visible by default now
|
||||||
|
- Bugfix: title bar text broken
|
||||||
|
- Bugfix: rename cardinal to octant (by mledoze)
|
||||||
|
- Bugfix: Chat display broken in Opera
|
||||||
|
- Bugfix: Chat tab completion in Chrome
|
||||||
|
- Bugfix: wrong timestamps displayed in chat input bar
|
||||||
|
- Bugfix: don’t autobuild when git meta info changes (by ZauberNerd)
|
||||||
|
- Bugfix: resistance owned portals had wrong border when viewing the full image
|
||||||
|
|
||||||
|
|
||||||
|
CHANGES IN 0.3
|
||||||
|
--------------
|
||||||
|
|
||||||
- Feature: more info for shields in tooltip (by JasonMillward)
|
- Feature: more info for shields in tooltip (by JasonMillward)
|
||||||
- Feature: pretty display for redeemed codes (by integ3r)
|
- Feature: pretty display for redeemed codes (by integ3r)
|
||||||
- Change: Portal details are now scrollable when height is too small
|
- Change: Portal details are now scrollable when height is too small
|
||||||
|
30
README.md
30
README.md
@ -31,20 +31,14 @@ Features
|
|||||||
- may toggle portals/links/fields
|
- may toggle portals/links/fields
|
||||||
- hack range (yellow circle) and link range (large red circle) for portals. Click on the range link in the sidebar to zoom to link range.
|
- hack range (yellow circle) and link range (large red circle) for portals. Click on the range link in the sidebar to zoom to link range.
|
||||||
- double clicking a portal zooms in and focuses it
|
- double clicking a portal zooms in and focuses it
|
||||||
- display of XM and AP rewards for redeemed passcodes by [Dovahkiin](http://bit.ly/mjcode)
|
- display of XM and AP rewards for redeemed passcodes
|
||||||
|
|
||||||
|
|
||||||
Missing
|
|
||||||
-------
|
|
||||||
|
|
||||||
(and probably not going to implement it)
|
|
||||||
|
|
||||||
- logout link (but you wouldn’t want to *quit*, would you?), privacy link, etc.
|
|
||||||
|
|
||||||
|
|
||||||
Install
|
Install
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
Current version is 0.4. See [NEWS.md](https://github.com/breunigs/ingress-intel-total-conversion/blob/gh-pages/NEWS.md) for details.
|
||||||
|
|
||||||
[**INSTALL**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/total-conversion-build.user.js)
|
[**INSTALL**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/total-conversion-build.user.js)
|
||||||
|
|
||||||
|
|
||||||
@ -69,7 +63,6 @@ Install
|
|||||||
[**INSTALL**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/total-conversion-build.user.js)
|
[**INSTALL**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/total-conversion-build.user.js)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Contributing
|
Contributing
|
||||||
------------
|
------------
|
||||||
|
|
||||||
@ -81,16 +74,23 @@ Please do!
|
|||||||
Contributors
|
Contributors
|
||||||
------------
|
------------
|
||||||
|
|
||||||
- [integ3r](https://github.com/integ3r)
|
[Bananeweizen](https://github.com/Bananeweizen),
|
||||||
- [Bananeweizen](https://github.com/Bananeweizen)
|
[cmrn](https://github.com/cmrn),
|
||||||
- [epf](https://github.com/epf)
|
[epf](https://github.com/epf),
|
||||||
- [JasonMillward](https://github.com/JasonMillward)
|
[integ3r](https://github.com/integ3r),
|
||||||
|
[JasonMillward](https://github.com/JasonMillward),
|
||||||
|
[mledoze](https://github.com/mledoze),
|
||||||
|
[OshiHidra](https://github.com/OshiHidra),
|
||||||
|
[Scrool](https://github.com/Scrool),
|
||||||
|
[sorgo](https://github.com/sorgo),
|
||||||
|
[Xelio](https://github.com/Xelio),
|
||||||
|
[ZauberNerd](https://github.com/ZauberNerd)
|
||||||
|
|
||||||
|
|
||||||
Hacking
|
Hacking
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Execute `./build.rb` or `./build.py` to effectively concatenate `main.js` with all the files in `code/`. It generates the user script which may be installed into your browser. Do not modify `total-conversion-build.user.js` manually, because it is automatically generated. Please don’t include it in patches either, because it makes merging harder. Instead, modify the files in `code/` and have that file built for you.
|
Execute `./build.py` to effectively concatenate `main.js` with all the files in `code/`. It generates the user script which may be installed into your browser. Do not modify `total-conversion-build.user.js` manually, because it is automatically generated. Please don’t include it in patches either, because it makes merging harder. Instead, modify the files in `code/` and have that file built for you.
|
||||||
|
|
||||||
`style.css` contains most styles required for the user-script. The extra ones can be found in `code/boot.js#window.setupStyles`. Only CSS rules that depend on config variables should be defined there.
|
`style.css` contains most styles required for the user-script. The extra ones can be found in `code/boot.js#window.setupStyles`. Only CSS rules that depend on config variables should be defined there.
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
./build.rb
|
./build.py
|
||||||
FORMAT=$(echo "\033[1;33m%w%f\033[0m written")
|
FORMAT=$(echo "\033[1;33m%w%f\033[0m written")
|
||||||
while inotifywait -qre close_write --exclude "total-conversion-build.user.js|.git*" --format "$FORMAT" .
|
while inotifywait -qre close_write --exclude "total-conversion-build.user.js|.git*" --format "$FORMAT" .
|
||||||
do
|
do
|
||||||
./build.rb
|
./build.py
|
||||||
done
|
done
|
||||||
|
6
build.py
Normal file → Executable file
6
build.py
Normal file → Executable file
@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import glob
|
import glob
|
||||||
import time
|
import time
|
||||||
|
|
||||||
def readfile(fn):
|
def readfile(fn):
|
||||||
with open(fn, 'Ur') as f:
|
with open(fn, 'Ur', encoding='utf8') as f:
|
||||||
return f.read()
|
return f.read()
|
||||||
|
|
||||||
c = '\n\n'.join(map(readfile, glob.glob('code/*')))
|
c = '\n\n'.join(map(readfile, glob.glob('code/*')))
|
||||||
@ -14,7 +14,7 @@ m = m.split('@@INJECTHERE@@')
|
|||||||
m.insert(1, c)
|
m.insert(1, c)
|
||||||
t = '\n\n'.join(m)
|
t = '\n\n'.join(m)
|
||||||
|
|
||||||
with open('total-conversion-build.user.js', 'w') as f:
|
with open('total-conversion-build.user.js', 'w', encoding='utf8') as f:
|
||||||
f.write(t)
|
f.write(t)
|
||||||
|
|
||||||
# vim: ai si ts=4 sw=4 sts=4 et
|
# vim: ai si ts=4 sw=4 sts=4 et
|
||||||
|
9
build.rb
9
build.rb
@ -1,9 +0,0 @@
|
|||||||
#!/usr/bin/env ruby
|
|
||||||
# encoding: utf-8
|
|
||||||
|
|
||||||
c = Dir.glob('code/*').map { |f| File.read(f) }
|
|
||||||
n = Time.now.strftime('%Y-%m-%d-%H%M%S')
|
|
||||||
m = File.read('main.js').gsub('@@BUILDDATE@@', n)
|
|
||||||
m = m.split('@@INJECTHERE@@')
|
|
||||||
t = m.insert(1, c).flatten.join("\n\n")
|
|
||||||
File.open('total-conversion-build.user.js', 'w') {|f| f.write(t) }
|
|
60
code/boot.js
60
code/boot.js
@ -27,16 +27,17 @@ window.setupLargeImagePreview = function() {
|
|||||||
|
|
||||||
window.setupStyles = function() {
|
window.setupStyles = function() {
|
||||||
$('head').append('<style>' +
|
$('head').append('<style>' +
|
||||||
[ '#map { margin-right: '+(SIDEBAR_WIDTH+2)+'px } ',
|
[ '#largepreview.enl img { border:2px solid '+COLORS[TEAM_ENL]+'; } ',
|
||||||
'#largepreview.enl img { border:2px solid '+COLORS[TEAM_ENL]+'; } ',
|
|
||||||
'#largepreview.res img { border:2px solid '+COLORS[TEAM_RES]+'; } ',
|
'#largepreview.res img { border:2px solid '+COLORS[TEAM_RES]+'; } ',
|
||||||
'#largepreview.none img { border:2px solid '+COLORS[TEAM_NONE]+'; } ',
|
'#largepreview.none img { border:2px solid '+COLORS[TEAM_NONE]+'; } ',
|
||||||
'#chatcontrols { bottom: '+(CHAT_SHRINKED+24)+'px; }',
|
'#chatcontrols { bottom: '+(CHAT_SHRINKED+24)+'px; }',
|
||||||
'#chat { height: '+CHAT_SHRINKED+'px; } ',
|
'#chat { height: '+CHAT_SHRINKED+'px; } ',
|
||||||
'#updatestatus { width:'+(SIDEBAR_WIDTH-2*4)+'px; } ',
|
'.leaflet-right { margin-right: '+(SIDEBAR_WIDTH+1)+'px } ',
|
||||||
'#sidebar { width:'+(SIDEBAR_WIDTH + HIDDEN_SCROLLBAR_ASSUMED_WIDTH + 2 /*border*/)+'px; } ',
|
'#updatestatus { width:'+(SIDEBAR_WIDTH-2*4+1)+'px; } ',
|
||||||
|
'#sidebar { width:'+(SIDEBAR_WIDTH + HIDDEN_SCROLLBAR_ASSUMED_WIDTH + 1 /*border*/)+'px; } ',
|
||||||
|
'#sidebartoggle { right:'+SIDEBAR_WIDTH+'px; } ',
|
||||||
'#scrollwrapper { width:'+(SIDEBAR_WIDTH + 2*HIDDEN_SCROLLBAR_ASSUMED_WIDTH)+'px; right:-'+(2*HIDDEN_SCROLLBAR_ASSUMED_WIDTH-2)+'px } ',
|
'#scrollwrapper { width:'+(SIDEBAR_WIDTH + 2*HIDDEN_SCROLLBAR_ASSUMED_WIDTH)+'px; right:-'+(2*HIDDEN_SCROLLBAR_ASSUMED_WIDTH-2)+'px } ',
|
||||||
'#sidebar input, h2, #updatestatus { width:'+(SIDEBAR_WIDTH - 2*4)+'px !important } ',
|
'#sidebar input, h2 { width:'+(SIDEBAR_WIDTH - 2*4)+'px !important } ',
|
||||||
'#sidebar > *, #gamestat span, .imgpreview img { width:'+SIDEBAR_WIDTH+'px; }'].join("\n")
|
'#sidebar > *, #gamestat span, .imgpreview img { width:'+SIDEBAR_WIDTH+'px; }'].join("\n")
|
||||||
+ '</style>');
|
+ '</style>');
|
||||||
}
|
}
|
||||||
@ -93,7 +94,22 @@ window.setupMap = function() {
|
|||||||
map.attributionControl.setPrefix('');
|
map.attributionControl.setPrefix('');
|
||||||
// listen for changes and store them in cookies
|
// listen for changes and store them in cookies
|
||||||
map.on('moveend', window.storeMapPosition);
|
map.on('moveend', window.storeMapPosition);
|
||||||
map.on('zoomend', window.storeMapPosition);
|
map.on('zoomend', function() {
|
||||||
|
window.storeMapPosition;
|
||||||
|
|
||||||
|
// remove all resonators if zoom out to < RESONATOR_DISPLAY_ZOOM_LEVEL
|
||||||
|
if(isResonatorsShow()) return;
|
||||||
|
for(var i = 1; i < portalsLayers.length; i++) {
|
||||||
|
portalsLayers[i].eachLayer(function(item) {
|
||||||
|
var itemGuid = item.options.guid;
|
||||||
|
// check if 'item' is a resonator
|
||||||
|
if(getTypeByGuid(itemGuid) != TYPE_RESONATOR) return true;
|
||||||
|
portalsLayers[i].removeLayer(item);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Remove all resonators');
|
||||||
|
});
|
||||||
$("[name='leaflet-base-layers']").change(function () {
|
$("[name='leaflet-base-layers']").change(function () {
|
||||||
writeCookie('ingress.intelmap.type', $(this).parent().index());
|
writeCookie('ingress.intelmap.type', $(this).parent().index());
|
||||||
});
|
});
|
||||||
@ -154,6 +170,24 @@ window.setupPlayerStat = function() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.setupSidebarToggle = function() {
|
||||||
|
$('#sidebartoggle').on('click', function() {
|
||||||
|
var toggle = $('#sidebartoggle');
|
||||||
|
var sidebar = $('#sidebar');
|
||||||
|
if(sidebar.is(':visible')) {
|
||||||
|
sidebar.hide();
|
||||||
|
$('.leaflet-right').css('margin-right','0');
|
||||||
|
toggle.html('◢<br>◥');
|
||||||
|
toggle.css('right', '0');
|
||||||
|
} else {
|
||||||
|
sidebar.show();
|
||||||
|
$('.leaflet-right').css('margin-right', SIDEBAR_WIDTH+1+'px');
|
||||||
|
toggle.html('◣<br>◤');
|
||||||
|
toggle.css('right', SIDEBAR_WIDTH+1+'px');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// BOOTING ///////////////////////////////////////////////////////////
|
// BOOTING ///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -164,6 +198,7 @@ function boot() {
|
|||||||
window.setupGeosearch();
|
window.setupGeosearch();
|
||||||
window.setupRedeem();
|
window.setupRedeem();
|
||||||
window.setupLargeImagePreview();
|
window.setupLargeImagePreview();
|
||||||
|
window.setupSidebarToggle();
|
||||||
window.updateGameScore();
|
window.updateGameScore();
|
||||||
window.setupPlayerStat();
|
window.setupPlayerStat();
|
||||||
window.chat.setup();
|
window.chat.setup();
|
||||||
@ -176,6 +211,11 @@ function boot() {
|
|||||||
window.PLAYER['nickMatcher'] = new RegExp('\\b('+n+')\\b', 'ig');
|
window.PLAYER['nickMatcher'] = new RegExp('\\b('+n+')\\b', 'ig');
|
||||||
|
|
||||||
$('#sidebar').show();
|
$('#sidebar').show();
|
||||||
|
|
||||||
|
if(window.bootPlugins)
|
||||||
|
$.each(window.bootPlugins, function(ind, ref) { ref(); });
|
||||||
|
|
||||||
|
window.iitcLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is the minified load.js script that allows us to easily load
|
// this is the minified load.js script that allows us to easily load
|
||||||
@ -187,10 +227,12 @@ function asyncLoadScript(a){return function(b,c){var d=document.createElement("s
|
|||||||
|
|
||||||
// modified version of https://github.com/shramov/leaflet-plugins. Also
|
// modified version of https://github.com/shramov/leaflet-plugins. Also
|
||||||
// contains the default Ingress map style.
|
// contains the default Ingress map style.
|
||||||
var LLGMAPS = 'http://breunigs.github.com/ingress-intel-total-conversion/leaflet_google.js';
|
var LLGMAPS = 'http://breunigs.github.com/ingress-intel-total-conversion/external/leaflet_google.js';
|
||||||
var JQUERY = 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js';
|
var JQUERY = 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js';
|
||||||
var LEAFLET = 'http://cdn.leafletjs.com/leaflet-0.5/leaflet.js';
|
var LEAFLET = 'http://cdn.leafletjs.com/leaflet-0.5/leaflet.js';
|
||||||
var AUTOLINK = 'http://raw.github.com/bryanwoods/autolink-js/master/autolink.js';
|
var AUTOLINK = 'http://breunigs.github.com/ingress-intel-total-conversion/external/autolink.js';
|
||||||
|
|
||||||
// after all scripts have loaded, boot the actual app
|
// after all scripts have loaded, boot the actual app
|
||||||
load(JQUERY, LEAFLET, AUTOLINK).then(LLGMAPS).thenRun(boot);
|
load(JQUERY, LEAFLET, AUTOLINK).then(LLGMAPS).onError(function (err) {
|
||||||
|
alert('Could not all resources, the script likely won’t work.\n\nIf this happend the first time for you, it’s probably a temporary issue. Just wait a bit and try again.\n\nIf you installed the script for the first time and this happens:\n– try disabling NoScript if you have it installed\n– press CTRL+SHIFT+K in Firefox or CTRL+SHIFT+I in Chrome/Opera and reload the page. Additional info may be available in the console.\n– Open an issue at https://github.com/breunigs/ingress-intel-total-conversion/issues');
|
||||||
|
}).thenRun(boot);
|
||||||
|
@ -456,7 +456,7 @@ window.chat.renderMsg = function(msg, nick, time, team) {
|
|||||||
var t = '<time title="'+tb+'" data-timestamp="'+time+'">'+ta+'</time>';
|
var t = '<time title="'+tb+'" data-timestamp="'+time+'">'+ta+'</time>';
|
||||||
var s = 'style="color:'+COLORS[team]+'"';
|
var s = 'style="color:'+COLORS[team]+'"';
|
||||||
var title = nick.length >= 8 ? 'title="'+nick+'" class="help"' : '';
|
var title = nick.length >= 8 ? 'title="'+nick+'" class="help"' : '';
|
||||||
return '<p>'+t+'<mark '+s+'>'+nick+'</mark><span>'+msg+'</span></p>';
|
return '<p>'+t+'<span class="invisibleseparator"> <</span><mark '+s+'>'+nick+'</mark><span class="invisibleseparator">> </span><span>'+msg+'</span></p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -469,14 +469,16 @@ window.chat.getActive = function() {
|
|||||||
window.chat.toggle = function() {
|
window.chat.toggle = function() {
|
||||||
var c = $('#chat, #chatcontrols');
|
var c = $('#chat, #chatcontrols');
|
||||||
if(c.hasClass('expand')) {
|
if(c.hasClass('expand')) {
|
||||||
$('#chatcontrols a:first').text('expand');
|
$('#chatcontrols a:first').text('◢◣');
|
||||||
c.removeClass('expand');
|
c.removeClass('expand');
|
||||||
var div = $('#chat > div:visible');
|
var div = $('#chat > div:visible');
|
||||||
div.data('ignoreNextScroll', true);
|
div.data('ignoreNextScroll', true);
|
||||||
div.scrollTop(99999999); // scroll to bottom
|
div.scrollTop(99999999); // scroll to bottom
|
||||||
|
$('.leaflet-control').css('margin-left', '13px');
|
||||||
} else {
|
} else {
|
||||||
$('#chatcontrols a:first').text('shrink');
|
$('#chatcontrols a:first').text('◥◤');
|
||||||
c.addClass('expand');
|
c.addClass('expand');
|
||||||
|
$('.leaflet-control').css('margin-left', '720px');
|
||||||
chat.needMoreMessages();
|
chat.needMoreMessages();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
47
code/hooks.js
Normal file
47
code/hooks.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// PLUGIN HOOKS ////////////////////////////////////////////////////////
|
||||||
|
// Plugins may listen to any number of events by specifying the name of
|
||||||
|
// the event to listen to and handing a function that should be exe-
|
||||||
|
// cuted when an event occurs. Callbacks will receive additional data
|
||||||
|
// the event created as their first parameter. The value is always a
|
||||||
|
// hash that contains more details.
|
||||||
|
//
|
||||||
|
// For example, this line will listen for portals to be added and print
|
||||||
|
// the data generated by the event to the console:
|
||||||
|
// window.addHook('portalAdded', function(data) { console.log(data) });
|
||||||
|
//
|
||||||
|
// Boot hook: booting is handled differently because IITC may not yet
|
||||||
|
// be available. Have a look at the plugins in plugins/. All
|
||||||
|
// code before “// PLUGIN START” and after “// PLUGIN END” os
|
||||||
|
// required to successfully boot the plugin.
|
||||||
|
//
|
||||||
|
// Here’s more specific information about each event:
|
||||||
|
// portalAdded: called when a portal has been received and is about to
|
||||||
|
// be added to its layer group. Note that this does NOT
|
||||||
|
// mean it is already visible or will be, shortly after.
|
||||||
|
// If a portal is added to a hidden layer it may never be
|
||||||
|
// shown at all. Injection point is in
|
||||||
|
// code/map_data.js#renderPortal near the end. Will hand
|
||||||
|
// the Leaflet CircleMarker for the portal in "portal" var.
|
||||||
|
|
||||||
|
window._hooks = {}
|
||||||
|
window.VALID_HOOKS = ['portalAdded'];
|
||||||
|
|
||||||
|
window.runHooks = function(event, data) {
|
||||||
|
if(VALID_HOOKS.indexOf(event) === -1) throw('Unknown event type: ' + event);
|
||||||
|
|
||||||
|
if(!_hooks[event]) return;
|
||||||
|
$.each(_hooks[event], function(ind, callback) {
|
||||||
|
callback(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
window.addHook = function(event, callback) {
|
||||||
|
if(VALID_HOOKS.indexOf(event) === -1) throw('Unknown event type: ' + event);
|
||||||
|
if(typeof callback !== 'function') throw('Callback must be a function.');
|
||||||
|
|
||||||
|
if(!_hooks[event])
|
||||||
|
_hooks[event] = [callback];
|
||||||
|
else
|
||||||
|
_hooks[event].push(callback);
|
||||||
|
}
|
258
code/map_data.js
258
code/map_data.js
@ -69,8 +69,16 @@ window.handleDataResponse = function(data, textStatus, jqXHR) {
|
|||||||
// to be in the foreground, or they cannot be clicked. See
|
// to be in the foreground, or they cannot be clicked. See
|
||||||
// https://github.com/Leaflet/Leaflet/issues/185
|
// https://github.com/Leaflet/Leaflet/issues/185
|
||||||
var ppp = [];
|
var ppp = [];
|
||||||
|
var p2f = {};
|
||||||
$.each(m, function(qk, val) {
|
$.each(m, function(qk, val) {
|
||||||
$.each(val.deletedGameEntityGuids, function(ind, guid) {
|
$.each(val.deletedGameEntityGuids, function(ind, guid) {
|
||||||
|
if(getTypeByGuid(guid) === TYPE_FIELD && window.fields[guid] !== undefined) {
|
||||||
|
$.each(window.fields[guid].options.vertices, function(ind, vertex) {
|
||||||
|
if(window.portals[vertex.guid] === undefined) return true;
|
||||||
|
fieldArray = window.portals[vertex.guid].options.portalV2.linkedFields;
|
||||||
|
fieldArray.splice($.inArray(guid, fieldArray), 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
window.removeByGuid(guid);
|
window.removeByGuid(guid);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -92,17 +100,34 @@ window.handleDataResponse = function(data, textStatus, jqXHR) {
|
|||||||
|
|
||||||
|
|
||||||
ppp.push(ent); // delay portal render
|
ppp.push(ent); // delay portal render
|
||||||
} else if(ent[2].edge !== undefined)
|
} else if(ent[2].edge !== undefined) {
|
||||||
renderLink(ent);
|
renderLink(ent);
|
||||||
else if(ent[2].capturedRegion !== undefined)
|
} else if(ent[2].capturedRegion !== undefined) {
|
||||||
|
$.each(ent[2].capturedRegion, function(ind, vertex) {
|
||||||
|
if(p2f[vertex.guid] === undefined)
|
||||||
|
p2f[vertex.guid] = new Array();
|
||||||
|
p2f[vertex.guid].push(ent[0]);
|
||||||
|
});
|
||||||
renderField(ent);
|
renderField(ent);
|
||||||
else
|
} else {
|
||||||
throw('Unknown entity: ' + JSON.stringify(ent));
|
throw('Unknown entity: ' + JSON.stringify(ent));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$.each(ppp, function(ind, portal) {
|
||||||
|
if(p2f[portal[0]] === undefined)
|
||||||
|
portal[2].portalV2['linkedFields'] = [];
|
||||||
|
else
|
||||||
|
portal[2].portalV2['linkedFields'] = $.unique(p2f[portal[0]]);
|
||||||
|
});
|
||||||
|
|
||||||
$.each(ppp, function(ind, portal) { renderPortal(portal); });
|
$.each(ppp, function(ind, portal) { renderPortal(portal); });
|
||||||
if(portals[selectedPortal]) portals[selectedPortal].bringToFront();
|
if(portals[selectedPortal]) {
|
||||||
|
try {
|
||||||
|
portals[selectedPortal].bringToFront();
|
||||||
|
} catch(e) { /* portal is now visible, catch Leaflet error */ }
|
||||||
|
}
|
||||||
|
|
||||||
if(portalInUrlAvailable) {
|
if(portalInUrlAvailable) {
|
||||||
renderPortalDetails(urlPortal);
|
renderPortalDetails(urlPortal);
|
||||||
@ -121,13 +146,16 @@ window.cleanUp = function() {
|
|||||||
var minlvl = getMinPortalLevel();
|
var minlvl = getMinPortalLevel();
|
||||||
for(var i = 0; i < portalsLayers.length; i++) {
|
for(var i = 0; i < portalsLayers.length; i++) {
|
||||||
// i is also the portal level
|
// i is also the portal level
|
||||||
portalsLayers[i].eachLayer(function(portal) {
|
portalsLayers[i].eachLayer(function(item) {
|
||||||
|
var itemGuid = item.options.guid;
|
||||||
|
// check if 'item' is a portal
|
||||||
|
if(getTypeByGuid(itemGuid) != TYPE_PORTAL) return true;
|
||||||
// portal must be in bounds and have a high enough level. Also don’t
|
// portal must be in bounds and have a high enough level. Also don’t
|
||||||
// remove if it is selected.
|
// remove if it is selected.
|
||||||
if(portal.options.guid == window.selectedPortal ||
|
if(itemGuid == window.selectedPortal ||
|
||||||
(b.contains(portal.getLatLng()) && i >= minlvl)) return;
|
(b.contains(item.getLatLng()) && i >= minlvl)) return true;
|
||||||
cnt[0]++;
|
cnt[0]++;
|
||||||
portalsLayers[i].removeLayer(portal);
|
portalsLayers[i].removeLayer(item);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
linksLayer.eachLayer(function(link) {
|
linksLayer.eachLayer(function(link) {
|
||||||
@ -143,31 +171,30 @@ window.cleanUp = function() {
|
|||||||
console.log('removed out-of-bounds: '+cnt[0]+' portals, '+cnt[1]+' links, '+cnt[2]+' fields');
|
console.log('removed out-of-bounds: '+cnt[0]+' portals, '+cnt[1]+' links, '+cnt[2]+' fields');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// removes given entity from map
|
// removes given entity from map
|
||||||
window.removeByGuid = function(guid) {
|
window.removeByGuid = function(guid) {
|
||||||
// portals end in “.11” or “.12“, links in “.9", fields in “.b”
|
switch(getTypeByGuid(guid)) {
|
||||||
// .11 == portals
|
case TYPE_PORTAL:
|
||||||
// .12 == portals
|
|
||||||
// .9 == links
|
|
||||||
// .b == fields
|
|
||||||
// .c == player/creator
|
|
||||||
// .d == chat messages
|
|
||||||
switch(guid.slice(33)) {
|
|
||||||
case '11':
|
|
||||||
case '12':
|
|
||||||
if(!window.portals[guid]) return;
|
if(!window.portals[guid]) return;
|
||||||
var p = window.portals[guid];
|
var p = window.portals[guid];
|
||||||
for(var i = 0; i < portalsLayers.length; i++)
|
for(var i = 0; i < portalsLayers.length; i++)
|
||||||
portalsLayers[i].removeLayer(p);
|
portalsLayers[i].removeLayer(p);
|
||||||
break;
|
break;
|
||||||
case '9':
|
case TYPE_LINK:
|
||||||
if(!window.links[guid]) return;
|
if(!window.links[guid]) return;
|
||||||
linksLayer.removeLayer(window.links[guid]);
|
linksLayer.removeLayer(window.links[guid]);
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case TYPE_FIELD:
|
||||||
if(!window.fields[guid]) return;
|
if(!window.fields[guid]) return;
|
||||||
fieldsLayer.removeLayer(window.fields[guid]);
|
fieldsLayer.removeLayer(window.fields[guid]);
|
||||||
break;
|
break;
|
||||||
|
case TYPE_RESONATOR:
|
||||||
|
if(!window.resonators[guid]) return;
|
||||||
|
var r = window.resonators[guid];
|
||||||
|
for(var i = 1; i < portalsLayers.length; i++)
|
||||||
|
portalsLayers[i].removeLayer(r);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
console.warn('unknown GUID type: ' + guid);
|
console.warn('unknown GUID type: ' + guid);
|
||||||
//window.debug.printStackTrace();
|
//window.debug.printStackTrace();
|
||||||
@ -178,59 +205,148 @@ window.removeByGuid = function(guid) {
|
|||||||
|
|
||||||
// renders a portal on the map from the given entity
|
// renders a portal on the map from the given entity
|
||||||
window.renderPortal = function(ent) {
|
window.renderPortal = function(ent) {
|
||||||
removeByGuid(ent[0]);
|
|
||||||
|
|
||||||
if(Object.keys(portals).length >= MAX_DRAWN_PORTALS && ent[0] != selectedPortal)
|
if(Object.keys(portals).length >= MAX_DRAWN_PORTALS && ent[0] != selectedPortal)
|
||||||
return;
|
return removeByGuid(ent[0]);
|
||||||
|
|
||||||
var latlng = [ent[2].locationE6.latE6/1E6, ent[2].locationE6.lngE6/1E6];
|
|
||||||
// needs to be checked before, so the portal isn’t added to the
|
|
||||||
// details list and other places
|
|
||||||
//if(!getPaddedBounds().contains(latlng)) return;
|
|
||||||
|
|
||||||
// hide low level portals on low zooms
|
// hide low level portals on low zooms
|
||||||
var portalLevel = getPortalLevel(ent[2]);
|
var portalLevel = getPortalLevel(ent[2]);
|
||||||
if(portalLevel < getMinPortalLevel() && ent[0] != selectedPortal) return;
|
if(portalLevel < getMinPortalLevel() && ent[0] != selectedPortal)
|
||||||
|
return removeByGuid(ent[0]);
|
||||||
// pre-load player names for high zoom levels
|
|
||||||
if(map.getZoom() >= PRECACHE_PLAYER_NAMES_ZOOM) {
|
|
||||||
if(ent[2].captured && ent[2].captured.capturingPlayerId)
|
|
||||||
getPlayerName(ent[2].captured.capturingPlayerId);
|
|
||||||
if(ent[2].resonatorArray && ent[2].resonatorArray.resonators)
|
|
||||||
$.each(ent[2].resonatorArray.resonators, function(ind, reso) {
|
|
||||||
if(reso) getPlayerName(reso.ownerGuid);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var team = getTeam(ent[2]);
|
var team = getTeam(ent[2]);
|
||||||
|
|
||||||
|
// do nothing if portal did not change
|
||||||
|
var layerGroup = portalsLayers[parseInt(portalLevel)];
|
||||||
|
var old = findEntityInLeaflet(layerGroup, window.portals, ent[0]);
|
||||||
|
if(old) {
|
||||||
|
var oo = old.options;
|
||||||
|
var u = oo.team !== team;
|
||||||
|
u = u || oo.level !== portalLevel;
|
||||||
|
// nothing for the portal changed, so don’t update. Let resonators
|
||||||
|
// manage themselves if they want to be updated.
|
||||||
|
if(!u) return renderResonators(ent);
|
||||||
|
removeByGuid(ent[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// there were changes, remove old portal
|
||||||
|
removeByGuid(ent[0]);
|
||||||
|
|
||||||
|
var latlng = [ent[2].locationE6.latE6/1E6, ent[2].locationE6.lngE6/1E6];
|
||||||
|
|
||||||
|
// pre-loads player names for high zoom levels
|
||||||
|
loadPlayerNamesForPortal(ent[2]);
|
||||||
|
|
||||||
|
|
||||||
|
var lvWeight = Math.max(2, portalLevel / 1.5);
|
||||||
|
var lvRadius = Math.max(portalLevel + 3, 5);
|
||||||
|
|
||||||
var p = L.circleMarker(latlng, {
|
var p = L.circleMarker(latlng, {
|
||||||
radius: 7,
|
radius: lvRadius,
|
||||||
color: ent[0] == selectedPortal ? COLOR_SELECTED_PORTAL : COLORS[team],
|
color: ent[0] == selectedPortal ? COLOR_SELECTED_PORTAL : COLORS[team],
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
weight: 3,
|
weight: lvWeight,
|
||||||
fillColor: COLORS[team],
|
fillColor: COLORS[team],
|
||||||
fillOpacity: 0.5,
|
fillOpacity: 0.5,
|
||||||
clickable: true,
|
clickable: true,
|
||||||
level: portalLevel,
|
level: portalLevel,
|
||||||
|
team: team,
|
||||||
details: ent[2],
|
details: ent[2],
|
||||||
guid: ent[0]});
|
guid: ent[0]});
|
||||||
|
|
||||||
p.on('remove', function() { delete window.portals[this.options.guid]; });
|
p.on('remove', function() {
|
||||||
|
var portalGuid = this.options.guid
|
||||||
|
|
||||||
|
// remove attached resonators, skip if
|
||||||
|
// all resonators have already removed by zooming
|
||||||
|
if(isResonatorsShow()) {
|
||||||
|
for(var i = 0; i <= 7; i++)
|
||||||
|
removeByGuid(portalResonatorGuid(portalGuid,i));
|
||||||
|
}
|
||||||
|
delete window.portals[portalGuid];
|
||||||
|
if(window.selectedPortal === portalGuid) {
|
||||||
|
window.unselectOldPortal();
|
||||||
|
window.map.removeLayer(window.portalAccessIndicator);
|
||||||
|
window.portalAccessIndicator = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
p.on('add', function() {
|
p.on('add', function() {
|
||||||
|
// enable for debugging
|
||||||
|
if(window.portals[this.options.guid]) throw('duplicate portal detected');
|
||||||
window.portals[this.options.guid] = this;
|
window.portals[this.options.guid] = this;
|
||||||
// handles the case where a selected portal gets removed from the
|
// handles the case where a selected portal gets removed from the
|
||||||
// map by hiding all portals with said level
|
// map by hiding all portals with said level
|
||||||
if(window.selectedPortal != this.options.guid)
|
if(window.selectedPortal != this.options.guid)
|
||||||
window.portalResetColor(this);
|
window.portalResetColor(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
p.on('click', function() { window.renderPortalDetails(ent[0]); });
|
p.on('click', function() { window.renderPortalDetails(ent[0]); });
|
||||||
p.on('dblclick', function() {
|
p.on('dblclick', function() {
|
||||||
window.renderPortalDetails(ent[0]);
|
window.renderPortalDetails(ent[0]);
|
||||||
window.map.setView(latlng, 17);
|
window.map.setView(latlng, 17);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.renderResonators(ent);
|
||||||
|
|
||||||
|
window.runHooks('portalAdded', {portal: p});
|
||||||
|
|
||||||
// portalLevel contains a float, need to round down
|
// portalLevel contains a float, need to round down
|
||||||
p.addTo(portalsLayers[parseInt(portalLevel)]);
|
p.addTo(layerGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.renderResonators = function(ent) {
|
||||||
|
var portalLevel = getPortalLevel(ent[2]);
|
||||||
|
if(portalLevel < getMinPortalLevel() && ent[0] != selectedPortal) return;
|
||||||
|
|
||||||
|
if(!isResonatorsShow()) return;
|
||||||
|
|
||||||
|
for(var i=0; i < ent[2].resonatorArray.resonators.length; i++) {
|
||||||
|
var rdata = ent[2].resonatorArray.resonators[i];
|
||||||
|
|
||||||
|
if(rdata == null) continue;
|
||||||
|
|
||||||
|
if(window.resonators[portalResonatorGuid(ent[0],i)]) continue;
|
||||||
|
|
||||||
|
// offset in meters
|
||||||
|
var dn = rdata.distanceToPortal*SLOT_TO_LAT[rdata.slot];
|
||||||
|
var de = rdata.distanceToPortal*SLOT_TO_LNG[rdata.slot];
|
||||||
|
|
||||||
|
// Coordinate offset in radians
|
||||||
|
var dLat = dn/EARTH_RADIUS;
|
||||||
|
var dLon = de/(EARTH_RADIUS*Math.cos(Math.PI/180*(ent[2].locationE6.latE6/1E6)));
|
||||||
|
|
||||||
|
// OffsetPosition, decimal degrees
|
||||||
|
var lat0 = ent[2].locationE6.latE6/1E6 + dLat * 180/Math.PI;
|
||||||
|
var lon0 = ent[2].locationE6.lngE6/1E6 + dLon * 180/Math.PI;
|
||||||
|
var Rlatlng = [lat0, lon0];
|
||||||
|
var r = L.circleMarker(Rlatlng, {
|
||||||
|
radius: 3,
|
||||||
|
// #AAAAAA outline seems easier to see the fill opacity
|
||||||
|
color: '#AAAAAA',
|
||||||
|
opacity: 1,
|
||||||
|
weight: 1,
|
||||||
|
fillColor: COLORS_LVL[rdata.level],
|
||||||
|
fillOpacity: rdata.energyTotal/RESO_NRG[rdata.level],
|
||||||
|
clickable: false,
|
||||||
|
level: rdata.level,
|
||||||
|
details: rdata,
|
||||||
|
pDetails: ent[2],
|
||||||
|
guid: portalResonatorGuid(ent[0],i) });
|
||||||
|
|
||||||
|
r.on('remove', function() { delete window.resonators[this.options.guid]; });
|
||||||
|
r.on('add', function() { window.resonators[this.options.guid] = this; });
|
||||||
|
|
||||||
|
r.addTo(portalsLayers[parseInt(portalLevel)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// append portal guid with -resonator-[slot] to get guid for resonators
|
||||||
|
window.portalResonatorGuid = function(portalGuid, slot) {
|
||||||
|
return portalGuid + '-resonator-' + slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.isResonatorsShow = function() {
|
||||||
|
return map.getZoom() >= RESONATOR_DISPLAY_ZOOM_LEVEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.portalResetColor = function(portal) {
|
window.portalResetColor = function(portal) {
|
||||||
@ -239,8 +355,12 @@ window.portalResetColor = function(portal) {
|
|||||||
|
|
||||||
// renders a link on the map from the given entity
|
// renders a link on the map from the given entity
|
||||||
window.renderLink = function(ent) {
|
window.renderLink = function(ent) {
|
||||||
removeByGuid(ent[0]);
|
if(Object.keys(links).length >= MAX_DRAWN_LINKS)
|
||||||
if(Object.keys(links).length >= MAX_DRAWN_LINKS) return;
|
return removeByGuid(ent[0]);
|
||||||
|
|
||||||
|
// assume that links never change. If they do, they will have a
|
||||||
|
// different ID.
|
||||||
|
if(findEntityInLeaflet(linksLayer, links, ent[0])) return;
|
||||||
|
|
||||||
var team = getTeam(ent[2]);
|
var team = getTeam(ent[2]);
|
||||||
var edge = ent[2].edge;
|
var edge = ent[2].edge;
|
||||||
@ -260,14 +380,23 @@ window.renderLink = function(ent) {
|
|||||||
if(!getPaddedBounds().intersects(poly.getBounds())) return;
|
if(!getPaddedBounds().intersects(poly.getBounds())) return;
|
||||||
|
|
||||||
poly.on('remove', function() { delete window.links[this.options.guid]; });
|
poly.on('remove', function() { delete window.links[this.options.guid]; });
|
||||||
poly.on('add', function() { window.links[this.options.guid] = this; });
|
poly.on('add', function() {
|
||||||
poly.addTo(linksLayer).bringToBack();
|
// enable for debugging
|
||||||
|
if(window.links[this.options.guid]) throw('duplicate link detected');
|
||||||
|
window.links[this.options.guid] = this;
|
||||||
|
this.bringToBack();
|
||||||
|
});
|
||||||
|
poly.addTo(linksLayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// renders a field on the map from a given entity
|
// renders a field on the map from a given entity
|
||||||
window.renderField = function(ent) {
|
window.renderField = function(ent) {
|
||||||
window.removeByGuid(ent[0]);
|
if(Object.keys(fields).length >= MAX_DRAWN_FIELDS)
|
||||||
if(Object.keys(fields).length >= MAX_DRAWN_FIELDS) return;
|
return window.removeByGuid(ent[0]);
|
||||||
|
|
||||||
|
// assume that fields never change. If they do, they will have a
|
||||||
|
// different ID.
|
||||||
|
if(findEntityInLeaflet(fieldsLayer, fields, ent[0])) return;
|
||||||
|
|
||||||
var team = getTeam(ent[2]);
|
var team = getTeam(ent[2]);
|
||||||
var reg = ent[2].capturedRegion;
|
var reg = ent[2].capturedRegion;
|
||||||
@ -282,11 +411,38 @@ window.renderField = function(ent) {
|
|||||||
stroke: false,
|
stroke: false,
|
||||||
clickable: false,
|
clickable: false,
|
||||||
smoothFactor: 10,
|
smoothFactor: 10,
|
||||||
|
vertices: ent[2].capturedRegion,
|
||||||
|
lastUpdate: ent[1],
|
||||||
guid: ent[0]});
|
guid: ent[0]});
|
||||||
|
|
||||||
if(!getPaddedBounds().intersects(poly.getBounds())) return;
|
if(!getPaddedBounds().intersects(poly.getBounds())) return;
|
||||||
|
|
||||||
poly.on('remove', function() { delete window.fields[this.options.guid]; });
|
poly.on('remove', function() { delete window.fields[this.options.guid]; });
|
||||||
poly.on('add', function() { window.fields[this.options.guid] = this; });
|
poly.on('add', function() {
|
||||||
poly.addTo(fieldsLayer).bringToBack();
|
// enable for debugging
|
||||||
|
if(window.fields[this.options.guid]) console.warn('duplicate field detected');
|
||||||
|
window.fields[this.options.guid] = this;
|
||||||
|
this.bringToBack();
|
||||||
|
});
|
||||||
|
poly.addTo(fieldsLayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// looks for the GUID in either the layerGroup or entityHash, depending
|
||||||
|
// on which is faster. Will either return the Leaflet entity or null, if
|
||||||
|
// it does not exist.
|
||||||
|
// For example, to find a field use the function like this:
|
||||||
|
// field = findEntityInLeaflet(fieldsLayer, fields, 'asdasdasd');
|
||||||
|
window.findEntityInLeaflet = function(layerGroup, entityHash, guid) {
|
||||||
|
// fast way
|
||||||
|
if(map.hasLayer(layerGroup)) return entityHash[guid] || null;
|
||||||
|
|
||||||
|
// slow way in case the layer is currently hidden
|
||||||
|
var ent = null;
|
||||||
|
layerGroup.eachLayer(function(entity) {
|
||||||
|
if(entity.options.guid !== guid) return true;
|
||||||
|
ent = entity;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
return ent;
|
||||||
}
|
}
|
||||||
|
@ -46,3 +46,18 @@ window.resolvePlayerNames = function() {
|
|||||||
window.setPlayerName = function(guid, nick) {
|
window.setPlayerName = function(guid, nick) {
|
||||||
localStorage[guid] = nick;
|
localStorage[guid] = nick;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
window.loadPlayerNamesForPortal = function(portal_details) {
|
||||||
|
if(map.getZoom() < PRECACHE_PLAYER_NAMES_ZOOM) return;
|
||||||
|
var e = portal_details;
|
||||||
|
|
||||||
|
if(e.captured && e.captured.capturingPlayerId)
|
||||||
|
getPlayerName(e.captured.capturingPlayerId);
|
||||||
|
|
||||||
|
if(!e.resonatorArray || !e.resonatorArray.resonators) return;
|
||||||
|
|
||||||
|
$.each(e.resonatorArray.resonators, function(ind, reso) {
|
||||||
|
if(reso) getPlayerName(reso.ownerGuid);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -29,8 +29,10 @@ window.renderPortalDetails = function(guid) {
|
|||||||
var time = d.captured ? unixTimeToString(d.captured.capturedTime) : null;
|
var time = d.captured ? unixTimeToString(d.captured.capturedTime) : null;
|
||||||
var sinceText = time ? 'since: ' + time : null;
|
var sinceText = time ? 'since: ' + time : null;
|
||||||
|
|
||||||
|
var linkedFields = 'fields: ' + d.portalV2.linkedFields.length;
|
||||||
|
|
||||||
// collect and html-ify random data
|
// collect and html-ify random data
|
||||||
var randDetails = [playerText, sinceText, getRangeText(d), getEnergyText(d), linksText, getAvgResoDistText(d)];
|
var randDetails = [playerText, sinceText, getRangeText(d), getEnergyText(d), linksText, getAvgResoDistText(d), linkedFields];
|
||||||
randDetails = randDetails.map(function(detail) {
|
randDetails = randDetails.map(function(detail) {
|
||||||
if(!detail) return '';
|
if(!detail) return '';
|
||||||
detail = detail.split(':');
|
detail = detail.split(':');
|
||||||
@ -69,7 +71,7 @@ window.renderPortalDetails = function(guid) {
|
|||||||
+ '<div id="destroydetails">'+getDestroyAP(d)+'</div>'
|
+ '<div id="destroydetails">'+getDestroyAP(d)+'</div>'
|
||||||
+ '<div class="linkdetails">'
|
+ '<div class="linkdetails">'
|
||||||
+ '<aside><a href="'+perma+'">portal link</a></aside>'
|
+ '<aside><a href="'+perma+'">portal link</a></aside>'
|
||||||
+ '<aside><a onclick="window.reportPortalIssue(\''+getReportIssueInfoText(d)+'\')">report issue</a></aside>'
|
+ '<aside><a onclick="window.reportPortalIssue()">report issue</a></aside>'
|
||||||
+ '</div>'
|
+ '</div>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,12 @@ window.getPortalDescriptionFromDetails = function(details) {
|
|||||||
window.getModDetails = function(d) {
|
window.getModDetails = function(d) {
|
||||||
var mods = [];
|
var mods = [];
|
||||||
var modsTitle = [];
|
var modsTitle = [];
|
||||||
|
var modsColor = [];
|
||||||
$.each(d.portalV2.linkedModArray, function(ind, mod) {
|
$.each(d.portalV2.linkedModArray, function(ind, mod) {
|
||||||
if(!mod) {
|
if(!mod) {
|
||||||
mods.push('');
|
mods.push('');
|
||||||
modsTitle.push('');
|
modsTitle.push('');
|
||||||
|
modsColor.push('#000');
|
||||||
} else if(mod.type === 'RES_SHIELD') {
|
} else if(mod.type === 'RES_SHIELD') {
|
||||||
|
|
||||||
var title = mod.rarity.capitalize() + ' ' + mod.displayName + '\n';
|
var title = mod.rarity.capitalize() + ' ' + mod.displayName + '\n';
|
||||||
@ -46,23 +48,29 @@ window.getModDetails = function(d) {
|
|||||||
|
|
||||||
mods.push(mod.rarity.capitalize().replace('_', ' ') + ' ' + mod.displayName);
|
mods.push(mod.rarity.capitalize().replace('_', ' ') + ' ' + mod.displayName);
|
||||||
modsTitle.push(title);
|
modsTitle.push(title);
|
||||||
|
modsColor.push(COLORS_MOD[mod.rarity]);
|
||||||
} else {
|
} else {
|
||||||
mods.push(mod.type);
|
mods.push(mod.type);
|
||||||
modsTitle.push('Unknown mod. No further details available.');
|
modsTitle.push('Unknown mod. No further details available.');
|
||||||
|
modsColor.push('#FFF');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var t = '<span title="'+modsTitle[0]+'">'+mods[0]+'</span>'
|
var t = '<span title="'+modsTitle[0]+'" style="color:'+modsColor[0]+'">'+mods[0]+'</span>'
|
||||||
+ '<span title="'+modsTitle[1]+'">'+mods[1]+'</span>'
|
+ '<span title="'+modsTitle[1]+'" style="color:'+modsColor[1]+'">'+mods[1]+'</span>'
|
||||||
+ '<span title="'+modsTitle[2]+'">'+mods[2]+'</span>'
|
+ '<span title="'+modsTitle[2]+'" style="color:'+modsColor[2]+'">'+mods[2]+'</span>'
|
||||||
+ '<span title="'+modsTitle[3]+'">'+mods[3]+'</span>'
|
+ '<span title="'+modsTitle[3]+'" style="color:'+modsColor[3]+'">'+mods[3]+'</span>'
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.getEnergyText = function(d) {
|
window.getEnergyText = function(d) {
|
||||||
var nrg = getPortalEnergy(d);
|
var currentNrg = getCurrentPortalEnergy(d);
|
||||||
return 'energy: ' + (nrg > 1000 ? Math.round(nrg/1000) +' k': nrg);
|
var totalNrg = getTotalPortalEnergy(d);
|
||||||
|
var inf = currentNrg + ' / ' + totalNrg;
|
||||||
|
var fill = prettyEnergy(currentNrg) + ' / ' + prettyEnergy(totalNrg)
|
||||||
|
var meter = 'energy: <tt title="'+inf+'">' + fill + '</tt>';
|
||||||
|
return meter;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.getAvgResoDistText = function(d) {
|
window.getAvgResoDistText = function(d) {
|
||||||
@ -70,21 +78,19 @@ window.getAvgResoDistText = function(d) {
|
|||||||
return '⌀ res dist: ' + avgDist + ' m';
|
return '⌀ res dist: ' + avgDist + ' m';
|
||||||
}
|
}
|
||||||
|
|
||||||
window.getReportIssueInfoText = function(d) {
|
|
||||||
return ('Your Nick: '+PLAYER.nickname+' '
|
|
||||||
+ 'Portal: '+d.portalV2.descriptiveText.TITLE+' '
|
|
||||||
+ 'Location: '+d.portalV2.descriptiveText.ADDRESS
|
|
||||||
+' (lat '+(d.locationE6.latE6/1E6)+'; lng '+(d.locationE6.lngE6/1E6)+')'
|
|
||||||
).replace(/['"]/, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
window.getResonatorDetails = function(d) {
|
window.getResonatorDetails = function(d) {
|
||||||
console.log('rendering reso details');
|
|
||||||
var resoDetails = '';
|
var resoDetails = '';
|
||||||
var slotsFilled = 0;
|
// octant=slot: 0=E, 1=NE, 2=N, 3=NW, 4=W, 5=SW, 6=S, SE=7
|
||||||
$.each(d.resonatorArray.resonators, function(ind, reso) {
|
// resos in the display should be ordered like this:
|
||||||
|
// N NE Since the view is displayed in columns, they
|
||||||
|
// NW E need to be ordered like this: N, NW, W, SW, NE,
|
||||||
|
// W SE E, SE, S, i.e. 2 3 4 5 1 0 7 6
|
||||||
|
// SW S
|
||||||
|
$.each([2, 3, 4, 5, 1, 0, 7, 6], function(ind, slot) {
|
||||||
|
var isLeft = slot >= 2 && slot <= 5;
|
||||||
|
var reso = d.resonatorArray.resonators[slot];
|
||||||
if(!reso) {
|
if(!reso) {
|
||||||
resoDetails += renderResonatorDetails(slotsFilled++, 0);
|
resoDetails += renderResonatorDetails(slot, 0, 0, null, null, isLeft);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,9 +98,11 @@ window.getResonatorDetails = function(d) {
|
|||||||
var v = parseInt(reso.energyTotal);
|
var v = parseInt(reso.energyTotal);
|
||||||
var nick = window.getPlayerName(reso.ownerGuid);
|
var nick = window.getPlayerName(reso.ownerGuid);
|
||||||
var dist = reso.distanceToPortal;
|
var dist = reso.distanceToPortal;
|
||||||
|
// if array order and slot order drift apart, at least the octant
|
||||||
|
// naming will still be correct.
|
||||||
|
slot = parseInt(reso.slot);
|
||||||
|
|
||||||
slotsFilled++;
|
resoDetails += renderResonatorDetails(slot, l, v, dist, nick, isLeft);
|
||||||
resoDetails += renderResonatorDetails(parseInt(reso.slot), l, v, dist, nick);
|
|
||||||
});
|
});
|
||||||
return resoDetails;
|
return resoDetails;
|
||||||
}
|
}
|
||||||
@ -103,15 +111,15 @@ window.getResonatorDetails = function(d) {
|
|||||||
// not work with raw details-hash. Needs digested infos instead:
|
// not work with raw details-hash. Needs digested infos instead:
|
||||||
// slot: which slot this resonator occupies. Starts with 0 (east) and
|
// slot: which slot this resonator occupies. Starts with 0 (east) and
|
||||||
// rotates clockwise. So, last one is 7 (southeast).
|
// rotates clockwise. So, last one is 7 (southeast).
|
||||||
window.renderResonatorDetails = function(slot, level, nrg, dist, nick) {
|
window.renderResonatorDetails = function(slot, level, nrg, dist, nick, isLeft) {
|
||||||
if(level == 0) {
|
if(level === 0) {
|
||||||
var meter = '<span class="meter" style="cursor:auto"></span>';
|
var meter = '<span class="meter" title="octant:\t' + OCTANTS[slot] + '"></span>';
|
||||||
} else {
|
} else {
|
||||||
var max = RESO_NRG[level];
|
var max = RESO_NRG[level];
|
||||||
var fillGrade = nrg/max*100;
|
var fillGrade = nrg/max*100;
|
||||||
|
|
||||||
var inf = 'energy:\t\t' + nrg + ' / ' + max + ' (' + Math.round(fillGrade) + '%)' + '\n'
|
var inf = 'energy:\t\t' + nrg + ' / ' + max + ' (' + Math.round(fillGrade) + '%)\n'
|
||||||
+ 'level:\t\t' + level +'\n'
|
+ 'level:\t\t' + level + '\n'
|
||||||
+ 'distance:\t' + dist + 'm\n'
|
+ 'distance:\t' + dist + 'm\n'
|
||||||
+ 'owner:\t\t' + nick + '\n'
|
+ 'owner:\t\t' + nick + '\n'
|
||||||
+ 'octant:\t' + OCTANTS[slot];
|
+ 'octant:\t' + OCTANTS[slot];
|
||||||
@ -124,12 +132,11 @@ window.renderResonatorDetails = function(slot, level, nrg, dist, nick) {
|
|||||||
|
|
||||||
var fill = '<span style="'+style+'"></span>';
|
var fill = '<span style="'+style+'"></span>';
|
||||||
|
|
||||||
var meter = '<span class="meter meter-rel" title="'+inf+'">'
|
var meter = '<span class="meter meter-rel" title="'+inf+'">' + fill + lbar + '</span>';
|
||||||
+ fill + lbar + '</span>';
|
|
||||||
}
|
}
|
||||||
var cls = slot <= 3 ? 'left' : 'right';
|
var cls = isLeft ? 'left' : 'right';
|
||||||
var text = '<span class="meter-text '+cls+'">'+(nick||'')+'</span>';
|
var text = '<span class="meter-text '+cls+'">'+(nick||'')+'</span>';
|
||||||
return (slot <= 3 ? text+meter : meter+text) + '<br/>';
|
return (isLeft ? text+meter : meter+text) + '<br/>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate AP gain from destroying portal
|
// calculate AP gain from destroying portal
|
||||||
|
@ -17,7 +17,21 @@ window.getPortalLevel = function(d) {
|
|||||||
return hasReso ? Math.max(1, lvl/8) : 0;
|
return hasReso ? Math.max(1, lvl/8) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.getPortalEnergy = function(d) {
|
window.getTotalPortalEnergy = function(d) {
|
||||||
|
var nrg = 0;
|
||||||
|
$.each(d.resonatorArray.resonators, function(ind, reso) {
|
||||||
|
if(!reso) return true;
|
||||||
|
var level = parseInt(reso.level);
|
||||||
|
var max = RESO_NRG[level];
|
||||||
|
nrg += max;
|
||||||
|
});
|
||||||
|
return nrg;
|
||||||
|
}
|
||||||
|
|
||||||
|
// For backwards compatibility
|
||||||
|
window.getPortalEnergy = window.getTotalPortalEnergy;
|
||||||
|
|
||||||
|
window.getCurrentPortalEnergy = function(d) {
|
||||||
var nrg = 0;
|
var nrg = 0;
|
||||||
$.each(d.resonatorArray.resonators, function(ind, reso) {
|
$.each(d.resonatorArray.resonators, function(ind, reso) {
|
||||||
if(!reso) return true;
|
if(!reso) return true;
|
||||||
|
@ -50,7 +50,7 @@ window.renderUpdateStatus = function() {
|
|||||||
t += ' <span style="color:red" class="help" title="Can only render so much before it gets unbearably slow. Not all entities are shown. Zoom in or increase the limit (search for MAX_DRAWN_*).">RENDER LIMIT</span> '
|
t += ' <span style="color:red" class="help" title="Can only render so much before it gets unbearably slow. Not all entities are shown. Zoom in or increase the limit (search for MAX_DRAWN_*).">RENDER LIMIT</span> '
|
||||||
|
|
||||||
if(window.failedRequestCount > 0)
|
if(window.failedRequestCount > 0)
|
||||||
t += ' <span style="color:red">' + window.failedRequestCount + ' requests failed</span>.'
|
t += ' <span style="color:red">' + window.failedRequestCount + ' failed</span>.'
|
||||||
|
|
||||||
t += '<br/>(';
|
t += '<br/>(';
|
||||||
var minlvl = getMinPortalLevel();
|
var minlvl = getMinPortalLevel();
|
||||||
|
@ -93,6 +93,13 @@ window.rangeLinkClick = function() {
|
|||||||
|
|
||||||
window.reportPortalIssue = function(info) {
|
window.reportPortalIssue = function(info) {
|
||||||
var t = 'Redirecting you to a Google Help Page. Once there, click on “Contact Us” in the upper right corner.\n\nThe text box contains all necessary information. Press CTRL+C to copy it.';
|
var t = 'Redirecting you to a Google Help Page. Once there, click on “Contact Us” in the upper right corner.\n\nThe text box contains all necessary information. Press CTRL+C to copy it.';
|
||||||
|
var d = window.portals[window.selectedPortal].options.details;
|
||||||
|
|
||||||
|
var info = 'Your Nick: ' + PLAYER.nickname + ' '
|
||||||
|
+ 'Portal: ' + d.portalV2.descriptiveText.TITLE + ' '
|
||||||
|
+ 'Location: ' + d.portalV2.descriptiveText.ADDRESS
|
||||||
|
+' (lat ' + (d.locationE6.latE6/1E6) + '; lng ' + (d.locationE6.lngE6/1E6) + ')';
|
||||||
|
|
||||||
//codename, approx addr, portalname
|
//codename, approx addr, portalname
|
||||||
if(prompt(t, info) !== null)
|
if(prompt(t, info) !== null)
|
||||||
location.href = 'https://support.google.com/ingress?hl=en';
|
location.href = 'https://support.google.com/ingress?hl=en';
|
||||||
@ -134,8 +141,51 @@ window.scrollBottom = function(elm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.zoomToAndShowPortal = function(guid, latlng) {
|
window.zoomToAndShowPortal = function(guid, latlng) {
|
||||||
renderPortalDetails(guid);
|
|
||||||
map.setView(latlng, 17);
|
map.setView(latlng, 17);
|
||||||
|
// if the data is available, render it immediately. Otherwise defer
|
||||||
|
// until it becomes available.
|
||||||
|
if(window.portals[guid])
|
||||||
|
renderPortalDetails(guid);
|
||||||
|
else
|
||||||
|
urlPortal = guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
// translates guids to entity types
|
||||||
|
window.getTypeByGuid = function(guid) {
|
||||||
|
// portals end in “.11” or “.12“, links in “.9", fields in “.b”
|
||||||
|
// .11 == portals
|
||||||
|
// .12 == portals
|
||||||
|
// .9 == links
|
||||||
|
// .b == fields
|
||||||
|
// .c == player/creator
|
||||||
|
// .d == chat messages
|
||||||
|
//
|
||||||
|
// others, not used in web:
|
||||||
|
// .5 == resources (burster/resonator)
|
||||||
|
// .6 == XM
|
||||||
|
// .4 == media items, maybe all droppped resources (?)
|
||||||
|
// resonator guid is [portal guid]-resonator-[slot]
|
||||||
|
switch(guid.slice(33)) {
|
||||||
|
case '11':
|
||||||
|
case '12':
|
||||||
|
return TYPE_PORTAL;
|
||||||
|
|
||||||
|
case '9':
|
||||||
|
return TYPE_LINK;
|
||||||
|
|
||||||
|
case 'b':
|
||||||
|
return TYPE_FIELD;
|
||||||
|
|
||||||
|
case 'c':
|
||||||
|
return TYPE_PLAYER;
|
||||||
|
|
||||||
|
case 'd':
|
||||||
|
return TYPE_CHAT;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if(guid.slice(-11,-2) == 'resonator') return TYPE_RESONATOR;
|
||||||
|
return TYPE_UNKNOWN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String.prototype.capitalize = function() {
|
String.prototype.capitalize = function() {
|
||||||
@ -148,3 +198,15 @@ if (typeof String.prototype.startsWith !== 'function') {
|
|||||||
return this.slice(0, str.length) === str;
|
return this.slice(0, str.length) === str;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.prettyEnergy = function(nrg) {
|
||||||
|
return nrg> 1000 ? Math.round(nrg/1000) + ' k': nrg;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.setPermaLink = function(elm) {
|
||||||
|
var c = map.getCenter();
|
||||||
|
var lat = Math.round(c.lat*1E6);
|
||||||
|
var lng = Math.round(c.lng*1E6);
|
||||||
|
var qry = 'latE6='+lat+'&lngE6='+lng+'&z=' + map.getZoom();
|
||||||
|
$(elm).attr('href', 'http://www.ingress.com/intel?' + qry);
|
||||||
|
}
|
||||||
|
33
external/autolink.js
vendored
Normal file
33
external/autolink.js
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// Generated by CoffeeScript 1.4.0
|
||||||
|
(function() {
|
||||||
|
var autoLink,
|
||||||
|
__slice = [].slice;
|
||||||
|
|
||||||
|
autoLink = function() {
|
||||||
|
var callbackThunk, key, link_attributes, option, options, url_pattern, value;
|
||||||
|
options = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||||
|
link_attributes = '';
|
||||||
|
option = options[0];
|
||||||
|
url_pattern = /(^|\s)(\b(https?|ftp):\/\/[\-A-Z0-9+\u0026@#\/%?=~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~_|])/gi;
|
||||||
|
if (!(options.length > 0)) {
|
||||||
|
return this.replace(url_pattern, "$1<a href='$2'>$2</a>");
|
||||||
|
}
|
||||||
|
if ((option['callback'] != null) && typeof option['callback'] === 'function') {
|
||||||
|
callbackThunk = option['callback'];
|
||||||
|
delete option['callback'];
|
||||||
|
}
|
||||||
|
for (key in option) {
|
||||||
|
value = option[key];
|
||||||
|
link_attributes += " " + key + "='" + value + "'";
|
||||||
|
}
|
||||||
|
return this.replace(url_pattern, function(match, space, url) {
|
||||||
|
var link, returnCallback;
|
||||||
|
returnCallback = callbackThunk && callbackThunk(url);
|
||||||
|
link = returnCallback || ("<a href='" + url + "'" + link_attributes + ">" + url + "</a>");
|
||||||
|
return "" + space + link;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
String.prototype['autoLink'] = autoLink;
|
||||||
|
|
||||||
|
}).call(this);
|
152
external/leaflet_google.js
vendored
Normal file
152
external/leaflet_google.js
vendored
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
/*
|
||||||
|
* L.TileLayer is used for standard xyz-numbered tile layers.
|
||||||
|
*/
|
||||||
|
L.Google = L.Class.extend({
|
||||||
|
includes: L.Mixin.Events,
|
||||||
|
|
||||||
|
options: {
|
||||||
|
minZoom: 0,
|
||||||
|
maxZoom: 18,
|
||||||
|
tileSize: 256,
|
||||||
|
subdomains: 'abc',
|
||||||
|
errorTileUrl: '',
|
||||||
|
attribution: '',
|
||||||
|
opacity: 1,
|
||||||
|
continuousWorld: false,
|
||||||
|
noWrap: false,
|
||||||
|
},
|
||||||
|
|
||||||
|
// Possible types: SATELLITE, ROADMAP, HYBRID, INGRESS
|
||||||
|
initialize: function(type, options, styles) {
|
||||||
|
L.Util.setOptions(this, options);
|
||||||
|
if(type === 'INGRESS') {
|
||||||
|
type = 'ROADMAP';
|
||||||
|
this._styles = [{featureType:"all", elementType:"all", stylers:[{visibility:"on"}, {hue:"#0091ff"}, {invert_lightness:true}]}, {featureType:"water", elementType:"all", stylers:[{visibility:"on"}, {hue:"#005eff"}, {invert_lightness:true}]}, {featureType:"poi", stylers:[{visibility:"off"}]}, {featureType:"transit", elementType:"all", stylers:[{visibility:"off"}]}];
|
||||||
|
} else {
|
||||||
|
this._styles = null;
|
||||||
|
}
|
||||||
|
this._type = google.maps.MapTypeId[type || 'SATELLITE'];
|
||||||
|
},
|
||||||
|
|
||||||
|
onAdd: function(map, insertAtTheBottom) {
|
||||||
|
this._map = map;
|
||||||
|
this._insertAtTheBottom = insertAtTheBottom;
|
||||||
|
|
||||||
|
// create a container div for tiles
|
||||||
|
this._initContainer();
|
||||||
|
this._initMapObject();
|
||||||
|
|
||||||
|
// set up events
|
||||||
|
map.on('viewreset', this._resetCallback, this);
|
||||||
|
|
||||||
|
this._limitedUpdate = L.Util.limitExecByInterval(this._update, 150, this);
|
||||||
|
map.on('move', this._update, this);
|
||||||
|
//map.on('moveend', this._update, this);
|
||||||
|
|
||||||
|
this._reset();
|
||||||
|
this._update();
|
||||||
|
},
|
||||||
|
|
||||||
|
onRemove: function(map) {
|
||||||
|
this._map._container.removeChild(this._container);
|
||||||
|
//this._container = null;
|
||||||
|
|
||||||
|
this._map.off('viewreset', this._resetCallback, this);
|
||||||
|
|
||||||
|
this._map.off('move', this._update, this);
|
||||||
|
//this._map.off('moveend', this._update, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
getAttribution: function() {
|
||||||
|
return this.options.attribution;
|
||||||
|
},
|
||||||
|
|
||||||
|
setOpacity: function(opacity) {
|
||||||
|
this.options.opacity = opacity;
|
||||||
|
if (opacity < 1) {
|
||||||
|
L.DomUtil.setOpacity(this._container, opacity);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_initContainer: function() {
|
||||||
|
var tilePane = this._map._container
|
||||||
|
first = tilePane.firstChild;
|
||||||
|
|
||||||
|
if (!this._container) {
|
||||||
|
this._container = L.DomUtil.create('div', 'leaflet-google-layer leaflet-top leaflet-left');
|
||||||
|
this._container.id = "_GMapContainer";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (true) {
|
||||||
|
tilePane.insertBefore(this._container, first);
|
||||||
|
|
||||||
|
this.setOpacity(this.options.opacity);
|
||||||
|
var size = this._map.getSize();
|
||||||
|
this._container.style.width = size.x + 'px';
|
||||||
|
this._container.style.height = size.y + 'px';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_initMapObject: function() {
|
||||||
|
this._google_center = new google.maps.LatLng(0, 0);
|
||||||
|
var map = new google.maps.Map(this._container, {
|
||||||
|
center: this._google_center,
|
||||||
|
zoom: 0,
|
||||||
|
styles: this._styles,
|
||||||
|
mapTypeId: this._type,
|
||||||
|
disableDefaultUI: true,
|
||||||
|
keyboardShortcuts: false,
|
||||||
|
draggable: false,
|
||||||
|
disableDoubleClickZoom: true,
|
||||||
|
scrollwheel: false,
|
||||||
|
streetViewControl: false
|
||||||
|
});
|
||||||
|
|
||||||
|
var _this = this;
|
||||||
|
this._reposition = google.maps.event.addListenerOnce(map, "center_changed",
|
||||||
|
function() { _this.onReposition(); });
|
||||||
|
|
||||||
|
map.backgroundColor = '#ff0000';
|
||||||
|
this._google = map;
|
||||||
|
},
|
||||||
|
|
||||||
|
_resetCallback: function(e) {
|
||||||
|
this._reset(e.hard);
|
||||||
|
},
|
||||||
|
|
||||||
|
_reset: function(clearOldContainer) {
|
||||||
|
this._initContainer();
|
||||||
|
},
|
||||||
|
|
||||||
|
_update: function() {
|
||||||
|
this._resize();
|
||||||
|
|
||||||
|
var bounds = this._map.getBounds();
|
||||||
|
var ne = bounds.getNorthEast();
|
||||||
|
var sw = bounds.getSouthWest();
|
||||||
|
var google_bounds = new google.maps.LatLngBounds(
|
||||||
|
new google.maps.LatLng(sw.lat, sw.lng),
|
||||||
|
new google.maps.LatLng(ne.lat, ne.lng)
|
||||||
|
);
|
||||||
|
var center = this._map.getCenter();
|
||||||
|
var _center = new google.maps.LatLng(center.lat, center.lng);
|
||||||
|
|
||||||
|
this._google.setCenter(_center);
|
||||||
|
this._google.setZoom(this._map.getZoom());
|
||||||
|
//this._google.fitBounds(google_bounds);
|
||||||
|
},
|
||||||
|
|
||||||
|
_resize: function() {
|
||||||
|
var size = this._map.getSize();
|
||||||
|
if (this._container.style.width == size.x &&
|
||||||
|
this._container.style.height == size.y)
|
||||||
|
return;
|
||||||
|
this._container.style.width = size.x + 'px';
|
||||||
|
this._container.style.height = size.y + 'px';
|
||||||
|
google.maps.event.trigger(this._google, "resize");
|
||||||
|
},
|
||||||
|
|
||||||
|
onReposition: function() {
|
||||||
|
//google.maps.event.trigger(this._google, "resize");
|
||||||
|
}
|
||||||
|
});
|
45
main.js
45
main.js
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @id ingress-intel-total-conversion@breunigs
|
// @id ingress-intel-total-conversion@breunigs
|
||||||
// @name intel map total conversion
|
// @name intel map total conversion
|
||||||
// @version 0.3-@@BUILDDATE@@
|
// @version 0.4-@@BUILDDATE@@
|
||||||
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
|
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
|
||||||
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/total-conversion-build.user.js
|
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/total-conversion-build.user.js
|
||||||
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/total-conversion-build.user.js
|
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/total-conversion-build.user.js
|
||||||
@ -28,6 +28,19 @@ for(var x in scr) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(!d) {
|
||||||
|
// page doesn’t have a script tag with player information.
|
||||||
|
if(document.getElementById('header_email')) {
|
||||||
|
// however, we are logged in.
|
||||||
|
setTimeout('location.reload();', 10*1000);
|
||||||
|
throw('Page doesn’t have player data, but you are logged in. Reloading in 10s.');
|
||||||
|
}
|
||||||
|
// FIXME: handle nia takedown in progress
|
||||||
|
throw('Couldn’t retrieve player data. Are you logged in?');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for(var i = 0; i < d.length; i++) {
|
for(var i = 0; i < d.length; i++) {
|
||||||
if(!d[i].match('var PLAYER = ')) continue;
|
if(!d[i].match('var PLAYER = ')) continue;
|
||||||
eval(d[i].match(/^var /, 'window.'));
|
eval(d[i].match(/^var /, 'window.'));
|
||||||
@ -36,7 +49,6 @@ for(var i = 0; i < d.length; i++) {
|
|||||||
// player information is now available in a hash like this:
|
// player information is now available in a hash like this:
|
||||||
// window.PLAYER = {"ap": "123", "energy": 123, "available_invites": 123, "nickname": "somenick", "team": "ALIENS||RESISTANCE"};
|
// window.PLAYER = {"ap": "123", "energy": 123, "available_invites": 123, "nickname": "somenick", "team": "ALIENS||RESISTANCE"};
|
||||||
|
|
||||||
|
|
||||||
// remove complete page. We only wanted the user-data and the page’s
|
// remove complete page. We only wanted the user-data and the page’s
|
||||||
// security context so we can access the API easily. Setup as much as
|
// security context so we can access the API easily. Setup as much as
|
||||||
// possible without requiring scripts.
|
// possible without requiring scripts.
|
||||||
@ -50,7 +62,7 @@ document.getElementsByTagName('head')[0].innerHTML = ''
|
|||||||
document.getElementsByTagName('body')[0].innerHTML = ''
|
document.getElementsByTagName('body')[0].innerHTML = ''
|
||||||
+ '<div id="map">Loading, please wait</div>'
|
+ '<div id="map">Loading, please wait</div>'
|
||||||
+ '<div id="chatcontrols" style="display:none">'
|
+ '<div id="chatcontrols" style="display:none">'
|
||||||
+ ' <a>expand</a><a>automated</a><a>public</a><a class="active">faction</a>'
|
+ ' <a>◢◣</a><a>automated</a><a>public</a><a class="active">faction</a>'
|
||||||
+ '</div>'
|
+ '</div>'
|
||||||
+ '<div id="chat" style="display:none">'
|
+ '<div id="chat" style="display:none">'
|
||||||
+ ' <div id="chatfaction"></div>'
|
+ ' <div id="chatfaction"></div>'
|
||||||
@ -58,6 +70,7 @@ document.getElementsByTagName('body')[0].innerHTML = ''
|
|||||||
+ ' <div id="chatautomated"></div>'
|
+ ' <div id="chatautomated"></div>'
|
||||||
+ '</div>'
|
+ '</div>'
|
||||||
+ '<form id="chatinput" style="display:none"><time></time><span>tell faction:</span><input type="text"/></form>'
|
+ '<form id="chatinput" style="display:none"><time></time><span>tell faction:</span><input type="text"/></form>'
|
||||||
|
+ '<a id="sidebartoggle">◣<br>◤</a>'
|
||||||
+ '<div id="scrollwrapper">' // enable scrolling for small screens
|
+ '<div id="scrollwrapper">' // enable scrolling for small screens
|
||||||
+ ' <div id="sidebar" style="display: none">'
|
+ ' <div id="sidebar" style="display: none">'
|
||||||
+ ' <div id="playerstat">t</div>'
|
+ ' <div id="playerstat">t</div>'
|
||||||
@ -65,9 +78,11 @@ document.getElementsByTagName('body')[0].innerHTML = ''
|
|||||||
+ ' <input id="geosearch" placeholder="Search location…" type="text"/>'
|
+ ' <input id="geosearch" placeholder="Search location…" type="text"/>'
|
||||||
+ ' <div id="portaldetails"></div>'
|
+ ' <div id="portaldetails"></div>'
|
||||||
+ ' <input id="redeem" placeholder="Redeem code…" type="text"/>'
|
+ ' <input id="redeem" placeholder="Redeem code…" type="text"/>'
|
||||||
+ ' <div id="updatestatus"></div>'
|
+ ' <div id="toolbox"><a onmouseover="setPermaLink(this)">permalink</a></div>'
|
||||||
+ ' </div>';
|
+ ' <div id="spacer"></div>'
|
||||||
+ '</div>';
|
+ ' </div>'
|
||||||
|
+ '</div>'
|
||||||
|
+ '<div id="updatestatus"></div>';
|
||||||
|
|
||||||
// putting everything in a wrapper function that in turn is placed in a
|
// 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
|
// script tag on the website allows us to execute in the site’s context
|
||||||
@ -114,6 +129,9 @@ var MAX_DRAWN_FIELDS = 200;
|
|||||||
var COLOR_SELECTED_PORTAL = '#f00';
|
var COLOR_SELECTED_PORTAL = '#f00';
|
||||||
var COLORS = ['#FFCE00', '#0088FF', '#03FE03']; // none, res, enl
|
var COLORS = ['#FFCE00', '#0088FF', '#03FE03']; // none, res, enl
|
||||||
var COLORS_LVL = ['#000', '#FECE5A', '#FFA630', '#FF7315', '#E40000', '#FD2992', '#EB26CD', '#C124E0', '#9627F4'];
|
var COLORS_LVL = ['#000', '#FECE5A', '#FFA630', '#FF7315', '#E40000', '#FD2992', '#EB26CD', '#C124E0', '#9627F4'];
|
||||||
|
var COLORS_MOD = {VERY_RARE: '#F78AF6', RARE: '#AD8AFF', COMMON: '#84FBBD'};
|
||||||
|
|
||||||
|
|
||||||
// circles around a selected portal that show from where you can hack
|
// circles around a selected portal that show from where you can hack
|
||||||
// it and how far the portal reaches (i.e. how far links may be made
|
// it and how far the portal reaches (i.e. how far links may be made
|
||||||
// from this portal)
|
// from this portal)
|
||||||
@ -125,7 +143,7 @@ var RANGE_INDICATOR_COLOR = 'red';
|
|||||||
var RESO_NRG = [0, 1000, 1500, 2000, 2500, 3000, 4000, 5000, 6000];
|
var RESO_NRG = [0, 1000, 1500, 2000, 2500, 3000, 4000, 5000, 6000];
|
||||||
var MAX_XM_PER_LEVEL = [0, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000];
|
var MAX_XM_PER_LEVEL = [0, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000];
|
||||||
var MIN_AP_FOR_LEVEL = [0, 10000, 30000, 70000, 150000, 300000, 600000, 1200000];
|
var MIN_AP_FOR_LEVEL = [0, 10000, 30000, 70000, 150000, 300000, 600000, 1200000];
|
||||||
var HACK_RANGE = 35; // in meters, max. distance from portal to be able to access it
|
var HACK_RANGE = 40; // in meters, max. distance from portal to be able to access it
|
||||||
var OCTANTS = ['E', 'NE', 'N', 'NW', 'W', 'SW', 'S', 'SE'];
|
var OCTANTS = ['E', 'NE', 'N', 'NW', 'W', 'SW', 'S', 'SE'];
|
||||||
var DEFAULT_PORTAL_IMG = 'http://commondatastorage.googleapis.com/ingress/img/default-portal-image.png';
|
var DEFAULT_PORTAL_IMG = 'http://commondatastorage.googleapis.com/ingress/img/default-portal-image.png';
|
||||||
var DESTROY_RESONATOR = 75; //AP for destroying portal
|
var DESTROY_RESONATOR = 75; //AP for destroying portal
|
||||||
@ -137,10 +155,19 @@ var NOMINATIM = 'http://nominatim.openstreetmap.org/search?format=json&limit=1&q
|
|||||||
var DEG2RAD = Math.PI / 180;
|
var DEG2RAD = Math.PI / 180;
|
||||||
var TEAM_NONE = 0, TEAM_RES = 1, TEAM_ENL = 2;
|
var TEAM_NONE = 0, TEAM_RES = 1, TEAM_ENL = 2;
|
||||||
var TEAM_TO_CSS = ['none', 'res', 'enl'];
|
var TEAM_TO_CSS = ['none', 'res', 'enl'];
|
||||||
|
var TYPE_UNKNOWN = 0, TYPE_PORTAL = 1, TYPE_LINK = 2, TYPE_FIELD = 3, TYPE_PLAYER = 4, TYPE_CHAT = 5, TYPE_RESONATOR = 6;
|
||||||
// make PLAYER variable available in site context
|
// make PLAYER variable available in site context
|
||||||
var PLAYER = window.PLAYER;
|
var PLAYER = window.PLAYER;
|
||||||
var CHAT_SHRINKED = 60;
|
var CHAT_SHRINKED = 60;
|
||||||
|
|
||||||
|
// Minimum zoom level resonator will display
|
||||||
|
var RESONATOR_DISPLAY_ZOOM_LEVEL = 17;
|
||||||
|
|
||||||
|
// Constants for resonator positioning
|
||||||
|
var SLOT_TO_LAT = [0, Math.sqrt(2)/2, 1, Math.sqrt(2)/2, 0, -Math.sqrt(2)/2, -1, -Math.sqrt(2)/2];
|
||||||
|
var SLOT_TO_LNG = [1, Math.sqrt(2)/2, 0, -Math.sqrt(2)/2, -1, -Math.sqrt(2)/2, 0, Math.sqrt(2)/2];
|
||||||
|
var EARTH_RADIUS=6378137;
|
||||||
|
|
||||||
// STORAGE ///////////////////////////////////////////////////////////
|
// STORAGE ///////////////////////////////////////////////////////////
|
||||||
// global variables used for storage. Most likely READ ONLY. Proper
|
// global variables used for storage. Most likely READ ONLY. Proper
|
||||||
// way would be to encapsulate them in an anonymous function and write
|
// way would be to encapsulate them in an anonymous function and write
|
||||||
@ -161,7 +188,11 @@ var portalsLayers, linksLayer, fieldsLayer;
|
|||||||
window.portals = {};
|
window.portals = {};
|
||||||
window.links = {};
|
window.links = {};
|
||||||
window.fields = {};
|
window.fields = {};
|
||||||
|
window.resonators = {};
|
||||||
|
|
||||||
|
// plugin framework. Plugins may load earlier than iitc, so don’t
|
||||||
|
// overwrite data
|
||||||
|
if(typeof window.plugin !== 'function') window.plugin = function() {};
|
||||||
|
|
||||||
|
|
||||||
@@INJECTHERE@@
|
@@INJECTHERE@@
|
||||||
|
28
plugins/README.md
Normal file
28
plugins/README.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
Plugins
|
||||||
|
=======
|
||||||
|
|
||||||
|
Install
|
||||||
|
-------
|
||||||
|
Plugins are installed the same way the total conversion script is. Please see there for specific instructions for your browser.
|
||||||
|
|
||||||
|
|
||||||
|
Available Plugins
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
- [**Guess Player Level**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/guess-player-levels.user.js) looks for the highest placed resonator per player in the current view to guess the player level.
|
||||||
|
|
||||||
|
|
||||||
|
Hacking
|
||||||
|
-------
|
||||||
|
|
||||||
|
Plugins may be developed in the same way as the total conversion script. Plugins may provide features tailored to specific needs and are allowed to change things as they see fit. You can provide them separately oder submit a pull request to have them managed in this repository. There are currently no hooks that allow integration with the main script, but I will add those if the need arises. Simply open a bug report.
|
||||||
|
|
||||||
|
You can use the guess player level script as an example to get you started. Just update the names and the part between `// PLUGIN START` and `// PLUGIN END` and you should be able to develop your plugin. The other code ensures your plugin is executed after the main script.
|
||||||
|
|
||||||
|
If you happen the write general purpose functions for your plugin, consider adding them to the main script instead. For example, if you write a `getResoCountFromPortal(details)` function it may be very well added to `code/portal_info.js`.
|
||||||
|
|
||||||
|
|
||||||
|
Available Hooks
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Available hooks are documented in the code. Please refer to the [boilerplate explanation in `hooks.js`](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/code/hooks.js) to see which are available and how to listen for them. If you need additional hooks, open bug reports (preferably with patches attached).
|
106
plugins/guess-player-levels.user.js
Normal file
106
plugins/guess-player-levels.user.js
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
// ==UserScript==
|
||||||
|
// @id iitc-plugin-guess-player-levels@breunigs
|
||||||
|
// @name iitc: guess player level
|
||||||
|
// @version 0.1
|
||||||
|
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
|
||||||
|
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/guess-player-levels.user.js
|
||||||
|
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/guess-player-levels.user.js
|
||||||
|
// @description Tries to determine player levels from the data available in the current view
|
||||||
|
// @include http://www.ingress.com/intel*
|
||||||
|
// @match http://www.ingress.com/intel*
|
||||||
|
// ==/UserScript==
|
||||||
|
|
||||||
|
function wrapper() {
|
||||||
|
// ensure plugin framework is there, even if iitc is not yet loaded
|
||||||
|
if(typeof window.plugin !== 'function') window.plugin = function() {};
|
||||||
|
|
||||||
|
|
||||||
|
// PLUGIN START ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// use own namespace for plugin
|
||||||
|
window.plugin.guessPlayerLevels = function() {};
|
||||||
|
|
||||||
|
window.plugin.guessPlayerLevels.setupCallback = function() {
|
||||||
|
$('#toolbox').append('<a onclick="window.plugin.guessPlayerLevels.guess()">guess player levels</a> ');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
window.plugin.guessPlayerLevels.setLevelTitle = function(dom) {
|
||||||
|
//expects dom node with nick in its child text node
|
||||||
|
var playersNamed = window.plugin.guessPlayerLevels.prepareGuess();
|
||||||
|
var el = $(dom);
|
||||||
|
var nick = el.text();
|
||||||
|
var text;
|
||||||
|
if (nick in playersNamed) {
|
||||||
|
text = 'Min player level: ' + playersNamed[nick] + ' (guessed)';
|
||||||
|
} else {
|
||||||
|
text = 'Min player level unknown';
|
||||||
|
}
|
||||||
|
el.attr('title', text);
|
||||||
|
el.addClass('help');
|
||||||
|
}
|
||||||
|
|
||||||
|
window.plugin.guessPlayerLevels.setupChatNickHelper = function() {
|
||||||
|
$('#portaldetails').delegate('#resodetails .meter-text', 'mouseenter', function() {
|
||||||
|
window.plugin.guessPlayerLevels.setLevelTitle(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#chat').delegate('mark', 'mouseenter', function() {
|
||||||
|
window.plugin.guessPlayerLevels.setLevelTitle(this);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
window.plugin.guessPlayerLevels.prepareGuess = function() {
|
||||||
|
var players = {};
|
||||||
|
$.each(window.portals, function(ind, portal) {
|
||||||
|
var r = portal.options.details.resonatorArray.resonators;
|
||||||
|
$.each(r, function(ind, reso) {
|
||||||
|
if(!reso) return true;
|
||||||
|
var p = reso.ownerGuid;
|
||||||
|
var l = reso.level;
|
||||||
|
if(!players[p] || players[p] < l) players[p] = l;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
var playersNamed = {};
|
||||||
|
$.each(players, function(guid, level) {
|
||||||
|
playersNamed[getPlayerName(guid)] = level;
|
||||||
|
});
|
||||||
|
return playersNamed;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.plugin.guessPlayerLevels.guess = function() {
|
||||||
|
var playersNamed = window.plugin.guessPlayerLevels.prepareGuess();
|
||||||
|
|
||||||
|
var s = 'the players have at least the following level:\n\n';
|
||||||
|
$.each(Object.keys(playersNamed).sort(), function(ind, playerName) {
|
||||||
|
var level = playersNamed[playerName];
|
||||||
|
var nick = (playerName + ': ').slice(0, 20);
|
||||||
|
s += nick + '\t' + level + '\n';
|
||||||
|
});
|
||||||
|
|
||||||
|
s += '\n\nIf there are some unresolved names, simply try again.'
|
||||||
|
|
||||||
|
alert(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
var setup = function() {
|
||||||
|
window.plugin.guessPlayerLevels.setupCallback();
|
||||||
|
window.plugin.guessPlayerLevels.setupChatNickHelper();
|
||||||
|
}
|
||||||
|
|
||||||
|
// PLUGIN END //////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
if(window.iitcLoaded && typeof setup === 'function') {
|
||||||
|
setup();
|
||||||
|
} else {
|
||||||
|
if(window.bootPlugins)
|
||||||
|
window.bootPlugins.push(setup);
|
||||||
|
else
|
||||||
|
window.bootPlugins = [setup];
|
||||||
|
}
|
||||||
|
} // wrapper end
|
||||||
|
// inject code into site context
|
||||||
|
var script = document.createElement('script');
|
||||||
|
script.appendChild(document.createTextNode('('+ wrapper +')();'));
|
||||||
|
(document.body || document.head || document.documentElement).appendChild(script);
|
82
style.css
82
style.css
@ -10,38 +10,45 @@ body {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#map {
|
|
||||||
margin-right:302px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#scrollwrapper {
|
#scrollwrapper {
|
||||||
height: 100%;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
right: -38px;
|
right: -38px;
|
||||||
top: 0;
|
top: 0;
|
||||||
width: 340px;
|
width: 340px;
|
||||||
|
bottom: 45px;
|
||||||
|
z-index: 1001;
|
||||||
}
|
}
|
||||||
|
|
||||||
#sidebar {
|
#sidebar {
|
||||||
background: #000;
|
background-color: rgba(8, 48, 78, 0.9);
|
||||||
border-left: 2px solid #c3c3c3;
|
border-left: 1px solid #20A8B1;
|
||||||
color: #888;
|
color: #888;
|
||||||
height: 100%;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
left: 0;
|
left: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
max-height: 100%;
|
||||||
overflow-y:scroll;
|
overflow-y:scroll;
|
||||||
overflow-x:hidden;
|
overflow-x:hidden;
|
||||||
|
z-index: 3000;
|
||||||
}
|
}
|
||||||
|
|
||||||
#redeem {
|
#sidebartoggle {
|
||||||
/* cheap hack to prevent sidebar content being overlayed by the map
|
display: block;
|
||||||
* status box */
|
padding: 20px 5px;
|
||||||
margin-bottom: 55px;
|
margin-top: -31px;
|
||||||
|
line-height: 10px;
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
z-index: 3001;
|
||||||
|
background-color: rgba(8, 48, 78, 0.9);
|
||||||
|
color: #FFCE00;
|
||||||
|
border: 1px solid #20A8B1;
|
||||||
|
border-right: none;
|
||||||
|
border-radius: 5px 0 0 5px;
|
||||||
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.enl {
|
.enl {
|
||||||
color: #03fe03 !important;
|
color: #03fe03 !important;
|
||||||
}
|
}
|
||||||
@ -106,6 +113,11 @@ a:hover {
|
|||||||
border: 1px solid #20A8B1;
|
border: 1px solid #20A8B1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#chatcontrols a:first-child {
|
||||||
|
letter-spacing:-1px;
|
||||||
|
text-decoration: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
#chatcontrols a.active {
|
#chatcontrols a.active {
|
||||||
border-color: #FFCE00;
|
border-color: #FFCE00;
|
||||||
border-bottom-width:0px;
|
border-bottom-width:0px;
|
||||||
@ -213,6 +225,11 @@ summary {
|
|||||||
z-index: 3001;
|
z-index: 3001;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#chat .invisibleseparator {
|
||||||
|
color: rgba(8, 48, 78, 0.0);
|
||||||
|
overflow: hidden;
|
||||||
|
width: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#chatinput span {
|
#chatinput span {
|
||||||
@ -238,7 +255,7 @@ summary {
|
|||||||
/* sidebar ************************************************************/
|
/* sidebar ************************************************************/
|
||||||
|
|
||||||
#sidebar > * {
|
#sidebar > * {
|
||||||
border-bottom: 1px solid #c3c3c3;
|
border-bottom: 1px solid #20A8B1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -302,7 +319,7 @@ h2 sup, h2 sub {
|
|||||||
|
|
||||||
/* geosearch input, and others */
|
/* geosearch input, and others */
|
||||||
input {
|
input {
|
||||||
background: #313131;
|
background-color: rgba(0, 0, 0, 0.3);
|
||||||
color: #ffce00;
|
color: #ffce00;
|
||||||
height: 22px;
|
height: 22px;
|
||||||
line-height: 22px;
|
line-height: 22px;
|
||||||
@ -350,7 +367,7 @@ h3 {
|
|||||||
font-size: 40px;
|
font-size: 40px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 10px;
|
right: 10px;
|
||||||
text-shadow: 0 0 2px #000000, 0 0 5px #ffffff;
|
text-shadow: -1px -1px #000, 1px -1px #000, -1px 1px #000, 1px 1px #000, 0 0 5px #fff;
|
||||||
top: 100px;
|
top: 100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,11 +375,16 @@ h3 {
|
|||||||
.mods {
|
.mods {
|
||||||
margin-bottom: 1px;
|
margin-bottom: 1px;
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
|
height: 75px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mods span {
|
.mods span {
|
||||||
background: #313131;
|
background-color: rgba(0, 0, 0, 0.3);
|
||||||
display: inline-block;
|
/* can’t use inline-block because Webkit’s implementation is buggy and
|
||||||
|
* introduces additional margins in random cases. No clear necessary,
|
||||||
|
* as that’s solved by setting height on .mods. */
|
||||||
|
display: block;
|
||||||
|
float:left;
|
||||||
height: 63.7px;
|
height: 63.7px;
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@ -370,6 +392,7 @@ h3 {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
width: 63.7px;
|
width: 63.7px;
|
||||||
cursor:help;
|
cursor:help;
|
||||||
|
border: 1px solid #666;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mods span[title=""] {
|
.mods span[title=""] {
|
||||||
@ -431,6 +454,7 @@ aside:nth-child(odd) span {
|
|||||||
|
|
||||||
/* resonators */
|
/* resonators */
|
||||||
#resodetails {
|
#resodetails {
|
||||||
|
white-space: nowrap;
|
||||||
margin: 16px 0;
|
margin: 16px 0;
|
||||||
-moz-column-gap: 10px;
|
-moz-column-gap: 10px;
|
||||||
-moz-column-width: 141px;
|
-moz-column-width: 141px;
|
||||||
@ -483,31 +507,47 @@ aside:nth-child(odd) span {
|
|||||||
|
|
||||||
.linkdetails {
|
.linkdetails {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
.linkdetails aside {
|
.linkdetails aside {
|
||||||
margin: 0 4px;
|
margin: 0 4px;
|
||||||
width: 140px;
|
width: 140px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#toolbox {
|
||||||
|
padding: 4px;
|
||||||
|
font-size:90%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#toolbox > a {
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#spacer {
|
||||||
|
height: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
/* a common portal display takes this much space (prevents moving
|
/* a common portal display takes this much space (prevents moving
|
||||||
* content when first selecting a portal) */
|
* content when first selecting a portal) */
|
||||||
|
|
||||||
#portaldetails {
|
#portaldetails {
|
||||||
min-height: 532px;
|
min-height: 553px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* update status */
|
/* update status */
|
||||||
#updatestatus {
|
#updatestatus {
|
||||||
background: #000;
|
background-color: rgba(8, 48, 78, 1);
|
||||||
border-bottom: 0;
|
border-bottom: 0;
|
||||||
border-top: 1px solid #c3c3c3;
|
border-top: 1px solid #20A8B1;
|
||||||
|
border-left: 1px solid #20A8B1;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
color: #ffce00;
|
color: #ffce00;
|
||||||
font-size:13px;
|
font-size:13px;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
right: 0;
|
right: 0;
|
||||||
|
z-index:3002;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @id ingress-intel-total-conversion@breunigs
|
// @id ingress-intel-total-conversion@breunigs
|
||||||
// @name intel map total conversion
|
// @name intel map total conversion
|
||||||
// @version 0.3-2013-02-08-030330
|
// @version 0.4-2013-02-09-151927
|
||||||
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
|
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
|
||||||
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/total-conversion-build.user.js
|
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/total-conversion-build.user.js
|
||||||
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/total-conversion-build.user.js
|
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/total-conversion-build.user.js
|
||||||
@ -42,7 +42,8 @@ for(var i = 0; i < d.length; i++) {
|
|||||||
// possible without requiring scripts.
|
// possible without requiring scripts.
|
||||||
document.getElementsByTagName('head')[0].innerHTML = ''
|
document.getElementsByTagName('head')[0].innerHTML = ''
|
||||||
//~ + '<link rel="stylesheet" type="text/css" href="http://0.0.0.0:8000/style.css"/>'
|
//~ + '<link rel="stylesheet" type="text/css" href="http://0.0.0.0:8000/style.css"/>'
|
||||||
+ '<link rel="stylesheet" type="text/css" href="http://breunigs.github.com/ingress-intel-total-conversion/style.css"/>'
|
+ '<title>Ingress Intel Map</title>'
|
||||||
|
+ '<link rel="stylesheet" type="text/css" href="http://breunigs.github.com/ingress-intel-total-conversion/style.css?2013-02-09-151927"/>'
|
||||||
+ '<link rel="stylesheet" type="text/css" href="http://cdn.leafletjs.com/leaflet-0.5/leaflet.css"/>'
|
+ '<link rel="stylesheet" type="text/css" href="http://cdn.leafletjs.com/leaflet-0.5/leaflet.css"/>'
|
||||||
+ '<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Coda"/>';
|
+ '<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Coda"/>';
|
||||||
|
|
||||||
@ -64,6 +65,8 @@ document.getElementsByTagName('body')[0].innerHTML = ''
|
|||||||
+ ' <input id="geosearch" placeholder="Search location…" type="text"/>'
|
+ ' <input id="geosearch" placeholder="Search location…" type="text"/>'
|
||||||
+ ' <div id="portaldetails"></div>'
|
+ ' <div id="portaldetails"></div>'
|
||||||
+ ' <input id="redeem" placeholder="Redeem code…" type="text"/>'
|
+ ' <input id="redeem" placeholder="Redeem code…" type="text"/>'
|
||||||
|
+ ' <div id="toolbox"></div>'
|
||||||
|
+ ' <div id="spacer"></div>'
|
||||||
+ ' <div id="updatestatus"></div>'
|
+ ' <div id="updatestatus"></div>'
|
||||||
+ ' </div>';
|
+ ' </div>';
|
||||||
+ '</div>';
|
+ '</div>';
|
||||||
@ -113,6 +116,9 @@ var MAX_DRAWN_FIELDS = 200;
|
|||||||
var COLOR_SELECTED_PORTAL = '#f00';
|
var COLOR_SELECTED_PORTAL = '#f00';
|
||||||
var COLORS = ['#FFCE00', '#0088FF', '#03FE03']; // none, res, enl
|
var COLORS = ['#FFCE00', '#0088FF', '#03FE03']; // none, res, enl
|
||||||
var COLORS_LVL = ['#000', '#FECE5A', '#FFA630', '#FF7315', '#E40000', '#FD2992', '#EB26CD', '#C124E0', '#9627F4'];
|
var COLORS_LVL = ['#000', '#FECE5A', '#FFA630', '#FF7315', '#E40000', '#FD2992', '#EB26CD', '#C124E0', '#9627F4'];
|
||||||
|
var COLORS_MOD = {VERY_RARE: '#F78AF6', RARE: '#AD8AFF', COMMON: '#84FBBD'};
|
||||||
|
|
||||||
|
|
||||||
// circles around a selected portal that show from where you can hack
|
// circles around a selected portal that show from where you can hack
|
||||||
// it and how far the portal reaches (i.e. how far links may be made
|
// it and how far the portal reaches (i.e. how far links may be made
|
||||||
// from this portal)
|
// from this portal)
|
||||||
@ -125,7 +131,7 @@ var RESO_NRG = [0, 1000, 1500, 2000, 2500, 3000, 4000, 5000, 6000];
|
|||||||
var MAX_XM_PER_LEVEL = [0, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000];
|
var MAX_XM_PER_LEVEL = [0, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000];
|
||||||
var MIN_AP_FOR_LEVEL = [0, 10000, 30000, 70000, 150000, 300000, 600000, 1200000];
|
var MIN_AP_FOR_LEVEL = [0, 10000, 30000, 70000, 150000, 300000, 600000, 1200000];
|
||||||
var HACK_RANGE = 35; // in meters, max. distance from portal to be able to access it
|
var HACK_RANGE = 35; // in meters, max. distance from portal to be able to access it
|
||||||
var SLOT_TO_CARDINAL = ['E', 'NE', 'N', 'NW', 'W', 'SW', 'S', 'SE'];
|
var OCTANTS = ['E', 'NE', 'N', 'NW', 'W', 'SW', 'S', 'SE'];
|
||||||
var DEFAULT_PORTAL_IMG = 'http://commondatastorage.googleapis.com/ingress/img/default-portal-image.png';
|
var DEFAULT_PORTAL_IMG = 'http://commondatastorage.googleapis.com/ingress/img/default-portal-image.png';
|
||||||
|
|
||||||
// OTHER MORE-OR-LESS CONSTANTS //////////////////////////////////////
|
// OTHER MORE-OR-LESS CONSTANTS //////////////////////////////////////
|
||||||
@ -149,7 +155,7 @@ window.selectedPortal = null;
|
|||||||
window.portalRangeIndicator = null;
|
window.portalRangeIndicator = null;
|
||||||
window.portalAccessIndicator = null;
|
window.portalAccessIndicator = null;
|
||||||
window.mapRunsUserAction = false;
|
window.mapRunsUserAction = false;
|
||||||
var portalsLayer, linksLayer, fieldsLayer;
|
var portalsLayers, linksLayer, fieldsLayer;
|
||||||
|
|
||||||
// contain references to all entities shown on the map. These are
|
// contain references to all entities shown on the map. These are
|
||||||
// automatically kept in sync with the items on *sLayer, so never ever
|
// automatically kept in sync with the items on *sLayer, so never ever
|
||||||
@ -158,6 +164,9 @@ window.portals = {};
|
|||||||
window.links = {};
|
window.links = {};
|
||||||
window.fields = {};
|
window.fields = {};
|
||||||
|
|
||||||
|
// plugin framework. Plugins may load earlier than iitc, so don’t
|
||||||
|
// overwrite data
|
||||||
|
if(typeof window.plugin !== 'function') window.plugin = function() {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -283,14 +292,17 @@ window.cleanUp = function() {
|
|||||||
var cnt = [0,0,0];
|
var cnt = [0,0,0];
|
||||||
var b = getPaddedBounds();
|
var b = getPaddedBounds();
|
||||||
var minlvl = getMinPortalLevel();
|
var minlvl = getMinPortalLevel();
|
||||||
portalsLayer.eachLayer(function(portal) {
|
for(var i = 0; i < portalsLayers.length; i++) {
|
||||||
|
// i is also the portal level
|
||||||
|
portalsLayers[i].eachLayer(function(portal) {
|
||||||
// portal must be in bounds and have a high enough level. Also don’t
|
// portal must be in bounds and have a high enough level. Also don’t
|
||||||
// remove if it is selected.
|
// remove if it is selected.
|
||||||
if(portal.options.guid == window.selectedPortal ||
|
if(portal.options.guid == window.selectedPortal ||
|
||||||
(b.contains(portal.getLatLng()) && portal.options.level >= minlvl)) return;
|
(b.contains(portal.getLatLng()) && i >= minlvl)) return;
|
||||||
cnt[0]++;
|
cnt[0]++;
|
||||||
portalsLayer.removeLayer(portal);
|
portalsLayers[i].removeLayer(portal);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
linksLayer.eachLayer(function(link) {
|
linksLayer.eachLayer(function(link) {
|
||||||
if(b.intersects(link.getBounds())) return;
|
if(b.intersects(link.getBounds())) return;
|
||||||
cnt[1]++;
|
cnt[1]++;
|
||||||
@ -317,7 +329,9 @@ window.removeByGuid = function(guid) {
|
|||||||
case '11':
|
case '11':
|
||||||
case '12':
|
case '12':
|
||||||
if(!window.portals[guid]) return;
|
if(!window.portals[guid]) return;
|
||||||
portalsLayer.removeLayer(window.portals[guid]);
|
var p = window.portals[guid];
|
||||||
|
for(var i = 0; i < portalsLayers.length; i++)
|
||||||
|
portalsLayers[i].removeLayer(p);
|
||||||
break;
|
break;
|
||||||
case '9':
|
case '9':
|
||||||
if(!window.links[guid]) return;
|
if(!window.links[guid]) return;
|
||||||
@ -376,13 +390,24 @@ window.renderPortal = function(ent) {
|
|||||||
guid: ent[0]});
|
guid: ent[0]});
|
||||||
|
|
||||||
p.on('remove', function() { delete window.portals[this.options.guid]; });
|
p.on('remove', function() { delete window.portals[this.options.guid]; });
|
||||||
p.on('add', function() { window.portals[this.options.guid] = this; });
|
p.on('add', function() {
|
||||||
|
window.portals[this.options.guid] = this;
|
||||||
|
// handles the case where a selected portal gets removed from the
|
||||||
|
// map by hiding all portals with said level
|
||||||
|
if(window.selectedPortal != this.options.guid)
|
||||||
|
window.portalResetColor(this);
|
||||||
|
});
|
||||||
p.on('click', function() { window.renderPortalDetails(ent[0]); });
|
p.on('click', function() { window.renderPortalDetails(ent[0]); });
|
||||||
p.on('dblclick', function() {
|
p.on('dblclick', function() {
|
||||||
window.renderPortalDetails(ent[0]);
|
window.renderPortalDetails(ent[0]);
|
||||||
window.map.setView(latlng, 17);
|
window.map.setView(latlng, 17);
|
||||||
});
|
});
|
||||||
p.addTo(portalsLayer);
|
// portalLevel contains a float, need to round down
|
||||||
|
p.addTo(portalsLayers[parseInt(portalLevel)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.portalResetColor = function(portal) {
|
||||||
|
portal.setStyle({color: portal.options.fillColor});
|
||||||
}
|
}
|
||||||
|
|
||||||
// renders a link on the map from the given entity
|
// renders a link on the map from the given entity
|
||||||
@ -476,7 +501,7 @@ window.requests.abort = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// gives user feedback about pending operations. Draws current status
|
// gives user feedback about pending operations. Draws current status
|
||||||
// to website.
|
// to website. Updates info in layer chooser.
|
||||||
window.renderUpdateStatus = function() {
|
window.renderUpdateStatus = function() {
|
||||||
var t = '<b>map status:</b> ';
|
var t = '<b>map status:</b> ';
|
||||||
if(mapRunsUserAction)
|
if(mapRunsUserAction)
|
||||||
@ -492,15 +517,20 @@ window.renderUpdateStatus = function() {
|
|||||||
t += ' <span style="color:red" class="help" title="Can only render so much before it gets unbearably slow. Not all entities are shown. Zoom in or increase the limit (search for MAX_DRAWN_*).">RENDER LIMIT</span> '
|
t += ' <span style="color:red" class="help" title="Can only render so much before it gets unbearably slow. Not all entities are shown. Zoom in or increase the limit (search for MAX_DRAWN_*).">RENDER LIMIT</span> '
|
||||||
|
|
||||||
if(window.failedRequestCount > 0)
|
if(window.failedRequestCount > 0)
|
||||||
t += ' ' + window.failedRequestCount + ' requests failed.'
|
t += ' <span style="color:red">' + window.failedRequestCount + ' requests failed</span>.'
|
||||||
|
|
||||||
t += '<br/>(';
|
t += '<br/>(';
|
||||||
var minlvl = getMinPortalLevel();
|
var minlvl = getMinPortalLevel();
|
||||||
if(minlvl === 0)
|
if(minlvl === 0)
|
||||||
t += 'showing all portals';
|
t += 'loading all portals';
|
||||||
else
|
else
|
||||||
t+= 'only showing portals with level '+minlvl+' and up';
|
t+= 'only loading portals with level '+minlvl+' and up';
|
||||||
t += ')</span>';
|
t += ')';
|
||||||
|
|
||||||
|
var portalSelection = $('.leaflet-control-layers-overlays label');
|
||||||
|
portalSelection.slice(0, minlvl+1).addClass('disabled').attr('title', 'Zoom in to show those.');
|
||||||
|
portalSelection.slice(minlvl, 8).removeClass('disabled').attr('title', '');
|
||||||
|
|
||||||
|
|
||||||
$('#updatestatus').html(t);
|
$('#updatestatus').html(t);
|
||||||
}
|
}
|
||||||
@ -696,6 +726,13 @@ String.prototype.capitalize = function() {
|
|||||||
return this.charAt(0).toUpperCase() + this.slice(1).toLowerCase();
|
return this.charAt(0).toUpperCase() + this.slice(1).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// http://stackoverflow.com/a/646643/1684530 by Bergi and CMS
|
||||||
|
if (typeof String.prototype.startsWith !== 'function') {
|
||||||
|
String.prototype.startsWith = function (str){
|
||||||
|
return this.slice(0, str.length) === str;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -728,13 +765,14 @@ window.setupStyles = function() {
|
|||||||
$('head').append('<style>' +
|
$('head').append('<style>' +
|
||||||
[ '#map { margin-right: '+(SIDEBAR_WIDTH+2)+'px } ',
|
[ '#map { margin-right: '+(SIDEBAR_WIDTH+2)+'px } ',
|
||||||
'#largepreview.enl img { border:2px solid '+COLORS[TEAM_ENL]+'; } ',
|
'#largepreview.enl img { border:2px solid '+COLORS[TEAM_ENL]+'; } ',
|
||||||
|
'#largepreview.res img { border:2px solid '+COLORS[TEAM_RES]+'; } ',
|
||||||
'#largepreview.none img { border:2px solid '+COLORS[TEAM_NONE]+'; } ',
|
'#largepreview.none img { border:2px solid '+COLORS[TEAM_NONE]+'; } ',
|
||||||
'#chatcontrols { bottom: '+(CHAT_SHRINKED+24)+'px; }',
|
'#chatcontrols { bottom: '+(CHAT_SHRINKED+24)+'px; }',
|
||||||
'#chat { height: '+CHAT_SHRINKED+'px; } ',
|
'#chat { height: '+CHAT_SHRINKED+'px; } ',
|
||||||
'#updatestatus { width:'+(SIDEBAR_WIDTH-2*4)+'px; } ',
|
'#updatestatus { width:'+(SIDEBAR_WIDTH-2*4)+'px; } ',
|
||||||
'#sidebar { width:'+(SIDEBAR_WIDTH + HIDDEN_SCROLLBAR_ASSUMED_WIDTH + 2 /*border*/)+'px; } ',
|
'#sidebar { width:'+(SIDEBAR_WIDTH + HIDDEN_SCROLLBAR_ASSUMED_WIDTH + 2 /*border*/)+'px; } ',
|
||||||
'#scrollwrapper { width:'+(SIDEBAR_WIDTH + 2*HIDDEN_SCROLLBAR_ASSUMED_WIDTH)+'px; right:-'+(2*HIDDEN_SCROLLBAR_ASSUMED_WIDTH-2)+'px } ',
|
'#scrollwrapper { width:'+(SIDEBAR_WIDTH + 2*HIDDEN_SCROLLBAR_ASSUMED_WIDTH)+'px; right:-'+(2*HIDDEN_SCROLLBAR_ASSUMED_WIDTH-2)+'px } ',
|
||||||
'input, h2, #updatestatus { width:'+(SIDEBAR_WIDTH - 2*4)+'px !important } ',
|
'#sidebar input, h2, #updatestatus { width:'+(SIDEBAR_WIDTH - 2*4)+'px !important } ',
|
||||||
'#sidebar > *, #gamestat span, .imgpreview img { width:'+SIDEBAR_WIDTH+'px; }'].join("\n")
|
'#sidebar > *, #gamestat span, .imgpreview img { width:'+SIDEBAR_WIDTH+'px; }'].join("\n")
|
||||||
+ '</style>');
|
+ '</style>');
|
||||||
}
|
}
|
||||||
@ -752,16 +790,33 @@ window.setupMap = function() {
|
|||||||
var views = [cmMid, cmMin, osm, new L.Google('INGRESS'), new L.Google('ROADMAP'),
|
var views = [cmMid, cmMin, osm, new L.Google('INGRESS'), new L.Google('ROADMAP'),
|
||||||
new L.Google('SATELLITE'), new L.Google('HYBRID')];
|
new L.Google('SATELLITE'), new L.Google('HYBRID')];
|
||||||
|
|
||||||
portalsLayer = L.layerGroup([]);
|
|
||||||
linksLayer = L.layerGroup([]);
|
window.map = new L.Map('map', $.extend(getPosition(),
|
||||||
fieldsLayer = L.layerGroup([]);
|
{zoomControl: !(localStorage['iitc.zoom.buttons'] === 'false')}
|
||||||
window.map = new L.Map('map', $.extend(getPosition(), {zoomControl: false}));
|
));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
map.addLayer(views[readCookie('ingress.intelmap.type')]);
|
map.addLayer(views[readCookie('ingress.intelmap.type')]);
|
||||||
} catch(e) { map.addLayer(views[0]); }
|
} catch(e) { map.addLayer(views[0]); }
|
||||||
map.addLayer(portalsLayer);
|
|
||||||
|
var addLayers = {};
|
||||||
|
|
||||||
|
portalsLayers = [];
|
||||||
|
for(var i = 0; i <= 8; i++) {
|
||||||
|
portalsLayers[i] = L.layerGroup([]);
|
||||||
|
map.addLayer(portalsLayers[i]);
|
||||||
|
var t = (i === 0 ? 'Unclaimed' : 'Level ' + i) + ' Portals';
|
||||||
|
addLayers[t] = portalsLayers[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldsLayer = L.layerGroup([]);
|
||||||
map.addLayer(fieldsLayer, true);
|
map.addLayer(fieldsLayer, true);
|
||||||
|
addLayers['Fields'] = fieldsLayer;
|
||||||
|
|
||||||
|
linksLayer = L.layerGroup([]);
|
||||||
map.addLayer(linksLayer, true);
|
map.addLayer(linksLayer, true);
|
||||||
|
addLayers['Links'] = linksLayer;
|
||||||
|
|
||||||
map.addControl(new L.Control.Layers({
|
map.addControl(new L.Control.Layers({
|
||||||
'OSM Cloudmade Midnight': views[0],
|
'OSM Cloudmade Midnight': views[0],
|
||||||
'OSM Cloudmade Minimal': views[1],
|
'OSM Cloudmade Minimal': views[1],
|
||||||
@ -770,11 +825,7 @@ window.setupMap = function() {
|
|||||||
'Google Roads': views[4],
|
'Google Roads': views[4],
|
||||||
'Google Satellite': views[5],
|
'Google Satellite': views[5],
|
||||||
'Google Hybrid': views[6]
|
'Google Hybrid': views[6]
|
||||||
}, {
|
}, addLayers));
|
||||||
'Portals': portalsLayer,
|
|
||||||
'Links': linksLayer,
|
|
||||||
'Fields': fieldsLayer
|
|
||||||
}));
|
|
||||||
map.attributionControl.setPrefix('');
|
map.attributionControl.setPrefix('');
|
||||||
// listen for changes and store them in cookies
|
// listen for changes and store them in cookies
|
||||||
map.on('moveend', window.storeMapPosition);
|
map.on('moveend', window.storeMapPosition);
|
||||||
@ -858,9 +909,14 @@ function boot() {
|
|||||||
|
|
||||||
// load only once
|
// load only once
|
||||||
var n = window.PLAYER['nickname'];
|
var n = window.PLAYER['nickname'];
|
||||||
window.PLAYER['nickMatcher'] = new RegExp('\\b('+n+')\\b');
|
window.PLAYER['nickMatcher'] = new RegExp('\\b('+n+')\\b', 'ig');
|
||||||
|
|
||||||
$('#sidebar').show();
|
$('#sidebar').show();
|
||||||
|
|
||||||
|
if(window.bootPlugins)
|
||||||
|
$.each(window.bootPlugins, function(ind, ref) { ref(); });
|
||||||
|
|
||||||
|
window.iitcLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is the minified load.js script that allows us to easily load
|
// this is the minified load.js script that allows us to easily load
|
||||||
@ -872,13 +928,15 @@ function asyncLoadScript(a){return function(b,c){var d=document.createElement("s
|
|||||||
|
|
||||||
// modified version of https://github.com/shramov/leaflet-plugins. Also
|
// modified version of https://github.com/shramov/leaflet-plugins. Also
|
||||||
// contains the default Ingress map style.
|
// contains the default Ingress map style.
|
||||||
var LLGMAPS = 'http://breunigs.github.com/ingress-intel-total-conversion/leaflet_google.js';
|
var LLGMAPS = 'http://breunigs.github.com/ingress-intel-total-conversion/external/leaflet_google.js';
|
||||||
var JQUERY = 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js';
|
var JQUERY = 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js';
|
||||||
var LEAFLET = 'http://cdn.leafletjs.com/leaflet-0.5/leaflet.js';
|
var LEAFLET = 'http://cdn.leafletjs.com/leaflet-0.5/leaflet.js';
|
||||||
var AUTOLINK = 'https://raw.github.com/bryanwoods/autolink-js/master/autolink.js';
|
var AUTOLINK = 'http://breunigs.github.com/ingress-intel-total-conversion/external/autolink.js';
|
||||||
|
|
||||||
// after all scripts have loaded, boot the actual app
|
// after all scripts have loaded, boot the actual app
|
||||||
load(JQUERY, LEAFLET, AUTOLINK).then(LLGMAPS).thenRun(boot);
|
load(JQUERY, LEAFLET, AUTOLINK).then(LLGMAPS).onError(function (err) {
|
||||||
|
alert('Could not all resources, the script likely won’t work.\n\nIf this happend the first time for you, it’s probably a temporary issue. Just wait a bit and try again.\n\nIf you installed the script for the first time and this happens:\n– try disabling NoScript if you have it installed\n– press CTRL+SHIFT+K in Firefox or CTRL+SHIFT+I in Chrome/Opera and reload the page. Additional info may be available in the console.\n– Open an issue at https://github.com/breunigs/ingress-intel-total-conversion/issues');
|
||||||
|
}).thenRun(boot);
|
||||||
|
|
||||||
|
|
||||||
window.chat = function() {};
|
window.chat = function() {};
|
||||||
@ -1406,7 +1464,7 @@ window.chat.chooser = function(event) {
|
|||||||
|
|
||||||
case 'public':
|
case 'public':
|
||||||
span.css('cssText', 'color: red !important');
|
span.css('cssText', 'color: red !important');
|
||||||
span.text('tell public:');
|
span.text('broadcast:');
|
||||||
elm = $('#chatpublic');
|
elm = $('#chatpublic');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1499,7 +1557,9 @@ window.chat.setupTime = function() {
|
|||||||
var updateTime = function() {
|
var updateTime = function() {
|
||||||
if(window.isIdle()) return;
|
if(window.isIdle()) return;
|
||||||
var d = new Date();
|
var d = new Date();
|
||||||
inputTime.text(d.toLocaleTimeString().slice(0, 5));
|
var h = d.getHours() + ''; if(h.length === 1) h = '0' + h;
|
||||||
|
var m = d.getMinutes() + ''; if(m.length === 1) m = '0' + m;
|
||||||
|
inputTime.text(h+':'+m);
|
||||||
// update ON the minute (1ms after)
|
// update ON the minute (1ms after)
|
||||||
setTimeout(updateTime, (60 - d.getSeconds()) * 1000 + 1);
|
setTimeout(updateTime, (60 - d.getSeconds()) * 1000 + 1);
|
||||||
};
|
};
|
||||||
@ -1514,7 +1574,7 @@ window.chat.setupTime = function() {
|
|||||||
|
|
||||||
|
|
||||||
window.chat.setupPosting = function() {
|
window.chat.setupPosting = function() {
|
||||||
$('#chatinput input').keypress(function(event) {
|
$('#chatinput input').keydown(function(event) {
|
||||||
try{
|
try{
|
||||||
|
|
||||||
var kc = (event.keyCode ? event.keyCode : event.which);
|
var kc = (event.keyCode ? event.keyCode : event.which);
|
||||||
@ -1598,10 +1658,12 @@ window.getPortalDescriptionFromDetails = function(details) {
|
|||||||
window.getModDetails = function(d) {
|
window.getModDetails = function(d) {
|
||||||
var mods = [];
|
var mods = [];
|
||||||
var modsTitle = [];
|
var modsTitle = [];
|
||||||
|
var modsColor = [];
|
||||||
$.each(d.portalV2.linkedModArray, function(ind, mod) {
|
$.each(d.portalV2.linkedModArray, function(ind, mod) {
|
||||||
if(!mod) {
|
if(!mod) {
|
||||||
mods.push('');
|
mods.push('');
|
||||||
modsTitle.push('');
|
modsTitle.push('');
|
||||||
|
modsColor.push('#000');
|
||||||
} else if(mod.type === 'RES_SHIELD') {
|
} else if(mod.type === 'RES_SHIELD') {
|
||||||
|
|
||||||
var title = mod.rarity.capitalize() + ' ' + mod.displayName + '\n';
|
var title = mod.rarity.capitalize() + ' ' + mod.displayName + '\n';
|
||||||
@ -1615,16 +1677,18 @@ window.getModDetails = function(d) {
|
|||||||
|
|
||||||
mods.push(mod.rarity.capitalize().replace('_', ' ') + ' ' + mod.displayName);
|
mods.push(mod.rarity.capitalize().replace('_', ' ') + ' ' + mod.displayName);
|
||||||
modsTitle.push(title);
|
modsTitle.push(title);
|
||||||
|
modsColor.push(COLORS_MOD[mod.rarity]);
|
||||||
} else {
|
} else {
|
||||||
mods.push(mod.type);
|
mods.push(mod.type);
|
||||||
modsTitle.push('Unknown mod. No further details available.');
|
modsTitle.push('Unknown mod. No further details available.');
|
||||||
|
modsColor.push('#FFF');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var t = '<span title="'+modsTitle[0]+'">'+mods[0]+'</span>'
|
var t = '<span title="'+modsTitle[0]+'" style="color:'+modsColor[0]+'">'+mods[0]+'</span>'
|
||||||
+ '<span title="'+modsTitle[1]+'">'+mods[1]+'</span>'
|
+ '<span title="'+modsTitle[1]+'" style="color:'+modsColor[1]+'">'+mods[1]+'</span>'
|
||||||
+ '<span title="'+modsTitle[2]+'">'+mods[2]+'</span>'
|
+ '<span title="'+modsTitle[2]+'" style="color:'+modsColor[2]+'">'+mods[2]+'</span>'
|
||||||
+ '<span title="'+modsTitle[3]+'">'+mods[3]+'</span>'
|
+ '<span title="'+modsTitle[3]+'" style="color:'+modsColor[3]+'">'+mods[3]+'</span>'
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
@ -1679,16 +1743,22 @@ window.renderResonatorDetails = function(slot, level, nrg, dist, nick) {
|
|||||||
var max = RESO_NRG[level];
|
var max = RESO_NRG[level];
|
||||||
var fillGrade = nrg/max*100;
|
var fillGrade = nrg/max*100;
|
||||||
|
|
||||||
var inf = 'energy:\t\t' + nrg + ' / ' + max + '\n'
|
var inf = 'energy:\t\t' + nrg + ' / ' + max + ' (' + Math.round(fillGrade) + '%)' + '\n'
|
||||||
+ 'level:\t\t' + level +'\n'
|
+ 'level:\t\t' + level +'\n'
|
||||||
+ 'distance:\t' + dist + 'm\n'
|
+ 'distance:\t' + dist + 'm\n'
|
||||||
+ 'owner:\t\t' + nick + '\n'
|
+ 'owner:\t\t' + nick + '\n'
|
||||||
+ 'cardinal:\t' + SLOT_TO_CARDINAL[slot];
|
+ 'octant:\t' + OCTANTS[slot];
|
||||||
|
|
||||||
|
var style = 'width:'+fillGrade+'%; background:'+COLORS_LVL[level]+';';
|
||||||
|
|
||||||
|
var color = (level < 3 ? "#9900FF" : "#FFFFFF");
|
||||||
|
|
||||||
|
var lbar = '<span class="meter-level" style="color: ' + color + ';"> ' + level + ' </span>';
|
||||||
|
|
||||||
var style = 'width:'+fillGrade+'%; background:'+COLORS_LVL[level]+'; color:'+COLORS_LVL[level];
|
|
||||||
var fill = '<span style="'+style+'"></span>';
|
var fill = '<span style="'+style+'"></span>';
|
||||||
var meter = '<span class="meter" title="'+inf+'">'
|
|
||||||
+ fill + '</span>';
|
var meter = '<span class="meter meter-rel" title="'+inf+'">'
|
||||||
|
+ fill + lbar + '</span>';
|
||||||
}
|
}
|
||||||
var cls = slot <= 3 ? 'left' : 'right';
|
var cls = slot <= 3 ? 'left' : 'right';
|
||||||
var text = '<span class="meter-text '+cls+'">'+(nick||'')+'</span>';
|
var text = '<span class="meter-text '+cls+'">'+(nick||'')+'</span>';
|
||||||
@ -1992,8 +2062,7 @@ window.setPortalIndicators = function(d) {
|
|||||||
window.selectPortal = function(guid) {
|
window.selectPortal = function(guid) {
|
||||||
var update = selectedPortal === guid;
|
var update = selectedPortal === guid;
|
||||||
var oldPortal = portals[selectedPortal];
|
var oldPortal = portals[selectedPortal];
|
||||||
if(!update && oldPortal)
|
if(!update && oldPortal) portalResetColor(oldPortal);
|
||||||
oldPortal.setStyle({color: oldPortal.options.fillColor});
|
|
||||||
|
|
||||||
selectedPortal = guid;
|
selectedPortal = guid;
|
||||||
|
|
||||||
@ -2137,7 +2206,8 @@ window.debug.printStackTrace = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.debug.clearPortals = function() {
|
window.debug.clearPortals = function() {
|
||||||
portalsLayer.clearLayers();
|
for(var i = 0; i < portalsLayers.length; i++)
|
||||||
|
portalsLayers[i].clearLayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
window.debug.clearLinks = function() {
|
window.debug.clearLinks = function() {
|
||||||
|
Reference in New Issue
Block a user