Skip to content

Commit

Permalink
Autofill from q param.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansundin committed Nov 19, 2016
1 parent f4b3ff3 commit 67cd9f8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions public/js/main.js
Expand Up @@ -10,6 +10,14 @@ function fmt_filesize(bytes, digits=1) {
return `${size} ${units[i]}`;
}

function toObject(arr) {
var obj = {};
arr.forEach(function(e) {
obj[e[0]] = e[1];
});
return obj;
}

$(document).ready(function() {
window.dirty = 0;
$(window).on("beforeunload", function(event) {
Expand Down Expand Up @@ -177,4 +185,9 @@ $(document).ready(function() {
xhr.setRequestHeader("Accept", "application/json");
xhr.send();
});

var params = toObject(window.location.search.substr(1).split("&").map(function(arg){ return arg.split("="); }));
if (params.q) {
$('input[type="search"]').val(params.q);
}
});

0 comments on commit 67cd9f8

Please sign in to comment.