2023-11-09 09:44:04 +00:00
|
|
|
const m = require('mithril')
|
|
|
|
const Authentication = require('./authentication')
|
|
|
|
const Header = require('./header')
|
|
|
|
const Login = require('./page_login')
|
|
|
|
const Browse = require('./page_browse')
|
2023-11-14 07:27:04 +00:00
|
|
|
const Upload = require('./page_upload')
|
2023-11-20 07:12:08 +00:00
|
|
|
const Article = require('./page_article')
|
2023-11-09 09:44:04 +00:00
|
|
|
window.m = m
|
|
|
|
|
2023-11-15 04:43:05 +00:00
|
|
|
let css = [
|
|
|
|
'/assets/app.css?v=2',
|
|
|
|
'/assets/tempus-dominus.css',
|
|
|
|
'/assets/fontawesome.css',
|
|
|
|
]
|
|
|
|
|
|
|
|
for (let item of css) {
|
|
|
|
var fileref = document.createElement("link");
|
|
|
|
fileref.setAttribute("rel", "stylesheet");
|
|
|
|
fileref.setAttribute("type", "text/css");
|
|
|
|
fileref.setAttribute("href", item);
|
|
|
|
document.head.appendChild(fileref)
|
|
|
|
}
|
2023-11-09 09:44:04 +00:00
|
|
|
|
|
|
|
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 = {
|
|
|
|
'/': Login,
|
|
|
|
'/browse': Browse,
|
2023-11-14 07:27:04 +00:00
|
|
|
'/upload': Upload,
|
2023-11-20 07:12:08 +00:00
|
|
|
'/:year': Browse,
|
|
|
|
'/:year/:month': Browse,
|
|
|
|
'/:year/:month/:id': Article,
|
2023-11-09 09:44:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
AVIF.src = 'data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAABAA0ABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgAPkgIaDQgMgkf8AAAQAAAr3A=';
|