diff options
| author | Raymaekers Luca <luca@spacehb.net> | 2025-11-19 12:42:03 +0100 |
|---|---|---|
| committer | Raymaekers Luca <luca@spacehb.net> | 2025-11-19 12:43:27 +0100 |
| commit | 5f9f9c024b46cd0d9fb24a1a916d7ccadbce1371 (patch) | |
| tree | 40e14092856f4ccaf2402e95d132f222441720ce /code/index.tmpl.html | |
| parent | 543bda8e6c9eca9e861a88e6b1af9c7854e52381 (diff) | |
checkpoint
Diffstat (limited to 'code/index.tmpl.html')
| -rw-r--r-- | code/index.tmpl.html | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/code/index.tmpl.html b/code/index.tmpl.html index 43e9db4..f60ecf6 100644 --- a/code/index.tmpl.html +++ b/code/index.tmpl.html @@ -81,7 +81,7 @@ textarea { //- Globals let people = [{{ range .People }} - {"name": "{{.Name}}", "has_picked": {{.HasPicked}},}, {{ end }} + {"name": "{{.Name}}", "has_picked": {{.HasPicked}}}, {{ end }} ]; let local_storage_key = "{{.Key}}"; @@ -220,7 +220,7 @@ function setPageOtherPerson() { let wishlist = document.getElementById(wishlistID); wishlist.textContent = global_all_data.otherWishlist; - fetch(`/api/list/?name=${global_all_data.thisName}&token=${global_all_data.token}`) + fetch(`/api/list/?user=${global_all_data.thisName}&name=${global_all_data.otherName}&token=${global_all_data.token}`) .then(function(response) { if (!response.ok) { console.error('Network response was not ok'); @@ -231,7 +231,7 @@ function setPageOtherPerson() { if(wishlist.textContent != response) { global_all_data.otherWishlist = response; - wishlist.textContent = global_all_data.otherWishlist; + wishlist.textContent = response; localStorage.setItem(local_storage_key, JSON.stringify(global_all_data)); } }) @@ -302,6 +302,26 @@ function setPageThisPerson() { let letterTextArea = document.getElementById(letterTextAreaID); letterTextArea.textContent = global_all_data.thisWishlist; + fetch(`/api/list/?user=${global_all_data.thisName}&name=${global_all_data.thisName}&token=${global_all_data.token}`) + .then(function(response) { + if (!response.ok) { + console.error('Network response was not ok'); + } + return response.text(); + }) + .then(function(response) { + if(wishlist.textContent != response) + { + global_all_data.thisWishlist = response; + letterTextArea.textContent = response; + localStorage.setItem(local_storage_key, JSON.stringify(global_all_data)); + } + }) + .catch(function(error) { + console.error('There was a problem with the fetch operation:', error); + }); + + let sendLetterButton = document.getElementById(sendLetterButtonID); sendLetterButton.addEventListener("click", function(event) { event.preventDefault(); |
