Skip to content

Commit

Permalink
Masterserver fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Nov 4, 2013
1 parent 4a8a50a commit cf0786d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
26 changes: 17 additions & 9 deletions 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 '?';
Expand Down Expand Up @@ -63,13 +63,21 @@ function hoverList(name, list) {
return str + '</div>';
}

function hoverString(name, string) {
if (!string) return '';
return '<div class="mts_hover_list">'
+ name + ':<br />'
+ escapeHTML(string) + '<br />'
+ '</div>';
}

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(){
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion util/master/servers.jst
Expand Up @@ -47,7 +47,8 @@
{{=tooltipString(server.description, 50)}}
</td>{{?}}
{{? !master.no_flags}}
<td class="flags" {{? server.privs}}title="{{=escapeHTML(server.privs)}}"{{?}}>
<td class="flags {{? server.privs}} mts_hover_list_text{{?}}">
{{=hoverString("Privs", server.privs)}}
{{=server.creative ? 'Cre ' : ''}}
{{=server.dedicated ? 'Ded ' : ''}}
{{=server.damage ? 'Dmg ' : ''}}
Expand Down

0 comments on commit cf0786d

Please sign in to comment.