blob: 2406f043cb7bad5cf9cf02156c2897ccf8108a37 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import './style.css'
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 (const v of voivs) {
const tr = document.createElement("tr")
const td = document.createElement("td")
td.innerText = v
td.onclick = () => showCities(v, v);
tr.appendChild(td)
tbody.appendChild(tr)
}
})()
async function showCities(n: string, id: string) {
const res = await (await fetch(URL, {
method: "POST",
body: id,
})).json() as string[]
const nh = document.getElementById("name-here") as HTMLTableRowElement
const vt = document.getElementById("vtds-here") as HTMLTableSectionElement
vt.innerHTML = ''
nh.innerHTML = `<th>Miasta w ${n} (${res.length}, <a href="https://duckduckgo.com/?q=wikipedia+Kategoria%3AMiasta+w+wojew%C3%B3dztwie+${n}" target="_blank">internet</a>)</th>`
for (const c of res) {
const tr = document.createElement("tr")
const td = document.createElement("td")
td.innerText = c
tr.appendChild(td)
vt.appendChild(tr)
}
}
|