From c2716348f3d3209ee17e6334f2fa84b1b30e58b1 Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Tue, 22 Nov 2022 19:57:43 -0600 Subject: [PATCH] Make contest banner a bit better --- templates/base.html | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/templates/base.html b/templates/base.html index a9b3d6b..ca9b245 100644 --- a/templates/base.html +++ b/templates/base.html @@ -118,8 +118,8 @@ return false; }); - if (localStorage.getItem("contest_timer_pos")) { - data = localStorage.getItem("contest_timer_pos").split(":"); + if (localStorage.getItem("contest_timer_position")) { + data = localStorage.getItem("contest_timer_position").split(":"); $("#contest-info").css({ left: data[0], top: data[1] @@ -137,14 +137,13 @@ $(document).mousemove(function (e) { x_pos = e.screenX; y_pos = e.screenY; - x_pos = Math.max(Math.min(x_pos, window.innerWidth), 0); - y_pos = Math.max(Math.min(y_pos, window.innerHeight), 0); - + if (selected !== null) { - left_px = (x_pos - x_elem) + 'px'; - top_px = (y_pos - y_elem) + 'px'; - - localStorage.setItem("contest_timer_pos", left_px + ":" + top_px); + left_px = (x_pos - x_elem); + top_px = (y_pos - y_elem); + left_px = Math.max(Math.min(left_px, window.innerWidth), 0) / window.innerWidth * 100 + '%'; + top_px = Math.max(Math.min(top_px, window.innerHeight), 0) / window.innerHeight * 100 + '%'; + localStorage.setItem("contest_timer_position", left_px + ":" + top_px); selected.css({ left: left_px,