From 3f375f41a0d8176396da0a5988a9db06383e1636 Mon Sep 17 00:00:00 2001 From: Maksymilian Jopek Date: Thu, 24 Mar 2022 14:31:15 +0100 Subject: Option to use or two xpaths ( speed ) --- src/main.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/main.ts') diff --git a/src/main.ts b/src/main.ts index 7ecd320..2406f04 100644 --- a/src/main.ts +++ b/src/main.ts @@ -5,11 +5,11 @@ const URL = "http://localhost:8000/index.php"; (async () => { const voivs = await (await fetch(URL)).json() as string[] const tbody = document.getElementById('tds-here') as HTMLTableSectionElement; - for (let i = 0; i < voivs.length; i += 2) { + for (const v of voivs) { const tr = document.createElement("tr") const td = document.createElement("td") - td.innerText = voivs[i + 1] - td.onclick = () => showCities(voivs[i + 1], voivs[i]); + td.innerText = v + td.onclick = () => showCities(v, v); tr.appendChild(td) tbody.appendChild(tr) } @@ -20,7 +20,6 @@ async function showCities(n: string, id: string) { method: "POST", body: id, })).json() as string[] - // console.log(res) const nh = document.getElementById("name-here") as HTMLTableRowElement const vt = document.getElementById("vtds-here") as HTMLTableSectionElement vt.innerHTML = '' -- cgit v1.3.1