Merge branch 'master' into highlighter
This commit is contained in:
52
code/boot.js
52
code/boot.js
@@ -1,4 +1,3 @@
|
||||
|
||||
// SETUP /////////////////////////////////////////////////////////////
|
||||
// these functions set up specific areas after the boot function
|
||||
// created a basic framework. All of these functions should only ever
|
||||
@@ -103,15 +102,35 @@ window.setupStyles = function() {
|
||||
window.setupMap = function() {
|
||||
$('#map').text('');
|
||||
|
||||
var osmOpt = {attribution: 'Map data © OpenStreetMap contributors', maxZoom: 18, detectRetina: true};
|
||||
var osm = new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', osmOpt);
|
||||
//OpenStreetMap attribution - required by several of the layers
|
||||
osmAttribution = 'Map data © OpenStreetMap contributors';
|
||||
|
||||
var cmOpt = {attribution: 'Map data © OpenStreetMap contributors, Imagery © CloudMade', maxZoom: 18, detectRetina: true};
|
||||
var cmMin = new L.TileLayer('http://{s}.tile.cloudmade.com/654cef5fd49a432ab81267e200ecc502/22677/256/{z}/{x}/{y}.png', cmOpt);
|
||||
var cmMid = new L.TileLayer('http://{s}.tile.cloudmade.com/654cef5fd49a432ab81267e200ecc502/999/256/{z}/{x}/{y}.png', cmOpt);
|
||||
//OpenStreetMap tiles - we shouldn't use these by default, or even an option - https://wiki.openstreetmap.org/wiki/Tile_usage_policy
|
||||
// "Heavy use (e.g. distributing an app that uses tiles from openstreetmap.org) is forbidden without prior permission from the System Administrators"
|
||||
//var osmOpt = {attribution: osmAttribution, maxZoom: 18, detectRetina: true};
|
||||
//var osm = new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', osmOpt);
|
||||
|
||||
var views = [cmMid, cmMin, osm, new L.Google('INGRESS'), new L.Google('ROADMAP'),
|
||||
new L.Google('SATELLITE'), new L.Google('HYBRID')];
|
||||
//CloudMade layers - only 500,000 tiles/month in their free plan. nowhere near enough for IITC
|
||||
var cmOpt = {attribution: osmAttribution+', Imagery © CloudMade', maxZoom: 18, detectRetina: true};
|
||||
//var cmMin = new L.TileLayer('http://{s}.tile.cloudmade.com/{your api key here}/22677/256/{z}/{x}/{y}.png', cmOpt);
|
||||
//var cmMid = new L.TileLayer('http://{s}.tile.cloudmade.com/{your api key here}/999/256/{z}/{x}/{y}.png', cmOpt);
|
||||
|
||||
//MapQuest offer tiles - http://developer.mapquest.com/web/products/open/map
|
||||
//their usage policy has no limits (except required notification above 4000 tiles/sec - we're perhaps at 50 tiles/sec based on CloudMade stats)
|
||||
var mqSubdomains = [ 'otile1','otile2', 'otile3', 'otile4' ];
|
||||
var mqMapOpt = {attribution: osmAttribution+', Tiles Courtesy of MapQuest', mazZoom: 18, detectRetena: true, subdomains: mqSubdomains};
|
||||
var mqMap = new L.TileLayer('http://{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpg',mqMapOpt);
|
||||
//MapQuest satellite coverage outside of the US is rather limited - so not really worth having as we have google as an option
|
||||
//var mqSatOpt = {attribution: 'Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency', mazZoom: 18, detectRetena: true, subdomains: mqSubdomains};
|
||||
//var mqSat = new L.TileLayer('http://{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg',mqSatOpt);
|
||||
|
||||
var views = [
|
||||
/*0*/ mqMap,
|
||||
/*1*/ new L.Google('INGRESS'),
|
||||
/*2*/ new L.Google('ROADMAP'),
|
||||
/*3*/ new L.Google('SATELLITE'),
|
||||
/*4*/ new L.Google('HYBRID')
|
||||
];
|
||||
|
||||
|
||||
window.map = new L.Map('map', $.extend(getPosition(),
|
||||
@@ -137,13 +156,11 @@ window.setupMap = function() {
|
||||
addLayers['Links'] = linksLayer;
|
||||
|
||||
window.layerChooser = new L.Control.Layers({
|
||||
'OSM Midnight': views[0],
|
||||
'OSM Minimal': views[1],
|
||||
'OSM Mapnik': views[2],
|
||||
'Default Ingress Map': views[3],
|
||||
'Google Roads': views[4],
|
||||
'Google Satellite': views[5],
|
||||
'Google Hybrid': views[6]
|
||||
'MapQuest OSM': views[0],
|
||||
'Default Ingress Map': views[1],
|
||||
'Google Roads': views[2],
|
||||
'Google Satellite': views[3],
|
||||
'Google Hybrid': views[4]
|
||||
}, addLayers);
|
||||
|
||||
map.addControl(window.layerChooser);
|
||||
@@ -291,12 +308,13 @@ window.setupDialogs = function() {
|
||||
autoOpen: false,
|
||||
modal: true,
|
||||
buttons: [
|
||||
{ text: 'OK', click: function() { $(this).dialog('close'); } }
|
||||
{ text: 'OK', click: function() { if($(this).data("closeCallback")) {$(this).data("closeCallback")();} $(this).dialog('close'); } }
|
||||
]
|
||||
});
|
||||
|
||||
window.alert = function(text, isHTML) {
|
||||
window.alert = function(text, isHTML, closeCallback) {
|
||||
var h = isHTML ? text : window.convertTextToTableMagic(text);
|
||||
$('#dialog').data("closeCallback", closeCallback);
|
||||
$('#dialog').html(h).dialog('open');
|
||||
}
|
||||
}
|
||||
|
13
code/chat.js
13
code/chat.js
@@ -241,6 +241,14 @@ window.chat.renderFull = function(oldMsgsWereAdded) {
|
||||
// common
|
||||
//
|
||||
|
||||
window.chat.nicknameClicked = function(event, nickname) {
|
||||
var hookData = { event: event, nickname: nickname };
|
||||
|
||||
if (window.runHooks('nicknameClicked', hookData)) {
|
||||
window.chat.addNickname('@' + nickname);
|
||||
}
|
||||
}
|
||||
|
||||
window.chat.writeDataToHash = function(newData, storageHash, isPublicChannel) {
|
||||
$.each(newData.result, function(ind, json) {
|
||||
// avoid duplicates
|
||||
@@ -283,9 +291,10 @@ window.chat.writeDataToHash = function(newData, storageHash, isPublicChannel) {
|
||||
case 'AT_PLAYER':
|
||||
var thisToPlayer = (markup[1].plain == ('@'+window.PLAYER.nickname));
|
||||
var spanClass = thisToPlayer ? "pl_nudge_me" : (markup[1].team + " pl_nudge_player");
|
||||
var atPlayerName = markup[1].plain.replace(/^@/, "");
|
||||
msg += $('<div/>').html($('<span/>')
|
||||
.attr('class', spanClass)
|
||||
.attr('onclick',"window.chat.addNickname('"+markup[1].plain+"')")
|
||||
.attr('onclick',"window.chat.nicknameClicked(event, '"+atPlayerName+"')")
|
||||
.text(markup[1].plain)).html();
|
||||
msgToPlayer = msgToPlayer || thisToPlayer;
|
||||
break;
|
||||
@@ -401,7 +410,7 @@ window.chat.renderMsg = function(msg, nick, time, team, msgToPlayer, systemNarro
|
||||
var s = 'style="cursor:pointer; color:'+color+'"';
|
||||
var title = nick.length >= 8 ? 'title="'+nick+'" class="help"' : '';
|
||||
var i = ['<span class="invisep"><</span>', '<span class="invisep">></span>'];
|
||||
return '<tr><td>'+t+'</td><td>'+i[0]+'<mark class="nickname" onclick="window.chat.addNickname(\'@' + nick + '\')" ' + s + '>'+ nick+'</mark>'+i[1]+'</td><td>'+msg+'</td></tr>';
|
||||
return '<tr><td>'+t+'</td><td>'+i[0]+'<mark class="nickname" onclick="window.chat.nicknameClicked(event, \'' + nick + '\')" ' + s + '>'+ nick+'</mark>'+i[1]+'</td><td>'+msg+'</td></tr>';
|
||||
}
|
||||
|
||||
window.chat.addNickname= function(nick){
|
||||
|
@@ -4,7 +4,14 @@
|
||||
window.setupGeosearch = function() {
|
||||
$('#geosearch').keypress(function(e) {
|
||||
if((e.keyCode ? e.keyCode : e.which) != 13) return;
|
||||
$.getJSON(NOMINATIM + encodeURIComponent($(this).val()), function(data) {
|
||||
|
||||
var search = $(this).val();
|
||||
|
||||
if (!runHooks('geoSearch', search)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.getJSON(NOMINATIM + encodeURIComponent(search), function(data) {
|
||||
if(!data || !data[0]) return;
|
||||
var b = data[0].boundingbox;
|
||||
if(!b) return;
|
||||
|
@@ -59,15 +59,21 @@
|
||||
window._hooks = {}
|
||||
window.VALID_HOOKS = ['portalAdded', 'portalDetailsUpdated',
|
||||
'publicChatDataAvailable', 'factionChatDataAvailable', 'portalDataLoaded',
|
||||
'beforePortalReRender', 'checkRenderLimit', 'requestFinished'];
|
||||
'beforePortalReRender', 'checkRenderLimit', 'requestFinished', 'nicknameClicked',
|
||||
'geoSearch'];
|
||||
|
||||
window.runHooks = function(event, data) {
|
||||
if(VALID_HOOKS.indexOf(event) === -1) throw('Unknown event type: ' + event);
|
||||
|
||||
if(!_hooks[event]) return;
|
||||
if(!_hooks[event]) return true;
|
||||
var interupted = false;
|
||||
$.each(_hooks[event], function(ind, callback) {
|
||||
callback(data);
|
||||
if (callback(data) === false) {
|
||||
interupted = true;
|
||||
return false; //break from $.each
|
||||
}
|
||||
});
|
||||
return !interupted;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -21,11 +21,18 @@ window.storeMapPosition = function() {
|
||||
// returns a map that shows the whole world.
|
||||
window.getPosition = function() {
|
||||
if(getURLParam('latE6') && getURLParam('lngE6')) {
|
||||
console.log("mappos: reading URL params");
|
||||
console.log("mappos: reading email URL params");
|
||||
var lat = parseInt(getURLParam('latE6'))/1E6 || 0.0;
|
||||
var lng = parseInt(getURLParam('lngE6'))/1E6 || 0.0;
|
||||
// google seems to zoom in far more than leaflet
|
||||
var z = parseInt(getURLParam('z'))+1 || 17;
|
||||
var z = parseInt(getURLParam('z')) || 17;
|
||||
return {center: new L.LatLng(lat, lng), zoom: z > 18 ? 18 : z};
|
||||
}
|
||||
|
||||
if(getURLParam('ll')) {
|
||||
console.log("mappos: reading stock Intel URL params");
|
||||
var lat = parseFloat(getURLParam('ll').split(",")[0]) || 0.0;
|
||||
var lng = parseFloat(getURLParam('ll').split(",")[1]) || 0.0;
|
||||
var z = parseInt(getURLParam('z')) || 17;
|
||||
return {center: new L.LatLng(lat, lng), zoom: z > 18 ? 18 : z};
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,30 @@
|
||||
|
||||
|
||||
// UTILS + MISC ///////////////////////////////////////////////////////
|
||||
|
||||
window.aboutIITC = function(){
|
||||
var v = '@@BUILDNAME@@-@@BUILDDATE@@'
|
||||
var a = ''
|
||||
+ ' <div><b>About IITC</b></div> '
|
||||
+ ' <div>Ingress Intel Total Conversion</div> '
|
||||
+ ' <hr>'
|
||||
+ ' <div>'
|
||||
+ ' <a href="http://iitc.jonatkins.com/" target="_blank">IITC Homepage</a><br />'
|
||||
+ ' On the script’s homepage you can:'
|
||||
+ ' <ul>'
|
||||
+ ' <li>Find Updates</li>'
|
||||
+ ' <li>Get Plugins</li>'
|
||||
+ ' <li>Report Bugs</li>'
|
||||
+ ' <li>Contribute!</li>'
|
||||
+ ' </ul>'
|
||||
+ ' </div>'
|
||||
+ ' <div>'
|
||||
+ ' MapQuest OSM tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png">'
|
||||
+ ' </div>'
|
||||
+ ' <hr>'
|
||||
+ ' <div>Version: ' + v + '</div>';
|
||||
alert(a);
|
||||
}
|
||||
|
||||
|
||||
window.layerGroupLength = function(layerGroup) {
|
||||
var layersCount = 0;
|
||||
var layers = layerGroup._layers;
|
||||
@@ -257,7 +280,7 @@ 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()-1);
|
||||
var qry = 'latE6='+lat+'&lngE6='+lng+'&z=' + map.getZoom();
|
||||
$(elm).attr('href', '/intel?' + qry);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user