@gudhub/ssg-web-components-library 1.0.71 → 1.0.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -10,17 +10,18 @@ class CookiesPopup extends GHComponent {
|
|
|
10
10
|
async onServerRender() {
|
|
11
11
|
super.render(html);
|
|
12
12
|
}
|
|
13
|
-
|
|
14
13
|
async onClientReady() {
|
|
15
14
|
let inEU = localStorage.getItem("inEU");
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
try {
|
|
17
|
+
if (inEU == null) {
|
|
18
|
+
await fetch("https://ipapi.co/json/").then((response) => response.json()).then((data) => inEU = data.in_eu);
|
|
19
|
+
localStorage.setItem("inEU", inEU)
|
|
20
|
+
}
|
|
21
|
+
} catch (error) {
|
|
22
|
+
inEU = true; // This was done because the API had a limited number of requests.
|
|
20
23
|
}
|
|
21
24
|
|
|
22
|
-
inEU = true; // для теста
|
|
23
|
-
|
|
24
25
|
if (inEU) {
|
|
25
26
|
let hasDayPassed = this.checkTime();
|
|
26
27
|
let showPopup = (localStorage.getItem("agreeWithCookies") == null) || (localStorage.getItem("agreeWithCookies") === "false" && hasDayPassed);
|
|
@@ -112,4 +113,4 @@ class CookiesPopup extends GHComponent {
|
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
window.customElements.define("cookies-popup", CookiesPopup);
|
|
116
|
+
window.customElements.define("cookies-popup", CookiesPopup);
|