From 43ef9fd62723b0b83149800c70ade6c4eeea7ac5 Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 5 Mar 2024 10:25:48 -0900 Subject: [PATCH 1/5] Temporarily disable CORS Origin policy and point javascript to local pytho server for local development --- app.py | 2 +- docs/index.html | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index c115fe8..a0430b1 100644 --- a/app.py +++ b/app.py @@ -74,7 +74,7 @@ def index_empty_get(): CORS_CONFIG = CORSConfig( - allow_origin='https://land.codeforanchorage.org', + # allow_origin='https://land.codeforanchorage.org', allow_headers=['X-Special-Header'], max_age=600, expose_headers=['X-Special-Header'], diff --git a/docs/index.html b/docs/index.html index 13c43df..b6cb3da 100644 --- a/docs/index.html +++ b/docs/index.html @@ -72,7 +72,8 @@

// const base_url = "https://ak-land.herokuapp.com/?Body=austin,mn" //const base_url = `https://anchorage-land-cors.herokuapp.com/https://ak-land.herokuapp.com/?Body=${e.target[0].value}` //const base_url = `https://anchorage-land-cors.herokuapp.com/https://42fehusrq0.execute-api.us-west-2.amazonaws.com/api/${e.target[0].value}` - const base_url = `https://42fehusrq0.execute-api.us-west-2.amazonaws.com/api/${e.target[0].value}` + // const base_url = `https://42fehusrq0.execute-api.us-west-2.amazonaws.com/api/${e.target[0].value}` + const base_url = `http://127.0.0.1:8000/${e.target[0].value}` e.preventDefault(); var inp = document.getElementById('textInput'); From bcfdf7fe03cf1d66abd7d3126282ddb19d6083d8 Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 5 Mar 2024 10:36:21 -0900 Subject: [PATCH 2/5] Update javascript in index.html to temporarily hide input elements while page is loading, also remove unneeded style changes to input elements --- docs/index.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/index.html b/docs/index.html index b6cb3da..20597ca 100644 --- a/docs/index.html +++ b/docs/index.html @@ -79,19 +79,21 @@

var inp = document.getElementById('textInput'); var sub = document.getElementById('textSubmit'); - inp.classList.add("loading"); - sub.classList.add("loading"); + inp.style.display='none'; + sub.style.display='none'; axios.get(base_url) .then(function(response) { document.getElementById('output').innerHTML = response.data - inp.classList.remove("loading"); - sub.classList.remove("loading"); + + inp.style.display=''; + sub.style.display=''; }, (error) => { console.log(error); - inp.classList.remove("loading"); - sub.classList.remove("loading"); + + inp.style.display=''; + sub.style.display=''; }); } From 7db555cd03661017e1c0b355452f984323e85646 Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 5 Mar 2024 11:05:41 -0900 Subject: [PATCH 3/5] Add loading icon and associated javascript to index.html, add new styles with keyframes animation to styles.css --- docs/css/style.css | 22 ++++++++++++++++++++-- docs/index.html | 7 +++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/docs/css/style.css b/docs/css/style.css index de67edc..f1c8081 100644 --- a/docs/css/style.css +++ b/docs/css/style.css @@ -24,8 +24,21 @@ input { margin: 1.5%; } -.loading { - opacity: .5; +#loading-icon-wrapper { +display: none; +justify-content: center; +align-items: center; +align-content: center; +} + +#loading-icon { +align-content: center; +border: 8px solid #ffffff; +border-top: 8px solid #eb8d15; +border-radius: 50%; +width: 50px; +height: 50px; +animation: spin 1s linear infinite; } main { @@ -126,3 +139,8 @@ section.info { font-size:2em } } + +@keyframes spin { +0% { transform: rotate(0deg); } +100% { transform: rotate(360deg); } +} diff --git a/docs/index.html b/docs/index.html index 20597ca..21ff48b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -44,6 +44,9 @@

Whose land am I on?

+
+
+

Enter your Canadian or US zip code or [city, state], or city, state & country for Australia, NZ or South America to the Facebook Messenger bot @@ -78,7 +81,9 @@

e.preventDefault(); var inp = document.getElementById('textInput'); var sub = document.getElementById('textSubmit'); + let loadIcon = document.getElementById('loading-icon-wrapper'); + loadIcon.style.display='flex'; inp.style.display='none'; sub.style.display='none'; @@ -88,12 +93,14 @@

inp.style.display=''; sub.style.display=''; + loadIcon.style.display = 'none'; }, (error) => { console.log(error); inp.style.display=''; sub.style.display=''; + loadIcon.style.display = 'none'; }); } From 3f8f1334912fe3f2a0a40e0d770c9c90a3d109d8 Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 5 Mar 2024 11:08:54 -0900 Subject: [PATCH 4/5] Update location of loading icon to load above output when page is loaded multiple times --- docs/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/index.html b/docs/index.html index 21ff48b..744e526 100644 --- a/docs/index.html +++ b/docs/index.html @@ -42,11 +42,11 @@

Whose land am I on?

-

-
-
+
+

+

Enter your Canadian or US zip code or [city, state], or city, state & country for Australia, NZ or South America to the Facebook Messenger bot From bc23f93b82e0e1d20c8b5abdb81eb5b1c612bf4e Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 5 Mar 2024 11:11:23 -0900 Subject: [PATCH 5/5] Revert CORS policy change and target url change in index.html --- app.py | 2 +- docs/index.html | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index a0430b1..c115fe8 100644 --- a/app.py +++ b/app.py @@ -74,7 +74,7 @@ def index_empty_get(): CORS_CONFIG = CORSConfig( - # allow_origin='https://land.codeforanchorage.org', + allow_origin='https://land.codeforanchorage.org', allow_headers=['X-Special-Header'], max_age=600, expose_headers=['X-Special-Header'], diff --git a/docs/index.html b/docs/index.html index 744e526..23eb0f2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -75,8 +75,7 @@

// const base_url = "https://ak-land.herokuapp.com/?Body=austin,mn" //const base_url = `https://anchorage-land-cors.herokuapp.com/https://ak-land.herokuapp.com/?Body=${e.target[0].value}` //const base_url = `https://anchorage-land-cors.herokuapp.com/https://42fehusrq0.execute-api.us-west-2.amazonaws.com/api/${e.target[0].value}` - // const base_url = `https://42fehusrq0.execute-api.us-west-2.amazonaws.com/api/${e.target[0].value}` - const base_url = `http://127.0.0.1:8000/${e.target[0].value}` + const base_url = `https://42fehusrq0.execute-api.us-west-2.amazonaws.com/api/${e.target[0].value}` e.preventDefault(); var inp = document.getElementById('textInput');