2023-02-15 05:18:18 +00:00
|
|
|
const m = require('mithril')
|
|
|
|
const Authentication = require('./authentication')
|
|
|
|
|
|
|
|
const Header = {
|
|
|
|
oninit: function(vnode) {
|
|
|
|
this.currentActive = 'home'
|
|
|
|
this.error = ''
|
|
|
|
this.loading = false
|
|
|
|
this.onbeforeupdate()
|
|
|
|
},
|
|
|
|
|
|
|
|
onbeforeupdate: function() {
|
|
|
|
let currentPath = m.route.get()
|
|
|
|
console.log(currentPath)
|
|
|
|
|
|
|
|
if (currentPath === '/') this.currentActive = 'home'
|
|
|
|
else if (currentPath === '/login') this.currentActive = 'login'
|
|
|
|
},
|
|
|
|
|
|
|
|
logOut: function() {
|
|
|
|
Authentication.clearToken()
|
|
|
|
m.route.set('/')
|
|
|
|
},
|
|
|
|
|
|
|
|
view: function() {
|
|
|
|
return [
|
|
|
|
m(m.route.Link,
|
|
|
|
{ href: '/', class: 'title' },
|
|
|
|
[
|
|
|
|
m('img.logo', { src: '/assets/img/logo.svg' }),
|
|
|
|
]
|
|
|
|
),
|
|
|
|
m('div.filler'),
|
|
|
|
m('div.links', [
|
|
|
|
m(m.route.Link, { href: '/#Heim' }, 'Heim'),
|
|
|
|
m(m.route.Link, { href: '/#GoodAdvice' }, 'Góð ráð'),
|
2023-02-16 09:41:07 +00:00
|
|
|
//m(m.route.Link, { class: 'button-active', href: '/#Subscribe' }, 'Subscribe'),
|
2023-02-15 05:18:18 +00:00
|
|
|
]),
|
|
|
|
]
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Header
|