From cb44f3e34591c61985081aad21b1ab82c0a9f389 Mon Sep 17 00:00:00 2001 From: Dave Date: Thu, 25 Jan 2024 11:03:07 +0000 Subject: [PATCH 1/2] Added redirect function --- static/worksheets/api/abcc.js | 40 ++++++++++++++++----------------- static/worksheets/api/abct.js | 13 +++++++++++ static/worksheets/settings.html | 4 ++++ 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/static/worksheets/api/abcc.js b/static/worksheets/api/abcc.js index 8d3197b..b9e80db 100644 --- a/static/worksheets/api/abcc.js +++ b/static/worksheets/api/abcc.js @@ -2,25 +2,23 @@ window.addEventListener('load', function () { const startScriptOnLoad = localStorage.getItem('startScriptOnLoad'); if (startScriptOnLoad === 'true') { - startScript(); - } -}); + var directPreviousPage = localStorage.getItem('directPreviousPage') || 'https://www.google.com/'; + var currentURL = window.location.href; + var baseURL = currentURL.substring(0, currentURL.lastIndexOf("/") + 1); + var indexURL = baseURL + "main.html"; -function startScript() { - var currentURL = window.location.href; - var baseURL = currentURL.substring(0, currentURL.lastIndexOf("/") + 1); - var indexURL = baseURL + "main.html"; - - win = window.open(); - win.document.body.style.margin = "0"; - win.document.body.style.height = "100vh"; - var iframe = win.document.createElement("iframe"); - iframe.style.border = "none"; - iframe.style.width = "100%"; - iframe.style.height = "100%"; - iframe.style.margin = "0"; - iframe.referrerpolicy = "no-referrer"; - iframe.allow = "fullscreen"; - iframe.src = indexURL; - win.document.body.appendChild(iframe); -} + win = window.open(); + win.document.body.style.margin = "0"; + win.document.body.style.height = "100vh"; + var iframe = win.document.createElement("iframe"); + iframe.style.border = "none"; + iframe.style.width = "100%"; + iframe.style.height = "100%"; + iframe.style.margin = "0"; + iframe.referrerpolicy = "no-referrer"; + iframe.allow = "fullscreen"; + iframe.src = indexURL; + win.document.body.appendChild(iframe); + this.window.location.replace(directPreviousPage); + } +}); \ No newline at end of file diff --git a/static/worksheets/api/abct.js b/static/worksheets/api/abct.js index 3fc88db..77f7bb5 100644 --- a/static/worksheets/api/abct.js +++ b/static/worksheets/api/abct.js @@ -1,4 +1,5 @@ const ABCCheckbox = document.getElementById('ABC'); +const ABCDirect = document.getElementById('ABCDirect'); function handleCheckboxChange() { const startScriptOnLoad = ABCCheckbox.checked; @@ -12,14 +13,26 @@ function handleCheckboxChange() { } } +function handleTextChange() { + localStorage.setItem('directPreviousPage', ABCDirect.value); + console.log('ABC will direct to ' + directPreviousPage + ' on page load.'); +} + +ABCDirect.addEventListener('change', handleTextChange); ABCCheckbox.addEventListener('change', handleCheckboxChange); window.addEventListener('load', () => { const startScriptOnLoad = localStorage.getItem('startScriptOnLoad'); + const directPreviousPage = localStorage.getItem('directPreviousPage'); if (startScriptOnLoad === 'true') { ABCCheckbox.checked = true; } else { ABCCheckbox.checked = false; } + if (directPreviousPage == null) { + ABCDirect.value = 'https://www.google.com/'; + } else { + ABCDirect.value = directPreviousPage; + } }); \ No newline at end of file diff --git a/static/worksheets/settings.html b/static/worksheets/settings.html index 747669a..73a751c 100644 --- a/static/worksheets/settings.html +++ b/static/worksheets/settings.html @@ -96,6 +96,10 @@

Panic Button

About Blank Toggle

+
+ +
+ From 22791e28186ff77b7945446455d52e4a1e21ee2e Mon Sep 17 00:00:00 2001 From: Dave Date: Thu, 25 Jan 2024 13:17:49 +0000 Subject: [PATCH 2/2] Fixed error --- static/worksheets/api/abct.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/worksheets/api/abct.js b/static/worksheets/api/abct.js index 77f7bb5..bd4743a 100644 --- a/static/worksheets/api/abct.js +++ b/static/worksheets/api/abct.js @@ -15,7 +15,7 @@ function handleCheckboxChange() { function handleTextChange() { localStorage.setItem('directPreviousPage', ABCDirect.value); - console.log('ABC will direct to ' + directPreviousPage + ' on page load.'); + console.log('ABC will direct to ' + ABCDirect.value + ' on page load.'); } ABCDirect.addEventListener('change', handleTextChange); @@ -31,7 +31,7 @@ window.addEventListener('load', () => { ABCCheckbox.checked = false; } if (directPreviousPage == null) { - ABCDirect.value = 'https://www.google.com/'; + ABCDirect.value = 'https://google.com/'; } else { ABCDirect.value = directPreviousPage; }