Skip to content

Commit

Permalink
Add query param for initial search (#5)
Browse files Browse the repository at this point in the history
e.g. 61C can link to https://hivemind.eecs.berkeley.edu/?search=hive and enjoy less accidents.

Co-authored-by: Oliver Ni <[email protected]>
  • Loading branch information
chrononyan and oliver-ni authored Sep 2, 2023
1 parent fa953a3 commit 0febd16
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,27 @@ var app = new Vue({
},
watch: {
filteredServers: activateAllClipboards
},
created() {
let search = getQueryParam('search');
if (search) {
this.search = search;
}
}
});

function getQueryParam(name) {
// Could use URLSearchParams if IE is considered dead
// but dumb querystring parsing is also not too bad...
var params = window.location.search.substring(1).split('&');
for (var i = 0; i < params.length; i++) {
var param = params[i].split('=', 2);
if (param[0] === name) {
return decodeURIComponent(param[1]);
}
}
}

function activateAllClipboards() {
// TODO: Get the timing to work without setTimeout
setTimeout(function() {
Expand Down

0 comments on commit 0febd16

Please sign in to comment.