Compare commits
2 Commits
faf6e2abd7
...
b52216bd2f
| Author | SHA1 | Date | |
|---|---|---|---|
|
b52216bd2f
|
|||
|
2bc83a17dd
|
@@ -20,7 +20,7 @@ import (
|
|||||||
"git.t-juice.club/torjus/oubliette/internal/web"
|
"git.t-juice.club/torjus/oubliette/internal/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
const Version = "0.14.0"
|
const Version = "0.14.1"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if err := run(); err != nil {
|
if err := run(); err != nil {
|
||||||
|
|||||||
@@ -158,9 +158,14 @@
|
|||||||
var svg = container.querySelector('svg');
|
var svg = container.querySelector('svg');
|
||||||
if (!svg) return;
|
if (!svg) return;
|
||||||
|
|
||||||
var paths = svg.querySelectorAll('path[id]');
|
// Remove SVG title to prevent browser native tooltip
|
||||||
paths.forEach(function(path) {
|
var svgTitle = svg.querySelector('title');
|
||||||
var id = path.id.toLowerCase();
|
if (svgTitle) svgTitle.remove();
|
||||||
|
|
||||||
|
// Select both <path id="xx"> and <g id="xx"> country elements
|
||||||
|
var elements = svg.querySelectorAll('path[id], g[id]');
|
||||||
|
elements.forEach(function(el) {
|
||||||
|
var id = el.id.toLowerCase();
|
||||||
if (id.charAt(0) === '_') return; // skip non-country paths
|
if (id.charAt(0) === '_') return; // skip non-country paths
|
||||||
|
|
||||||
var count = lookup[id];
|
var count = lookup[id];
|
||||||
@@ -169,26 +174,34 @@
|
|||||||
var r = Math.round(30 + intensity * 69); // 30 -> 99
|
var r = Math.round(30 + intensity * 69); // 30 -> 99
|
||||||
var g = Math.round(30 + intensity * 72); // 30 -> 102
|
var g = Math.round(30 + intensity * 72); // 30 -> 102
|
||||||
var b = Math.round(62 + intensity * 179); // 62 -> 241
|
var b = Math.round(62 + intensity * 179); // 62 -> 241
|
||||||
path.style.fill = 'rgb(' + r + ',' + g + ',' + b + ')';
|
var color = 'rgb(' + r + ',' + g + ',' + b + ')';
|
||||||
|
// For <g> elements, color child paths; for <path>, color directly
|
||||||
|
if (el.tagName.toLowerCase() === 'g') {
|
||||||
|
el.querySelectorAll('path').forEach(function(p) {
|
||||||
|
p.style.fill = color;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
el.style.fill = color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
path.addEventListener('mouseenter', function(e) {
|
el.addEventListener('mouseenter', function(e) {
|
||||||
var cc = id.toUpperCase();
|
var cc = id.toUpperCase();
|
||||||
var n = lookup[id] || 0;
|
var n = lookup[id] || 0;
|
||||||
tooltip.textContent = cc + ': ' + n.toLocaleString() + ' attempts';
|
tooltip.textContent = cc + ': ' + n.toLocaleString() + ' attempts';
|
||||||
tooltip.style.display = 'block';
|
tooltip.style.display = 'block';
|
||||||
});
|
});
|
||||||
|
|
||||||
path.addEventListener('mousemove', function(e) {
|
el.addEventListener('mousemove', function(e) {
|
||||||
tooltip.style.left = (e.clientX + 12) + 'px';
|
tooltip.style.left = (e.clientX + 12) + 'px';
|
||||||
tooltip.style.top = (e.clientY - 10) + 'px';
|
tooltip.style.top = (e.clientY - 10) + 'px';
|
||||||
});
|
});
|
||||||
|
|
||||||
path.addEventListener('mouseleave', function() {
|
el.addEventListener('mouseleave', function() {
|
||||||
tooltip.style.display = 'none';
|
tooltip.style.display = 'none';
|
||||||
});
|
});
|
||||||
|
|
||||||
path.addEventListener('click', function() {
|
el.addEventListener('click', function() {
|
||||||
var input = document.querySelector('#filter-form input[name="country"]');
|
var input = document.querySelector('#filter-form input[name="country"]');
|
||||||
if (input) {
|
if (input) {
|
||||||
input.value = id.toUpperCase();
|
input.value = id.toUpperCase();
|
||||||
@@ -196,7 +209,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
path.style.cursor = 'pointer';
|
el.style.cursor = 'pointer';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user