From 4501c21d5052758394f4feecd8a5de0019349b35 Mon Sep 17 00:00:00 2001 From: Cade Scroggins Date: Sun, 23 Jul 2017 15:42:24 -0700 Subject: [PATCH] allow searching via q query param --- index.html | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.html b/index.html index c677181..042bf41 100644 --- a/index.html +++ b/index.html @@ -77,6 +77,10 @@ // the delimiter between the hours and minutes in the clock clockDelimiter: ' ', + + // note: you can pass in your search query via the q query param + // e.g. going to file:///path/to/tilde/index.html?q=hamsters is equivalent + // to typing "hamsters" and pressing enter }; @@ -874,6 +878,7 @@ this._inputElVal = ''; this._bindMethods(); this._registerEvents(); + this._loadQueryParam(); } _bindMethods() { @@ -945,6 +950,11 @@ } } + _loadQueryParam() { + const q = new URLSearchParams(window.location.search).get('q'); + if (q) this._submitWithValue(q); + } + _previewValue(value) { this._inputEl.value = value; this._setBackgroundFromQuery(value);