function for saving cookies
This commit is contained in:
12
index.html
12
index.html
@@ -128,7 +128,7 @@ function make_menu() {
|
||||
|
||||
function filter(ev) {
|
||||
var needle=document.getElementById('filter').value;
|
||||
document.cookie="filter="+needle;
|
||||
set_cookie("filter", needle);
|
||||
hitList=search_hits(needle);
|
||||
var c=hitList.length;
|
||||
var lastHit=hitList[c-1];
|
||||
@@ -217,6 +217,7 @@ function print_results(hitList) {
|
||||
doc.innerHTML="";
|
||||
var tbl=document.createElement("table");
|
||||
var tbody=document.createElement("tbody");
|
||||
var tr=document.createElement("tr");
|
||||
var print_cat=0;
|
||||
for (cat=0; cat<cats.length; cat++) {
|
||||
if (cats[cat].count>0) {
|
||||
@@ -309,7 +310,7 @@ function toggle_blank() {
|
||||
arrow.innerHTML=arrowChar;
|
||||
}
|
||||
function scroll_save() {
|
||||
document.cookie = "position=" + window.scrollY + "; path=" + window.location.pathname;
|
||||
set_cookie("position", window.scrollY);
|
||||
}
|
||||
function scroll_load() {
|
||||
var position=parseInt(get_cookie("position"));
|
||||
@@ -322,14 +323,17 @@ function filter_load() {
|
||||
}
|
||||
function get_cookie(name) {
|
||||
var nameEQ = name+"=";
|
||||
var ca = document.cookie.split(';');
|
||||
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);
|
||||
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 set_cookie(name,value) {
|
||||
document.cookie = name + "=" + value.toString() + "; path=" + window.location.pathname + ";";
|
||||
}
|
||||
document.onkeyup=keyboard_entry;
|
||||
document.onkeydown=keyboard_control;
|
||||
document.onscroll=scroll_save;
|
||||
|
||||
Reference in New Issue
Block a user