allow searching via q query param

This commit is contained in:
Cade Scroggins
2017-07-23 15:52:45 -07:00
parent 33632c7170
commit 4501c21d50
+10
View File
@@ -77,6 +77,10 @@
// the delimiter between the hours and minutes in the clock // the delimiter between the hours and minutes in the clock
clockDelimiter: ' ', 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
}; };
</script> </script>
@@ -874,6 +878,7 @@
this._inputElVal = ''; this._inputElVal = '';
this._bindMethods(); this._bindMethods();
this._registerEvents(); this._registerEvents();
this._loadQueryParam();
} }
_bindMethods() { _bindMethods() {
@@ -945,6 +950,11 @@
} }
} }
_loadQueryParam() {
const q = new URLSearchParams(window.location.search).get('q');
if (q) this._submitWithValue(q);
}
_previewValue(value) { _previewValue(value) {
this._inputEl.value = value; this._inputEl.value = value;
this._setBackgroundFromQuery(value); this._setBackgroundFromQuery(value);