save filter needle too
This commit is contained in:
18
index.html
18
index.html
@@ -70,6 +70,7 @@ function init() {
|
|||||||
}
|
}
|
||||||
document.getElementById("open_blank_arrow").innerHTML=config.arrows[0];
|
document.getElementById("open_blank_arrow").innerHTML=config.arrows[0];
|
||||||
document.getElementById("filter").focus();
|
document.getElementById("filter").focus();
|
||||||
|
filter_load();
|
||||||
hitList=search_hits(document.getElementById("filter").value);
|
hitList=search_hits(document.getElementById("filter").value);
|
||||||
print_results(hitList);
|
print_results(hitList);
|
||||||
scroll_load();
|
scroll_load();
|
||||||
@@ -127,6 +128,7 @@ function make_menu() {
|
|||||||
|
|
||||||
function filter(ev) {
|
function filter(ev) {
|
||||||
var needle=document.getElementById('filter').value;
|
var needle=document.getElementById('filter').value;
|
||||||
|
document.cookie="filter="+needle;
|
||||||
hitList=search_hits(needle);
|
hitList=search_hits(needle);
|
||||||
var c=hitList.length;
|
var c=hitList.length;
|
||||||
var lastHit=hitList[c-1];
|
var lastHit=hitList[c-1];
|
||||||
@@ -285,15 +287,23 @@ function scroll_save() {
|
|||||||
document.cookie = "position=" + window.scrollY + ";";
|
document.cookie = "position=" + window.scrollY + ";";
|
||||||
}
|
}
|
||||||
function scroll_load() {
|
function scroll_load() {
|
||||||
var nameEQ = "position=";
|
var position=parseInt(get_cookie("position"));
|
||||||
|
window.scrollTo(0,position);
|
||||||
|
}
|
||||||
|
function filter_load() {
|
||||||
|
var needle=get_cookie("filter");
|
||||||
|
if (needle===null) { return }
|
||||||
|
document.getElementById("filter").value=needle;
|
||||||
|
}
|
||||||
|
function get_cookie(name) {
|
||||||
|
var nameEQ = name+"=";
|
||||||
var ca = document.cookie.split(';');
|
var ca = document.cookie.split(';');
|
||||||
position=0;
|
|
||||||
for(var i=0;i < ca.length;i++) {
|
for(var i=0;i < ca.length;i++) {
|
||||||
var c = ca[i];
|
var c = ca[i];
|
||||||
while (c.charAt(0)==' ') c = c.substring(1,c.length);
|
while (c.charAt(0)==' ') c = c.substring(1,c.length);
|
||||||
if (c.indexOf(nameEQ) == 0) { position=parseInt(c.substring(nameEQ.length,c.length)); break; }
|
if (c.indexOf(nameEQ) == 0) { return c.substring(nameEQ.length,c.length); }
|
||||||
}
|
}
|
||||||
window.scrollTo(0,position);
|
return null
|
||||||
}
|
}
|
||||||
document.onkeyup=move_cursor;
|
document.onkeyup=move_cursor;
|
||||||
document.onscroll=scroll_save;
|
document.onscroll=scroll_save;
|
||||||
|
|||||||
Reference in New Issue
Block a user