X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/921547406c8cdd5b4cffee21bca0ee56f23251dc..0de8fbee36cf18ea98dba85a7fc629db7e6ca769:/latinsample.js diff --git a/latinsample.js b/latinsample.js index f4a6a6d..c17242a 100644 --- a/latinsample.js +++ b/latinsample.js @@ -33,16 +33,27 @@ function appendsample() { } }; +function getrequest(name) { + // find GET variable in page request + var match = new RegExp('[?&]'+name+'=([^&]*)'); + var param = match.exec(window.location.search); + return param ? decodeURIComponent(param[1]) : ''; +} + function prependinput(target) { var form = document.createElement('FORM'); form.id = 'search'; form.className = 'aside'; + form.onsubmit = function () { return false }; var input = document.createElement('INPUT'); input.oninput = appendsample; input.placeholder = 'Sample'; input.type = 'search'; input.name = 'q'; + if (input.value = getrequest('q')) { + input.oninput(); + } form.appendChild(input); target.parentNode.insertBefore(form, target);