2023-11-09 09:44:04 +00:00
|
|
|
const m = require('mithril')
|
|
|
|
const videos = require('./videos')
|
|
|
|
const Authentication = require('./authentication')
|
2023-11-15 04:43:05 +00:00
|
|
|
const lang = require('./lang')
|
2023-11-09 09:44:04 +00:00
|
|
|
|
|
|
|
const Menu = {
|
|
|
|
oninit: function(vnode) {
|
|
|
|
this.currentActive = 'home'
|
|
|
|
this.loading = false
|
|
|
|
this.onbeforeupdate()
|
|
|
|
},
|
|
|
|
|
|
|
|
onbeforeupdate: function() {
|
|
|
|
let currentPath = m.route.get()
|
|
|
|
|
|
|
|
/*if (currentPath === '/') this.currentActive = 'home'
|
|
|
|
else if (currentPath === '/login') this.currentActive = 'login'
|
|
|
|
else if (currentPath && currentPath.startsWith('/page')) this.currentActive = currentPath.slice(currentPath.lastIndexOf('/') + 1)*/
|
|
|
|
},
|
|
|
|
|
|
|
|
logOut: function() {
|
|
|
|
Authentication.clearToken()
|
|
|
|
m.route.set('/')
|
|
|
|
},
|
|
|
|
|
|
|
|
view: function() {
|
|
|
|
return Authentication.currentUser
|
|
|
|
? [
|
|
|
|
m('nav', [
|
2023-11-15 04:43:05 +00:00
|
|
|
m('h4', m(m.route.Link, { href: '/browse' }, lang.header_title /* Filadelfia archival center */)),
|
|
|
|
m('a.change', { onclick: lang.langtoggle }, lang.lang_current),
|
2023-11-09 09:44:04 +00:00
|
|
|
Authentication.currentUser.rank > 10
|
2023-11-15 04:43:05 +00:00
|
|
|
? m(m.route.Link, { class: 'upload', href: '/upload' }, lang.upload_goto) // Upload
|
2023-11-09 09:44:04 +00:00
|
|
|
: null,
|
2023-11-15 04:43:05 +00:00
|
|
|
m('button.logout', { onclick: this.logOut }, lang.header_logout), // Log out
|
2023-11-09 09:44:04 +00:00
|
|
|
])
|
|
|
|
]
|
|
|
|
: null
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Menu
|