Add search based on state

This commit is contained in:
Clement Ho 2016-11-08 13:20:37 -06:00
parent 7564c57133
commit 6b4358eaf7
1 changed files with 16 additions and 1 deletions

View File

@ -147,7 +147,22 @@
search() {
console.log('search');
let path = '?scope=all&state=opened&utf8=✓';
let path = '?scope=all&utf8=✓';
// Check current state
const currentPath = window.location.search;
const stateIndex = currentPath.indexOf('state=');
const defaultState = 'opened';
let currentState = defaultState;
if (stateIndex !== -1) {
const remaining = currentPath.slice(stateIndex + 6);
const separatorIndex = remaining.indexOf('&');
currentState = separatorIndex === -1 ? remaining : remaining.slice(0, separatorIndex);
}
path += `&state=${currentState}`
this.tokens.forEach((token) => {
const param = validTokenKeys.find((t) => {