2021-01-27 17:39:12 +01:00
|
|
|
|
if(user_preferences.theme === 'auto')
|
|
|
|
|
link(rel="stylesheet", type="text/css", href="/css/dark.css", media="(prefers-color-scheme: dark)")
|
2021-01-09 11:48:49 +01:00
|
|
|
|
if(user_preferences.theme === 'dark')
|
|
|
|
|
link(rel="stylesheet", type="text/css", href="/css/dark.css")
|
2021-01-19 21:49:03 +01:00
|
|
|
|
if(user_preferences.theme === 'sepia')
|
|
|
|
|
link(rel="stylesheet", type="text/css", href="/css/sepia.css")
|
2022-07-07 22:42:01 +02:00
|
|
|
|
if(user_preferences.theme === 'nord')
|
|
|
|
|
link(rel="stylesheet", type="text/css", href="/css/nord.css")
|
2020-11-17 21:44:32 +01:00
|
|
|
|
link(rel="stylesheet", type="text/css", href="/css/styles.css")
|
|
|
|
|
link(rel="icon", type="image/png", sizes="32x32", href="/favicon.png")
|
2022-06-10 11:12:56 +02:00
|
|
|
|
meta(property='og:site_name', content='teddit')
|
2020-11-17 21:44:32 +01:00
|
|
|
|
meta(name="viewport", content="width=device-width, initial-scale=1.0")
|
|
|
|
|
-
|
2021-03-21 21:14:11 +01:00
|
|
|
|
if(!user_preferences)
|
|
|
|
|
user_preferences = {}
|
|
|
|
|
|
2020-11-17 21:44:32 +01:00
|
|
|
|
function kFormatter(num) {
|
|
|
|
|
return Math.abs(num) > 999 ? Math.sign(num)*((Math.abs(num)/1000).toFixed(1)) + 'k' : Math.sign(num)*Math.abs(num)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toDateString(time) {
|
|
|
|
|
let d = new Date();
|
|
|
|
|
d.setTime(time*1000);
|
|
|
|
|
return d.toDateString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toUTCString(time) {
|
|
|
|
|
let d = new Date();
|
|
|
|
|
d.setTime(time*1000);
|
|
|
|
|
return d.toUTCString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function secondsToMMSS(time) {
|
|
|
|
|
return new Date(time * 1000).toISOString().substr(14,5)
|
|
|
|
|
}
|
2020-12-02 17:02:32 +01:00
|
|
|
|
|
2020-12-02 21:02:54 +01:00
|
|
|
|
function getFileExtension(url) {
|
|
|
|
|
try {
|
|
|
|
|
url = new URL(url)
|
|
|
|
|
let pathname = url.pathname
|
|
|
|
|
let file_ext = pathname.substring(pathname.lastIndexOf('.') + 1)
|
|
|
|
|
if(file_ext) {
|
|
|
|
|
return file_ext
|
|
|
|
|
} else {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(`Invalid url supplied to getFileExtension(). URL: ${url}`, error)
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-02 17:08:55 +01:00
|
|
|
|
function cleanTitle(s) {
|
|
|
|
|
if(s) {
|
|
|
|
|
var re = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;
|
|
|
|
|
var unescaped = {
|
|
|
|
|
'&': '&',
|
|
|
|
|
'&': '&',
|
|
|
|
|
'<': '<',
|
|
|
|
|
'<': '<',
|
|
|
|
|
'>': '>',
|
|
|
|
|
'>': '>',
|
|
|
|
|
''': "'",
|
|
|
|
|
''': "'",
|
|
|
|
|
'"': '"',
|
|
|
|
|
'"': '"'
|
|
|
|
|
}
|
|
|
|
|
return s.replace(re, (m) => {
|
|
|
|
|
return unescaped[m]
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
2020-12-02 17:02:32 +01:00
|
|
|
|
}
|