mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
Fix formatting issues, remove unused JS script
This commit is contained in:
@@ -5,9 +5,9 @@ import { isLocaleLoaded, setLocale } from './global_locale';
|
|||||||
|
|
||||||
const localeLoadingSemaphore = new Semaphore(1);
|
const localeLoadingSemaphore = new Semaphore(1);
|
||||||
|
|
||||||
const upstreamLocaleFiles = import.meta.glob<{ default: LocaleData['messages'] }>([
|
const upstreamLocaleFiles = import.meta.glob<{
|
||||||
'@/mastodon/locales/*.json',
|
default: LocaleData['messages'];
|
||||||
]);
|
}>(['@/mastodon/locales/*.json']);
|
||||||
const localeFiles = import.meta.glob<{ default: LocaleData['messages'] }>([
|
const localeFiles = import.meta.glob<{ default: LocaleData['messages'] }>([
|
||||||
'./*.json',
|
'./*.json',
|
||||||
]);
|
]);
|
||||||
@@ -25,11 +25,15 @@ export async function loadLocale() {
|
|||||||
if (isLocaleLoaded()) return;
|
if (isLocaleLoaded()) return;
|
||||||
|
|
||||||
// If there is no locale file, then fallback to english
|
// If there is no locale file, then fallback to english
|
||||||
const upstreamLocaleFile = Object.hasOwn(upstreamLocaleFiles, `/mastodon/locales/${locale}.json`)
|
const upstreamLocaleFile = Object.hasOwn(
|
||||||
|
upstreamLocaleFiles,
|
||||||
|
`/mastodon/locales/${locale}.json`,
|
||||||
|
)
|
||||||
? upstreamLocaleFiles[`/mastodon/locales/${locale}.json`]
|
? upstreamLocaleFiles[`/mastodon/locales/${locale}.json`]
|
||||||
: upstreamLocaleFiles['/mastodon/locales/en.json'];
|
: upstreamLocaleFiles['/mastodon/locales/en.json'];
|
||||||
|
|
||||||
if (!upstreamLocaleFile) throw new Error('Could not load the upstream locale JSON file');
|
if (!upstreamLocaleFile)
|
||||||
|
throw new Error('Could not load the upstream locale JSON file');
|
||||||
|
|
||||||
const { default: upstreamLocaleData } = await upstreamLocaleFile();
|
const { default: upstreamLocaleData } = await upstreamLocaleFile();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const upstreamTranslations = require(path.join(__dirname, "../app/javascript/mastodon/locales/en.json"));
|
const upstreamTranslations = require(
|
||||||
const currentTranslations = require(path.join(__dirname, "../app/javascript/flavours/glitch/locales/en.json"));
|
path.join(__dirname, '../app/javascript/mastodon/locales/en.json'),
|
||||||
|
);
|
||||||
|
const currentTranslations = require(
|
||||||
|
path.join(__dirname, '../app/javascript/flavours/glitch/locales/en.json'),
|
||||||
|
);
|
||||||
|
|
||||||
exports.format = (msgs) => {
|
exports.format = (msgs) => {
|
||||||
const results = {};
|
const results = {};
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
document.addEventListener("DOMContentLoaded", function(event) {
|
|
||||||
updateClock();
|
|
||||||
setInterval(updateClock, 1000);
|
|
||||||
});
|
|
||||||
|
|
||||||
function getNextOpen(now) {
|
|
||||||
var days = [[0, 14], [4, 18], [8, 22], [12], [2, 16], [6, 20], [10]]
|
|
||||||
var nowday = now.getUTCDay();
|
|
||||||
var nour = now.getUTCHours();
|
|
||||||
|
|
||||||
var open_hour = -1;
|
|
||||||
var d = 0;
|
|
||||||
|
|
||||||
while (open_hour == -1) {
|
|
||||||
var times = days[(nowday + d) % 7];
|
|
||||||
for (var i = 0; i < times.length; ++i) {
|
|
||||||
var time = times[i];
|
|
||||||
if (time == nour) {
|
|
||||||
return "refresh";
|
|
||||||
} else if (time > nour || d > 0) {
|
|
||||||
open_hour = time;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (open_hour == -1) {
|
|
||||||
d += 1;
|
|
||||||
nour = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var open = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() + d));
|
|
||||||
var ts = open.setUTCHours(open_hour);
|
|
||||||
return open;
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateClock() {
|
|
||||||
var clock = document.querySelector(".closed-registrations-message .clock");
|
|
||||||
var now = new Date();
|
|
||||||
var open = getNextOpen(now);
|
|
||||||
|
|
||||||
if (open == "refresh") {
|
|
||||||
location.reload();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var until = open - now;
|
|
||||||
var ms = until % 1000;
|
|
||||||
var s = Math.floor((until / 1000)) % 60;
|
|
||||||
var m = Math.floor((until / 1000 / 60)) % 60;
|
|
||||||
var h = Math.floor((until / 1000 / 60 / 60));
|
|
||||||
if (m < 10) m = "0" + m;
|
|
||||||
if (s < 10) s = "0" + s;
|
|
||||||
clock.innerHTML = h + ":" + m + ":" + s;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user