From d5f5557e0603603616f7551342d051f8e8e3e027 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Wed, 26 Oct 2022 20:10:45 -0700 Subject: [PATCH 1/4] change "Tube Archivist IP" to "Tube Archivist URL" --- extension/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension/index.html b/extension/index.html index 92b0713..fbe74b2 100644 --- a/extension/index.html +++ b/extension/index.html @@ -18,7 +18,7 @@
- + From afbcb5757e5208c835e752bceb38d7ae2dffa7b2 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Sun, 27 Nov 2022 15:17:11 -0800 Subject: [PATCH 2/4] use full url --- extension/background.js | 2 +- extension/index.html | 6 ++---- extension/popup.js | 17 +++++++++++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/extension/background.js b/extension/background.js index c6f3b80..7bcdb5f 100644 --- a/extension/background.js +++ b/extension/background.js @@ -16,7 +16,7 @@ function getBrowser() { return chrome; } } else { - console.log("failed to dedect browser"); + console.log("failed to detect browser"); throw "browser detection error" }; } diff --git a/extension/index.html b/extension/index.html index fbe74b2..6da6cc6 100644 --- a/extension/index.html +++ b/extension/index.html @@ -18,10 +18,8 @@
- - - - + + diff --git a/extension/popup.js b/extension/popup.js index beb4653..6e46931 100644 --- a/extension/popup.js +++ b/extension/popup.js @@ -21,10 +21,15 @@ function getBrowser() { // store access details document.getElementById("save-login").addEventListener("click", function () { + let url = document.getElementById("url").value; + if (!url.includes('://')) { + url = 'http://' + url; + } + let parsed = new URL(url); let toStore = { "access": { - "url": document.getElementById("url").value, - "port": document.getElementById("port").value, + "url": document.getElementById("full-url").host, + "port": document.getElementById("port").port || '80', "apiKey": document.getElementById("api-key").value } }; @@ -150,8 +155,12 @@ document.addEventListener("DOMContentLoaded", async () => { setStatusIcon(false); return } - document.getElementById("url").value = item.access.url; - document.getElementById("port").value = item.access.port; + let { url, port } = item.access; + let fullUrl = url; + if (!(url.startsWith('http://') && port === '80')) { + fullUrl += `:${port}`; + } + document.getElementById("full-url").value = fullUrl; document.getElementById("api-key").value = item.access.apiKey; pingBackend(); addUrl(item.access); From 4ea141c6fe2d602ebe83bf601f5300b9efcc40f5 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Sun, 27 Nov 2022 19:21:13 -0800 Subject: [PATCH 3/4] typos --- extension/popup.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/extension/popup.js b/extension/popup.js index 6e46931..ca99fae 100644 --- a/extension/popup.js +++ b/extension/popup.js @@ -21,15 +21,15 @@ function getBrowser() { // store access details document.getElementById("save-login").addEventListener("click", function () { - let url = document.getElementById("url").value; + let url = document.getElementById("full-url").value; if (!url.includes('://')) { url = 'http://' + url; } let parsed = new URL(url); let toStore = { "access": { - "url": document.getElementById("full-url").host, - "port": document.getElementById("port").port || '80', + "url": parsed.host, + "port": parsed.port || '80', "apiKey": document.getElementById("api-key").value } }; @@ -91,7 +91,7 @@ function pingBackend() { console.log("connection validated") } } - + function handleError(error) { console.log(`Error: ${error}`); setStatusIcon(false); @@ -175,7 +175,7 @@ document.addEventListener("DOMContentLoaded", async () => { setCookieState(); } - + function onError(error) { console.log(`Error: ${error}`); }; From 25dd6dbdc553e05c65684716e243bb1d5cd35773 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Sun, 27 Nov 2022 20:01:06 -0800 Subject: [PATCH 4/4] fix it better --- extension/popup.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extension/popup.js b/extension/popup.js index ca99fae..1fcc679 100644 --- a/extension/popup.js +++ b/extension/popup.js @@ -28,8 +28,8 @@ document.getElementById("save-login").addEventListener("click", function () { let parsed = new URL(url); let toStore = { "access": { - "url": parsed.host, - "port": parsed.port || '80', + "url": `${parsed.protocol}//${parsed.hostname}`, + "port": parsed.port || (parsed.protocol === 'https' ? '443' : '80'), "apiKey": document.getElementById("api-key").value } };