diff options
| author | stonedDiscord <stoned@derpymail.org> | 2020-04-13 19:18:25 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-13 19:18:25 +0200 |
| commit | d1235fcb242e6111f2ffff64519a45e4618af40c (patch) | |
| tree | 15eda50ca73d15d2b54023073f8db2326a87a8ee /webAO | |
| parent | 97caca41dfa78158fb64a0229f173d5d6f45a409 (diff) | |
| parent | 16b6800a1e95fa57bc33e4a6ba0f4034d98c3abf (diff) | |
Merge pull request #57 from AttorneyOnline/character_search
Character search
Diffstat (limited to 'webAO')
| -rw-r--r-- | webAO/client.html | 5 | ||||
| -rw-r--r-- | webAO/client.js | 22 | ||||
| -rw-r--r-- | webAO/styles/client.css | 1 |
3 files changed, 24 insertions, 4 deletions
diff --git a/webAO/client.html b/webAO/client.html index 74d374b..3ad3989 100644 --- a/webAO/client.html +++ b/webAO/client.html @@ -50,8 +50,9 @@ <div id="client_charselect"> <p>Choose your character</p> <button onclick="pickChar(1001)">Or spectate</button> - <br> - <br> + <br><br> + <input id="client_charactersearch" placeholder="Search" oninput="chartable_filter(event)"></input> + <br><br> <div id="client_chartable"></div> </div> <div id="client_error" class="error" style="display: none"> diff --git a/webAO/client.js b/webAO/client.js index 9be4529..b5c8c2f 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1124,9 +1124,9 @@ class Client extends EventEmitter { let img = document.getElementById(`demo_${i}`); if (args[i + 1] === "-1") - img.style = "opacity: 0.25"; + img.style.opacity = 0.25; else if (args[i + 1] === "0") - img.style = ""; + img.style.opacity = 1; } } @@ -2278,6 +2278,24 @@ function appendICLog(msg, name = "", time = new Date()) { } /** + * Triggered when the music search bar is changed + * @param {MouseEvent} event + */ +export function chartable_filter(_event) { + const searchname = document.getElementById("client_charactersearch").value; + + client.chars.forEach(function (character, charid) { + const demothing = document.getElementById(`demo_${charid}`); + if (character.name.toLowerCase().indexOf(searchname.toLowerCase()) === -1) { + demothing.style.display = "none"; + } else { + demothing.style.display = "inline-block"; + } + }); +} +window.chartable_filter = chartable_filter; + +/** * Requests to play as a character. * @param {number} ccharacter the character ID; if this is a large number, * then spectator is chosen instead. diff --git a/webAO/styles/client.css b/webAO/styles/client.css index 4063b67..4c15f93 100644 --- a/webAO/styles/client.css +++ b/webAO/styles/client.css @@ -126,6 +126,7 @@ max-height: 60px; margin: 3px; border: 1px solid #000; + vertical-align: top; } #client_icwrapper { |
