mobile statusbar: update statusbar immediately on selection using reduced data, redraw when portal details available

This commit is contained in:
fkloft 2013-12-17 23:05:50 +01:00
parent f1aaad3c22
commit a68c72583f

View File

@ -66,40 +66,51 @@ window.runOnSmartphonesBeforeBoot = function() {
} }
window.smartphoneInfo = function(data) { window.smartphoneInfo = function(data) {
var d = data.portalDetails; var guid = data.selectedPortalGuid;
var lvl = Math.floor(getPortalLevel(d)); if(!window.portals[guid]) return;
if(lvl == 0)
var t = '<span class="portallevel">L' + lvl + '</span>'; var data = window.portals[selectedPortal].options.data;
var details = window.portalDetail.get(guid);
var lvl = data.level;
if(data.team === "NEUTRAL")
var t = '<span class="portallevel">L0</span>';
else else
var t = '<span class="portallevel" style="background: '+COLORS_LVL[lvl]+';">L' + lvl + '</span>'; var t = '<span class="portallevel" style="background: '+COLORS_LVL[lvl]+';">L' + lvl + '</span>';
var percentage = '0%';
var totalEnergy = getTotalPortalEnergy(d); var percentage = data.health;
if(getTotalPortalEnergy(d) > 0) { if(details) {
percentage = Math.floor((getCurrentPortalEnergy(d) / getTotalPortalEnergy(d) * 100)) + '%'; var totalEnergy = getTotalPortalEnergy(details);
if(getTotalPortalEnergy(details) > 0) {
percentage = Math.floor(getCurrentPortalEnergy(details) / totalEnergy * 100);
}
} }
t += ' ' + percentage + ' '; t += ' ' + percentage + '% ';
t += d.portalV2.descriptiveText.TITLE; t += data.title;
var l,v,max,perc; if(details) {
for(var i=0;i<8;i++) var l,v,max,perc;
{ var className = TEAM_TO_CSS[getTeam(details)];
var reso = d.resonatorArray.resonators[i]; for(var i=0;i<8;i++)
if(reso) { {
l = parseInt(reso.level); var reso = details.resonatorArray.resonators[i];
v = parseInt(reso.energyTotal); if(reso) {
max = RESO_NRG[l]; l = parseInt(reso.level);
perc = v/max*100; v = parseInt(reso.energyTotal);
} max = RESO_NRG[l];
else { perc = v/max*100;
l = 0; }
v = 0; else {
max = 0; l = 0;
perc = 0; v = 0;
} max = 0;
perc = 0;
}
t += '<div class="resonator '+TEAM_TO_CSS[getTeam(d)]+'" style="border-top-color: '+COLORS_LVL[l]+';left: '+(100*i/8.0)+'%;">'; t += '<div class="resonator '+className+'" style="border-top-color: '+COLORS_LVL[l]+';left: '+(100*i/8.0)+'%;">';
t += '<div class="filllevel" style="width:'+perc+'%;"></div>'; t += '<div class="filllevel" style="width:'+perc+'%;"></div>';
t += '</div>' t += '</div>'
}
} }
$('#mobileinfo').html(t); $('#mobileinfo').html(t);
@ -113,7 +124,7 @@ window.runOnSmartphonesAfterBoot = function() {
// add a div/hook for updating mobile info // add a div/hook for updating mobile info
$('#updatestatus').prepend('<div id="mobileinfo" onclick="show(\'info\')"></div>'); $('#updatestatus').prepend('<div id="mobileinfo" onclick="show(\'info\')"></div>');
window.addHook('portalDetailsUpdated', window.smartphoneInfo); window.addHook('portalSelected', window.smartphoneInfo);
// init msg of status bar. hint for the user that a tap leads to the info screen // init msg of status bar. hint for the user that a tap leads to the info screen
$('#mobileinfo').html('<div style="text-align: center"><b>tap here for info screen</b></div>'); $('#mobileinfo').html('<div style="text-align: center"><b>tap here for info screen</b></div>');