diff --git a/docs/js/index.js b/docs/js/index.js
index 64be29f..a1ce8bc 100644
--- a/docs/js/index.js
+++ b/docs/js/index.js
@@ -17,11 +17,11 @@ const test = () => {
// console.log(c)
// b = "nova hodnota"
-// const o = {
-// data: () => {
-// console.log("data");
-// },
-// };
-// o["data"]?.();
-// o["data2"]?.();
+const o = {
+ data: () => {
+ console.log("data");
+ },
+};
+o["data"]?.();
+o["data2"]?.();
test();
diff --git a/docs/js/index2.js b/docs/js/index2.js
index 1cf29dc..2ce1074 100644
--- a/docs/js/index2.js
+++ b/docs/js/index2.js
@@ -1,4 +1,5 @@
console.clear();
+
const obj = {
a: 1,
self: () => obj,
@@ -19,6 +20,8 @@ const obj = {
console.log("test2:");
console.log(obj.test2());
+
+
console.log("test:");
console.log(obj.test());
@@ -30,5 +33,7 @@ console.log(obj.test2.apply({}));
console.log("self");
console.log(obj.self());
+
+console.log("----- TIMEOUT ------")
setTimeout(obj.testConsole, 3000);
setTimeout(obj.testConsole2, 3000);
diff --git a/docs/js3/hell_await.js b/docs/js3/hell_await.js
index 23aaa98..d90cce9 100644
--- a/docs/js3/hell_await.js
+++ b/docs/js3/hell_await.js
@@ -28,7 +28,7 @@ const demo = () => {
const run = async () => {
try {
- console.log("HODNOTA "+ hodnota);
+ // console.log("HODNOTA "+ hodnota);
await deleteCopyFile();
const items = await getItems();
await writeItems(items);
diff --git a/docs/js3/hell_promise.js b/docs/js3/hell_promise.js
index 6d80941..ae801a9 100644
--- a/docs/js3/hell_promise.js
+++ b/docs/js3/hell_promise.js
@@ -26,7 +26,7 @@ deleteCopyFile()
.then(getItems)
.then(writeItems)
.then(() => {
- console.log("DONE");
+ console.log("All done");
})
.catch((err) => {
console.error("oops");
diff --git a/docs/js3/index.html b/docs/js3/index.html
index f25fc1d..46c6f73 100644
--- a/docs/js3/index.html
+++ b/docs/js3/index.html
@@ -3,35 +3,46 @@
-
Demo
-
-
-
-
-
+
+
+
+
+
+
diff --git a/docs/js3/pocasi.html b/docs/js3/pocasi.html
index 0e258d3..bfa67ff 100644
--- a/docs/js3/pocasi.html
+++ b/docs/js3/pocasi.html
@@ -6,9 +6,8 @@
-
-
+
diff --git a/docs/js3/pocasi.js b/docs/js3/pocasi.js
index 61ecaa7..a28c500 100644
--- a/docs/js3/pocasi.js
+++ b/docs/js3/pocasi.js
@@ -8,11 +8,7 @@ const getCityCoords = async (cityName) => {
try {
const response = await fetch(`https://geocoding-api.open-meteo.com/v1/search?name=${cityName}&language=en&format=json`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ key: "value" }),
+ method: "GET",
});
@@ -25,6 +21,7 @@ const getCityCoords = async (cityName) => {
return { latitude, longitude };
} catch (e) {
window.alert(e.message);
+ return undefined;
}
};
const getForecast = async ({ latitude, longitude }) => {
@@ -38,7 +35,7 @@ const getForecast = async ({ latitude, longitude }) => {
const max = jsonResponse.daily.temperature_2m_max[0];
const min = jsonResponse.daily.temperature_2m_min[0];
const average = (max + min) / 2;
- print({ average: average + jsonResponse.daily_units.temperature_2m_max });
+ return average + jsonResponse.daily_units.temperature_2m_max;
} catch (e) {
window.alert(e.message);
}
@@ -46,10 +43,9 @@ const getForecast = async ({ latitude, longitude }) => {
window.document.getElementById("pocasi").addEventListener("click", async () => {
- const mesto = "Praha";
+ const cities = document.querySelector("textarea").value.split(/[:;]/);
- const cityCoords = await getCityCoords(mesto);
- print(cityCoords);
-
- const forecast = await getForecast(cityCoords);
+ const cityCoords = await getCityCoords(cities[0]);
+ print(`\n Coordinates: ${JSON.stringify(cityCoords, null, 4)}\n`);
+ print(` ${await getForecast(cityCoords)}`);
});