From b956f575a6f237fa63237fbdfda8bc6b3d03aa7f Mon Sep 17 00:00:00 2001 From: TiviPlus <57223640+TiviPlus@users.noreply.github.com> Date: Thu, 13 Feb 2025 17:16:38 +0100 Subject: [PATCH] Fix stat panel turf list menu clicks only working on the text (#89456) ## About The Pull Request Only the div was setting onmousedown ## Changelog :cl: fix: Fixed stat panel turf list menu clicks only working on the text /:cl: Co-authored-by: TiviPlus <572233640+TiviPlus@users.noreply.com> --- html/statbrowser.js | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/html/statbrowser.js b/html/statbrowser.js index d4f5c6cd428..964cf87ffef 100644 --- a/html/statbrowser.js +++ b/html/statbrowser.js @@ -438,24 +438,7 @@ 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) { @@ -483,6 +466,26 @@ function draw_listedturf() { window.location.href = clickcatcher; } }(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"));