save scroll state
This commit is contained in:
16
index.html
16
index.html
@@ -72,6 +72,7 @@ function init() {
|
||||
document.getElementById("filter").focus();
|
||||
hitList=search_hits(document.getElementById("filter").value);
|
||||
print_results(hitList);
|
||||
scroll_load();
|
||||
}
|
||||
function narrow_window() {
|
||||
return window.innerWidth < config.narrow;
|
||||
@@ -280,7 +281,22 @@ function toggle_blank() {
|
||||
}
|
||||
arrow.innerHTML=arrowChar;
|
||||
}
|
||||
function scroll_save() {
|
||||
document.cookie = "position=" + window.scrollY + ";";
|
||||
}
|
||||
function scroll_load() {
|
||||
var nameEQ = "position=";
|
||||
var ca = document.cookie.split(';');
|
||||
position=0;
|
||||
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) { position=parseInt(c.substring(nameEQ.length,c.length)); break; }
|
||||
}
|
||||
window.scrollTo(0,position);
|
||||
}
|
||||
document.onkeyup=move_cursor;
|
||||
document.onscroll=scroll_save;
|
||||
var linkReg=/([^\[]*)\[([^\]]+)\]\(([^\)]+)\)(.*)/;
|
||||
var linkPlain=/(.*)(http[^\s]+)(.*)/;
|
||||
var linkList=[];
|
||||
|
||||
Reference in New Issue
Block a user