From 3648dd880bfa4f324beaf434763511c22e62fa26 Mon Sep 17 00:00:00 2001 From: Christopher Date: Thu, 1 Feb 2024 03:04:27 +0100 Subject: [PATCH] =?UTF-8?q?Mo=C5=BCliwo=C5=9B=C4=87=20dodania=20API=20do?= =?UTF-8?q?=20przegl=C4=85darki?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- script.js | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index bf47e02..3f31bd1 100644 --- a/index.html +++ b/index.html @@ -36,7 +36,7 @@
-

Stworzone przez Krzysztof Smaga
Wykorzystano: OpenWeatherMap API

+

Stworzone przez Krzysztof Smaga
Wykorzystano: OpenWeatherMap API
Dodaj API do ciasteczek

diff --git a/script.js b/script.js index eb709a9..44136b6 100644 --- a/script.js +++ b/script.js @@ -1,4 +1,7 @@ -let api = "{ADD_YOUR_API_KEY}"; +if(getCookie("api") == "") + addApi(); + +let api = getCookie("api") != "" ? getCookie("api") : ""; let city = getCookie("city") != "" ? getCookie("city") : "3093133"; let type = getCookie("type") != "" ? getCookie("type") : "id"; @@ -66,4 +69,15 @@ function getCookie(cname) { } } return ""; +} + +function addApi(){ + let temp_api = prompt("Podaj swoje API, które zapiszesz w ciasteczkach swojej przeglądarki:"); + + if(temp_api != null && temp_api != "") + api = temp_api; + + setCookie("api", api); + + call(); } \ No newline at end of file