From 16c11eb4a3bb46a388c645b7db738762e444cde8 Mon Sep 17 00:00:00 2001 From: proller Date: Sat, 30 Mar 2013 02:03:24 +0400 Subject: Masterserver: report gameid, uptime, cosmetic fixes on server web page --- util/master/list.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'util/master/list.js') diff --git a/util/master/list.js b/util/master/list.js index dcc30e091..18cbc4b68 100644 --- a/util/master/list.js +++ b/util/master/list.js @@ -2,11 +2,12 @@ function e(s) { if (typeof s === "undefined") s = ''; return s.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); //mc" } -function human_time(t) { + +function human_time(t, abs) { var n = 's'; if (!t || t < 0) t = 0; var f = 0; - var s = parseInt((new Date().getTime() / 1000 - (t || 0))); + var s = parseInt(abs ? (t || 0) : (new Date().getTime() / 1000 - (t || 0))); if (!s || s <= 0) s = 0; if (s == 0) return 'now'; if (s >= 60) { @@ -35,38 +36,37 @@ function human_time(t) { } return ((f ? parseFloat(s).toFixed(1) : parseInt(s)) + n); } + function success(r) { if (!r || !r.list) return; - var h = ''; + var h = '
ip:portclients, maxversionnamedescflagsupdated/startedping
'; for (var i = 0; i < r.list.length; ++i) { var s = r.list[i]; if (!s) continue; - h += ''; - h += ''; - h += ''; - h += ''; - h += ''; + h += ''; + h += ''; + h += ''; + h += ''; - h += ''; - h += ''; + h += ''; + h += ''; if (!s.time || s.time < 0) s.time = 0; if (!s.start || s.start < 0) s.start = 0; - h += ''; - h += ''; + h += ''; + h += ''; h += ''; } h += '
ip[:port]clients/maxversion gameidnamedescflagsuptimeping
' + e(s.address) + ':' + e(s.port) + '' + e(s.clients) + (s.clients_max ? '/' + e(s.clients_max) : '') + (s.clients_top ? ', ' + s.clients_top : '') + '' + e(s.version) + ''; + h += '
' + e(s.address) + (s.port != 30000 ? (':' + e(s.port)) : '') + '' + e(s.clients) + (s.clients_max ? '/' + e(s.clients_max) : '') + (s.clients_top ? ', ' + s.clients_top : '') + '' + e(s.version) + ' ' + e(s.gameid) + ''; if (s.url) h += ''; h += e(s.name || s.url); if (s.url) h += ''; h += '' + e(s.description) + '' + e(s.password ? 'Pwd ' : '') + (s.creative ? 'Cre ' : '') + (s.damage ? 'Dmg ' : '') + (s.pvp ? 'Pvp ' : '') + (s.dedicated ? 'Ded ' : '') + '' + e(s.description) + '' + e(s.password ? 'Pwd ' : '') + (s.creative ? 'Cre ' : '') + (s.damage ? 'Dmg ' : '') + (s.pvp ? 'Pvp ' : '') + (s.dedicated ? 'Ded ' : '') + '' + human_time(s.time) + (s.start ? '/' + human_time(s.start) : '') + '' + (s.ping ? parseFloat(s.ping).toFixed(3)*1000 : '') + '' + (s.uptime ? human_time(s.uptime, 1) : '') + '' + (s.ping ? parseFloat(s.ping).toFixed(3) * 1000 : '') + '
' jQuery('#table').html(h); } +var master_root; + function get() { - jQuery.ajax({ - url: 'list', - dataType: 'json', - success: success - }); + jQuery.getJSON((master_root || '') + 'list', success); setTimeout(get, 60000); } -get(); \ No newline at end of file +get(); -- cgit v1.2.3