Skip to content

Commit

Permalink
Make search result share-able by URL
Browse files Browse the repository at this point in the history
  • Loading branch information
RadhiFadlillah committed Aug 29, 2019
1 parent 89aad30 commit 3f43424
Show file tree
Hide file tree
Showing 6 changed files with 263 additions and 294 deletions.
17 changes: 9 additions & 8 deletions internal/view/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
title: "Home",
icon: "fa-home",
page: "page-home",
},{
}, {
title: "Setting",
icon: "fa-cog",
page: "page-setting",
Expand All @@ -69,10 +69,12 @@
methods: {
switchPage(page) {
var pageName = page.replace("page-", ""),
state = {activePage: page};
state = { activePage: page },
url = new Url;

url.hash = pageName;
this.activePage = page;
history.pushState(state, page, `#${pageName}`);
history.pushState(state, page, url);
},
logout() {
this.showDialog({
Expand Down Expand Up @@ -114,7 +116,7 @@
keepMetadata = (typeof opts.keepMetadata === "boolean") ? opts.keepMetadata : false,
useArchive = (typeof opts.useArchive === "boolean") ? opts.useArchive : false,
makePublic = (typeof opts.makePublic === "boolean") ? opts.makePublic : false;

this.appOptions = {
showId: showId,
listMode: listMode,
Expand All @@ -131,7 +133,7 @@
id = (typeof account.id === "number") ? account.id : 0,
username = (typeof account.username === "string") ? account.username : "",
owner = (typeof account.owner === "boolean") ? account.owner : false;

this.activeAccount = {
id: id,
username: username,
Expand All @@ -156,12 +158,11 @@
})

// Set initial active page
var initialPage = (new Url).hash.replace(/^([^?]+).*$/, "$1");

var initialPage = (new Url).hash || "home";
if (initialPage === "home" || initialPage === "setting") {
this.activePage = `page-${initialPage}`;
} else {
history.replaceState(null, "page-home", "#home");
history.replaceState(null, "page-home", "/#home");
}
}
})
Expand Down
Loading

0 comments on commit 3f43424

Please sign in to comment.