nfp_sites/heimaerbest/app/index.js

42 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

2023-02-15 05:18:18 +00:00
const m = require('mithril')
const Header = require('./header')
2023-02-16 06:58:31 +00:00
const Footer = require('./footer')
2023-02-15 05:18:18 +00:00
const Frontpage = require('./site_frontpage')
const NotFound = require('./site_404')
window.m = m
m.route.setOrig = m.route.set
m.route.set = function(path, data, options){
m.route.setOrig(path, data, options)
window.scrollTo(0, 0)
}
m.route.linkOrig = m.route.link
m.route.link = function(vnode){
m.route.linkOrig(vnode)
window.scrollTo(0, 0)
}
m.route.prefix = ''
const allRoutes = {
'/': Frontpage, // Frontpage
'/:404...': NotFound,
}
// Wait until we finish checking avif support, some views render immediately and will ask for this immediately before the callback gets called.
/*
* imgsupport.js from leechy/imgsupport
*/
const AVIF = new Image();
AVIF.onload = AVIF.onerror = function () {
window.supportsavif = (AVIF.height === 2)
document.body.className = document.body.className + ' ' + (window.supportsavif ? 'avifsupport' : 'jpegonly')
m.mount(document.getElementById('header'), Header)
m.route(document.getElementById('main'), '/', allRoutes)
2023-02-16 06:58:31 +00:00
m.mount(document.getElementById('footer'), Footer)
2023-02-15 05:18:18 +00:00
}
AVIF.src = 'data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAABAA0ABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgAPkgIaDQgMgkf8AAAQAAAr3A=';