From ef31fac5ca29c1052c3dc260630129b13f4aa008 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 20 Nov 2025 14:52:55 +0100 Subject: Added -set_seed flag; Added animation on error --- code/index.tmpl.html | 38 +++++++++++++++++++++++--------------- code/noelan.go | 10 ++++++---- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/code/index.tmpl.html b/code/index.tmpl.html index 4c392bb..7e5f7bb 100644 --- a/code/index.tmpl.html +++ b/code/index.tmpl.html @@ -1,4 +1,5 @@ -{{ if false }} + +{{ if .Internal }} {{ end }} - - - @@ -142,13 +140,13 @@ function setPageChoose() { document.body.innerHTML = `
-
-
- - - -
-
+
+
+ + + +
+
@@ -199,6 +197,7 @@ function setPageChoose() { .then(function(response) { if (!response.ok) { console.error('Network response was not ok'); + const textElement = document.createElement('div'); } return response.json(); }) @@ -254,7 +253,16 @@ function setPageChoose() { }) .then(function(response) { if (!response.ok) { - console.error('Network response was not ok'); + console.error('Network response was not ok'); + + const textElement = document.createElement('div'); + textElement.textContent = 'Erreur'; + textElement.classList.add('fade'); + let buttons = document.querySelector("div#pin-login > form"); + buttons.appendChild(textElement); + setTimeout(function() { + textElement.remove(); + }, 1000); } return response.json(); }) @@ -418,7 +426,7 @@ function setPageThisPerson() { return response.text(); }) .then(function(response) { - {{ if false }} + {{ if .Internal }} console.log("response:", response); console.log(typeof(response)); console.log("wishlist.value:", wishlist.value); @@ -441,7 +449,7 @@ function setPageThisPerson() { sendWishlistButton.addEventListener("click", function(event) { event.preventDefault(); - {{ if false }} + {{ if .Internal }} console.log("Sending list of", global_all_data.thisName); console.log("content:", wishlist.value); {{ end }} @@ -485,7 +493,7 @@ function setPageThisPerson() { //- Main window.onload = function() { - {{ if false }} + {{ if .Internal }} // NOTE(luca): Users will expect going back to go to the home page so we do this manually. {{ end }} window.addEventListener('popstate', function(event) { diff --git a/code/noelan.go b/code/noelan.go index 1e168a2..b33b8ff 100644 --- a/code/noelan.go +++ b/code/noelan.go @@ -291,7 +291,7 @@ func Run() { var internal, slow, save bool var serve, shuffle, unpickall, show_people, reset_tokens bool var add_person, remove_person, unpick string - var set_local_storage_key int64 + var set_local_storage_key, set_seed int64 flag.BoolVar(&internal, "internal", false, "run commands in internal mode") flag.BoolVar(&slow, "slow", false, "run commands in slow mode") @@ -304,16 +304,18 @@ func Run() { flag.StringVar(&remove_person, "remove_person", "", "remove person by name") flag.StringVar(&unpick, "unpick", "", "unpick person by name") flag.Int64Var(&set_local_storage_key, "set_local_storage_key", 0, "Set the local storage key") + flag.Int64Var(&set_seed, "set_seed", 0, "Set the random seed") flag.BoolVar(&serve, "serve", false, "run http server") flag.Parse() logger := log.New(os.Stdout, "[noel] ", log.Ldate|log.Ltime) var seed int64 - if internal { - seed = rand.Int63() + // NOTE(luca): Since we use the + if set_seed != 0 { + seed = set_seed } else { - seed = 7967946373046491984 + seed = rand.Int63() } logger.Println("seed:", seed) source := rand.NewSource(seed) -- cgit v1.2.3-70-g09d2