Skip to content

Commit 067a9d5

Browse files
committed
refactor: change ticks to the more modern way
1 parent 69f97d9 commit 067a9d5

8 files changed

Lines changed: 114 additions & 114 deletions

File tree

src/ts/eew.ts

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
11

2-
import { Wave } from './utils/wave/wave'
3-
import { getTtjbTravelTimeTable } from './utils/wave/taup'
4-
//import { notify } from './utils/notification'
5-
import { flyZoom, placeMarker, deleteMarker, map } from './utils/map'
6-
import { speak, playSound } from './utils/speaker'
7-
import { calculateElapsedTimeOfTheWave, parseTime } from './utils/time'
8-
import { changeEvent, removeEvent, addEvent, switchEvents } from './utils/event'
9-
import { homeLon, homeLat } from './utils/map'
10-
import i18n from 'i18next'
11-
12-
import eqSound from '../assets/sounds/eq.mp3'
13-
import updateSound from '../assets/sounds/update.mp3'
14-
import eew2Sound from '../assets/sounds/eew2.mp3'
15-
import eew5Sound from '../assets/sounds/eew5.wav'
2+
import { Wave } from "./utils/wave/wave"
3+
import { getTtjbTravelTimeTable } from "./utils/wave/taup"
4+
//import { notify } from "./utils/notification"
5+
import { flyZoom, placeMarker, deleteMarker, map } from "./utils/map"
6+
import { speak, playSound } from "./utils/speaker"
7+
import { calculateElapsedTimeOfTheWave, parseTime } from "./utils/time"
8+
import { changeEvent, removeEvent, addEvent, switchEvents } from "./utils/event"
9+
import { homeLon, homeLat } from "./utils/map"
10+
import i18n from "i18next"
11+
12+
import eqSound from "../assets/sounds/eq.mp3"
13+
import updateSound from "../assets/sounds/update.mp3"
14+
import eew2Sound from "../assets/sounds/eew2.mp3"
15+
import eew5Sound from "../assets/sounds/eew5.wav"
1616

1717

1818
export const shindoToIntensity = new Map([
19-
['1', 1],
20-
['2', 1],
21-
['3', 3],
22-
['4', 4],
23-
['5-', 5],
24-
['5+', 6],
25-
['6-', 7],
26-
['6+', 8],
27-
['7', 9]
19+
["1", 1],
20+
["2", 1],
21+
["3", 3],
22+
["4", 4],
23+
["5-", 5],
24+
["5+", 6],
25+
["6-", 7],
26+
["6+", 8],
27+
["7", 9]
2828
]);
2929

3030
export const numericIntensityToMMI = new Map([
31-
[1, 'Ⅰ'],
32-
[2, 'Ⅱ'],
33-
[3, 'Ⅲ'],
34-
[4, 'Ⅳ'],
35-
[5, 'Ⅴ'],
36-
[6, 'Ⅵ'],
37-
[7, 'Ⅶ'],
38-
[8, 'Ⅷ'],
39-
[9, 'Ⅸ'],
40-
[10, 'Ⅹ'],
41-
[11, 'Ⅺ'],
42-
[12, 'Ⅻ']
31+
[1, "Ⅰ"],
32+
[2, "Ⅱ"],
33+
[3, "Ⅲ"],
34+
[4, "Ⅳ"],
35+
[5, "Ⅴ"],
36+
[6, "Ⅵ"],
37+
[7, "Ⅶ"],
38+
[8, "Ⅷ"],
39+
[9, "Ⅸ"],
40+
[10, "Ⅹ"],
41+
[11, "Ⅺ"],
42+
[12, "Ⅻ"]
4343
]);
4444

4545
interface WarnArea {
@@ -94,8 +94,8 @@ const addEEW = (data: EewData): void => {
9494
const sWaveTime = ttjbTravelTimeTable[(Math.round(depth / 10) * 10).toString()].S;
9595
const pWaveTime = ttjbTravelTimeTable[(Math.round(depth / 10) * 10).toString()].P;
9696

97-
const sWave = new Wave(map, Number(sWaveTime), lat, lon, calculateElapsedTimeOfTheWave(originTime, announcedTime, type, author), `${id}-S`, 'S');
98-
const pWave = new Wave(map, Number(pWaveTime), lat, lon, calculateElapsedTimeOfTheWave(originTime, announcedTime, type, author), `${id}-P`, 'P');
97+
const sWave = new Wave(map, Number(sWaveTime), lat, lon, calculateElapsedTimeOfTheWave(originTime, announcedTime, type, author), `${id}-S`, "S");
98+
const pWave = new Wave(map, Number(pWaveTime), lat, lon, calculateElapsedTimeOfTheWave(originTime, announcedTime, type, author), `${id}-P`, "P");
9999

100100
sWave?.addWaveFeature();
101101
pWave?.addWaveFeature();
@@ -106,16 +106,16 @@ const addEEW = (data: EewData): void => {
106106

107107

108108

109-
speak(1.1, i18n.language, i18n.t('eewLocated', { location: location }));
109+
speak(1.1, i18n.language, i18n.t("eewLocated", { location: location }));
110110

111111
setTimeout(() => {
112-
speak(1.2, i18n.language, i18n.t('eewReport', { number: reportNumber, mag: mag, depth: depth, intensity: intensity }));
113-
//speak(1.2, i18n.language, i18n.t('eewIntensity', { intensity: intensity }));
112+
speak(1.2, i18n.language, i18n.t("eewReport", { number: reportNumber, mag: mag, depth: depth, intensity: intensity }));
113+
//speak(1.2, i18n.language, i18n.t("eewIntensity", { intensity: intensity }));
114114
}, 2000);
115115

116116

117-
console.log('added');
118-
placeMarker(lon, lat, '60px', '60px', id, 'images/epicenter.png');
117+
console.log("added");
118+
placeMarker(lon, lat, "60px", "60px", id, "images/epicenter.png");
119119
addEvent(title, reportNumber, intensity, location, originTime, mag, depth);
120120

121121
if (earthquakes.size > 1) {
@@ -149,13 +149,13 @@ const updateEEW = (data: EewData): void => {
149149
});
150150

151151
deleteMarker(id);
152-
placeMarker(lon, lat, '60px', '60px', id, 'images/epicenter.png');
153-
speak(1.2, i18n.language, i18n.t('eewReport', { number: reportNumber, mag: mag, depth: depth, intensity: intensity }));
154-
//speak(1.2, i18n.language, i18n.t('eewIntensity', { intensity: intensity }));
152+
placeMarker(lon, lat, "60px", "60px", id, "images/epicenter.png");
153+
speak(1.2, i18n.language, i18n.t("eewReport", { number: reportNumber, mag: mag, depth: depth, intensity: intensity }));
154+
//speak(1.2, i18n.language, i18n.t("eewIntensity", { intensity: intensity }));
155155
changeEvent(title, reportNumber, intensity, location, originTime, mag, depth);
156156
playSound(updateSound);
157157

158-
console.log('changed');
158+
console.log("changed");
159159
};
160160

161161

@@ -168,7 +168,7 @@ export const deleteEEW = (id: string, waveID: string): void => {
168168
currentData?.pWave.deleteWaveFeature();
169169
flyZoom(homeLon, homeLat, 5, 1);
170170
earthquakes.delete(id);
171-
console.log('deleted');
171+
console.log("deleted");
172172

173173
clearInterval(interval);
174174
if (earthquakes.size === 0) {
@@ -208,7 +208,7 @@ export const eew = (data: EewData) => {
208208

209209
setInterval(() => {
210210
const currentData = earthquakes.get(id);
211-
if (currentData && Date.now() - currentData['lastReport'] > 180000) {
211+
if (currentData && Date.now() - currentData["lastReport"] > 180000) {
212212
deleteEEW(id, `${id}-${Number(reportNumber)}`);
213213
}
214214
}, 10000);

src/ts/er.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { updatePastEvents } from './utils/event'
1+
import { updatePastEvents } from "./utils/event"
22

33

44

src/ts/utils/color.ts

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
11

22
export const getColorShindo = (intensity: string) => {
33
switch(intensity) {
4-
case '1':
5-
return '#3298c0';
6-
case '2':
7-
return '#4bbe9b';
8-
case '3':
9-
return '#f5c64b';
10-
case '4':
11-
return '#fe993a';
12-
case '5-':
13-
return '#da2815';
14-
case '5+':
15-
return '#ca1a19';
16-
case '6-':
17-
return '#850a55';
18-
case '6+':
19-
return '#7e0466';
20-
case '7':
21-
return '#52068a';
4+
case "1":
5+
return "#3298c0";
6+
case "2":
7+
return "#4bbe9b";
8+
case "3":
9+
return "#f5c64b";
10+
case "4":
11+
return "#fe993a";
12+
case "5-":
13+
return "#da2815";
14+
case "5+":
15+
return "#ca1a19";
16+
case "6-":
17+
return "#850a55";
18+
case "6+":
19+
return "#7e0466";
20+
case "7":
21+
return "#52068a";
2222
}
23-
return '#464646ff';
23+
return "#464646ff";
2424
};
2525

2626
export const getColorPga = (pga: number) => {
2727
if (pga <= 0.05) {
28-
return '#0007c5ff';
28+
return "#0007c5ff";
2929
} else if (pga <= 0.1) {
30-
return '#0024dd';
30+
return "#0024dd";
3131
} else if (pga <= 0.2) {
32-
return '#0065c3ff';
32+
return "#0065c3ff";
3333
} else if (pga <= 0.5) {
34-
return '#09bf8d';
34+
return "#09bf8d";
3535
} else if (pga <= 1) {
36-
return '#1aeb5b';
36+
return "#1aeb5b";
3737
} else if (pga <= 2) {
38-
return '#5ff225';
38+
return "#5ff225";
3939
} else if (pga <= 5) {
40-
return '#adf43bff';
40+
return "#adf43bff";
4141
} else if (pga <= 10) {
42-
return '#e5f43bff';
42+
return "#e5f43bff";
4343
} else if (pga <= 20) {
44-
return '#ebc052ff';
44+
return "#ebc052ff";
4545
} else if (pga <= 50) {
46-
return '#e17d26ff';
46+
return "#e17d26ff";
4747
} else if (pga <= 100) {
48-
return '#eb6c2cff';
48+
return "#eb6c2cff";
4949
} else if (pga <= 200) {
50-
return '#eb4f2cff';
50+
return "#eb4f2cff";
5151
} else if (pga <= 500) {
52-
return '#ee291fff';
52+
return "#ee291fff";
5353
} else {
54-
return '#880605';
54+
return "#880605";
5555
}
5656
};
5757

src/ts/utils/debugInfo.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11

22

33
const setVersion = () => {
4-
const infoVersionText = document.querySelector<HTMLElement>('.debug-info__version-text');
4+
const infoVersionText = document.querySelector<HTMLElement>(".debug-info__version-text");
55
if (!infoVersionText) return;
66

77
infoVersionText.textContent = __APP_VERSION__;
8-
infoVersionText.style.color = '#077fe9ff';
8+
infoVersionText.style.color = "#077fe9ff";
99
};
1010

1111
export const setConnection = (el: string, isConnected: boolean) => {
12-
const infoServerConnectionText = document.querySelector<HTMLElement>('.' + el);
12+
const infoServerConnectionText = document.querySelector<HTMLElement>("." + el);
1313
if (!infoServerConnectionText) return;
1414

1515
if (isConnected) {
16-
infoServerConnectionText.style.color = '#51ff00';
16+
infoServerConnectionText.style.color = "#51ff00";
1717
} else {
18-
infoServerConnectionText.style.color = '#ff0303';
18+
infoServerConnectionText.style.color = "#ff0303";
1919
}
2020

2121
};
@@ -25,9 +25,9 @@ export const startFpsCounter = () => {
2525
let frames = 0;
2626
let fps = 0;
2727

28-
const infoFpsText = document.querySelector<HTMLElement>('.debug-info__fps-text');
28+
const infoFpsText = document.querySelector<HTMLElement>(".debug-info__fps-text");
2929
if (!infoFpsText) return;
30-
infoFpsText.style.color = '#077fe9ff';
30+
infoFpsText.style.color = "#077fe9ff";
3131

3232
const updateFPS = () => {
3333
const now = performance.now();

src/ts/utils/speaker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const playSound = (sound: string) => {
1414
activeSounds.add(audio);
1515

1616
audio.play()
17-
.catch(err => console.error('Failed to play sound:', err))
17+
.catch(err => console.error("Failed to play sound:", err))
1818
.finally(() => {
1919
audio.onended = () => activeSounds.delete(audio);
2020
});

src/ts/utils/time.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
export const convertTimeToHoursMinutes = (time: string) => {
44
const timeString = time;
55
const date = new Date(timeString);
6-
const hours = String(date.getHours()).padStart(2, '0');
7-
const minutes = String(date.getMinutes()).padStart(2, '0');
6+
const hours = String(date.getHours()).padStart(2, "0");
7+
const minutes = String(date.getMinutes()).padStart(2, "0");
88
const hhmm = `${hours}:${minutes}`;
99
return hhmm;
1010
};
1111

1212
export const parseJMAtime = (time: string) => {
13-
const formattedTime = time.replace(/\//g, '-');
13+
const formattedTime = time.replace(/\//g, "-");
1414

1515
const timeParsed = new Date(formattedTime);
1616

@@ -23,9 +23,9 @@ export const parseExptechTime = (time: string) => {
2323
};
2424

2525
export const parseTime = (time: string, author: string, type: string) => {
26-
if (type === 'jma_eew' && author === 'wolfx') {
26+
if (type === "jma_eew" && author === "wolfx") {
2727
return parseJMAtime(time);
28-
} else if (author === 'exptech') {
28+
} else if (author === "exptech") {
2929
return parseExptechTime(time);
3030
}
3131
};
@@ -41,20 +41,20 @@ export const calculateElapsedTimeOfTheWave = (originTime: string, announcedTime:
4141

4242
export const showTime = () => {
4343
const date = new Date();
44-
const timeEl = document.getElementById('time');
44+
const timeEl = document.getElementById("time");
4545

4646
if (timeEl) {
4747
const options: Intl.DateTimeFormatOptions = {
48-
timeZone: 'Asia/Tokyo',
49-
year: 'numeric',
50-
month: '2-digit',
51-
day: '2-digit',
52-
hour: '2-digit',
53-
minute: '2-digit',
54-
second: '2-digit',
48+
timeZone: "Asia/Tokyo",
49+
year: "numeric",
50+
month: "2-digit",
51+
day: "2-digit",
52+
hour: "2-digit",
53+
minute: "2-digit",
54+
second: "2-digit",
5555
};
5656

57-
const jstString = new Intl.DateTimeFormat('ja-JP', options).format(date);
57+
const jstString = new Intl.DateTimeFormat("ja-JP", options).format(date);
5858

5959
timeEl.textContent = `${jstString} JST`;
6060
}

src/ts/utils/wave/taup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type TtjbTravelTimeTableEntry = {
77
type TtjbTravelTimeTable = Record<string, TtjbTravelTimeTableEntry>;
88

99
export const getTtjbTravelTimeTable = async () => {
10-
const response = await fetch('/taup/ttjb.json');
10+
const response = await fetch("/taup/ttjb.json");
1111
return (await response.json()) as TtjbTravelTimeTable;
1212
};
1313

0 commit comments

Comments
 (0)