From 4d28d4fec183985fd5f40c703ef8eeccf70c6233 Mon Sep 17 00:00:00 2001 From: asyncnomi Date: Wed, 21 Dec 2022 23:22:56 +0100 Subject: [PATCH] Edit history --- static/js/main.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/static/js/main.js b/static/js/main.js index ce51694..d876505 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -2,17 +2,23 @@ const base_url = "https://oss110metz.rezo-rm.fr/" var historyHandler = []; window.onpopstate = history.onpushstate = function(e) { - show_page(e.state); + if (e.state) { + show_page(e.state, true); + } else { + history.back(); + } }; history.pushState("#main-page", "", "") -function show_page(id) { +function show_page(id, historyPush) { $('#main-page').hide(); $('#admin-page').hide(); $('#login-page').hide(); $('#demande-page').hide(); $(id).show(); - history.pushState(id, "", "") + if (!historyPush) { + history.pushState(id, "", "") + } } $("#login-button").click(function (e) {