diff --git a/static/script.js b/static/script.js index f08aa8d..68a5cad 100644 --- a/static/script.js +++ b/static/script.js @@ -87,13 +87,16 @@ function dropDownHide() { } } } - -// Close the dropdown menu if the user clicks outside of it -window.onclick = function(event) { - if (!event.target.matches('.dropbtn')) { - dropDownHide(); - } -} +function get_cookie(name) { + var nameEQ = name+"="; + var ca = document.cookie.split(';'); + for(var i=0;i < ca.length;i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf(nameEQ) == 0) { return c.substring(nameEQ.length,c.length); } + } + return null +} function sortMarkdown(boughtOrder=false) { var divs = document.getElementsByClassName("entry"); @@ -124,3 +127,19 @@ function orderStringSorter(a,b) { return 0; } +function scrollBack() { + var position=parseInt(get_cookie("position")); + window.scrollTo(0,position); +} + +// Close the dropdown menu if the user clicks outside of it +window.onclick = function(event) { + if (!event.target.matches('.dropbtn')) { + dropDownHide(); + } +} +document.onscroll = function(event) { + document.cookie = "position=" + window.scrollY + "; path=" + window.location.pathname; +} +window.onload = scrollBack; + diff --git a/templates/show_shop.html b/templates/show_shop.html index b42f0fa..75af0f9 100644 --- a/templates/show_shop.html +++ b/templates/show_shop.html @@ -6,7 +6,7 @@