From 8bdb043923bfe9819e51002bb4f2f88b01e7484c Mon Sep 17 00:00:00 2001 From: Skylar Sadlier Date: Wed, 10 May 2023 19:38:10 -0600 Subject: [PATCH] Closes #11 - Add autocomplete for server types instead of having to search at bottom of config page --- query-game-server.html | 83 ++++++++++++++++++------------------------ query-game-server.js | 11 ++++-- 2 files changed, 43 insertions(+), 51 deletions(-) diff --git a/query-game-server.html b/query-game-server.html index 8145e42..b37d6f2 100644 --- a/query-game-server.html +++ b/query-game-server.html @@ -32,20 +32,38 @@ return 'Query Game Server'; }, oneditprepare: function() { + let server_types = null; + $.getJSON('/gamedig/types', function(data) { - let html = '' + - '' + - ''; - for(let game of data) { - html += "" + - "" + - "" + - "" + - ""; + if(data.result !== 'ok' || !data.hasOwnProperty("server_types")) + { + console.error("server_types failed to load"); + return; + } + + server_types = data.server_types; + }); + + $("#node-input-server_type").autoComplete({ + search: function(val) { + if(!server_types) return false; // ignore until we have the types loaded + + let matches = []; + server_types.forEach(v => { + if ( + v.name.toLowerCase().indexOf(val.toLowerCase()) > -1 || + v.type.toLowerCase().indexOf(val.toLowerCase()) > -1 || + v.protocol.toLowerCase().indexOf(val.toLowerCase()) > -1 + ) { + matches.push({ + value: v.type, + label: `${v.name} (${v.type})`, + protocol: v.protocol + }); + } + }); + return matches; } - html += '' + - '
TypeNameProtocol
"+game['type']+""+game['name']+""+game['protocol']+"
'; - $("#query-game-server-types").html(html); }); } }); @@ -68,10 +86,10 @@
- +
- View server types below. + Recommend visiting the GameDig GitHub page for more information about the server type you are trying to query. Some types require extra setup.
@@ -84,7 +102,7 @@
- +
Query port for the server (join and query port may differ). @@ -106,7 +124,7 @@
- +
Number of attempts to query server in case of failure. @@ -114,7 +132,7 @@
- +
Milliseconds to wait for a single packet. Beware that increasing this will cause many queries to take longer even if the server is online. @@ -122,7 +140,7 @@
- +
Milliseconds allowed for an entire query attempt. This timeout is not commonly hit, as the socketTimeout typically fires first. @@ -177,35 +195,6 @@
IP family/version returned when looking up hostnames via DNS, can be IPv4 and IPv6, IPv4 only or IPv6 only.
- -

Server Types

-

- Search available types below.
- You can also view the list here. -

- -
- -
-
-