From d56cda95723e44ce3f0d3f198f635b7d0187e44f Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Sun, 28 May 2023 16:16:56 +0200 Subject: [PATCH] added aspect ratio to every point --- res/panorama/script.js | 5 ++++- res/script.js | 18 +++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/res/panorama/script.js b/res/panorama/script.js index ade25b3..6385b19 100644 --- a/res/panorama/script.js +++ b/res/panorama/script.js @@ -75,12 +75,15 @@ function check_param() { let params = new URLSearchParams(window.location.search); img_url = params.get("img"); + x = params.get("aspect_x"); + y = params.get("aspect_y"); - if (img_url == null) + if (img_url == null || x == null || y == null) { alert("This link seems to be corrupted!"); open("../index.html", "_self"); } img_url = 'http://207.180.212.190/fht/fabrika_imgs/' + img_url + '.jpg'; //TODO: Change + ASPECT_RATIO = x / y; } \ No newline at end of file diff --git a/res/script.js b/res/script.js index bc5f632..c8fd624 100644 --- a/res/script.js +++ b/res/script.js @@ -1,6 +1,6 @@ const points = [ - [1240, 625, "1;2"] + [1240, 625, "1;2", 9, 16] ]; const tolerance = 3; @@ -16,30 +16,30 @@ window.onload = function() { if ( - (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) + ((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)) ) { - move(points[i][2]); + move(points[i][2], points[i][3], points[i][4]); break; } } } } -function open_panorama(img) +function open_panorama(img, x, y) { - open("./res/panorama.html?img=" + img, "_self"); + open("./res/panorama.html?img=" + img + "&aspect_x=" + x + "&aspect_y=" + y, "_self"); } -function move(img) +function move(img, x, y) { if (!img.includes(";")) { - open_panorama(img); + open_panorama(img, x, y); } else { let imgs = img.split(";"); - open_panorama(imgs[Math.floor(Math.random() * imgs.length)]); + open_panorama(imgs[Math.floor(Math.random() * imgs.length)], x, y); } } \ No newline at end of file