From 6ae8ec4526a01b8c9f4c082bd60e579f2a64c481 Mon Sep 17 00:00:00 2001 From: ashboundscar Date: Sat, 23 May 2026 15:25:32 +0300 Subject: [PATCH 1/2] Added click-to-copy and cursor toggle to coordinate display --- frontend/static/yw/javascript/owot.js | 32 ++++++++++++++++++++++++++- frontend/templates/yourworld.html | 10 ++++++--- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/frontend/static/yw/javascript/owot.js b/frontend/static/yw/javascript/owot.js index 5157b5f4..a6efb3c0 100644 --- a/frontend/static/yw/javascript/owot.js +++ b/frontend/static/yw/javascript/owot.js @@ -281,6 +281,9 @@ defineElements({ // elm[] nav_elm: byId("nav"), menu_corner_area_elm: byId("menu_corner_area"), coords: byId("coords"), + coord_display: byId("coord_display"), + toggle_cursor: byId("toggle_cursor"), + coord_status: byId("coord_status"), cursor_coords: byId("cursor_coords"), cursor_on: byId("cursor_on"), cursor_off: byId("cursor_off"), @@ -7249,16 +7252,43 @@ function setupDOMEvents() { } } - elm.coords.onclick = function() { + elm.toggle_cursor.onclick = function() { showCursorCoordinates = !showCursorCoordinates; if(showCursorCoordinates) { elm.cursor_coords.style.display = ""; + elm.toggle_cursor.innerText = "▲"; updateCoordDisplay(); } else { elm.cursor_coords.style.display = "none"; + elm.toggle_cursor.innerText = "▼"; updateCoordDisplay(); } } + + elm.coord_display.onclick = function() { + var x = elm.coord_X.innerText; + var y = elm.coord_Y.innerText; + var coordStr = "X: " + x + ", Y: " + y; + w.clipboard.copy(coordStr); + elm.coord_status.style.display = ""; + setTimeout(function() { + elm.coord_status.style.display = "none"; + }, 1000); + } + + elm.cursor_coords.onclick = function() { + if(elm.cursor_on.style.display == "none") return; + var tx = elm.tile_X.innerText; + var ty = elm.tile_Y.innerText; + var cx = elm.char_X.innerText; + var cy = elm.char_Y.innerText; + var coordStr = "Tile: " + tx + ", " + ty + " / Char: " + cx + ", " + cy; + w.clipboard.copy(coordStr); + elm.coord_status.style.display = ""; + setTimeout(function() { + elm.coord_status.style.display = "none"; + }, 1000); + } window.onhashchange = function(e) { manageCoordHash(); diff --git a/frontend/templates/yourworld.html b/frontend/templates/yourworld.html index 902ea9ed..04b0cd6b 100644 --- a/frontend/templates/yourworld.html +++ b/frontend/templates/yourworld.html @@ -34,9 +34,13 @@