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