Access document language via documentElement

This commit is contained in:
0x1eef 2024-05-31 02:06:08 -03:00
parent 5145cb9858
commit bbb3659a91
2 changed files with 9 additions and 9 deletions

View file

@ -5,12 +5,12 @@ import { T } from "~/lib/t";
import { SurahIndex } from "~/components/SurahIndex";
(function () {
const root: HTMLElement = document.querySelector(".root")!;
const doc = document.documentElement;
const root = doc.querySelector(".root")!;
const t = T(require("@json/t.json"));
const byLocale = require("@json/surahs");
const locale = (() => {
const l = document.querySelector("html")!.getAttribute("lang")!;
return Quran.locales.find(ll => ll.name === l);
return Quran.locales.find(ll => ll.name === doc.lang);
})()!;
const surahs: Surah[] = byLocale[locale.name].map((e: TSurah) => new Surah(e));

View file

@ -5,19 +5,19 @@ import { T } from "~/lib/t";
import { SurahStream } from "~/components/SurahStream";
(function () {
const root: HTMLElement = document.querySelector(".root")!;
const doc = document.documentElement;
const root = doc.querySelector(".root")!;
const t = T(require("@json/t.json"));
const locale = (() => {
const l = document.querySelector("html")!.getAttribute("lang")!;
return Quran.locales.find(ll => ll.name === l);
return Quran.locales.find(ll => ll.name === doc.lang);
})()!;
/*
* Configure an instance of Surah
*/
const node1: HTMLScriptElement = document.querySelector(".json.surahinfo")!;
const node2: HTMLScriptElement = document.querySelector(".json.surah")!;
const node3: HTMLScriptElement = document.querySelector(".json.durations")!;
const node1: HTMLScriptElement = doc.querySelector(".json.surahinfo")!;
const node2: HTMLScriptElement = doc.querySelector(".json.surah")!;
const node3: HTMLScriptElement = doc.querySelector(".json.durations")!;
const blob1: TSurah = JSON.parse(node1.innerText)!;
const blob2: Array<[number, string]> = JSON.parse(node2.innerText)!;
const blob3: Array<[number, number]> = JSON.parse(node3.innerText)!;