aboutsummaryrefslogtreecommitdiff
path: root/internal/admin/static/map.js
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-07-01 04:53:56 -0400
committerhistoria <[not public]>2026-07-01 04:53:56 -0400
commitbf7c27c2cbf3eb56a0a4c5141e39b152c51614b5 (patch)
tree5383c325fafeb34c01ea737a7070402f040fc5af /internal/admin/static/map.js
parentfbe5090ac3325ff8ea6989cdf4515c7f077c975b (diff)
downloadthehouseoficarus-bf7c27c2cbf3eb56a0a4c5141e39b152c51614b5.tar.gz
feat: admin gui map, item, and objects mostly complete
Diffstat (limited to 'internal/admin/static/map.js')
-rw-r--r--internal/admin/static/map.js40
1 files changed, 38 insertions, 2 deletions
diff --git a/internal/admin/static/map.js b/internal/admin/static/map.js
index e5d9a19..95bde7e 100644
--- a/internal/admin/static/map.js
+++ b/internal/admin/static/map.js
@@ -594,8 +594,8 @@ function renderItemsTab(spawns) {
spawns.forEach(function(spawn, i) {
h += '<div class="entry-row" data-idx="' + i + '">';
h += '<div class="entry-fields">';
- h += '<span class="entry-id">' + esc(spawn.id || '') + '</span>';
h += '<div style="display:flex;gap:8px;align-items:center;">';
+ h += '<span class="entry-id" style="flex:1;display:inline;padding:0">' + esc(spawn.id || '') + '</span>';
h += '<div><label class="mini-label">Quantity</label><input class="mini-input spawn-qty" type="text" inputmode="numeric" pattern="[0-9]*" value="' + (spawn.quantity || 0) + '" onchange="updateSpawn(' + i + ')"></div>';
h += '<div><label class="mini-label">Respawn</label><input class="mini-input spawn-respawn" type="text" inputmode="numeric" pattern="[0-9]*" value="' + (spawn.respawn_ticks || 0) + '" onchange="updateSpawn(' + i + ')"></div>';
h += '</div>';
@@ -1066,7 +1066,7 @@ function searchMobs(input) {
function searchAndShow(input, type, onSelect) {
var val = input.value.trim();
var results = input.parentElement.querySelector('.search-results');
- if (!val) { results.style.display = 'none'; results.innerHTML = ''; return; }
+ if (!val) { results.style.display = 'none'; results.innerHTML = ''; results._selectedIndex = -1; return; }
API.get('/api/search?q=' + encodeURIComponent(val)).then(function(data) {
var items = [];
if (type === 'objects' && data.objects) items = data.objects;
@@ -1084,9 +1084,36 @@ function searchAndShow(input, type, onSelect) {
}).join('');
results._items = items;
results._onSelect = onSelect;
+ results._selectedIndex = -1;
}).catch(function() {
results.style.display = 'none';
});
+
+ input._searchKeySetup = input._searchKeySetup || (function() {
+ input.addEventListener('keydown', function(e) {
+ if (results.style.display === 'none' || !results.children.length) return;
+ if (results._selectedIndex === undefined) results._selectedIndex = -1;
+
+ if (e.key === 'ArrowDown') {
+ e.preventDefault();
+ results._selectedIndex = Math.min(results._selectedIndex + 1, results.children.length - 1);
+ updateSearchHighlight(results);
+ } else if (e.key === 'ArrowUp') {
+ e.preventDefault();
+ results._selectedIndex = Math.max(results._selectedIndex - 1, 0);
+ updateSearchHighlight(results);
+ } else if (e.key === 'Enter') {
+ if (results._selectedIndex >= 0) {
+ e.preventDefault();
+ selectSearchResult(results.children[results._selectedIndex]);
+ }
+ } else if (e.key === 'Escape') {
+ results.style.display = 'none';
+ results._selectedIndex = -1;
+ }
+ });
+ return true;
+ })();
}
function selectSearchResult(el) {
@@ -1101,6 +1128,13 @@ function selectSearchResult(el) {
}
}
+function updateSearchHighlight(results) {
+ for (var i = 0; i < results.children.length; i++) {
+ results.children[i].classList.toggle('active', i === results._selectedIndex);
+ if (i === results._selectedIndex) results.children[i].scrollIntoView({block: 'nearest'});
+ }
+}
+
function openEditor(type, id) {
window.open('/editor/' + type + '#' + id, '_blank');
}
@@ -1111,11 +1145,13 @@ function reRenderPanel() {
}
function autoSave() {
+ if (window._colorPickerActive) return;
if (saveTimer) clearTimeout(saveTimer);
saveTimer = setTimeout(function() { doSavePanel(); }, 600);
}
function saveNow() {
+ if (window._colorPickerActive) return;
if (saveTimer) clearTimeout(saveTimer);
saveTimer = null;
doSavePanel();