]> git.openstreetmap.org Git - rails.git/commitdiff
Create heatmap links using <a> elements
authorAnton Khorev <tony29@yandex.ru>
Mon, 17 Mar 2025 01:49:52 +0000 (04:49 +0300)
committerAnton Khorev <tony29@yandex.ru>
Mon, 17 Mar 2025 01:56:21 +0000 (04:56 +0300)
app/assets/javascripts/heatmap.js

index 0670480d33dfe448e1ca3e9183b3be9d313b2899..09013ae5a10303d7a0136ce13c04f7ffd5b8f713 100644 (file)
@@ -70,17 +70,19 @@ document.addEventListener("DOMContentLoaded", () => {
       }]
     ]);
 
-    cal.on("mouseover", (event, _timestamp, value) => {
-      if (value) event.target.style.cursor = "pointer";
-    });
+    cal.on("mouseover", (event, timestamp, value) => {
+      if (!displayName || !value) return;
+      if (event.target.parentElement.nodeName === "a") return;
 
-    cal.on("click", (_event, timestamp) => {
-      if (!displayName) return;
       for (const { date, max_id } of heatmapData) {
         if (!max_id) continue;
         if (timestamp !== Date.parse(date)) continue;
+
         const params = new URLSearchParams([["before", max_id + 1]]);
-        location = `/user/${encodeURIComponent(displayName)}/history?${params}`;
+        const a = document.createElementNS("http://www.w3.org/2000/svg", "a");
+        a.setAttribute("href", `/user/${encodeURIComponent(displayName)}/history?${params}`);
+        $(event.target).wrap(a);
+        break;
       }
     });
   }