45 lines
1.1 KiB
JavaScript
Raw Normal View History

const points =
[
2023-05-28 16:16:56 +02:00
[1240, 625, "1;2", 9, 16]
];
const tolerance = 3;
window.onload = function()
{
document.querySelector("img").onclick = (e) =>
{
let x = e.pageX - e.target.offsetLeft;
let y = e.pageY - e.target.offsetTop;
for (let i = 0; i < points.length; i++)
{
if
(
2023-05-28 16:16:56 +02:00
((Math.abs(x - points[i][0]) <= tolerance || -Math.abs(x - points[i][0]) >= tolerance) &&
(Math.abs(y - points[i][1]) <= tolerance || -Math.abs(y - points[i][1]) >= tolerance))
)
{
2023-05-28 16:16:56 +02:00
move(points[i][2], points[i][3], points[i][4]);
break;
}
}
}
}
2023-05-28 16:16:56 +02:00
function open_panorama(img, x, y)
{
2023-05-28 16:16:56 +02:00
open("./res/panorama.html?img=" + img + "&aspect_x=" + x + "&aspect_y=" + y, "_self");
}
2023-05-28 16:16:56 +02:00
function move(img, x, y)
{
if (!img.includes(";"))
{
2023-05-28 16:16:56 +02:00
open_panorama(img, x, y);
} else
{
let imgs = img.split(";");
2023-05-28 16:16:56 +02:00
open_panorama(imgs[Math.floor(Math.random() * imgs.length)], x, y);
}
2023-05-24 12:01:54 +02:00
}