var master_root, output_to; var master; if (!master) master = { root: master_root, output: output_to }; function e(s) { if (typeof s === "undefined") s = ''; if (typeof s === "number") return s; return s.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); //mc" } function human_time(t, abs) { var n = 's'; if (!t || t < 0) t = 0; var f = 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) { s /= 60; n = 'm'; if (s >= 60) { s /= 60; n = 'h'; f = 1; if (s >= 24) { s /= 24; n = 'd'; f = 1; if (s >= 30) { s /= 30; n = 'M'; f = 1; if (s >= 12) { s /= 12; n = 'y'; f = 1; } } } } } return ((f ? parseFloat(s).toFixed(1) : parseInt(s)) + n); } function success(r) { if (!r || !r.list) return; var h = ''; if (!master.no_total && r.total && r.total_max) h += '
Players: ' + r.total.clients + ('/' + r.total_max.clients) + ' servers: ' + r.total.servers + ('/' + r.total_max.servers) + '
'; h += ''; if (r.list.length) { h += ''; if (!master.no_address) h += ''; if (!master.no_clients) h += ''; if (!master.no_version) h += ''; if (!master.no_name) h += ''; if (!master.no_description) h += ''; if (!master.no_flags) h += ''; if (!master.no_uptime) h += ''; if (!master.no_ping) h += ''; h += ''; } var count = 0; for (var i = 0; i < r.list.length; ++i) { if (++count > master.limit && master.limit) break; var s = r.list[i]; if (!s) continue; if (master.clients_min && s.clients < master.clients_min) continue; if (/:/.test(s.address)) s.address = '[' + s.address + ']'; h += ''; if (!master.no_address) h += ''; if (!master.no_clients) { h += ''; } var mods = 0; if (s.mods && jQuery.isArray(s.mods)) mods = s.mods.length; if (!master.no_version) { h += ''; } if (!master.no_name) { h += ''; } if (!master.no_description) h += ''; if (!master.no_flags) { h += ''; } if (!s.start || s.start < 0) s.start = 0; if (!master.no_uptime) h += ''; if (!master.no_ping) h += ''; h += ''; } h += '
ip[:port]players/maxversion gameid mapgennamedescriptionflagsuptime ageping
' + e(s.address) + (s.port != 30000 ? (':' + e(s.port)) : '') + ''; if (!master.no_clients_list && s.clients && s.clients_list) { h += '
Players (' + e(s.clients) + '):
'; for (var ii in s.clients_list) h += e(s.clients_list[ii]) + '
'; h += '
'; } h += e(s.clients) + (s.clients_max ? '/' + e(s.clients_max) : '') + (s.clients_top ? ', ' + e(s.clients_top) : '') + '
' + e(s.version) + ' ' + e(s.gameid) + ' ' + e(s.mapgen); if (!master.no_mods && mods) { h += '
Mods (' + mods + '):
'; for (var ii in s.mods) h += e(s.mods[ii]) + '
'; h += '
'; } h += '
'; if (s.url) h += ''; h += e(s.name || s.url); if (s.url) h += ''; h += '' + e(s.description) + '' + (s.password ? 'Pwd ' : '') + (s.creative ? 'Cre ' : '') + (s.damage ? 'Dmg ' : '') + (s.pvp ? 'Pvp ' : '') + (s.dedicated ? 'Ded ' : '') + (s.rollback ? 'Rol ' : '') + (s.liquid_finite ? 'Liq ' : '') + '' + (s.uptime ? human_time(s.uptime, 1) : s.start ? human_time(s.start) : '') + (s.game_time ? ' ' + human_time(s.game_time, 1) : '') + '' + (s.ping ? parseFloat(s.ping).toFixed(3) * 1000 : '') + '
'; if (master.clients_min || master.limit) h += 'more...'; jQuery(master.output || '#servers_table').html(h); } function get(refresh) { jQuery.getJSON((master.root || '') + 'list', success); if (!refresh && !master.no_refresh) setTimeout(get, 60000); } get();