fix gamescore loading - minor data format change
This commit is contained in:
parent
5d8b68747b
commit
749c7b3b5c
@ -2,7 +2,6 @@
|
||||
// GAME STATUS ///////////////////////////////////////////////////////
|
||||
// MindUnit display
|
||||
|
||||
window.updateGameScoreFailCount = 0;
|
||||
|
||||
window.updateGameScore = function(data) {
|
||||
if(!data) {
|
||||
@ -11,24 +10,24 @@ window.updateGameScore = function(data) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data && data.error) {
|
||||
// TODO? better retry handling in here...
|
||||
console.error('game score failed to load');
|
||||
if (data && data.result) {
|
||||
|
||||
var e = parseInt(data.result[0]); //enlightened score in result[0]
|
||||
var r = parseInt(data.result[1]); //resistance score in result[1]
|
||||
var s = r+e;
|
||||
var rp = r/s*100, ep = e/s*100;
|
||||
r = digits(r), e = digits(e);
|
||||
var rs = '<span class="res" style="width:'+rp+'%;">'+Math.round(rp)+'% </span>';
|
||||
var es = '<span class="enl" style="width:'+ep+'%;"> '+Math.round(ep)+'%</span>';
|
||||
$('#gamestat').html(rs+es).one('click', function() { window.updateGameScore() });
|
||||
// help cursor via “#gamestat span”
|
||||
$('#gamestat').attr('title', 'Resistance:\t'+r+' MindUnits\nEnlightened:\t'+e+' MindUnits');
|
||||
} else if (data && data.error) {
|
||||
console.warn('game score failed to load: '+data.error);
|
||||
} else {
|
||||
console.warn('game score failed to load - unknown reason');
|
||||
}
|
||||
|
||||
window.updateGameScoreFailCount = 0;
|
||||
|
||||
var e = parseInt(data[0]); //enlightened score in data[0]
|
||||
var r = parseInt(data[1]); //resistance score in data[1]
|
||||
var s = r+e;
|
||||
var rp = r/s*100, ep = e/s*100;
|
||||
r = digits(r), e = digits(e);
|
||||
var rs = '<span class="res" style="width:'+rp+'%;">'+Math.round(rp)+'% </span>';
|
||||
var es = '<span class="enl" style="width:'+ep+'%;"> '+Math.round(ep)+'%</span>';
|
||||
$('#gamestat').html(rs+es).one('click', function() { window.updateGameScore() });
|
||||
// help cursor via “#gamestat span”
|
||||
$('#gamestat').attr('title', 'Resistance:\t'+r+' MindUnits\nEnlightened:\t'+e+' MindUnits');
|
||||
|
||||
// TODO: idle handling - don't refresh when IITC is idle!
|
||||
window.setTimeout('window.updateGameScore', REFRESH_GAME_SCORE*1000);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user