new stuff

This commit is contained in:
ville rantanen
2018-09-25 10:26:51 +03:00
parent a8301bf1cc
commit d4ce7bab20
2 changed files with 43 additions and 8 deletions

View File

@@ -80,6 +80,7 @@ function init() {
print_results(hitList);
fold_initial();
scroll_load();
parse_request();
}
function narrow_window() {
return window.innerWidth < config.narrow;
@@ -141,6 +142,7 @@ function filter(ev) {
var c=hitList.length;
var lastHit=hitList[c-1];
print_results(hitList);
if (ev == null) { return }
var key=ev.keyCode;
if (key==13){
if (c==0) { document.getElementById('filter').focus(); }
@@ -273,9 +275,26 @@ function parse_links(s) {
linkList=links.slice(0);
init();
}
function parse_request() {
var request = window.location.search.substring(1);
var vars = request.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
if (decodeURIComponent(pair[0]) == "blank") {
toggle_blank();
}
if (decodeURIComponent(pair[0]) == "filter") {
var value = decodeURIComponent(pair[1]);
document.getElementById("filter").value = value;
filter(null);
}
}
}
function keyboard_entry(ev) {
var kC=ev.keyCode;
var k=String.fromCharCode(ev.keyCode);
var kC = ev.keyCode;
var k = String.fromCharCode(ev.keyCode);
if ( document.activeElement === document.getElementById("filter")) {
return
}
@@ -294,13 +313,13 @@ function toggle_blank() {
var span=document.getElementById('open_blank_span');
var arrow=document.getElementById('open_blank_arrow');
if (span.attributes['data']) {
if ( span.attributes['data']=="true" ) {
span.attributes['data']="false";
if ( span.attributes['data'] == "true" ) {
span.attributes['data'] = "false";
} else {
span.attributes['data']="true";
span.attributes['data'] = "true";
}
} else {
span.attributes['data']="true"
span.attributes['data'] = "true";
}
var blank=span.attributes['data']=="true";
var anchors = document.getElementsByTagName('a');
@@ -421,9 +440,9 @@ function fold_set_state(state) {
}
function set_cookie(name,value) {
// Save cookies for 2 hours
// Save cookies for 30 minutes
document.cookie = name + "=" + value.toString() + "&" + window.location.pathname +
";path=" + window.location.pathname + ";max-age="+ (60*60*2).toString() + ";";
";path=" + window.location.pathname + ";max-age="+ (60 * 30).toString() + ";";
}
function clear() {