Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes the enter key submit a search in the game panel #5161

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions html/create_object.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<form name="spawner" action="byond://?src=/* ref src */" method="get">
<input type="hidden" name="src" value="/* ref src */">
<input type="hidden" name="admin_token" value="/* href token */">
Type: <input type="text" name="filter" onkeypress="submitFirst(event)" style="width:350px"> <input
Type: <input type="text" name="filter" onkeypress="filterKeyPressed(event)" style="width:350px"> <input
type="button" class="button" value="Search" onclick="updateSearch()" /><br>

Offset: <input type="text" name="offset" value="x,y,z" style="width:250px">
Expand Down Expand Up @@ -66,14 +66,19 @@
populateList(filtered);
}

function submitFirst(event) {
if (!object_list.options.length) {
return false;
}

function filterKeyPressed(event) {
// Carriage return
if (event.keyCode == 13 || event.which == 13) {
object_list.options[0].selected = 'true';
// If the value of the input bar is different to the previous search.
if (document.spawner.filter.value != old_search) {
// Search!
updateSearch()
}
// Otherwise, if there are entries in the object list.
else if (object_list.options.length){
// Select and spawn the one at the top.
object_list.options[0].selected = 'true';
}
}
}
</script>
Expand Down
Loading