Merge branch 'master' into experimental

This commit is contained in:
Jon Atkins
2013-05-07 16:52:05 +01:00
60 changed files with 655 additions and 282 deletions

View File

@ -3,6 +3,8 @@
// created a basic framework. All of these functions should only ever
// be run once.
// Used to disable on multitouch devices
window.showZoom = true;
window.setupBackButton = function() {
var c = window.isSmartphone()
@ -156,7 +158,7 @@ window.setupMap = function() {
window.map = new L.Map('map', $.extend(getPosition(),
{zoomControl: true}
{zoomControl: window.showZoom}
));
var addLayers = {};
@ -169,20 +171,20 @@ window.setupMap = function() {
var t = (i === 0 ? 'Unclaimed' : 'Level ' + i) + ' Portals';
addLayers[t] = portalsLayers[i];
// Store it in hiddenLayer to remove later
if(!isLayerGroupDisplayed(t)) hiddenLayer.push(portalsLayers[i]);
if(!isLayerGroupDisplayed(t, true)) hiddenLayer.push(portalsLayers[i]);
}
fieldsLayer = L.layerGroup([]);
map.addLayer(fieldsLayer, true);
addLayers['Fields'] = fieldsLayer;
// Store it in hiddenLayer to remove later
if(!isLayerGroupDisplayed('Fields')) hiddenLayer.push(fieldsLayer);
if(!isLayerGroupDisplayed('Fields', true)) hiddenLayer.push(fieldsLayer);
linksLayer = L.layerGroup([]);
map.addLayer(linksLayer, true);
addLayers['Links'] = linksLayer;
// Store it in hiddenLayer to remove later
if(!isLayerGroupDisplayed('Links')) hiddenLayer.push(linksLayer);
if(!isLayerGroupDisplayed('Links', true)) hiddenLayer.push(linksLayer);
window.layerChooser = new L.Control.Layers({
'MapQuest OSM': views[0],
@ -236,8 +238,8 @@ window.setupMap = function() {
map.on('moveend zoomend', function() { window.mapRunsUserAction = false });
// update map hooks
map.on('movestart zoomstart', window.requests.abort);
map.on('moveend zoomend', function() { console.log('map moveend'); window.startRefreshTimeout(ON_MOVE_REFRESH*1000) });
map.on('movestart zoomstart', function() { window.requests.abort(); window.startRefreshTimeout(-1); });
map.on('moveend zoomend', function() { window.startRefreshTimeout(ON_MOVE_REFRESH*1000) });
window.addResumeFunction(window.requestData);
window.requests.addRefreshFunction(window.requestData);

View File

@ -473,16 +473,14 @@ window.chat.needMoreMessages = function() {
chat.requestPublic(true);
}
window.chat.chooser = function(event) {
var t = $(event.target);
window.chat.chooseAnchor = function(t) {
var tt = t.text();
var mark = $('#chatinput mark');
var input = $('#chatinput input');
$('#chatcontrols .active').removeClass('active');
t.addClass('active');
$("#chatcontrols a:contains('" + tt + "')").addClass('active');
$('#chat > div').hide();
@ -520,10 +518,23 @@ window.chat.chooser = function(event) {
elm.scrollTop(elm.data('needsScrollTop'));
elm.data('needsScrollTop', null);
}
chat.needMoreMessages();
}
window.chat.show = function(name) {
window.isSmartphone
? $('#updatestatus').hide()
: $('#updatestatus').show();
$('#chat, #chatinput').show();
$('#map').css('visibility', 'hidden');
var t = $('<a>'+name+'</a>');
window.chat.chooseAnchor(t);
}
window.chat.chooser = function(event) {
var t = $(event.target);
window.chat.chooseAnchor(t);
}
// contains the logic to keep the correct scroll position.
window.chat.keepScrollPosition = function(box, scrollBefore, isOldMsgs) {

View File

@ -48,16 +48,23 @@ window.debug.console = function() {
$('#debugconsole').text();
}
window.debug.console.create = function() {
if($('#debugconsole').length) return;
$('#chatcontrols').append('<a>debug</a>');
$('#chatcontrols a:last').click(function() {
window.debug.console.show = function() {
$('#scrollwrapper, #updatestatus').hide();
// not displaying the map causes bugs in Leaflet
$('#map').css('visibility', 'hidden');
$('#chat, #chatinput').show();
window.debug.console.create();
$('#chatinput mark').css('cssText', 'color: #bbb !important').text('debug:');
$('#chat > div').hide();
$('#debugconsole').show();
$('#chatcontrols .active').removeClass('active');
$(this).addClass('active');
});
$("#chatcontrols a:contains('debug')").addClass('active');
}
window.debug.console.create = function() {
if($('#debugconsole').length) return;
$('#chatcontrols').append('<a>debug</a>');
$('#chatcontrols a:last').click(window.debug.console.show);
$('#chat').append('<div style="display: none" id="debugconsole"><table></table></div>');
}

View File

@ -95,9 +95,16 @@ window.setPortalIndicators = function(d) {
).addTo(map);
else
portalAccessIndicator.setLatLng(coord);
}
window.clearPortalIndicators = function() {
if(portalRangeIndicator) map.removeLayer(portalRangeIndicator);
portalRangeIndicator = null;
if(portalAccessIndicator) map.removeLayer(portalAccessIndicator);
portalAccessIndicator = null;
}
// highlights portal with given GUID. Automatically clears highlights
// on old selection. Returns false if the selected portal changed.
// Returns true if its still the same portal that just needs an
@ -123,4 +130,5 @@ window.unselectOldPortal = function() {
if(oldPortal) portalResetColor(oldPortal);
selectedPortal = null;
$('#portaldetails').html('');
clearPortalIndicators();
}

View File

@ -38,6 +38,7 @@ window.requests.abort = function() {
// gives user feedback about pending operations. Draws current status
// to website. Updates info in layer chooser.
window.renderUpdateStatus = function() {
var t = '<b>map status:</b> ';
if(mapRunsUserAction)
t += 'paused during interaction';
@ -48,7 +49,7 @@ window.renderUpdateStatus = function() {
else if(window.requests._quickRefreshPending)
t += 'refreshing...';
else
t += 'Up to date.';
t += 'Up to date. <a style="cursor: pointer" onclick="startRefreshTimeout(10)" title="Refresh">⟳</a>';
if(renderLimitReached())
t += ' <span style="color:#f66" 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> '
@ -82,6 +83,8 @@ window.startRefreshTimeout = function(override) {
// status bar
window.renderUpdateStatus();
if(refreshTimeout) clearTimeout(refreshTimeout);
if(override == -1) return; //don't set a new timeout
var t = 0;
if(override) {
window.requests._quickRefreshPending = true;

View File

@ -34,20 +34,12 @@ window.runOnSmartphonesBeforeBoot = function() {
+ '</style>');
}
// this also matches the expand button, but it is hidden via CSS
$('#chatcontrols a').click(function() {
$('#scrollwrapper, #updatestatus').hide();
// not displaying the map causes bugs in Leaflet
$('#map').css('visibility', 'hidden');
$('#chat, #chatinput').show();
});
window.smartphone.mapButton = $('<a>map</a>').click(function() {
$('#chat, #chatinput, #scrollwrapper').hide();
$('#map').css('visibility', 'visible');
$('#updatestatus').show();
$('.active').removeClass('active');
$(this).addClass('active');
$('#chatcontrols a .active').removeClass('active');
$("#chatcontrols a:contains('map')").addClass('active');
});
window.smartphone.sideButton = $('<a>info</a>').click(function() {
@ -55,7 +47,7 @@ window.runOnSmartphonesBeforeBoot = function() {
$('#map').css('visibility', 'hidden');
$('#scrollwrapper').show();
$('.active').removeClass('active');
$(this).addClass('active');
$("#chatcontrols a:contains('info')").addClass('active');
});
$('#chatcontrols').append(smartphone.mapButton).append(smartphone.sideButton);
@ -80,7 +72,6 @@ window.runOnSmartphonesAfterBoot = function() {
if(!isSmartphone()) return;
console.warn('running smartphone post boot stuff');
chat.toggle();
smartphone.mapButton.click();
// disable img full view

View File

@ -359,16 +359,21 @@ window.updateDisplayedLayerGroup = function(name, display) {
// Read layerGroup status from window.overlayStatus if it was added to map,
// read from cookie if it has not added to map yet.
// return true if both overlayStatus and cookie didn't have the record
window.isLayerGroupDisplayed = function(name) {
// return 'defaultDisplay' if both overlayStatus and cookie didn't have the record
window.isLayerGroupDisplayed = function(name, defaultDisplay) {
if(typeof(overlayStatus[name]) !== 'undefined') return overlayStatus[name];
var layersJSON = readCookie('ingress.intelmap.layergroupdisplayed');
if(!layersJSON) return true;
if(!layersJSON) return defaultDisplay;
var layers = JSON.parse(layersJSON);
// keep latest overlayStatus
overlayStatus = $.extend(layers, overlayStatus);
if(typeof(overlayStatus[name]) === 'undefined') return true;
if(typeof(overlayStatus[name]) === 'undefined') return defaultDisplay;
return overlayStatus[name];
}
window.addLayerGroup = function(name, layerGroup, defaultDisplay) {
if(isLayerGroupDisplayed(name, defaultDisplay)) map.addLayer(layerGroup);
layerChooser.addOverlay(layerGroup, name);
}

30
code/window_management.js Normal file
View File

@ -0,0 +1,30 @@
// created to start cleaning up "window" interaction
//
window.show = function(id) {
switch(id) {
case 'full':
window.chat.show('full');
break;
case 'compact':
window.chat.show('compact');
break;
case 'public':
window.chat.show('public');
break;
case 'faction':
window.chat.show('faction');
break;
case 'debug':
window.debug.console.show();
break;
case 'map':
window.smartphone.mapButton.click();
break;
case 'info':
window.smartphone.sideButton.click();
break;
default:
window.smartphone.mapButton.click();
break;
}
}