Add dropdown that filters by protocol version
This commit is contained in:
@@ -14,6 +14,9 @@
|
||||
color: #336BA1;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var master = {show_proto_select: true};
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="server_list"></div>
|
||||
|
||||
@@ -5,6 +5,7 @@ if (!master.output) master.output = '#server_list';
|
||||
if (!master.list) master.list = "list";
|
||||
if (!master.list_root) master.list_root = master.root;
|
||||
if (!master.list_url) master.list_url = master.list_root + master.list;
|
||||
master.cached_json = null;
|
||||
|
||||
// Utility functions used by the templating code
|
||||
|
||||
@@ -81,12 +82,22 @@ function constantWidth(str, width) {
|
||||
// Code that fetches & displays the actual list
|
||||
|
||||
function draw(json) {
|
||||
if (json == null)
|
||||
return;
|
||||
|
||||
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
|
||||
});
|
||||
}
|
||||
|
||||
function get() {
|
||||
jQuery.getJSON(master.list_url, draw);
|
||||
jQuery.getJSON(master.list_url, function(json) {
|
||||
master.cached_json = json;
|
||||
draw(json);
|
||||
});
|
||||
}
|
||||
|
||||
function loaded(){
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
{{? !master.no_total}}
|
||||
<div class="total">
|
||||
Players: {{=it.total.clients}}/{{=it.total_max.clients}}
|
||||
Servers: {{=it.total.servers}}/{{=it.total_max.servers}}
|
||||
<div>
|
||||
<span class="header_total">
|
||||
Players: {{=it.total.clients}}/{{=it.total_max.clients}}
|
||||
Servers: {{=it.total.servers}}/{{=it.total_max.servers}}
|
||||
</span>
|
||||
{{? master.show_proto_select}}
|
||||
, 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>
|
||||
</select>{{?}}
|
||||
</div>
|
||||
{{?}}
|
||||
<table>
|
||||
@@ -19,6 +27,8 @@
|
||||
{{~it.list :server:index}}
|
||||
{{ if (master.limit && index + 1 > master.limit) break;}}
|
||||
{{ if (master.min_clients && server.clients < master.min_clients) continue;}}
|
||||
{{ var tmp = master.proto_range ? JSON.parse(master.proto_range) : null;}}
|
||||
{{ if (tmp && (server.proto_min < tmp[0] || server.proto_max > tmp[1])) continue;}}
|
||||
<tr>
|
||||
{{? !master.no_address}}
|
||||
<td class ="address">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#server_list .total {
|
||||
#server_list .header_total {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user