Ports Alt-click Fix (#21143)

* Ported an alt-click statpanel fix.

https://github.com/tgstation/tgstation/pull/88918

Fixes https://github.com/Aurorastation/Aurora.3/issues/20675
This commit is contained in:
Geeves
2025-08-10 14:10:26 +00:00
committed by GitHub
parent 99571daa0a
commit 712dd1c49e
2 changed files with 33 additions and 24 deletions
+6
View File
@@ -0,0 +1,6 @@
author: Geeves
delete-after: True
changes:
- bugfix: "Ported an alt-click statpanel fix."
+27 -24
View File
@@ -440,38 +440,21 @@ function draw_listedturf() {
var table = document.createElement("table");
for (var i = 0; i < turfcontents.length; i++) {
var part = turfcontents[i];
if (storedimages[part[1]] == null && part[2]) {
var img = document.createElement("img");
img.src = part[2];
img.id = part[1];
storedimages[part[1]] = part[2];
img.onerror = iconError;
table.appendChild(img);
} else {
var img = document.createElement("img");
img.onerror = iconError;
img.src = storedimages[part[1]];
img.id = part[1];
table.appendChild(img);
}
var b = document.createElement("div");
var clickcatcher = "";
b.className = "link";
b.onmousedown = function (part) {
var clickfunc = (function (part) {
// The outer function is used to close over a fresh "part" variable,
// rather than every onmousedown getting the "part" of the last entry.
return function (e) {
e.preventDefault();
clickcatcher = "?src=" + part[1];
clickcatcher = "byond://?src=" + part[1];
switch (e.button) {
case 1:
clickcatcher += ";statpanel_item_click=middle"
clickcatcher += ";statpanel_item_click=middle";
break;
case 2:
clickcatcher += ";statpanel_item_click=right"
clickcatcher += ";statpanel_item_click=right";
break;
default:
clickcatcher += ";statpanel_item_click=left"
clickcatcher += ";statpanel_item_click=left";
}
if (e.shiftKey) {
clickcatcher += ";statpanel_item_shiftclick=1";
@@ -483,8 +466,28 @@ function draw_listedturf() {
clickcatcher += ";statpanel_item_altclick=1";
}
window.location.href = clickcatcher;
}
}(part);
};
})(part);
if (storedimages[part[1]] == null && part[2]) {
var img = document.createElement("img");
img.src = part[2];
img.id = part[1];
storedimages[part[1]] = part[2];
img.onerror = iconError;
img.onmousedown = clickfunc;
table.appendChild(img);
} else {
var img = document.createElement("img");
img.onerror = iconError;
img.onmousedown = clickfunc;
img.src = storedimages[part[1]];
img.id = part[1];
table.appendChild(img);
}
var b = document.createElement("div");
var clickcatcher = "";
b.className = "link";
b.onmousedown = clickfunc;
b.textContent = part[0];
table.appendChild(b);
table.appendChild(document.createElement("br"));