diff options
author | proller <proller@github.com> | 2013-11-04 04:55:35 +0400 |
---|---|---|
committer | proller <proller@github.com> | 2013-11-04 04:56:39 +0400 |
commit | 4a8a50a2a22e9a87089b817f966bf5270eb4bc2f (patch) | |
tree | 5d8de7402db5fe4d4c9f1c3d07e8c53cbb886ae7 /util | |
parent | 0fd29b7e09883c730af175cf2c8e78fe3898cad2 (diff) | |
download | minetest-4a8a50a2a22e9a87089b817f966bf5270eb4bc2f.tar.gz minetest-4a8a50a2a22e9a87089b817f966bf5270eb4bc2f.tar.bz2 minetest-4a8a50a2a22e9a87089b817f966bf5270eb4bc2f.zip |
Masterserver show privs and js autoload
Diffstat (limited to 'util')
-rw-r--r-- | util/master/README.md | 10 | ||||
-rw-r--r-- | util/master/index.html | 6 | ||||
-rw-r--r-- | util/master/list.js | 22 | ||||
-rwxr-xr-x | util/master/master.cgi | 2 | ||||
-rw-r--r-- | util/master/servers.jst | 6 | ||||
-rw-r--r-- | util/master/style.css | 7 |
6 files changed, 34 insertions, 19 deletions
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 +---------------------- +<script>var master = {root: 'http://servers.minetest.net/', limit:10, clients_min:1, no_flags:1, no_ping:1, no_uptime:1};</script> +<script src="http://servers.minetest.net/list.js"></script> 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 @@ <head> <meta charset="utf-8"> <title>Minetest server list</title> - <link rel="stylesheet" href="style.css" /> - <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> - <script src="servers.js"></script> - <script src="list.js"></script> </head> <body> <div id="server_list"></div> </body> </html> - +<script src="list.js"></script> 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 = '<span' if (shortStr.length > 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 = '<span'; if (shortStr.length > maxLen) { shortStr = shortStr.substr(0, maxLen - 2) + "…"; - ret += ' class="tooltip" title="' + str + '"'; + ret += ' class="mts_tooltip" title="' + str + '"'; } return ret + '>' + shortStr + '</span>'; } function hoverList(name, list) { if (!list || list.length == 0) return ''; - var str = '<div class="hover_list">' + var str = '<div class="mts_hover_list">' str += name + '(' + list.length + ')<br />'; for (var i in list) { str += escapeHTML(list[i]) + '<br />'; @@ -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)}} </td>{{?}} {{? !master.no_clients}} - <td class="clients{{? server.clients_list && server.clients_list.length > 0}} hover_list_text{{?}}"> + <td class="clients{{? server.clients_list && server.clients_list.length > 0}} mts_hover_list_text{{?}}"> {{=server.clients}}/{{=server.clients_max}} {{=server.clients_top}} {{=hoverList("Clients", server.clients_list)}} </td>{{?}} {{? !master.no_version}} - <td class="version{{? server.mods && server.mods.length > 0}} hover_list_text{{?}}"> + <td class="version{{? server.mods && server.mods.length > 0}} mts_hover_list_text{{?}}"> {{=escapeHTML(server.version)}}, {{=escapeHTML(server.gameid)}}, {{=escapeHTML(server.mapgen || '?')}} {{=hoverList("Mods", server.mods)}} @@ -47,7 +47,7 @@ {{=tooltipString(server.description, 50)}} </td>{{?}} {{? !master.no_flags}} - <td class="flags"> + <td class="flags" {{? server.privs}}title="{{=escapeHTML(server.privs)}}"{{?}}> {{=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; } - |