mirror of
https://github.com/moparisthebest/minetest
synced 2024-11-04 16:35:03 -05:00
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") {
|
||||
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");
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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;
|
||||
|
@ -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 ' : ''}}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user