2
0
mirror of https://github.com/urbanguacamole/torrent-paradise synced 2024-10-31 21:20:13 +00:00

feat: interpret q parameter as query

Closes #6.
This commit is contained in:
Mingye Wang 2021-02-28 15:32:38 +08:00 committed by urbanguacamole
parent 774c2a98b0
commit 81bb90c141
2 changed files with 20 additions and 4 deletions

View File

@ -7,7 +7,8 @@ window.addEventListener("message", receiveMessage, false);
function receiveMessage(event) { function receiveMessage(event) {
app.resultPageHeight = event.data app.resultPageHeight = event.data
} }
searchbox = document.getElementById('searchbox')
const searchbox = document.getElementById('searchbox')
if (searchbox != null) { if (searchbox != null) {
searchbox.onkeydown = function (event) { searchbox.onkeydown = function (event) {
if (event.keyCode == 13) { if (event.keyCode == 13) {
@ -15,3 +16,10 @@ if (searchbox != null) {
} }
} }
} }
const urlParams = new URLSearchParams(window.location.search);
const query = urlParams.get('q');
if (query != null) {
searchbox.value = query
searchTriggered()
}

View File

@ -7,7 +7,8 @@ window.addEventListener("message", receiveMessage, false);
function receiveMessage(event) { function receiveMessage(event) {
app.resultPageHeight = event.data app.resultPageHeight = event.data
} }
searchbox = document.getElementById('searchbox')
const searchbox = document.getElementById('searchbox')
if (searchbox != null) { if (searchbox != null) {
searchbox.onkeydown = function (event) { searchbox.onkeydown = function (event) {
if (event.keyCode == 13) { if (event.keyCode == 13) {
@ -15,3 +16,10 @@ if (searchbox != null) {
} }
} }
} }
const urlParams = new URLSearchParams(window.location.search);
const query = urlParams.get('q');
if (query != null) {
searchbox.value = query
searchTriggered()
}