diff --git a/src/lib/mapData.js b/src/lib/mapData.js index bf41d91..1dfe65f 100644 --- a/src/lib/mapData.js +++ b/src/lib/mapData.js @@ -3,6 +3,7 @@ let overlayItaly = "https://maptiler.infoplaza.io/api/maps/Border/static/11.69,4 let overlayEurope = "https://maptiler.infoplaza.io/api/maps/Border/static/8.24,49.41,4.2/1560x1560.png?attribution=false"; let mese = new Date().getUTCMonth() + 1; let giorno = new Date().getUTCDate(); +let ieri = giorno - 1 let anno = new Date().getFullYear(); var offset = new Date().getTimezoneOffset() / 60; var minuti = new Date().getMinutes() @@ -56,6 +57,18 @@ function getUrl(mapStyle, region, i, ora) { } else if (region == "europe") { zone = "/5/8/14/14/20"; } + console.log(time.substring(0, 2), giorno, ieri) + if (parseInt(time.substring(0, 2)) >= 20 && parseInt(time.substring(0, 2)) < 24) { + if (giorno - 1 == ieri) { + giorno = giorno - 1 + } + } else if (parseInt(time.substring(0, 2)) >= 24) { + if (giorno = ieri ){ + giorno = giorno + 1 + } + time = `0${(time.substring(0, 2)-24)*-1}${time.substring(2)}` + console.log(time) + } let url = base + diff --git a/src/lib/maps/radar.svelte b/src/lib/maps/radar.svelte index e71517b..0a4b295 100644 --- a/src/lib/maps/radar.svelte +++ b/src/lib/maps/radar.svelte @@ -14,6 +14,7 @@ let playpause = true; let value = "0"; let sourceIndex = 0; + let y = sourceIndex; let source: string = ""; let sourceTime: string = ""; let sources: Array<{ url: string; time: string }> = []; @@ -22,6 +23,9 @@ getUrls("radarsatellite-europe", "italy"); function getUrls(type: string, region: string): void { for (let i = 0; i <= stepNum - 3; i++) { + if (ora < 0) { + ora = 24 + ora; + } if (minutes[sourceIndex] === "00") { ora++; } @@ -31,7 +35,6 @@ if (sourceIndex >= minutes.length) { sourceIndex -= minutes.length; } - const url = getUrl(type, region, sourceIndex, ora); sources.push({ url: url["url"], time: `${ora}${minutes[sourceIndex]}` }); sourceIndex++; @@ -51,8 +54,11 @@ stopLoop(); const { url, time } = sources[sourceIndex]; source = url; - const hours = time.substring(0, 2); + let hours = time.substring(0, 2); const minutes = time.substring(2, 4); + if (parseInt(hours) + offset >= 24) { + hours = String(parseInt(hours) - 24); + } sourceTime = `${parseInt(hours, 10) + offset}:${minutes}`; } } @@ -76,8 +82,6 @@ } } - let y = 0; - const loopFunction = (): void => { if (showmap) { if (y >= sources.length) { diff --git a/src/lib/maps/satellite.svelte b/src/lib/maps/satellite.svelte index e7687fe..6718cf7 100644 --- a/src/lib/maps/satellite.svelte +++ b/src/lib/maps/satellite.svelte @@ -24,6 +24,9 @@ function getUrls(type: string, region: string): void { for (let i = 0; i <= stepNum; i++) { + if (ora < 0) { + ora = 24 + ora; + } if (minutes[sourceIndex] === "00") { ora++; } diff --git a/src/lib/maps/satelliteEurope.svelte b/src/lib/maps/satelliteEurope.svelte index 922e6d9..c1b088e 100644 --- a/src/lib/maps/satelliteEurope.svelte +++ b/src/lib/maps/satelliteEurope.svelte @@ -14,6 +14,7 @@ let playpause = true; let value = "0"; let sourceIndex = 0; + let y = sourceIndex; let source: string = ""; let sourceTime: string = ""; let sources: Array<{ url: string; time: string }> = []; @@ -23,6 +24,9 @@ function getUrls(type: string, region: string): void { for (let i = 0; i <= stepNum; i++) { + if (ora < 0) { + ora = 24 + ora; + } if (minutes[sourceIndex] === "00") { ora++; } @@ -32,7 +36,6 @@ if (sourceIndex >= minutes.length) { sourceIndex -= minutes.length; } - const url = getUrl(type, region, sourceIndex, ora); sources.push({ url: url["url"], time: `${ora}${minutes[sourceIndex]}` }); sourceIndex++; @@ -52,8 +55,11 @@ stopLoop(); const { url, time } = sources[sourceIndex]; source = url; - const hours = time.substring(0, 2); + let hours = time.substring(0, 2); const minutes = time.substring(2, 4); + if (parseInt(hours) + offset >= 24) { + hours = String(parseInt(hours) - 24); + } sourceTime = `${parseInt(hours, 10) + offset}:${minutes}`; } } @@ -77,8 +83,6 @@ } } - let y = 0; - const loopFunction = (): void => { if (showmap) { if (y >= sources.length) {