remove bloat fonts, get rid of svelte-i18n
Signed-off-by: ngn <ngn@ngn.tf>
This commit is contained in:
@@ -1,61 +1,60 @@
|
||||
import { locale_from_browser } from "$lib/locale.js";
|
||||
import { localizer } from "$lib/locale.js";
|
||||
|
||||
const colors = [
|
||||
"yellow",
|
||||
"cyan",
|
||||
"green",
|
||||
"pinkish",
|
||||
"red",
|
||||
// "blue" (looks kinda ass)
|
||||
];
|
||||
// colors defined in static/css/global.css
|
||||
const colors = ["yellow", "cyan", "green", "pinkish", "red", "blue"];
|
||||
|
||||
let colors_pos = -1;
|
||||
|
||||
function color() {
|
||||
if (colors_pos < 0) colors_pos = Math.floor(Math.random() * colors.length);
|
||||
else if (colors_pos >= colors.length) colors_pos = 0;
|
||||
|
||||
return colors[colors_pos];
|
||||
// randomly select a color
|
||||
export function color() {
|
||||
return colors[Math.floor(Math.random() * colors.length)];
|
||||
}
|
||||
|
||||
function click() {
|
||||
// play a click sound
|
||||
export function click() {
|
||||
let audio = new Audio("/assets/click.wav");
|
||||
audio.play();
|
||||
}
|
||||
|
||||
function urljoin(url, path = null) {
|
||||
if (undefined === url || null === url) return;
|
||||
// join a given path to the URL
|
||||
export function urljoin(url, path = null) {
|
||||
if (null === path || path.length === 0) {
|
||||
return url;
|
||||
}
|
||||
|
||||
if (url[url.length - 1] != "/") url += "/";
|
||||
if (url[url.length - 1] != "/") {
|
||||
url += "/";
|
||||
}
|
||||
|
||||
if (path[0] === "/") {
|
||||
path = path.slice(1);
|
||||
}
|
||||
|
||||
if (null === path || "" === path) return url;
|
||||
if (path[0] === "/") return url + path.slice(1);
|
||||
return url + path;
|
||||
}
|
||||
|
||||
function time_from_ts(ts) {
|
||||
if (ts === 0 || ts === undefined) return;
|
||||
|
||||
let ts_date = new Date(ts * 1000);
|
||||
let ts_zone = ts_date.toString().match(/([A-Z]+[\+-][0-9]+)/)[1];
|
||||
|
||||
return (
|
||||
new Intl.DateTimeFormat(locale_from_browser(), {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
}).format(ts_date) + ` (${ts_zone})`
|
||||
);
|
||||
}
|
||||
|
||||
function date_from_ts(ts) {
|
||||
if (ts === 0 || ts === undefined) return;
|
||||
|
||||
return new Intl.DateTimeFormat(locale_from_browser(), {
|
||||
// convert Date() to readable date
|
||||
export function date(date) {
|
||||
return new Intl.DateTimeFormat(localizer.browser(), {
|
||||
month: "2-digit",
|
||||
year: "2-digit",
|
||||
day: "2-digit",
|
||||
}).format(new Date(ts * 1000));
|
||||
}).format(date);
|
||||
}
|
||||
|
||||
export { color, click, urljoin, time_from_ts, date_from_ts };
|
||||
// convert timestamp to readable time
|
||||
export function time_from_ts(ts) {
|
||||
const date = new Date(ts * 1000);
|
||||
const zone = date.toString().match(/([A-Z]+[\+-][0-9]+)/)[1];
|
||||
|
||||
return (
|
||||
new Intl.DateTimeFormat(localizer.browser(), {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
}).format(date) + ` (${zone})`
|
||||
);
|
||||
}
|
||||
|
||||
// convert timestamp to readable date
|
||||
export function date_from_ts(ts) {
|
||||
return date(new Date(ts * 1000));
|
||||
}
|
||||
|
Reference in New Issue
Block a user