auto scroll back

This commit is contained in:
ville rantanen
2017-07-05 19:44:57 +03:00
parent 57abc49f1b
commit 95920c0cd9
2 changed files with 27 additions and 8 deletions

View File

@@ -87,12 +87,15 @@ 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) {
@@ -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;

View File

@@ -6,7 +6,7 @@
<input type=hidden name=shopid value="{{ shopid }}" >
<div id="entry_loop">
{% for entry in entries %}
<div class=entry><input class="submit tickbox {{ entry.extra_class }}" type=submit name=item{{ entry.row }} value="{{ entry.icon }}" ><span class=md_entry>{{ entry.text|safe }}</span><br></div>
<div class=entry><input class="submit tickbox {{ entry.extra_class }}" type=submit name=item{{ entry.row }} id=itemId{{ entry.row }} value="{{ entry.icon }}" ><span class=md_entry>{{ entry.text|safe }}</span><br></div>
{% endfor %}
</div>
</form>