diff --git a/code/portal_detail_display_tools.js b/code/portal_detail_display_tools.js
index 217e425c..755a8407 100644
--- a/code/portal_detail_display_tools.js
+++ b/code/portal_detail_display_tools.js
@@ -159,27 +159,40 @@ window.getResonatorDetails = function(d) {
var resoDetails = [];
// octant=slot: 0=E, 1=NE, 2=N, 3=NW, 4=W, 5=SW, 6=S, SE=7
// 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
+ // N NE Since the view is displayed in rows, they
+ // NW E need to be ordered like this: N NE NW E W SE SW S
+ // W SE i.e. 2 1 3 0 4 7 5 6
// SW S
+ // note: as of 2014-05-23 update, this is not true for portals with empty slots!
- $.each([2, 1, 3, 0, 4, 7, 5, 6], function(ind, slot) {
- var reso = d.resonators[slot];
- if(!reso) {
- resoDetails.push(renderResonatorDetails(slot, 0, 0, null, null));
- return true;
+ var processResonatorSlot = function(reso,slot) {
+ var lvl=0, nrg=0, owner=null;
+
+ if (reso) {
+ lvl = parseInt(reso.level);
+ nrg = parseInt(reso.energy);
+ owner = reso.owner;
}
- var l = parseInt(reso.level);
- var v = parseInt(reso.energy);
- var nick = reso.owner;
- // if array order and slot order drift apart, at least the octant
- // naming will still be correct.
- slot = ind;
+ resoDetails.push(renderResonatorDetails(slot, lvl, nrg, owner));
+ };
+
+
+ // if all 8 resonators are deployed, we know which is in which slot
+
+ if (d.resonators.length == 8) {
+ // fully deployed - we can make assumptions about deployment slots
+ $.each([2, 1, 3, 0, 4, 7, 5, 6], function(ind, slot) {
+ processResonatorSlot(d.resonators[slot],slot);
+ });
+ } else {
+ // partially deployed portal - we can no longer find out which resonator is in which slot
+ for(var ind=0; ind<8; ind++) {
+ processResonatorSlot(ind < d.resonators.length ? d.resonators[ind] : null, null);
+ }
+
+ }
- resoDetails.push(renderResonatorDetails(slot, l, v, null, nick));
- });
return '
' + genFourColumnTable(resoDetails) + '
';
}
@@ -188,33 +201,31 @@ window.getResonatorDetails = function(d) {
// not work with raw details-hash. Needs digested infos instead:
// slot: which slot this resonator occupies. Starts with 0 (east) and
// rotates clockwise. So, last one is 7 (southeast).
-window.renderResonatorDetails = function(slot, level, nrg, dist, nick) {
+window.renderResonatorDetails = function(slot, level, nrg, nick) {
if(OCTANTS[slot] === 'N')
var className = 'meter north';
else
var className = 'meter';
- if(level === 0) {
- var meter = '';
- } else {
- var max = RESO_NRG[level];
- var fillGrade = nrg/max*100;
+ var max = RESO_NRG[level];
+ var fillGrade = level > 0 ? nrg/max*100 : 0;
- var inf = 'energy:\t' + nrg + ' / ' + max + ' (' + Math.round(fillGrade) + '%)\n'
- + 'level:\t' + level + '\n'
- + 'owner:\t' + nick + '\n'
- + 'octant:\t' + OCTANTS[slot] + ' ' + OCTANTS_ARROW[slot];
+ var inf = (level > 0 ? 'energy:\t' + nrg + ' / ' + max + ' (' + Math.round(fillGrade) + '%)\n'
+ +'level:\t' + level + '\n'
+ +'owner:\t' + nick + '\n'
+ : '')
+ + (slot !== null ? 'octant:\t' + OCTANTS[slot] + ' ' + OCTANTS_ARROW[slot]:'');
- var style = 'width:'+fillGrade+'%; background:'+COLORS_LVL[level]+';';
+ var style = fillGrade ? 'width:'+fillGrade+'%; background:'+COLORS_LVL[level]+';':'';
- var color = (level < 3 ? "#9900FF" : "#FFFFFF");
+ var color = (level < 3 ? "#9900FF" : "#FFFFFF");
- var lbar = ' L ' + level + ' ';
+ var lbar = level > 0 ? ' L ' + level + ' ' : '';
- var fill = '';
+ var fill = '';
+
+ var meter = '' + fill + lbar + '';
- var meter = '' + fill + lbar + '';
- }
nick = nick ? ''+nick+'' : null;
return [meter, nick || ''];
}
diff --git a/code/smartphone.js b/code/smartphone.js
index 6e5e2454..8ed9c445 100644
--- a/code/smartphone.js
+++ b/code/smartphone.js
@@ -90,26 +90,34 @@ window.smartphoneInfo = function(data) {
if(details) {
var l,v,max,perc;
- for(var i=0;i<8;i++)
+ var eastAnticlockwiseToNorthClockwise = [2,1,0,7,6,5,4,3];
+
+ for(var ind=0;ind<8;ind++)
{
+ if (details.resonators.length == 8) {
+ var slot = eastAnticlockwiseToNorthClockwise[ind];
+ var reso = details.resonators[slot];
+ } else {
+ var slot = null;
+ var reso = ind < details.resonators.length ? details.resonators[ind] : null;
+ }
+
var className = TEAM_TO_CSS[getTeam(details)];
- if(OCTANTS[i] === 'N')
+ if(slot !== null && OCTANTS[slot] === 'N')
className += ' north'
- var reso = details.resonators[i];
if(reso) {
l = parseInt(reso.level);
v = parseInt(reso.energy);
max = RESO_NRG[l];
perc = v/max*100;
- }
- else {
+ } else {
l = 0;
v = 0;
max = 0;
perc = 0;
}
- t += '