From 4a8a50a2a22e9a87089b817f966bf5270eb4bc2f Mon Sep 17 00:00:00 2001 From: proller Date: Mon, 4 Nov 2013 04:55:35 +0400 Subject: [PATCH] Masterserver show privs and js autoload --- src/serverlist.cpp | 1 + util/master/README.md | 10 ++++++++++ util/master/index.html | 6 +----- util/master/list.js | 22 ++++++++++++++++------ util/master/master.cgi | 2 +- util/master/servers.jst | 6 +++--- util/master/style.css | 7 +++---- 7 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/serverlist.cpp b/src/serverlist.cpp index fb5bc9c87..fa2ddad15 100644 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -222,6 +222,7 @@ void sendAnnounce(std::string action, const std::vector & clients_n if(server["action"] == "start") { server["dedicated"] = g_settings->get("server_dedicated"); + server["privs"] = g_settings->get("default_privs"); server["rollback"] = g_settings->getBool("enable_rollback_recording"); server["liquid_finite"] = g_settings->getBool("liquid_finite"); server["mapgen"] = g_settings->get("mg_name"); diff --git a/util/master/README.md b/util/master/README.md index 4730dc269..232986deb 100644 --- a/util/master/README.md +++ b/util/master/README.md @@ -17,8 +17,18 @@ Then install doT.js and it's dependencies: $ cd doT $ npm install +Or by npm: + $ npm install dot commander mkdirp + And finally compile the template: $ cd ~/minetest/util/master $ ~/code/doT/bin/dot-packer -s . -d . +or + $ ./node_modules/dot/bin/dot-packer -s . -d . +Embending to any page +---------------------- + + + diff --git a/util/master/index.html b/util/master/index.html index 339ebe565..48a973eac 100644 --- a/util/master/index.html +++ b/util/master/index.html @@ -3,13 +3,9 @@ Minetest server list - - - -
- + diff --git a/util/master/list.js b/util/master/list.js index ee4568e24..a47111342 100644 --- a/util/master/list.js +++ b/util/master/list.js @@ -35,7 +35,7 @@ function addressString(server) { var str = ' 25) { shortStr = shortStr.substr(0, 23) + "…"; - str += ' class="tooltip" title="' + addrStr + '"' + str += ' class="mts_tooltip" title="' + addrStr + '"' } if (server.port != 30000) shortStr += ':' + server.port; @@ -48,14 +48,14 @@ function tooltipString(str, maxLen) { var ret = ' maxLen) { shortStr = shortStr.substr(0, maxLen - 2) + "…"; - ret += ' class="tooltip" title="' + str + '"'; + ret += ' class="mts_tooltip" title="' + str + '"'; } return ret + '>' + shortStr + ''; } function hoverList(name, list) { if (!list || list.length == 0) return ''; - var str = '
' + var str = '
' str += name + '(' + list.length + ')
'; for (var i in list) { str += escapeHTML(list[i]) + '
'; @@ -72,9 +72,19 @@ function get() { jQuery.getJSON(master.url, draw); } -if (!master.no_refresh) { - setInterval(get, 60 * 1000); +function loaded(){ + if (!master.no_refresh) { + setInterval(get, 60 * 1000); + } + get(); } -get(); +// 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() { + if (typeof(jQuery)!='undefined') + loaded(); + else + toast('//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', loaded); +}); diff --git a/util/master/master.cgi b/util/master/master.cgi index 6dbf83fca..f48816c5d 100755 --- a/util/master/master.cgi +++ b/util/master/master.cgi @@ -241,7 +241,7 @@ sub request (;$) { $param->{clients_top} = $old->{clients_top} if $old->{clients_top} > $param->{clients}; $param->{clients_top} ||= $param->{clients} || 0; # params reported once on start, must be same as src/serverlist.cpp:~221 if(server["action"] == "start") { ... - for (qw(dedicated rollback liquid_finite mapgen mods)) { + for (qw(dedicated rollback liquid_finite mapgen mods privs)) { $param->{$_} ||= $old->{$_} if $old->{$_} and !($param->{action} ~~ 'start'); } $param->{pop_n} = $old->{pop_n} + 1; diff --git a/util/master/servers.jst b/util/master/servers.jst index ff17c2d10..5031f083d 100644 --- a/util/master/servers.jst +++ b/util/master/servers.jst @@ -24,12 +24,12 @@ {{=addressString(server)}} {{?}} {{? !master.no_clients}} - + {{=server.clients}}/{{=server.clients_max}} {{=server.clients_top}} {{=hoverList("Clients", server.clients_list)}} {{?}} {{? !master.no_version}} - + {{=escapeHTML(server.version)}}, {{=escapeHTML(server.gameid)}},  {{=escapeHTML(server.mapgen || '?')}} {{=hoverList("Mods", server.mods)}} @@ -47,7 +47,7 @@ {{=tooltipString(server.description, 50)}} {{?}} {{? !master.no_flags}} - + {{=server.creative ? 'Cre ' : ''}} {{=server.dedicated ? 'Ded ' : ''}} {{=server.damage ? 'Dmg ' : ''}} diff --git a/util/master/style.css b/util/master/style.css index 47d58029b..76a4f998d 100644 --- a/util/master/style.css +++ b/util/master/style.css @@ -11,7 +11,7 @@ border: 1px solid gray; } -.hover_list{ +.mts_hover_list{ visibility: hidden; border: gray solid 1px; position: absolute; @@ -20,12 +20,11 @@ padding: 0.5em; } -td:hover .hover_list { +td:hover .mts_hover_list { visibility: visible; } -.hover_list_text, .tooltip { +.mts_hover_list_text, .mts_tooltip { text-decoration: underline; text-decoration-style: dashed; } -