changed e to _ as e was not used

Signed-off-by: rodude123 <rodude123@gmail.com>
This commit is contained in:
2023-07-12 03:30:45 +01:00
parent 3b71ba4d23
commit 65bfe759b7
+41
View File
@@ -0,0 +1,41 @@
document.addEventListener('DOMContentLoaded', () =>
{
goToURL(window.location.pathname);
});
window.addEventListener('popstate', _ =>
{
goToURL(window.history.state);
});
/**
* goToURL tries to go to the specified URL if not shows the error page (not yet implemented)
* @param {string} url of the page
*/
function goToURL(url)
{
// Get the current URL and split it into an array
let urlArray = url.split('/');
let newUrl = "";
if (urlArray.includes('blog'))
{
newUrl = url;
}
// Check if the URL is a post page
if (urlArray[0] === 'post')
{
// Create a new URL with the dynamic part
newUrl = "/blog/" + url;
}
// Update the URL in the browser without reloading the page
window.history.pushState(null, null, newUrl);
// Get the dynamic part of the URL
document.querySelector("#url").innerHTML = decodeURI(urlArray[urlArray.length - 1]);
}