Compare commits

..

No commits in common. "8ec53d6e069db14caeccd427f9c54023d999763a" and "e8b1a21a3bf6e9d1d1d207c847400343c3401dc1" have entirely different histories.

3 changed files with 17 additions and 7 deletions

View File

@ -116,7 +116,7 @@ export default function LED_vision(props) {
if (data.split(",")[0] === station.Station_JP) {
if (data.match(",発,")) {
trainData.time = data.split(",発,")[1];
} else if(data.match(",着,")){
} else {
trainData.time = data.split(",着,")[1];
trainData.lastStation = "当駅止";
}
@ -127,7 +127,7 @@ export default function LED_vision(props) {
time: trainData.time,
lastStation: trainData.lastStation,
};
}).filter((d) => d.time);
});
return returnData.sort((a, b) => {
switch (true) {
case parseInt(a.time.split(":")[0]) < parseInt(b.time.split(":")[0]):
@ -138,8 +138,6 @@ export default function LED_vision(props) {
return -1;
case parseInt(a.time.split(":")[1]) > parseInt(b.time.split(":")[1]):
return 1;
default:
return 0;
}
});
};

View File

@ -5,7 +5,7 @@ type nameString =
| "SPCL"
| "Normal"
| string;
type colorString = "aqua" | "red" | "#297bff" | "white";
type colorString = "aqua" | "red" | "blue" | "white";
type trainTypeString =
| "快速"
| "特急"
@ -29,7 +29,7 @@ export const getTrainType: getTrainType = (nameString) => {
case "NightLTDEXP":
return { color: "red", name: "寝台特急", data: "express" };
case "SPCL":
return { color: "#297bff", name: "臨時", data: "normal" };
return { color: "blue", name: "臨時", data: "normal" };
case "OneMan":
return { color: "white", name: "普通列車(ワンマン)", data: "normal" };
case "Normal":

14
menu.js
View File

@ -131,7 +131,19 @@ export default function Menu({ getCurrentTrain }) {
const [trainDiagram, setTrainDiagram] = useState(null); // 全列車のダイヤを列番ベースで整理
useEffect(() => {
//全列車リストを生成する副作用[無条件初回実行]
setTrainDiagram(trainList);
fetch(
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=traintimeinfo&arg3=dia",
HeaderConfig
)
.then((response) => response.text())
.then((d) => {
if (d.indexOf("<title>404 Not Found</title>") != -1) throw Error;
setTrainDiagram(parseAllTrainDiagram(d));
})
.catch(() => {
console.log("fallback");
setTrainDiagram(trainList);
});
}, []);
const oPSign = () => {