File tree 4 files changed +29
-5
lines changed
4 files changed +29
-5
lines changed Original file line number Diff line number Diff line change 14
14
color : # 336BA1 ;
15
15
}
16
16
</ style >
17
+ < script >
18
+ var master = { show_proto_select : true } ;
19
+ </ script >
17
20
</ head >
18
21
< body >
19
22
< div id ="server_list "> </ div >
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ if (!master.output) master.output = '#server_list';
5
5
if ( ! master . list ) master . list = "list" ;
6
6
if ( ! master . list_root ) master . list_root = master . root ;
7
7
if ( ! master . list_url ) master . list_url = master . list_root + master . list ;
8
+ master . cached_json = null ;
8
9
9
10
// Utility functions used by the templating code
10
11
@@ -81,12 +82,22 @@ function constantWidth(str, width) {
81
82
// Code that fetches & displays the actual list
82
83
83
84
function draw ( json ) {
85
+ if ( json == null )
86
+ return ;
87
+
84
88
var html = window . render . servers ( json ) ;
85
89
jQuery ( master . output ) . html ( html ) ;
90
+ jQuery ( '.proto_select' , master . output ) . on ( 'change' , function ( e ) {
91
+ master . proto_range = e . target . value ;
92
+ draw ( master . cached_json ) ; // re-render
93
+ } ) ;
86
94
}
87
95
88
96
function get ( ) {
89
- jQuery . getJSON ( master . list_url , draw ) ;
97
+ jQuery . getJSON ( master . list_url , function ( json ) {
98
+ master . cached_json = json ;
99
+ draw ( json ) ;
100
+ } ) ;
90
101
}
91
102
92
103
function loaded ( ) {
Original file line number Diff line number Diff line change 1
1
{{? !master.no_total}}
2
- <div class =" total" >
3
- Players: {{=it.total.clients}}/{{=it.total_max.clients}}  ;
4
- Servers: {{=it.total.servers}}/{{=it.total_max.servers}}
2
+ <div >
3
+ <span class =" header_total" >
4
+ Players: {{=it.total.clients}}/{{=it.total_max.clients}}  ;
5
+ Servers: {{=it.total.servers}}/{{=it.total_max.servers}}
6
+ </span >
7
+ {{? master.show_proto_select}}
8
+ , Protocol: <select class =" proto_select" >
9
+ <option value =" " >All</option >
10
+ <option value =" [11,32]" {{? master.proto_range ==' [11,32]' }}selected{{?}} >11-32 (Minetest 0.4)</option >
11
+ <option value =" [37,99]" {{? master.proto_range ==' [37,99]' }}selected{{?}} >37 (Minetest 5.0)</option >
12
+ </select >{{?}}
5
13
</div >
6
14
{{?}}
7
15
<table >
19
27
{{~it.list :server:index}}
20
28
{{ if (master.limit && index + 1 > master.limit) break;}}
21
29
{{ if (master.min_clients && server.clients < master.min_clients) continue;}}
30
+ {{ var tmp = master.proto_range ? JSON.parse(master.proto_range) : null;}}
31
+ {{ if (tmp && (server.proto_min < tmp[0] || server.proto_max > tmp[1])) continue;}}
22
32
<tr >
23
33
{{? !master.no_address}}
24
34
<td class =" address" >
Original file line number Diff line number Diff line change 1
- # server_list .total {
1
+ # server_list .header_total {
2
2
font-weight : bold;
3
3
}
4
4
You can’t perform that action at this time.
0 commit comments