2024-01-19 02:59:53 +00:00
|
|
|
function displayHeader() {
|
|
|
|
const links = [
|
|
|
|
{
|
|
|
|
href: "/",
|
|
|
|
name: "Home",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
href: "/register/",
|
|
|
|
name: "Register",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
href: "/login/",
|
|
|
|
name: "Login",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
href: "/upload/",
|
|
|
|
name: "Upload",
|
|
|
|
},
|
|
|
|
].map(({name, href}) => {
|
|
|
|
if (href === window.location.pathname) {
|
|
|
|
return `<a href="${href}"><b>${name}</b></a>`
|
|
|
|
} else {
|
|
|
|
return `<a href="${href}">${name}</a>`
|
|
|
|
}
|
|
|
|
}).join(" - ");
|
|
|
|
|
|
|
|
document.querySelector("h1").outerHTML = `
|
|
|
|
<header>
|
2024-01-19 20:56:47 +00:00
|
|
|
<a href="/">
|
|
|
|
<h1 id="app-name">MaoTube</h1>
|
|
|
|
</a>
|
|
|
|
<nav>
|
|
|
|
${links}
|
|
|
|
</nav>
|
|
|
|
<form method="GET" target="_self" action="/search">
|
|
|
|
<input type="text" id="search" name="query" placeholder="Search">
|
|
|
|
<input type="submit" value="Search">
|
|
|
|
</form>
|
2024-01-19 02:59:53 +00:00
|
|
|
</header>
|
|
|
|
`
|
|
|
|
}
|
|
|
|
|
|
|
|
displayHeader();
|