const m = require('mithril') const videos = require('./videos') const Authentication = require('./authentication') const lang = require('./lang') 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', [ m('h4', m(m.route.Link, { href: '/browse' }, lang.header_title /* Filadelfia archival center */)), m('a.change', { onclick: lang.langtoggle }, lang.lang_current), Authentication.currentUser.rank > 10 ? m(m.route.Link, { class: 'upload', href: '/upload' }, lang.upload_goto) // Upload : null, m('button.logout', { onclick: this.logOut }, lang.header_logout), // Log out ]) ] : null }, } module.exports = Menu