Compare commits
6 Commits
4e367d1e3c
...
e5da54da85
Author | SHA1 | Date | |
---|---|---|---|
|
e5da54da85 | ||
|
59e7ba5290 | ||
|
83539d5df3 | ||
|
9e831ecd6e | ||
|
0d9c1cdb18 | ||
|
bc4cb450a3 |
@@ -83,7 +83,9 @@ export const EachTrainInfoCore = ({
|
||||
const [haveThrough, setHaveThrough] = useState(false);
|
||||
|
||||
// 使用例
|
||||
const stopStationIDList = trainDataWidhThrough.map((i) => {
|
||||
const [stopStationIDList, setStopStationList] = useState([]);
|
||||
useEffect(() => {
|
||||
const x = trainDataWidhThrough.map((i) => {
|
||||
const [station, se, time] = i.split(",");
|
||||
const Stations = stationList.map((a) =>
|
||||
a.filter((d) => d.StationName == station)
|
||||
@@ -95,11 +97,15 @@ export const EachTrainInfoCore = ({
|
||||
}, []).map((d) => d.StationNumber);
|
||||
return StationNumbers;
|
||||
});
|
||||
setStopStationList(x);
|
||||
}, [trainDataWidhThrough]);
|
||||
|
||||
useEffect(() => {
|
||||
const isCancel = [];
|
||||
const stopStationList = trainData.map((i, index, array) => {
|
||||
const [station, se, time] = i.split(",");
|
||||
const [nextStation, nextSe, nextTime] = array[index+1]?.split(",") || [];
|
||||
const [nextStation, nextSe, nextTime] =
|
||||
array[index + 1]?.split(",") || [];
|
||||
isCancel.push(se.includes("休") && nextSe.includes("休"));
|
||||
if (se == "通編") setHaveThrough(true);
|
||||
return stationList.map((a) => a.filter((d) => d.StationName == station));
|
||||
@@ -131,8 +137,9 @@ export const EachTrainInfoCore = ({
|
||||
d.StationNumber > baseStationNumberFirst &&
|
||||
d.StationNumber < baseStationNumberSecond
|
||||
) {
|
||||
|
||||
allThroughStation.push(`${d.Station_JP},${isCancel[index] ? "通休編" : "通過"},`);
|
||||
allThroughStation.push(
|
||||
`${d.Station_JP},${isCancel[index] ? "通休編" : "通過"},`
|
||||
);
|
||||
setHaveThrough(true);
|
||||
reverse = false;
|
||||
} else {
|
||||
@@ -140,7 +147,9 @@ export const EachTrainInfoCore = ({
|
||||
d.StationNumber < baseStationNumberFirst &&
|
||||
d.StationNumber > baseStationNumberSecond
|
||||
) {
|
||||
allThroughStation.push(`${d.Station_JP},${isCancel[index] ? "通休編" : "通過"},`);
|
||||
allThroughStation.push(
|
||||
`${d.Station_JP},${isCancel[index] ? "通休編" : "通過"},`
|
||||
);
|
||||
setHaveThrough(true);
|
||||
reverse = true;
|
||||
}
|
||||
@@ -252,6 +261,7 @@ export const EachTrainInfoCore = ({
|
||||
|
||||
useEffect(() => {
|
||||
const position = getPosition(currentTrainData);
|
||||
if (stopStationIDList.length == 0) return;
|
||||
if (position) {
|
||||
if (position.length > 1) {
|
||||
if (position[0] == "-Iyo") {
|
||||
@@ -259,8 +269,7 @@ export const EachTrainInfoCore = ({
|
||||
stopStationIDList[
|
||||
stopStationIDList.findIndex((d) => d.includes("U14")) - 1
|
||||
][0];
|
||||
}
|
||||
else if (position[0] == "+Iyo") {
|
||||
} else if (position[0] == "+Iyo") {
|
||||
position[0] =
|
||||
stopStationIDList[
|
||||
stopStationIDList.findIndex((d) => d.includes("U14")) + 1
|
||||
@@ -281,7 +290,7 @@ export const EachTrainInfoCore = ({
|
||||
|
||||
setCurrentPosition(position);
|
||||
}
|
||||
}, [currentTrainData]);
|
||||
}, [currentTrainData,stopStationIDList]);
|
||||
|
||||
useEffect(() => {
|
||||
//列車現在地アイコン表示スイッチ
|
||||
@@ -365,9 +374,7 @@ export const EachTrainInfoCore = ({
|
||||
style: {
|
||||
maxHeight: isLandscape ? height - 94 : (height / 100) * 70,
|
||||
backgroundColor:
|
||||
customTrainType.data === "notService"
|
||||
? "#777777ff"
|
||||
: "white",
|
||||
customTrainType.data === "notService" ? "#777777ff" : "white",
|
||||
},
|
||||
}}
|
||||
shortHeader={
|
||||
|
@@ -34,8 +34,13 @@ export const FixedTrain: FC<props> = ({
|
||||
displaySize,
|
||||
setDisplaySize,
|
||||
}) => {
|
||||
const {fixedPosition, setFixedPosition, currentTrain, getCurrentStationData, getPosition } =
|
||||
useCurrentTrain();
|
||||
const {
|
||||
fixedPosition,
|
||||
setFixedPosition,
|
||||
currentTrain,
|
||||
getCurrentStationData,
|
||||
getPosition,
|
||||
} = useCurrentTrain();
|
||||
|
||||
const { mapSwitch } = useTrainMenu();
|
||||
const { allCustomTrainData, allTrainDiagram } = useAllTrainDiagram();
|
||||
@@ -53,8 +58,7 @@ export const FixedTrain: FC<props> = ({
|
||||
const stationData = getCurrentStationData(trainID);
|
||||
if (stationData) {
|
||||
setTrain(stationData);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
alert("追跡していた列車が消えました。追跡を終了します。");
|
||||
setFixedPosition({ type: null, value: null });
|
||||
}
|
||||
@@ -133,7 +137,9 @@ export const FixedTrain: FC<props> = ({
|
||||
});
|
||||
setTrainDataWithThrough(mainArray);
|
||||
}, [allTrainDiagram, stationList, trainID]);
|
||||
const stopStationIDList = trainDataWidhThrough.map((i) => {
|
||||
const [stopStationIDList, setStopStationList] = useState([]);
|
||||
useEffect(() => {
|
||||
const x = trainDataWidhThrough.map((i) => {
|
||||
const [station, se, time] = i.split(",");
|
||||
const Stations = stationList.map((a) =>
|
||||
a.filter((d) => d.StationName == station)
|
||||
@@ -145,10 +151,13 @@ export const FixedTrain: FC<props> = ({
|
||||
}, []).map((d) => d.StationNumber);
|
||||
return StationNumbers;
|
||||
});
|
||||
setStopStationList(x);
|
||||
}, [trainDataWidhThrough]);
|
||||
const [currentPosition, setCurrentPosition] = useState<string[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
let position = getPosition(train);
|
||||
if (stopStationIDList.length == 0) return;
|
||||
if (position) {
|
||||
if (position.length > 1) {
|
||||
if (position[0] == "-Iyo") {
|
||||
@@ -177,7 +186,7 @@ export const FixedTrain: FC<props> = ({
|
||||
|
||||
setCurrentPosition(position);
|
||||
}
|
||||
}, [train]);
|
||||
}, [train,stopStationIDList]);
|
||||
|
||||
const [nextStationData, setNextStationData] = useState<StationProps[]>([]);
|
||||
const [untilStationData, setUntilStationData] = useState<StationProps[]>([]);
|
||||
|
@@ -31,10 +31,17 @@ export const findReversalPoints = (array, stopStationIDList) => {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if (array[0] == "U15" && array[1] == "U14") {
|
||||
|
||||
return d[0] == "U13" ? true : false;
|
||||
} else if (array[0] == "S17" && array[1] == "U14") {
|
||||
|
||||
return d[0] == "U14" ? true : false;
|
||||
}
|
||||
|
||||
let returndata = false;
|
||||
d.forEach((x) => {
|
||||
console.log(array, x, d);
|
||||
if (array[0] < x && x < array[1]) {
|
||||
returndata = true;
|
||||
} else if (array[0] < x && x == array[1]) {
|
||||
|
@@ -112,7 +112,7 @@ export const CurrentTrainProvider: FC<props> = ({ children }) => {
|
||||
currentTrainData: trainDataType
|
||||
) => string[] | undefined;
|
||||
const getPosition: getPositionFuncType = (currentTrainData) => {
|
||||
//currentTrainData.Pos = "鴨川~端岡"; //test
|
||||
//currentTrainData = {Pos:"伊予若宮~伊予大洲"}; //test
|
||||
if (!currentTrainData) return;
|
||||
if (!currentTrainData?.Pos) return;
|
||||
if (currentTrainData?.Pos.match("~")) {
|
||||
|
@@ -127,7 +127,8 @@ export const StationListProvider: FC<Props> = ({ children }) => {
|
||||
});
|
||||
}
|
||||
});
|
||||
if (bootStationList[0].line === undefined) return "";
|
||||
console.log(bootStationList[0]);
|
||||
if (bootStationList[0] === undefined) return "";
|
||||
return `MoveDisplayStation('${bootStationList[0].line}_${bootStationList[0].station.MyStation}_${bootStationList[0].station.Station_JP}');document.getElementById("disp").insertAdjacentHTML("afterbegin", "<div />");setReload();`;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user