mirror of
https://git.waldn.net/git/knotteye/satyr.git
synced 2025-06-16 04:25:15 +00:00
Handle back button when the user navigates to one of our own history events
This commit is contained in:
parent
cc3876ff4a
commit
30a62e6378
@ -1,6 +1,7 @@
|
|||||||
async function render(path){
|
async function render(path, s){
|
||||||
var context = await getContext();
|
var context = await getContext();
|
||||||
history.pushState({}, context.sitename, location.protocol+'//'+location.host+path);
|
if(!s)
|
||||||
|
history.pushState({}, context.sitename, location.protocol+'//'+location.host+path);
|
||||||
switch(path){
|
switch(path){
|
||||||
//nothing but context
|
//nothing but context
|
||||||
case (path.match(/^\/about\/?$/) || {}).input:
|
case (path.match(/^\/about\/?$/) || {}).input:
|
||||||
@ -115,6 +116,10 @@ async function render(path){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.addEventListener('popstate', (event) => {
|
||||||
|
render(document.location.pathname, true);
|
||||||
|
});
|
||||||
|
|
||||||
async function getContext(){
|
async function getContext(){
|
||||||
var info = JSON.parse(await makeRequest('GET', '/api/instance/info'));
|
var info = JSON.parse(await makeRequest('GET', '/api/instance/info'));
|
||||||
info.sitename = info.name;
|
info.sitename = info.name;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user