2024-09-09 06:57:36 -05:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2024-09-10 04:39:53 -05:00
|
|
|
import type { Locale } from '../../../locales/index.js';
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
2024-09-09 06:57:36 -05:00
|
|
|
const address = new URL(document.querySelector<HTMLMetaElement>('meta[property="instance_url"]')?.content || location.href);
|
|
|
|
const siteName = document.querySelector<HTMLMetaElement>('meta[property="og:site_name"]')?.content;
|
|
|
|
|
|
|
|
export const host = address.host;
|
|
|
|
export const hostname = address.hostname;
|
|
|
|
export const url = address.origin;
|
|
|
|
export const apiUrl = location.origin + '/api';
|
2024-09-10 04:39:53 -05:00
|
|
|
export const wsOrigin = location.origin;
|
2024-09-09 06:57:36 -05:00
|
|
|
export const lang = localStorage.getItem('lang') ?? 'en-US';
|
|
|
|
export const langs = _LANGS_;
|
|
|
|
const preParseLocale = localStorage.getItem('locale');
|
2024-09-10 04:39:53 -05:00
|
|
|
export let locale: Locale = preParseLocale ? JSON.parse(preParseLocale) : null;
|
|
|
|
export const version = _VERSION_;
|
|
|
|
export const instanceName = (siteName === 'Misskey' || siteName == null) ? host : siteName;
|
|
|
|
export const ui = localStorage.getItem('ui');
|
2024-09-09 06:57:36 -05:00
|
|
|
export const debug = localStorage.getItem('debug') === 'true';
|
2024-09-10 04:39:53 -05:00
|
|
|
|
|
|
|
export function updateLocale(newLocale: Locale): void {
|
|
|
|
locale = newLocale;
|
|
|
|
}
|