Access document language via documentElement
This commit is contained in:
parent
5145cb9858
commit
bbb3659a91
2 changed files with 9 additions and 9 deletions
|
@ -5,12 +5,12 @@ import { T } from "~/lib/t";
|
||||||
import { SurahIndex } from "~/components/SurahIndex";
|
import { SurahIndex } from "~/components/SurahIndex";
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
const root: HTMLElement = document.querySelector(".root")!;
|
const doc = document.documentElement;
|
||||||
|
const root = doc.querySelector(".root")!;
|
||||||
const t = T(require("@json/t.json"));
|
const t = T(require("@json/t.json"));
|
||||||
const byLocale = require("@json/surahs");
|
const byLocale = require("@json/surahs");
|
||||||
const locale = (() => {
|
const locale = (() => {
|
||||||
const l = document.querySelector("html")!.getAttribute("lang")!;
|
return Quran.locales.find(ll => ll.name === doc.lang);
|
||||||
return Quran.locales.find(ll => ll.name === l);
|
|
||||||
})()!;
|
})()!;
|
||||||
const surahs: Surah[] = byLocale[locale.name].map((e: TSurah) => new Surah(e));
|
const surahs: Surah[] = byLocale[locale.name].map((e: TSurah) => new Surah(e));
|
||||||
|
|
||||||
|
|
|
@ -5,19 +5,19 @@ import { T } from "~/lib/t";
|
||||||
import { SurahStream } from "~/components/SurahStream";
|
import { SurahStream } from "~/components/SurahStream";
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
const root: HTMLElement = document.querySelector(".root")!;
|
const doc = document.documentElement;
|
||||||
|
const root = doc.querySelector(".root")!;
|
||||||
const t = T(require("@json/t.json"));
|
const t = T(require("@json/t.json"));
|
||||||
const locale = (() => {
|
const locale = (() => {
|
||||||
const l = document.querySelector("html")!.getAttribute("lang")!;
|
return Quran.locales.find(ll => ll.name === doc.lang);
|
||||||
return Quran.locales.find(ll => ll.name === l);
|
|
||||||
})()!;
|
})()!;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Configure an instance of Surah
|
* Configure an instance of Surah
|
||||||
*/
|
*/
|
||||||
const node1: HTMLScriptElement = document.querySelector(".json.surahinfo")!;
|
const node1: HTMLScriptElement = doc.querySelector(".json.surahinfo")!;
|
||||||
const node2: HTMLScriptElement = document.querySelector(".json.surah")!;
|
const node2: HTMLScriptElement = doc.querySelector(".json.surah")!;
|
||||||
const node3: HTMLScriptElement = document.querySelector(".json.durations")!;
|
const node3: HTMLScriptElement = doc.querySelector(".json.durations")!;
|
||||||
const blob1: TSurah = JSON.parse(node1.innerText)!;
|
const blob1: TSurah = JSON.parse(node1.innerText)!;
|
||||||
const blob2: Array<[number, string]> = JSON.parse(node2.innerText)!;
|
const blob2: Array<[number, string]> = JSON.parse(node2.innerText)!;
|
||||||
const blob3: Array<[number, number]> = JSON.parse(node3.innerText)!;
|
const blob3: Array<[number, number]> = JSON.parse(node3.innerText)!;
|
||||||
|
|
Loading…
Reference in a new issue