This repository has been archived by the owner on May 13, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We had added this features some time ago but it had to be deleted due Getkey was working on the game server list. I made some changes to the sort arrows (but haven't worked on sorting yet, sorry) My commit refers to https://github.com/KordonBleu/jumpsuit/projects/1#card-2123886
- Loading branch information
Showing
6 changed files
with
45 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
/*let searchInput = document.getElementById('search-input'), | ||
import * as servers from './servers.js'; | ||
|
||
let searchInput = document.getElementById('lobby-search'); | ||
|
||
export function applyLobbySearch() { | ||
wsClt.serverList.forEach(function(lobby, index) { | ||
//lobbyListElement.children are reversed compared to wsClt.serverList | ||
let currentElem = lobbyListElement.children[wsClt.serverList.length - index - 1], | ||
newValue = currentElem.firstChild.textContent; | ||
for (let entry of servers.slaveRows) { | ||
let tableRow = entry[1], | ||
tableItem = tableRow.firstChild, | ||
newValue = tableItem.textContent, | ||
serverName = entry[0].userData.serverName; | ||
|
||
if (searchInput.value === '') currentElem.classList.remove('search-hidden'); | ||
else { | ||
let regx = new RegExp(searchInput.value, 'gi'), | ||
match, | ||
offset = 0; | ||
while ((match = regx.exec(lobby.name)) !== null) { | ||
if (searchInput.value !== '') { | ||
let match, offset = 0, regex = new RegExp(searchInput.value.replace(/[#-.]|[[-^]|[?|{}]/g, '\\$&'), 'gi'); //clean RegEx | ||
while ((match = regex.exec(serverName)) !== null) { | ||
newValue = newValue.substr(0, match.index + offset) + '<u>' + newValue.substr(match.index + offset, match[0].length) + '</u>' + newValue.substr(offset + match.index + match[0].length); | ||
offset += 7; //<u>...</u> inserted so the string length and match indexes change | ||
} | ||
if (offset === 0) currentElem.classList.add('search-hidden'); | ||
else currentElem.classList.remove('search-hidden'); | ||
} | ||
currentElem.firstChild.innerHTML = newValue; //always set the innerHTML in order to clear highlights or re-highlight | ||
}); | ||
if (offset === 0) tableRow.classList.add('hidden'); | ||
else tableRow.classList.remove('hidden'); | ||
} else tableRow.classList.remove('hidden'); | ||
|
||
tableItem.innerHTML = newValue; | ||
} | ||
} | ||
searchInput.addEventListener('input', applyLobbySearch);*/ | ||
|
||
document.getElementById('lobby-search-reset').addEventListener('click', e => { | ||
e.preventDefault(); | ||
searchInput.value = ''; | ||
}); | ||
searchInput.addEventListener('input', applyLobbySearch); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters