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

@@ -40,3 +40,19 @@ are parsed.
[Source file](example_links.txt)
[Additional config](config.js)
[Project homepage](https://bitbucket.org/MoonQ/mdlinks)
# Advanced
## Parsing the request
[Open pages in new window](?blank)
[Predefined filter](?filter=predefined)
## Keyboard
- N: toggle new window opening
- C: clear filter
- S: enter filter editor

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,6 +275,23 @@ 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);
@@ -300,7 +319,7 @@ function toggle_blank() {
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() {