Skip to content

Commit

Permalink
Merge pull request #9 from SalaniLeo/Mobile
Browse files Browse the repository at this point in the history
🔧 Fixed maps clock
  • Loading branch information
SalaniLeo authored Jun 17, 2024
2 parents 5450833 + 9fdf567 commit 4ce313b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
13 changes: 13 additions & 0 deletions src/lib/mapData.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 +
Expand Down
12 changes: 8 additions & 4 deletions src/lib/maps/radar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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 }> = [];
Expand All @@ -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++;
}
Expand All @@ -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++;
Expand All @@ -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}`;
}
}
Expand All @@ -76,8 +82,6 @@
}
}
let y = 0;
const loopFunction = (): void => {
if (showmap) {
if (y >= sources.length) {
Expand Down
3 changes: 3 additions & 0 deletions src/lib/maps/satellite.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down
12 changes: 8 additions & 4 deletions src/lib/maps/satelliteEurope.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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 }> = [];
Expand All @@ -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++;
}
Expand All @@ -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++;
Expand All @@ -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}`;
}
}
Expand All @@ -77,8 +83,6 @@
}
}
let y = 0;
const loopFunction = (): void => {
if (showmap) {
if (y >= sources.length) {
Expand Down

0 comments on commit 4ce313b

Please sign in to comment.