From cf0786dc9d3e900692b54d2654fc8f298600f3bd Mon Sep 17 00:00:00 2001 From: proller Date: Mon, 4 Nov 2013 12:59:55 +0400 Subject: Masterserver fixes --- util/master/list.js | 26 +++++++++++++++++--------- util/master/servers.jst | 3 ++- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/util/master/list.js b/util/master/list.js index a47111342..2a831a268 100644 --- a/util/master/list.js +++ b/util/master/list.js @@ -1,10 +1,10 @@ var master; -if (!master) { - master = { - url: "http://servers.minetest.net/list", - output: "#server_list" - }; -} +if (!master) master = {}; +if (typeof(master.root)=='undefined') master.root = "http://servers.minetest.net/"; +if (!master.output) master.output = '#server_list'; +if (!master.list) master.list = "list"; +if (!master.list_root) master.list_root = master.root; +if (!master.list_url) master.list_url = master.list_root + master.list; function humanTime(seconds) { if (!seconds) return '?'; @@ -63,13 +63,21 @@ function hoverList(name, list) { return str + ''; } +function hoverString(name, string) { + if (!string) return ''; + return '
' + + name + ':
' + + escapeHTML(string) + '
' + + '
'; +} + function draw(json) { html = window.render.servers(json); - jQuery(master.output || '#server_list').html(html); + jQuery(master.output).html(html); } function get() { - jQuery.getJSON(master.url, draw); + jQuery.getJSON(master.list_url, draw); } function loaded(){ @@ -82,7 +90,7 @@ function loaded(){ // https://github.com/pyrsmk/toast this.toast=function(){var e=document,t=e.getElementsByTagName("head")[0],n=this.setTimeout,r="createElement",i="appendChild",s="addEventListener",o="onreadystatechange",u="styleSheet",a=10,f=0,l=function(){--f},c,h=function(e,r,i,s){if(!t)n(function(){h(e)},a);else if(e.length){c=-1;while(i=e[++c]){if((s=typeof i)=="function"){r=function(){return i(),!0};break}if(s=="string")p(i);else if(i.pop){p(i[0]),r=i[1];break}}d(r,Array.prototype.slice.call(e,c+1))}},p=function(n,s){++f,/\.css$/.test(n)?(s=e[r]("link"),s.rel=u,s.href=n,t[i](s),v(s)):(s=e[r]("script"),s.src=n,t[i](s),s[o]===null?s[o]=m:s.onload=l)},d=function(e,t){if(!f)if(!e||e()){h(t);return}n(function(){d(e,t)},a)},v=function(e){if(e.sheet||e[u]){l();return}n(function(){v(e)},a)},m=function(){/ded|co/.test(this.readyState)&&l()};h(arguments)}; -toast('style.css', 'servers.js', function() { +toast(master.root+'style.css', master.root+'servers.js', function() { if (typeof(jQuery)!='undefined') loaded(); else diff --git a/util/master/servers.jst b/util/master/servers.jst index 5031f083d..bf4a4bf54 100644 --- a/util/master/servers.jst +++ b/util/master/servers.jst @@ -47,7 +47,8 @@ {{=tooltipString(server.description, 50)}} {{?}} {{? !master.no_flags}} - + + {{=hoverString("Privs", server.privs)}} {{=server.creative ? 'Cre ' : ''}} {{=server.dedicated ? 'Ded ' : ''}} {{=server.damage ? 'Dmg ' : ''}} -- cgit v1.2.3