forked from Mirrorlandia_minetest/minetest
Masterserver show privs and js autoload
This commit is contained in:
parent
0fd29b7e09
commit
4a8a50a2a2
@ -222,6 +222,7 @@ void sendAnnounce(std::string action, const std::vector<std::string> & clients_n
|
|||||||
|
|
||||||
if(server["action"] == "start") {
|
if(server["action"] == "start") {
|
||||||
server["dedicated"] = g_settings->get("server_dedicated");
|
server["dedicated"] = g_settings->get("server_dedicated");
|
||||||
|
server["privs"] = g_settings->get("default_privs");
|
||||||
server["rollback"] = g_settings->getBool("enable_rollback_recording");
|
server["rollback"] = g_settings->getBool("enable_rollback_recording");
|
||||||
server["liquid_finite"] = g_settings->getBool("liquid_finite");
|
server["liquid_finite"] = g_settings->getBool("liquid_finite");
|
||||||
server["mapgen"] = g_settings->get("mg_name");
|
server["mapgen"] = g_settings->get("mg_name");
|
||||||
|
@ -17,8 +17,18 @@ Then install doT.js and it's dependencies:
|
|||||||
$ cd doT
|
$ cd doT
|
||||||
$ npm install
|
$ npm install
|
||||||
|
|
||||||
|
Or by npm:
|
||||||
|
$ npm install dot commander mkdirp
|
||||||
|
|
||||||
And finally compile the template:
|
And finally compile the template:
|
||||||
$ cd ~/minetest/util/master
|
$ cd ~/minetest/util/master
|
||||||
$ ~/code/doT/bin/dot-packer -s . -d .
|
$ ~/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>
|
||||||
|
@ -3,13 +3,9 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Minetest server list</title>
|
<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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="server_list"></div>
|
<div id="server_list"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
<script src="list.js"></script>
|
||||||
|
@ -35,7 +35,7 @@ function addressString(server) {
|
|||||||
var str = '<span'
|
var str = '<span'
|
||||||
if (shortStr.length > 25) {
|
if (shortStr.length > 25) {
|
||||||
shortStr = shortStr.substr(0, 23) + "…";
|
shortStr = shortStr.substr(0, 23) + "…";
|
||||||
str += ' class="tooltip" title="' + addrStr + '"'
|
str += ' class="mts_tooltip" title="' + addrStr + '"'
|
||||||
}
|
}
|
||||||
if (server.port != 30000)
|
if (server.port != 30000)
|
||||||
shortStr += ':' + server.port;
|
shortStr += ':' + server.port;
|
||||||
@ -48,14 +48,14 @@ function tooltipString(str, maxLen) {
|
|||||||
var ret = '<span';
|
var ret = '<span';
|
||||||
if (shortStr.length > maxLen) {
|
if (shortStr.length > maxLen) {
|
||||||
shortStr = shortStr.substr(0, maxLen - 2) + "…";
|
shortStr = shortStr.substr(0, maxLen - 2) + "…";
|
||||||
ret += ' class="tooltip" title="' + str + '"';
|
ret += ' class="mts_tooltip" title="' + str + '"';
|
||||||
}
|
}
|
||||||
return ret + '>' + shortStr + '</span>';
|
return ret + '>' + shortStr + '</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function hoverList(name, list) {
|
function hoverList(name, list) {
|
||||||
if (!list || list.length == 0) return '';
|
if (!list || list.length == 0) return '';
|
||||||
var str = '<div class="hover_list">'
|
var str = '<div class="mts_hover_list">'
|
||||||
str += name + '(' + list.length + ')<br />';
|
str += name + '(' + list.length + ')<br />';
|
||||||
for (var i in list) {
|
for (var i in list) {
|
||||||
str += escapeHTML(list[i]) + '<br />';
|
str += escapeHTML(list[i]) + '<br />';
|
||||||
@ -72,9 +72,19 @@ function get() {
|
|||||||
jQuery.getJSON(master.url, draw);
|
jQuery.getJSON(master.url, draw);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!master.no_refresh) {
|
function loaded(){
|
||||||
setInterval(get, 60 * 1000);
|
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);
|
||||||
|
});
|
||||||
|
@ -241,7 +241,7 @@ sub request (;$) {
|
|||||||
$param->{clients_top} = $old->{clients_top} if $old->{clients_top} > $param->{clients};
|
$param->{clients_top} = $old->{clients_top} if $old->{clients_top} > $param->{clients};
|
||||||
$param->{clients_top} ||= $param->{clients} || 0;
|
$param->{clients_top} ||= $param->{clients} || 0;
|
||||||
# params reported once on start, must be same as src/serverlist.cpp:~221 if(server["action"] == "start") { ...
|
# 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->{$_} ||= $old->{$_} if $old->{$_} and !($param->{action} ~~ 'start');
|
||||||
}
|
}
|
||||||
$param->{pop_n} = $old->{pop_n} + 1;
|
$param->{pop_n} = $old->{pop_n} + 1;
|
||||||
|
@ -24,12 +24,12 @@
|
|||||||
{{=addressString(server)}}
|
{{=addressString(server)}}
|
||||||
</td>{{?}}
|
</td>{{?}}
|
||||||
{{? !master.no_clients}}
|
{{? !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}}
|
{{=server.clients}}/{{=server.clients_max}} {{=server.clients_top}}
|
||||||
{{=hoverList("Clients", server.clients_list)}}
|
{{=hoverList("Clients", server.clients_list)}}
|
||||||
</td>{{?}}
|
</td>{{?}}
|
||||||
{{? !master.no_version}}
|
{{? !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.version)}}, {{=escapeHTML(server.gameid)}},
|
||||||
{{=escapeHTML(server.mapgen || '?')}}
|
{{=escapeHTML(server.mapgen || '?')}}
|
||||||
{{=hoverList("Mods", server.mods)}}
|
{{=hoverList("Mods", server.mods)}}
|
||||||
@ -47,7 +47,7 @@
|
|||||||
{{=tooltipString(server.description, 50)}}
|
{{=tooltipString(server.description, 50)}}
|
||||||
</td>{{?}}
|
</td>{{?}}
|
||||||
{{? !master.no_flags}}
|
{{? !master.no_flags}}
|
||||||
<td class="flags">
|
<td class="flags" {{? server.privs}}title="{{=escapeHTML(server.privs)}}"{{?}}>
|
||||||
{{=server.creative ? 'Cre ' : ''}}
|
{{=server.creative ? 'Cre ' : ''}}
|
||||||
{{=server.dedicated ? 'Ded ' : ''}}
|
{{=server.dedicated ? 'Ded ' : ''}}
|
||||||
{{=server.damage ? 'Dmg ' : ''}}
|
{{=server.damage ? 'Dmg ' : ''}}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
border: 1px solid gray;
|
border: 1px solid gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hover_list{
|
.mts_hover_list{
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
border: gray solid 1px;
|
border: gray solid 1px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -20,12 +20,11 @@
|
|||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
td:hover .hover_list {
|
td:hover .mts_hover_list {
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hover_list_text, .tooltip {
|
.mts_hover_list_text, .mts_tooltip {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
text-decoration-style: dashed;
|
text-decoration-style: dashed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user