From 222063399a79f5d6177a7cb0cfa0f23db1360c5a Mon Sep 17 00:00:00 2001 From: xuri Date: Sun, 24 Jan 2021 13:57:18 +0800 Subject: [PATCH] enable toggle menu and fix missing footer in 404 page --- handlers/error.go | 2 +- templates/404.html | 28 +++++++++++++++++++++++++--- templates/about.html | 26 ++++++++++++++++++++++++-- templates/high_scores.html | 26 ++++++++++++++++++++++++-- templates/home.html | 25 ++++++++++++++++++++++--- templates/report.html | 23 +++++++++++++++++++++-- templates/supporters.html | 26 ++++++++++++++++++++++++-- 7 files changed, 141 insertions(+), 15 deletions(-) diff --git a/handlers/error.go b/handlers/error.go index c3434d4..7e5887b 100644 --- a/handlers/error.go +++ b/handlers/error.go @@ -8,7 +8,7 @@ import ( func errorHandler(w http.ResponseWriter, r *http.Request, status int) { w.WriteHeader(status) if status == http.StatusNotFound { - t := template.Must(template.New("404.html").ParseFiles("templates/404.html", "templates/footer.html")) + t := template.Must(template.New("404.html").Delims("[[", "]]").ParseFiles("templates/404.html", "templates/footer.html")) t.Execute(w, nil) } } diff --git a/templates/404.html b/templates/404.html index e9fdbf7..0ad50ad 100644 --- a/templates/404.html +++ b/templates/404.html @@ -33,21 +33,21 @@ - + -
+ @@ -80,5 +80,27 @@ @-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } } @keyframes spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } } + + diff --git a/templates/about.html b/templates/about.html index 84cc7f9..2388835 100644 --- a/templates/about.html +++ b/templates/about.html @@ -33,14 +33,14 @@
- + -
+
High Scores @@ -67,5 +67,27 @@
[[ template "footer" . ]] + + diff --git a/templates/high_scores.html b/templates/high_scores.html index c581cda..016de85 100644 --- a/templates/high_scores.html +++ b/templates/high_scores.html @@ -33,14 +33,14 @@
- + -
+
High Scores @@ -86,5 +86,27 @@
[[ template "footer" . ]] + + diff --git a/templates/home.html b/templates/home.html index ac82d92..1c43e9e 100644 --- a/templates/home.html +++ b/templates/home.html @@ -31,14 +31,14 @@
- + -
+
High Scores @@ -103,7 +103,7 @@ [[ range .Recent ]] - [[ . ]] + [[ . ]] [[ end ]] @@ -204,6 +204,25 @@ // handle form submission $("form#check_form").submit(loadData); + + // Get all "header-toggle" elements + var $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.header-toggle'), 0); + // Check if there are any navbar burgers + if ($navbarBurgers.length > 0) { + // Add a click event on each of them + $navbarBurgers.forEach(function ($el) { + $el.addEventListener('click', function () { + // Get the target from the "data-target" attribute + var target = $el.dataset.target; + var $target = document.getElementById(target); + // Toggle the class on both the "header-toggle" and the "header-menu" + $el.classList.toggle('is-active'); + $target.classList.toggle('is-active'); + + }); + }); + } + }); diff --git a/templates/report.html b/templates/report.html index 8b65b1a..4cbb86b 100644 --- a/templates/report.html +++ b/templates/report.html @@ -37,14 +37,14 @@
- + -
+
High Scores @@ -346,6 +346,25 @@ $('nav.results').removeClass('stickytop'); } }); + + // Get all "header-toggle" elements + var $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.header-toggle'), 0); + // Check if there are any navbar burgers + if ($navbarBurgers.length > 0) { + // Add a click event on each of them + $navbarBurgers.forEach(function ($el) { + $el.addEventListener('click', function () { + // Get the target from the "data-target" attribute + var target = $el.dataset.target; + var $target = document.getElementById(target); + // Toggle the class on both the "header-toggle" and the "header-menu" + $el.classList.toggle('is-active'); + $target.classList.toggle('is-active'); + + }); + }); + } + }); diff --git a/templates/supporters.html b/templates/supporters.html index 01b3574..93c5e58 100644 --- a/templates/supporters.html +++ b/templates/supporters.html @@ -33,14 +33,14 @@
- + -
+
High Scores @@ -66,5 +66,27 @@
[[ template "footer" . ]] + +