Skip to content
Permalink
Browse files
Recalculate stats with protocol filter applied
closes #49
  • Loading branch information
sfan5 committed Sep 5, 2021
1 parent 5d5f31d commit 2f4ffde91670478f939340c9693de4dbe3f23d84
Showing with 17 additions and 4 deletions.
  1. +16 −1 static/list.js
  2. +1 −3 static/servers.jst
@@ -80,8 +80,23 @@ function draw(json) {
if (json == null)
return;

// pre-filter by chosen protocol range
var tmp = master.proto_range ? JSON.parse(master.proto_range) : null;
if (tmp) {
json = {
list: json.list.filter(function(server) {
return !(tmp[0] > server.proto_max || tmp[1] < server.proto_min);
}),
total: {clients: 0},
total_max: {clients: "?", servers: "?"}
};
json.list.forEach(function(server) { json.total.clients += server.clients; });
json.total.servers = json.list.length;
}

var html = window.render.servers(json);
jQuery(master.output).html(html);

jQuery('.proto_select', master.output).on('change', function(e) {
master.proto_range = e.target.value;
draw(master.cached_json); // re-render
@@ -110,6 +125,6 @@ toast(master.root + 'style.css', master.root + 'servers.js', function() {
if (typeof(jQuery) != 'undefined')
return loaded();
else
toast('//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js', loaded);
toast('//ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js', loaded);
});

@@ -8,7 +8,7 @@
, Protocol: <select class="proto_select">
<option value="">All</option>
<option value="[11,32]" {{? master.proto_range=='[11,32]'}}selected{{?}}>11-32 (Minetest 0.4)</option>
<option value="[37,99]" {{? master.proto_range=='[37,99]'}}selected{{?}}>37 (Minetest 5.0)</option>
<option value="[37,99]" {{? master.proto_range=='[37,99]'}}selected{{?}}>37+ (Minetest 5.x)</option>
</select>{{?}}
</div>
{{?}}
@@ -24,11 +24,9 @@
{{? !master.no_ping}}<th>Ping, Lag</th>{{?}}
</tr></thead>
<tbody>
{{ var tmp = master.proto_range ? JSON.parse(master.proto_range) : null;}}
{{~it.list :server:index}}
{{ if (master.limit && index + 1 > master.limit) break;}}
{{ if (master.min_clients && server.clients < master.min_clients) continue;}}
{{ if (tmp && (tmp[0] > server.proto_max || tmp[1] < server.proto_min)) continue;}}
<tr>
{{? !master.no_address}}
<td class="address">

0 comments on commit 2f4ffde

Please sign in to comment.