Merge commit 'cbce84a9ab1a79f4302c1b7c65a23a0263e78905'
This commit is contained in:
commit
f7965be3ef
62
App.js
62
App.js
@ -14,7 +14,6 @@ import trainbase from "./trainbaseview";
|
||||
import howto from "./howto";
|
||||
import menu from "./menu";
|
||||
import News from "./components/news.js";
|
||||
import TestArea from "./TestArea.js";
|
||||
import Setting from "./components/settings.js";
|
||||
import trainMenu from "./components/trainMenu.js";
|
||||
const Stack = createStackNavigator();
|
||||
@ -26,8 +25,7 @@ if (Platform.OS === "android") {
|
||||
}
|
||||
export default function App() {
|
||||
const navigationRef = useRef();
|
||||
var platform = Platform.OS === "android" ? 70 : 50;
|
||||
useEffect(() => UpdateAsync(), []);
|
||||
useEffect(UpdateAsync, []);
|
||||
return (
|
||||
<NavigationContainer name="Root" ref={navigationRef} style={{ flex: 1 }}>
|
||||
<Tab.Navigator>
|
||||
@ -38,9 +36,7 @@ export default function App() {
|
||||
tabBarLabel: "位置情報",
|
||||
headerTransparent: true,
|
||||
gestureEnabled: true,
|
||||
tabBarIcon: ({ color, size }) => (
|
||||
<AntDesign name="barchart" size={32} />
|
||||
),
|
||||
tabBarIcon: () => <AntDesign name="barchart" size={32} />,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
@ -50,9 +46,7 @@ export default function App() {
|
||||
tabBarLabel: "リンク",
|
||||
headerTransparent: true,
|
||||
gestureEnabled: true,
|
||||
tabBarIcon: ({ color, size }) => (
|
||||
<Ionicons name="ios-radio" size={32} />
|
||||
),
|
||||
tabBarIcon: () => <Ionicons name="ios-radio" size={32} />,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
@ -62,9 +56,7 @@ export default function App() {
|
||||
tabBarLabel: "運行情報",
|
||||
headerTransparent: true,
|
||||
gestureEnabled: true,
|
||||
tabBarIcon: ({ color, size }) => (
|
||||
<Ionicons name="md-train" size={32} />
|
||||
),
|
||||
tabBarIcon: () => <Ionicons name="md-train" size={32} />,
|
||||
}}
|
||||
/>
|
||||
</Tab.Navigator>
|
||||
@ -97,35 +89,14 @@ function top() {
|
||||
component={howto}
|
||||
options={{
|
||||
title: "使い方",
|
||||
gestureEnabled: true,
|
||||
...TransitionPresets.ModalPresentationIOS,
|
||||
cardOverlayEnabled: true,
|
||||
headerTransparent: true,
|
||||
headerShown: false,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen name="test" component={TestArea} options={{}} />
|
||||
<Stack.Screen
|
||||
name="news"
|
||||
component={News}
|
||||
options={{
|
||||
gestureEnabled: true,
|
||||
...TransitionPresets.ModalPresentationIOS,
|
||||
cardOverlayEnabled: true,
|
||||
headerTransparent: true,
|
||||
headerShown: false,
|
||||
...optionData,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen name="news" component={News} options={optionData} />
|
||||
<Stack.Screen
|
||||
name="trainMenu"
|
||||
component={trainMenu}
|
||||
options={{
|
||||
gestureEnabled: true,
|
||||
...TransitionPresets.ModalPresentationIOS,
|
||||
cardOverlayEnabled: true,
|
||||
headerTransparent: true,
|
||||
headerShown: false,
|
||||
}}
|
||||
options={optionData}
|
||||
/>
|
||||
</Stack.Navigator>
|
||||
);
|
||||
@ -142,17 +113,14 @@ function menuPage() {
|
||||
headerTransparent: true,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="setting"
|
||||
component={Setting}
|
||||
options={{
|
||||
gestureEnabled: true,
|
||||
...TransitionPresets.ModalPresentationIOS,
|
||||
cardOverlayEnabled: true,
|
||||
headerTransparent: true,
|
||||
headerShown: false,
|
||||
}}
|
||||
/>
|
||||
<Stack.Screen name="setting" component={Setting} options={optionData} />
|
||||
</Stack.Navigator>
|
||||
);
|
||||
}
|
||||
const optionData = {
|
||||
gestureEnabled: true,
|
||||
...TransitionPresets.ModalPresentationIOS,
|
||||
cardOverlayEnabled: true,
|
||||
headerTransparent: true,
|
||||
headerShown: false,
|
||||
};
|
||||
|
878
Apps.js
878
Apps.js
@ -10,6 +10,10 @@ import { WebView } from "react-native-webview";
|
||||
import Constants from "expo-constants";
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||
import { news } from "./config/newsUpdate";
|
||||
import { getStationList } from "./lib/getStationList";
|
||||
import { StationDeteilView } from "./components/ActionSheetComponents/StationDeteilView";
|
||||
import { injectJavascriptData } from "./lib/webViewInjectjavascript";
|
||||
import { getStationList2 } from "./lib/getStationList2";
|
||||
/*
|
||||
import StatusbarDetect from './StatusbarDetect';
|
||||
var Status = StatusbarDetect(); */
|
||||
@ -20,795 +24,42 @@ export default function Apps(props) {
|
||||
} = props;
|
||||
var urlcache = "";
|
||||
const webview = useRef();
|
||||
//画面表示関連
|
||||
const [iconSetting, setIconSetting] = useState(undefined);
|
||||
const [mapSwitch, setMapSwitch] = useState(undefined);
|
||||
const [stationMenu, setStationMenu] = useState(undefined);
|
||||
|
||||
const [stationData, setStationData] = useState(undefined);
|
||||
//地図用
|
||||
const [mapsStationData, setMapsStationData] = useState(undefined);
|
||||
useEffect(() => {
|
||||
const HeaderConfig = {
|
||||
headers: { referer: "https://train.jr-shikoku.co.jp/sp.html" },
|
||||
};
|
||||
|
||||
Promise.all([
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=yosan",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=uwajima",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=uwajima2",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=dosan",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=dosan2",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=koutoku",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=tokushima",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=naruto",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
]).then((values) => {
|
||||
let stationList = {};
|
||||
[
|
||||
stationList.yosan,
|
||||
stationList.uwajima,
|
||||
stationList.uwajima2,
|
||||
stationList.dosan,
|
||||
stationList.dosan2,
|
||||
stationList.koutoku,
|
||||
stationList.tokushima,
|
||||
stationList.naruto,
|
||||
] = values;
|
||||
setStationData(stationList);
|
||||
getStationList2().then((data) => {
|
||||
setMapsStationData(data);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const topMenu =
|
||||
mapSwitch != "true"
|
||||
? `
|
||||
document.getElementById('header').querySelector('a').style.display = 'none';
|
||||
document.getElementById('header').style.height = '50px';
|
||||
document.getElementById('main').style.paddingTop = '54px';
|
||||
//駅情報画面用
|
||||
const StationBoardAcSR = useRef(null);
|
||||
const [stationBoardData, setStationBoardData] = useState(undefined);
|
||||
const [originalStationList, setOriginalStationList] = useState();
|
||||
const [selectedStation, setSelectedStation] = useState(undefined);
|
||||
useEffect(() => getStationList().then(setOriginalStationList), []);
|
||||
|
||||
document.getElementById('headerStr').style.display = 'none';
|
||||
`
|
||||
: `
|
||||
document.getElementsByClassName('accordionClass')[0].style.display = 'none';
|
||||
document.getElementById('header').style.display = 'none';
|
||||
document.getElementById('main').style.paddingTop = '0px';
|
||||
document.getElementById('headerStr').style.display = 'none';
|
||||
`;
|
||||
const bootData =
|
||||
topMenu +
|
||||
`
|
||||
const setReload = () =>{
|
||||
try{
|
||||
document.getElementById('refreshIcon').click();
|
||||
setStrings();
|
||||
}catch{
|
||||
|
||||
}
|
||||
setTimeout(setReload, 10000);
|
||||
}
|
||||
setReload();
|
||||
`;
|
||||
|
||||
const trainIconMaker = `
|
||||
const setStationIcon = (行き先アイコン,img) =>{
|
||||
let newItem = document.createElement("div");
|
||||
if(行き先アイコン.getAttribute("style").includes("left")){
|
||||
行き先アイコン.insertAdjacentHTML('beforebegin', "<img src="+img+" style='float:left;height:20px;'>");
|
||||
}
|
||||
else{
|
||||
行き先アイコン.insertAdjacentHTML('beforebegin', "<img src="+img+" style='float:right;height:20px;'>");
|
||||
}
|
||||
行き先アイコン.remove();
|
||||
}
|
||||
`;
|
||||
|
||||
const trainIcon =
|
||||
iconSetting == "true"
|
||||
? `
|
||||
switch(列番データ){
|
||||
//しおかぜメイン
|
||||
//8000 ノーマル
|
||||
case "2M":
|
||||
case "4M":
|
||||
case "6M":
|
||||
case "14M":
|
||||
case "16M":
|
||||
case "18M":
|
||||
case "26M":
|
||||
case "28M":
|
||||
case "30M":
|
||||
case "1M":
|
||||
case "3M":
|
||||
case "5M":
|
||||
case "13M":
|
||||
case "15M":
|
||||
case "17M":
|
||||
case "25M":
|
||||
case "27M":
|
||||
case "29M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s8000nr.png');
|
||||
break;
|
||||
//8000 アンパン
|
||||
case "10M":
|
||||
case "22M":
|
||||
case "9M":
|
||||
case "21M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/f/s8000ap.png');
|
||||
break;
|
||||
|
||||
|
||||
//8600
|
||||
case "8M":
|
||||
case "12M":
|
||||
case "20M":
|
||||
case "24M":
|
||||
case "7M":
|
||||
case "11M":
|
||||
case "19M":
|
||||
case "23M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s8600.png');
|
||||
break;
|
||||
|
||||
//いしづちメイン
|
||||
//8000 ノーマル
|
||||
|
||||
case "1004M":
|
||||
case "1006M":
|
||||
case "1014M":
|
||||
case "1016M":
|
||||
case "1018M":
|
||||
case "1026M":
|
||||
case "1028M":
|
||||
case "1030M":
|
||||
case "1001M":
|
||||
case "1003M":
|
||||
case "1005M":
|
||||
case "1013M":
|
||||
case "1015M":
|
||||
case "1017M":
|
||||
case "1025M":
|
||||
case "1027M":
|
||||
case "1029M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s8000no.png');
|
||||
break;
|
||||
|
||||
//8000 アンパン
|
||||
case "1010M":
|
||||
case "1022M":
|
||||
case "1009M":
|
||||
case "1021M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/f/s8000ap.png');
|
||||
break;
|
||||
|
||||
//8600
|
||||
case "1008M":
|
||||
case "1012M":
|
||||
case "1020M":
|
||||
case "1024M":
|
||||
case "1007M":
|
||||
case "1011M":
|
||||
case "1019M":
|
||||
case "1023M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s8600_isz.png');
|
||||
break;
|
||||
|
||||
//MEXP
|
||||
//8000
|
||||
case "1092M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s8000no.png');
|
||||
break;
|
||||
//8600
|
||||
case "1091M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s8600_isz.png');
|
||||
break;
|
||||
//三桁いしづち
|
||||
//8000 アンパン
|
||||
case "1041M":
|
||||
case "1044M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/f/s8000ap.png');
|
||||
break;
|
||||
//8600
|
||||
case "1043M":
|
||||
case "1042M":
|
||||
case "1046M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s8600_isz.png');
|
||||
break;
|
||||
|
||||
|
||||
//南風 2700ノーマル
|
||||
case "34D":
|
||||
case "38D":
|
||||
case "40D":
|
||||
case "42D":
|
||||
case "46D":
|
||||
case "50D":
|
||||
case "52D":
|
||||
case "54D":
|
||||
case "58D":
|
||||
case "31D":
|
||||
case "35D":
|
||||
case "39D":
|
||||
case "41D":
|
||||
case "43D":
|
||||
case "47D":
|
||||
case "51D":
|
||||
case "53D":
|
||||
case "55D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s2700.png');
|
||||
break;
|
||||
//2700アンパン
|
||||
case "32D":
|
||||
case "36D":
|
||||
case "44D":
|
||||
case "48D":
|
||||
case "56D":
|
||||
case "33D":
|
||||
case "37D":
|
||||
case "45D":
|
||||
case "49D":
|
||||
case "57D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/f/s2700apr.png');
|
||||
break;
|
||||
|
||||
|
||||
|
||||
//うずしお
|
||||
//2700
|
||||
case "5006D":
|
||||
case "5022D":
|
||||
case "5013D":
|
||||
case "5029D":
|
||||
case "3002D":
|
||||
case "3004D":
|
||||
case "3010D":
|
||||
case "3012D":
|
||||
case "3016D":
|
||||
case "3018D":
|
||||
case "3024D":
|
||||
case "3028D":
|
||||
case "3030D":
|
||||
case "3003D":
|
||||
case "3005D":
|
||||
case "3007D":
|
||||
case "3015D":
|
||||
case "3019D":
|
||||
case "3021D":
|
||||
case "3025D":
|
||||
case "3027D":
|
||||
case "3031D":
|
||||
case "3033D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s2700_uzu.png');
|
||||
break;
|
||||
|
||||
//2600
|
||||
case "3008D":
|
||||
case "3014D":
|
||||
case "3020D":
|
||||
case "3026D":
|
||||
case "3001D":
|
||||
case "3011D":
|
||||
case "3017D":
|
||||
case "3023D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s2600.png');
|
||||
break;
|
||||
|
||||
//キハ185
|
||||
case "3009D":
|
||||
case "3032D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s185tu_uzu.png');
|
||||
break;
|
||||
|
||||
//マリンライナー
|
||||
case "3104M":
|
||||
case "3106M":
|
||||
case "3108M":
|
||||
case "3110M":
|
||||
case "3112M":
|
||||
case "3114M":
|
||||
case "3116M":
|
||||
case "3118M":
|
||||
case "3120M":
|
||||
case "3122M":
|
||||
case "3124M":
|
||||
case "3126M":
|
||||
case "3128M":
|
||||
case "3130M":
|
||||
case "3132M":
|
||||
case "3134M":
|
||||
case "3136M":
|
||||
case "3138M":
|
||||
case "3140M":
|
||||
case "3142M":
|
||||
case "3144M":
|
||||
case "3146M":
|
||||
case "3148M":
|
||||
case "3150M":
|
||||
case "3152M":
|
||||
case "3154M":
|
||||
case "3156M":
|
||||
case "3158M":
|
||||
case "3160M":
|
||||
case "3162M":
|
||||
case "3164M":
|
||||
case "3166M":
|
||||
case "3168M":
|
||||
case "3170M":
|
||||
case "3105M":
|
||||
case "3107M":
|
||||
case "3109M":
|
||||
case "3111M":
|
||||
case "3113M":
|
||||
case "3115M":
|
||||
case "3117M":
|
||||
case "3119M":
|
||||
case "3121M":
|
||||
case "3123M":
|
||||
case "3125M":
|
||||
case "3127M":
|
||||
case "3129M":
|
||||
case "3131M":
|
||||
case "3133M":
|
||||
case "3135M":
|
||||
case "3137M":
|
||||
case "3139M":
|
||||
case "3141M":
|
||||
case "3143M":
|
||||
case "3145M":
|
||||
case "3147M":
|
||||
case "3149M":
|
||||
case "3151M":
|
||||
case "3153M":
|
||||
case "3155M":
|
||||
case "3157M":
|
||||
case "3159M":
|
||||
case "3161M":
|
||||
case "3163M":
|
||||
case "3165M":
|
||||
case "3167M":
|
||||
case "3169M":
|
||||
case "3175M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s5001.png');
|
||||
break;
|
||||
case "3102M":
|
||||
case "3101M":
|
||||
case "3103M":
|
||||
case "3171M":
|
||||
case "3173M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s5001k.png');
|
||||
break;
|
||||
|
||||
//サンライズ瀬戸
|
||||
case "5032M":
|
||||
case "5031M":
|
||||
case "8041M": //琴平延長高松迄
|
||||
case "8031M": //琴平延長高松以降
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/w285.png');
|
||||
break;
|
||||
|
||||
//宇和海
|
||||
//2000 ノーマル
|
||||
case "1052D":
|
||||
case "1056D":
|
||||
case "1058D":
|
||||
case "1064D":
|
||||
case "1070D":
|
||||
case "1074D":
|
||||
case "1076D":
|
||||
case "1078D":
|
||||
case "1080D":
|
||||
case "1082D":
|
||||
case "1051D":
|
||||
case "1059D":
|
||||
case "1065D":
|
||||
case "1069D":
|
||||
case "1071D":
|
||||
case "1073D":
|
||||
case "1075D":
|
||||
case "1077D":
|
||||
case "1079D":
|
||||
case "1053D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s2000_uwa.png');
|
||||
break;
|
||||
//2000 アンパン込み
|
||||
case "1054D":
|
||||
case "1060D":
|
||||
case "1062D":
|
||||
case "1066D":
|
||||
case "1068D":
|
||||
case "1072D":
|
||||
case "1055D":
|
||||
case "1057D":
|
||||
case "1061D":
|
||||
case "1063D":
|
||||
case "1067D":
|
||||
case "1081D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/f/s2002a.png');
|
||||
break;
|
||||
//しまんと
|
||||
case "2002D":
|
||||
case "2004D":
|
||||
case "2006D":
|
||||
case "2008D":
|
||||
case "2001D":
|
||||
case "2003D":
|
||||
case "2005D":
|
||||
case "2007D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s2700_smn.png');
|
||||
break;
|
||||
|
||||
//あしずり 2000
|
||||
case "2074D":
|
||||
case "2076D":
|
||||
case "2080D":
|
||||
case "2084D":
|
||||
case "2086D":
|
||||
case "2071D":
|
||||
case "2075D":
|
||||
case "2077D":
|
||||
case "2081D":
|
||||
case "2083D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s2000_asi.png');
|
||||
break;
|
||||
|
||||
//あしずり 2700
|
||||
case "2078D":
|
||||
case "2082D":
|
||||
case "2088D":
|
||||
case "2073D":
|
||||
case "2079D":
|
||||
case "2085D":
|
||||
case "2072D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s2700_asi.png');
|
||||
break;
|
||||
//剣山
|
||||
case "4002D":
|
||||
case "4004D":
|
||||
case "4006D":
|
||||
case "4008D":
|
||||
case "4010D":
|
||||
case "4001D":
|
||||
case "4003D":
|
||||
case "4005D":
|
||||
case "4007D":
|
||||
case "4009D":
|
||||
case "4011D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s185tu.png');
|
||||
break;
|
||||
//むろと
|
||||
case "5051D":
|
||||
case "5052D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s185_mrt.png');
|
||||
break;
|
||||
|
||||
|
||||
//よしのがわトロッコ
|
||||
case "8452D":
|
||||
case "8451D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/f/s185to_ai.png');
|
||||
break;
|
||||
|
||||
//岡山高松アントロ
|
||||
case "8176D":
|
||||
case "8179D":
|
||||
//岡山琴平アントロ
|
||||
case "8277D":
|
||||
case "8278D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/f/s32to4.png');
|
||||
break;
|
||||
|
||||
//伊予灘ものがたり
|
||||
case "8901D":
|
||||
case "8903D":
|
||||
case "8902D":
|
||||
case "8904D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s185iyoy.png');
|
||||
break;
|
||||
|
||||
|
||||
//千年ものがたり
|
||||
case "8011D":
|
||||
case "8012D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s185mm1.png');
|
||||
break;
|
||||
|
||||
//夜明けものがたり
|
||||
case "8053D":
|
||||
case "8054D":
|
||||
case "8062D":
|
||||
case "8063D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s185ym1.png');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
`
|
||||
: ``;
|
||||
|
||||
const JRF_icon =
|
||||
iconSetting == "true"
|
||||
? `
|
||||
JRF || setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/f/ef210a.png');
|
||||
`
|
||||
: ``;
|
||||
const normal_train_name = `
|
||||
if(new RegExp(/^4[1-9]\\d\\d[DM]$/).test(列番データ) || new RegExp(/^5[1-7]\\d\\d[DM]$/).test(列番データ)){
|
||||
行き先情報.innerText = "ワンマン\\n"+行き先情報.innerText;
|
||||
flag=true;
|
||||
}
|
||||
if(new RegExp(/^49[0-4]\\dD$/).test(列番データ) || new RegExp(/^9[0-4]\\dD$/).test(列番データ)){
|
||||
行き先情報.innerText = "(海経由)"+(flag ? "" : "\\n")+行き先情報.innerText;
|
||||
}
|
||||
if(new RegExp(/^46\\d\\dD$/).test(列番データ) || new RegExp(/^6\\d\\dD$/).test(列番データ)){
|
||||
行き先情報.innerText = "(内子経由)"+(flag ? "" : "\\n")+行き先情報.innerText;
|
||||
}
|
||||
if(列番データ.indexOf("H") != -1){
|
||||
行き先情報.innerText = 行き先情報.innerText+"試運転\\n";
|
||||
}
|
||||
else if(列番データ.indexOf("R") != -1){
|
||||
行き先情報.innerText = 行き先情報.innerText+"回送\\n";
|
||||
}
|
||||
else if(列番データ.indexOf("S") != -1){
|
||||
行き先情報.innerText = 行き先情報.innerText+"臨時列車\\n";
|
||||
}
|
||||
`;
|
||||
const JRF_name =
|
||||
`
|
||||
let JRF = false;
|
||||
switch(列番データ){
|
||||
case "71":
|
||||
行き先情報.innerText = "東京(タ)→高松(タ)"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "73":
|
||||
case "75":
|
||||
行き先情報.innerText = "大阪(タ)→高松(タ)"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "3079":
|
||||
行き先情報.innerText = "高松(タ)→伊予三島"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "3071":
|
||||
case "3077":
|
||||
行き先情報.innerText = "高松(タ)→新居浜"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "3073":
|
||||
行き先情報.innerText = "高松(タ)→松山貨物"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "70":
|
||||
行き先情報.innerText = "高松(タ)→東京(タ)"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "74":
|
||||
case "76":
|
||||
行き先情報.innerText = "高松(タ)→大阪(タ)"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "3078":
|
||||
行き先情報.innerText = "伊予三島→高松(タ)"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "3070":
|
||||
行き先情報.innerText = "新居浜→高松(タ)"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "3076":
|
||||
行き先情報.innerText = "新居浜→高松(タ)"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "3072":
|
||||
行き先情報.innerText = "松山貨物→高松(タ)"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "9070":
|
||||
行き先情報.innerText = "臨時貨物"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
default:
|
||||
JRF = true;
|
||||
}
|
||||
` + JRF_icon;
|
||||
|
||||
const TKT_name = `
|
||||
//安芸行と併結列車を個別に表示、それ以外をdefaultで下りなら既定の行き先を、上りなら奈半利行を設定
|
||||
switch(列番データ){
|
||||
case "5814D":
|
||||
case "5816D":
|
||||
行き先情報.innerText = "ごめん・なはり線直通\\n快速 奈半利行";
|
||||
break;
|
||||
case "5812D":
|
||||
行き先情報.innerText = "ごめん・なはり線直通\\n快速 安芸行";
|
||||
break;
|
||||
case "5874D":
|
||||
case "5882D":
|
||||
行き先情報.innerText = "ごめん・なはり線直通\\n各停 安芸行";
|
||||
break;
|
||||
case "742D":
|
||||
case "746D":
|
||||
行き先情報.innerText = "土佐山田/奈半利行\\n(後免にて解結)\\nごめん・なはり線快速";
|
||||
break;
|
||||
default:
|
||||
if(new RegExp(/^58[1-3][1,3,5,7,9][DM]$/).test(列番データ)){
|
||||
行き先情報.innerText = "ごめん・なはり線直通\\n快速 "+行き先情報.innerText;
|
||||
}
|
||||
else if(new RegExp(/^58[4-9][1,3,5,7,9][DM]$/).test(列番データ)){
|
||||
行き先情報.innerText = "ごめん・なはり線直通\\n各停 "+行き先情報.innerText;
|
||||
}
|
||||
|
||||
else if(new RegExp(/^58[3-4][0,2,4,6,8][DM]$/).test(列番データ)){
|
||||
行き先情報.innerText = "ごめん・なはり線直通\\n快速 奈半利行";
|
||||
}
|
||||
else if(new RegExp(/^58[5-9][0,2,4,6,8][DM]$/).test(列番データ)){
|
||||
行き先情報.innerText = "ごめん・なはり線直通\\n各停 奈半利行";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
`;
|
||||
|
||||
const textInsert =
|
||||
`
|
||||
const setStrings = () =>{
|
||||
try {
|
||||
var elements = document.querySelectorAll('[onclick]');
|
||||
for (let element of elements) {
|
||||
if(element.getAttribute('onclick').indexOf('ShowTrainTimeInfo') == -1) continue;
|
||||
var 行き先情報 = element.getElementsByTagName("p")[0];
|
||||
var 列番データ = element.getAttribute('onclick').split('"')[1];
|
||||
var flag=false;
|
||||
var TrainType = undefined;
|
||||
if(行き先情報.innerText.includes(列番データ))continue; //回避
|
||||
` +
|
||||
trainIcon +
|
||||
normal_train_name +
|
||||
JRF_name +
|
||||
TKT_name +
|
||||
`
|
||||
//列番付与
|
||||
行き先情報.innerText = 行き先情報.innerText+列番データ+(JRF ? "":"レ");
|
||||
}
|
||||
try{
|
||||
for(let d of document.getElementById('disp').childNodes){
|
||||
switch(d.id){
|
||||
case 'pMENU_2':
|
||||
case 'pMENU_2_En':
|
||||
case 'pMENU_3':
|
||||
case 'pMENU_3_En':
|
||||
case 'pMENU_k':
|
||||
case 'pMENU_k_En':
|
||||
continue;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
d.style.width = '100vw';
|
||||
for(let f of d.childNodes){
|
||||
try{
|
||||
if(f.style.alignItems || f.style.textAlign){
|
||||
f.style.width = '38vw';
|
||||
}
|
||||
else{
|
||||
if(f.id == 'upTrainCrossBar'){
|
||||
f.style.width = '38vw';
|
||||
}
|
||||
else if(f.id == 'dwTrainCrossBar'){
|
||||
f.style.left = '62vw';
|
||||
f.style.width = '38vw';
|
||||
|
||||
}
|
||||
else {
|
||||
f.style.width = '0vw';
|
||||
}
|
||||
}
|
||||
if(f.style.textAlign == 'center'){
|
||||
f.style.width = '24vw';
|
||||
f.style.display = 'flex';
|
||||
f.childNodes.forEach(i =>{
|
||||
i.style.width = 'unset';
|
||||
i.style.left = 'unset';
|
||||
i.style.top = 'unset';
|
||||
i.style.position = 'unset';
|
||||
i.style.flex = '1';
|
||||
i.style.margin = '5px'
|
||||
|
||||
if(i.style.backgroundColor != 'rgb(247, 247, 247)'){
|
||||
i.childNodes.forEach(m=> m.style.width = '20vw')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}catch(e){}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
document.querySelector('#pMENU_2').style.borderStyle='solid';
|
||||
document.querySelector('#pMENU_2').style.borderColor='#00d3e8';
|
||||
document.querySelector('#pMENU_2').style.borderWidth='2px';
|
||||
document.querySelector('#pMENU_2').style.borderRadius='10%';
|
||||
document.querySelector('#pMENU_3').style.borderStyle='solid';
|
||||
document.querySelector('#pMENU_3').style.borderColor='#00d3e8';
|
||||
document.querySelector('#pMENU_3').style.borderWidth='2px';
|
||||
document.querySelector('#pMENU_3').style.borderRadius='10%';
|
||||
document.querySelectorAll('#pMENU_2 div').forEach((d)=>d.style.padding = '10px');
|
||||
document.querySelectorAll('#pMENU_3 div').forEach((d)=>d.style.padding = '10px');
|
||||
document.querySelectorAll('#topHeader div').forEach((d)=>d.style.width = '100vw');
|
||||
document.querySelectorAll('#disp div')[0].style.width = '100vw';
|
||||
document.getElementById('disp').style.width = '100vw';
|
||||
document.getElementById('disp').style.overflowX = 'hidden';
|
||||
|
||||
|
||||
|
||||
}catch(e){
|
||||
alert("にゃーん");
|
||||
}
|
||||
} catch (e) {}
|
||||
//setTimeout(setStrings,500);
|
||||
}
|
||||
const target = document.getElementById('disp'); // body要素を監視
|
||||
const observer = new MutationObserver( (mutations) => {
|
||||
// observer.disconnect(); // 監視を終了
|
||||
setStrings();
|
||||
});
|
||||
|
||||
// 監視を開始
|
||||
observer.observe(target, {
|
||||
attributes: true, // 属性変化の監視
|
||||
//attributeOldValue: true, // 変化前の属性値を matation.oldValue に格納する
|
||||
//characterData: true, // テキストノードの変化を監視
|
||||
//characterDataOldValue: true, // 変化前のテキストを matation.oldValue に格納する
|
||||
childList: true, // 子ノードの変化を監視
|
||||
//subtree: true // 子孫ノードも監視対象に含める
|
||||
});
|
||||
`;
|
||||
|
||||
const modal_content = `
|
||||
|
||||
const modal_content = document.getElementById('modal_content'); // body要素を監視
|
||||
const modal_observer = new MutationObserver( (mutations) => {
|
||||
// observer.disconnect(); // 監視を終了
|
||||
for(let d of modal_content.getElementsByTagName("button") ){
|
||||
const data = d.onclick.toString().split("\\"")[1];
|
||||
d.onclick = () => window.ReactNativeWebView.postMessage(data)
|
||||
}
|
||||
});
|
||||
|
||||
// 監視を開始
|
||||
modal_observer.observe(modal_content, {
|
||||
//attributes: true, // 属性変化の監視
|
||||
//attributeOldValue: true, // 変化前の属性値を matation.oldValue に格納する
|
||||
//characterData: true, // テキストノードの変化を監視
|
||||
//characterDataOldValue: true, // 変化前のテキストを matation.oldValue に格納する
|
||||
childList: true, // 子ノードの変化を監視
|
||||
//subtree: true // 子孫ノードも監視対象に含める
|
||||
});
|
||||
`;
|
||||
|
||||
const injectJavascriptData =
|
||||
bootData + modal_content + trainIconMaker + textInsert;
|
||||
//地図表示テキスト
|
||||
const injectJavascript = injectJavascriptData(
|
||||
mapSwitch,
|
||||
iconSetting,
|
||||
stationMenu
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
//ニュース表示
|
||||
AsyncStorage.getItem("status")
|
||||
.then((d) => {
|
||||
if (d != news) {
|
||||
navigate("news");
|
||||
}
|
||||
if (d != news) navigate("news");
|
||||
})
|
||||
.catch((e) => {
|
||||
navigate("news");
|
||||
});
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
.catch((e) => navigate("news"));
|
||||
|
||||
//列車アイコンスイッチ
|
||||
AsyncStorage.getItem("iconSwitch")
|
||||
.then((d) => {
|
||||
if (d) {
|
||||
@ -825,6 +76,7 @@ modal_observer.observe(modal_content, {
|
||||
)
|
||||
);
|
||||
|
||||
//地図スイッチ
|
||||
AsyncStorage.getItem("mapSwitch")
|
||||
.then((d) => {
|
||||
if (d) {
|
||||
@ -840,6 +92,22 @@ modal_observer.observe(modal_content, {
|
||||
Updates.reloadAsync()
|
||||
)
|
||||
);
|
||||
//駅メニュースイッチ
|
||||
AsyncStorage.getItem("stationSwitch")
|
||||
.then((d) => {
|
||||
if (d) {
|
||||
setStationMenu(d);
|
||||
} else {
|
||||
AsyncStorage.setItem("stationSwitch", "true").then(() =>
|
||||
Updates.reloadAsync()
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch((d) =>
|
||||
AsyncStorage.setItem("stationSwitch", "true").then(() =>
|
||||
Updates.reloadAsync()
|
||||
)
|
||||
);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
@ -863,7 +131,6 @@ modal_observer.observe(modal_content, {
|
||||
allowsBackForwardNavigationGestures={true}
|
||||
setSupportMultipleWindows={true}
|
||||
onNavigationStateChange={(event) => {
|
||||
console.log(event);
|
||||
if (event.url != urlcache) {
|
||||
//URL二重判定回避
|
||||
urlcache = event.url;
|
||||
@ -885,13 +152,58 @@ modal_observer.observe(modal_content, {
|
||||
}
|
||||
}}
|
||||
onMessage={(event) => {
|
||||
console.log(event.nativeEvent.data);
|
||||
if (event.nativeEvent.data.includes("PopUpMenu")) {
|
||||
const selectedStationPDFAddress = event.nativeEvent.data
|
||||
.split(",")[3]
|
||||
.replace("'", "")
|
||||
.replace("'", "");
|
||||
|
||||
if (!originalStationList) alert("originalStationListがありません");
|
||||
const findStationEachLine = (selectLine) => {
|
||||
let NearStation = selectLine.filter(
|
||||
(d) => d.StationTimeTable == selectedStationPDFAddress
|
||||
);
|
||||
return NearStation;
|
||||
};
|
||||
|
||||
const lineList = [
|
||||
"予讃線",
|
||||
"松宇線",
|
||||
"伊予灘線",
|
||||
"土讃線",
|
||||
"窪川線",
|
||||
"高徳線",
|
||||
"徳島線",
|
||||
"鳴門線",
|
||||
"瀬戸大橋線",
|
||||
];
|
||||
let returnDataBase = lineList
|
||||
.map((d) => findStationEachLine(originalStationList[d]))
|
||||
.filter((d) => d.length > 0)
|
||||
.reduce((pre, current) => {
|
||||
pre.push(...current);
|
||||
return pre;
|
||||
}, []);
|
||||
if (returnDataBase.length) {
|
||||
let currentStation =
|
||||
currentStation == undefined ? [] : currentStation;
|
||||
setStationBoardData(returnDataBase);
|
||||
StationBoardAcSR.current?.setModalVisible();
|
||||
} else {
|
||||
setStationBoardData(undefined);
|
||||
StationBoardAcSR.current?.hide();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
navigate("trainbase", { info: event.nativeEvent.data });
|
||||
}}
|
||||
injectedJavaScript={injectJavascriptData}
|
||||
injectedJavaScript={injectJavascript}
|
||||
/>
|
||||
<TouchableOpacity
|
||||
onPress={() => navigate("trainMenu", { webview, stationData })}
|
||||
onPress={() =>
|
||||
navigate("trainMenu", { webview, stationData: mapsStationData })
|
||||
}
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: Platform.OS == "ios" ? Constants.statusBarHeight : 0,
|
||||
@ -924,6 +236,12 @@ modal_observer.observe(modal_content, {
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</TouchableOpacity>
|
||||
|
||||
<StationDeteilView
|
||||
StationBoardAcSR={StationBoardAcSR}
|
||||
currentStation={stationBoardData}
|
||||
originalStationList={originalStationList}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
74
TestArea.js
74
TestArea.js
@ -1,74 +0,0 @@
|
||||
import React, { Component, useEffect, useState } from "react";
|
||||
import { StatusBar, View, ScrollView, Linking, Text } from "react-native";
|
||||
import Constants from "expo-constants";
|
||||
import { ListItem } from "react-native-elements";
|
||||
import Icon from "react-native-vector-icons/Entypo";
|
||||
import StatusbarDetect from "./StatusbarDetect";
|
||||
var Status = StatusbarDetect();
|
||||
let a = [];
|
||||
export default function TestArea(props) {
|
||||
const [data, setdata] = useState(null);
|
||||
useEffect(() => {
|
||||
data == null
|
||||
? test().then((res) => {
|
||||
//console.log(res);
|
||||
setdata(res);
|
||||
})
|
||||
: null;
|
||||
}, [data]);
|
||||
return (
|
||||
<View style={{ height: "100%", paddingTop: Constants.statusBarHeight }}>
|
||||
{Status}
|
||||
<ScrollView>
|
||||
<Text>TEST AREA!!</Text>
|
||||
{data}
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
async function test() {
|
||||
return fetch("https://train.jr-shikoku.co.jp/g?arg1=train&arg2=train", {
|
||||
headers: {
|
||||
authority: "train.jr-shikoku.co.jp",
|
||||
"cache-control": "no-cache",
|
||||
pragma: "no-cache",
|
||||
"if-modified-since": "Thu, 01 Jun 1970 00:00:00 GMT",
|
||||
accept: "*/*",
|
||||
"sec-fetch-site": "same-origin",
|
||||
"sec-fetch-mode": "cors",
|
||||
referer: "https://train.jr-shikoku.co.jp/sp.html",
|
||||
},
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((D) => {
|
||||
let d = [];
|
||||
D.forEach((element) => {
|
||||
console.log(element);
|
||||
d.push(
|
||||
<ListItem
|
||||
title={
|
||||
"Direction:" +
|
||||
element.Direction +
|
||||
" Index:" +
|
||||
element.Index +
|
||||
" Line:" +
|
||||
element.Line +
|
||||
" Pos:" +
|
||||
element.Pos +
|
||||
" PosNum:" +
|
||||
element.PosNum +
|
||||
" TrainNum:" +
|
||||
element.TrainNum +
|
||||
" Type:" +
|
||||
element.Type +
|
||||
" Delay:" +
|
||||
element.delay
|
||||
}
|
||||
/>
|
||||
);
|
||||
});
|
||||
a = d;
|
||||
return d;
|
||||
});
|
||||
}
|
167
components/ActionSheetComponents/JRSTraInfo.js
Normal file
167
components/ActionSheetComponents/JRSTraInfo.js
Normal file
@ -0,0 +1,167 @@
|
||||
import React, { Component, useRef, useState, useEffect } from "react";
|
||||
import {
|
||||
StatusBar,
|
||||
Platform,
|
||||
View,
|
||||
LayoutAnimation,
|
||||
ScrollView,
|
||||
Linking,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
} from "react-native";
|
||||
import Image from "react-native-remote-svg";
|
||||
import Constants from "expo-constants";
|
||||
import { List, ListItem } from "native-base";
|
||||
import Icon from "react-native-vector-icons/Entypo";
|
||||
import * as Location from "expo-location";
|
||||
import StatusbarDetect from "../../StatusbarDetect";
|
||||
var Status = StatusbarDetect();
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import AutoHeightImage from "react-native-auto-height-image";
|
||||
import {
|
||||
widthPercentageToDP as wp,
|
||||
heightPercentageToDP as hp,
|
||||
} from "react-native-responsive-screen";
|
||||
import {
|
||||
FontAwesome,
|
||||
Fontisto,
|
||||
Foundation,
|
||||
Ionicons,
|
||||
MaterialCommunityIcons,
|
||||
} from "@expo/vector-icons";
|
||||
import * as WebBrowser from "expo-web-browser";
|
||||
import ActionSheet from "react-native-actions-sheet";
|
||||
import LottieView from "lottie-react-native";
|
||||
import SvgUri from "react-native-svg-uri";
|
||||
export const JRSTraInfo = (props) => {
|
||||
const {
|
||||
JRSTraInfoEXAcSR,
|
||||
getTime,
|
||||
loadingDelayData,
|
||||
setLoadingDelayData,
|
||||
delayData,
|
||||
} = props;
|
||||
return (
|
||||
<ActionSheet
|
||||
ref={JRSTraInfoEXAcSR}
|
||||
gestureEnabled
|
||||
CustomHeaderComponent={() => { }}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: "#0099CC",
|
||||
borderRadius: 5,
|
||||
borderColor: "dark",
|
||||
borderWidth: 1,
|
||||
}}
|
||||
>
|
||||
<View style={{ height: 26, width: "100%" }}>
|
||||
<View
|
||||
style={{
|
||||
height: 6,
|
||||
width: 45,
|
||||
borderRadius: 100,
|
||||
backgroundColor: "#f0f0f0",
|
||||
marginVertical: 10,
|
||||
alignSelf: "center",
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<View
|
||||
style={{ padding: 10, flexDirection: "row", alignItems: "center" }}
|
||||
>
|
||||
<Text style={{ fontSize: 30, fontWeight: "bold", color: "white" }}>
|
||||
列車遅延速報EX
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
{/* <TouchableOpacity style={{padding:10,backgroundColor:"white",alignContent:"center"}} onPress={() => {doFetch()}}>
|
||||
<Text style={{fontSize:20,fontWeight:"bold",color:"#0099CC"}}>最新の情報へ更新</Text>
|
||||
</TouchableOpacity> */}
|
||||
<Text style={{ fontSize: 30, fontWeight: "bold", color: "white" }}>
|
||||
{getTime
|
||||
? getTime.toLocaleTimeString("ja-JP").split(":")[0] +
|
||||
":" +
|
||||
getTime.toLocaleTimeString("ja-JP").split(":")[1]
|
||||
: NaN}{" "}
|
||||
</Text>
|
||||
<Ionicons
|
||||
name="reload"
|
||||
color="white"
|
||||
size={30}
|
||||
style={{ margin: 5 }}
|
||||
onPress={() => {
|
||||
LayoutAnimation.easeInEaseOut(), setLoadingDelayData(true);
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<ScrollView>
|
||||
<View
|
||||
style={{
|
||||
padding: 10,
|
||||
backgroundColor: "white",
|
||||
borderBottomLeftRadius: 5,
|
||||
borderBottomRightRadius: 5,
|
||||
}}
|
||||
>
|
||||
{loadingDelayData ? (
|
||||
<View style={{ alignItems: "center" }}>
|
||||
<LottieView
|
||||
autoPlay
|
||||
loop
|
||||
style={{ width: 150, height: 150, backgroundColor: "#fff" }}
|
||||
source={require("../../assets/51690-loading-diamonds.json")}
|
||||
/>
|
||||
</View>
|
||||
) : delayData ? (
|
||||
delayData.map((d) => {
|
||||
let data = d.split(" ");
|
||||
return (
|
||||
<View style={{ flexDirection: "row" }}>
|
||||
<Text style={{ flex: 15, fontSize: 20 }}>
|
||||
{data[0].replace("\n", "")}
|
||||
</Text>
|
||||
<Text style={{ flex: 5, fontSize: 20 }}>{data[1]}</Text>
|
||||
<Text style={{ flex: 6, fontSize: 20 }}>{data[3]}</Text>
|
||||
</View>
|
||||
);
|
||||
})
|
||||
) : (
|
||||
<Text>現在、5分以上の遅れはありません。</Text>
|
||||
)}
|
||||
</View>
|
||||
|
||||
<View style={{ padding: 10 }}>
|
||||
<Text style={{ fontSize: 20, fontWeight: "bold", color: "white" }}>
|
||||
列車遅延情報EXについて
|
||||
</Text>
|
||||
<Text style={{ color: "white" }}>
|
||||
列車遅延情報をJR四国公式列車運行情報より5分毎に取得します。Twitterにて投稿している内容と同一のものとなります。
|
||||
</Text>
|
||||
</View>
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
padding: 10,
|
||||
flexDirection: "row",
|
||||
borderColor: "white",
|
||||
borderWidth: 1,
|
||||
margin: 10,
|
||||
borderRadius: 5,
|
||||
alignItems: "center",
|
||||
}}
|
||||
onPress={() => Linking.openURL("https://twitter.com/JRSTrainfoEX")}
|
||||
>
|
||||
<MaterialCommunityIcons name="twitter" color="white" size={30} />
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||
TwitterBOTはこちら!
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||
→
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</ActionSheet>
|
||||
);
|
||||
};
|
@ -1,4 +1,47 @@
|
||||
import React, { Component, useRef, useState, useEffect } from "react";
|
||||
import {
|
||||
StatusBar,
|
||||
Platform,
|
||||
View,
|
||||
LayoutAnimation,
|
||||
ScrollView,
|
||||
Linking,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
} from "react-native";
|
||||
import Image from "react-native-remote-svg";
|
||||
import Constants from "expo-constants";
|
||||
import { List, ListItem } from "native-base";
|
||||
import Icon from "react-native-vector-icons/Entypo";
|
||||
import * as Location from "expo-location";
|
||||
import StatusbarDetect from "../../StatusbarDetect";
|
||||
var Status = StatusbarDetect();
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import AutoHeightImage from "react-native-auto-height-image";
|
||||
import {
|
||||
widthPercentageToDP as wp,
|
||||
heightPercentageToDP as hp,
|
||||
} from "react-native-responsive-screen";
|
||||
import {
|
||||
FontAwesome,
|
||||
Fontisto,
|
||||
Foundation,
|
||||
Ionicons,
|
||||
MaterialCommunityIcons,
|
||||
} from "@expo/vector-icons";
|
||||
import * as WebBrowser from "expo-web-browser";
|
||||
import ActionSheet from "react-native-actions-sheet";
|
||||
import LottieView from "lottie-react-native";
|
||||
import SvgUri from "react-native-svg-uri";
|
||||
import Sign from "../../components/駅名表/Sign";
|
||||
|
||||
import { UsefulBox } from "../atom/UsefulBox";
|
||||
import { TicketBox } from "../atom/TicketBox";
|
||||
import { TextBox } from "../atom/TextBox";
|
||||
|
||||
export const StationDeteilView = (props) => {
|
||||
const { StationBoardAcSR, currentStation, originalStationList } = props;
|
||||
|
||||
return (
|
||||
<ActionSheet
|
||||
ref={StationBoardAcSR}
|
||||
|
23
components/atom/TextBox.js
Normal file
23
components/atom/TextBox.js
Normal file
@ -0,0 +1,23 @@
|
||||
import { TouchableOpacity, View } from "react-native";
|
||||
|
||||
export const TextBox = (props) => {
|
||||
const { backgroundColor, flex, onPressButton, children } = props;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
flex: flex,
|
||||
backgroundColor: backgroundColor,
|
||||
padding: 10,
|
||||
height: 70,
|
||||
alignItems: "center",
|
||||
alignContent: "center",
|
||||
margin: 2,
|
||||
}}
|
||||
onPress={onPressButton}
|
||||
>
|
||||
<View style={{ flex: 1 }} />
|
||||
{children}
|
||||
<View style={{ flex: 1 }} />
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
24
components/atom/TicketBox.js
Normal file
24
components/atom/TicketBox.js
Normal file
@ -0,0 +1,24 @@
|
||||
import { TouchableOpacity, Text } from "react-native";
|
||||
|
||||
export const TicketBox = (props) => {
|
||||
const { icon, backgroundColor, flex, onPressButton, children } = props;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
flex: flex,
|
||||
backgroundColor: backgroundColor,
|
||||
borderColor: "#0099CC",
|
||||
padding: 10,
|
||||
borderWidth: 1,
|
||||
margin: 2,
|
||||
alignItems: "center",
|
||||
}}
|
||||
onPress={onPressButton}
|
||||
>
|
||||
<Text style={{ color: "white", fontWeight: "bold", fontSize: 18 }}>
|
||||
{children}
|
||||
</Text>
|
||||
{icon}
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
22
components/atom/UsefulBox.js
Normal file
22
components/atom/UsefulBox.js
Normal file
@ -0,0 +1,22 @@
|
||||
import { TouchableOpacity, Text } from "react-native";
|
||||
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
export const UsefulBox = (props) => {
|
||||
const { icon, backgroundColor, flex, onPressButton, children } = props;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
flex: flex,
|
||||
backgroundColor: backgroundColor,
|
||||
padding: 10,
|
||||
alignItems: "center",
|
||||
margin: 2,
|
||||
}}
|
||||
onPress={onPressButton}
|
||||
>
|
||||
<MaterialCommunityIcons name={icon} color="white" size={50} />
|
||||
<Text style={{ color: "white", fontWeight: "bold", fontSize: 18 }}>
|
||||
{children}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
@ -12,15 +12,12 @@ export default function Setting(props) {
|
||||
} = props;
|
||||
const [iconSetting, setIconSetting] = useState(undefined);
|
||||
const [mapSwitch, setMapSwitch] = useState(undefined);
|
||||
const [stationMenu, setStationMenu] = useState(undefined);
|
||||
useEffect(() => {
|
||||
AsyncStorage.getItem("iconSwitch").then((d) => {
|
||||
setIconSetting(d);
|
||||
});
|
||||
AsyncStorage.getItem("mapSwitch").then((d) => {
|
||||
setMapSwitch(d);
|
||||
});
|
||||
AsyncStorage.getItem("iconSwitch").then(setIconSetting);
|
||||
AsyncStorage.getItem("mapSwitch").then(setMapSwitch);
|
||||
AsyncStorage.getItem("stationSwitch").then(setStationMenu);
|
||||
}, []);
|
||||
console.log(iconSetting);
|
||||
return (
|
||||
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
|
||||
<View style={{ flex: 1, backgroundColor: "white" }}>
|
||||
@ -86,7 +83,26 @@ export default function Setting(props) {
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
内部バージョン: 4.4.1
|
||||
駅メニューを表示(beta)
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Switch
|
||||
value={stationMenu == "true" ? true : false}
|
||||
color={stationMenu == "true" ? "red" : null}
|
||||
onValueChange={(value) => setStationMenu(value.toString())}
|
||||
/>
|
||||
</View>
|
||||
<View style={{ flexDirection: "row", padding: 10 }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 25,
|
||||
alignItems: "center",
|
||||
alignContent: "center",
|
||||
textAlign: "center",
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
内部バージョン: 4.4.2
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</View>
|
||||
@ -120,6 +136,7 @@ export default function Setting(props) {
|
||||
Promise.all([
|
||||
AsyncStorage.setItem("iconSwitch", iconSetting.toString()),
|
||||
AsyncStorage.setItem("mapSwitch", mapSwitch.toString()),
|
||||
AsyncStorage.setItem("stationSwitch", stationMenu.toString()),
|
||||
]).then(() => {
|
||||
Updates.reloadAsync();
|
||||
});
|
||||
|
@ -14,6 +14,7 @@ import {
|
||||
heightPercentageToDP as hp,
|
||||
} from "react-native-responsive-screen";
|
||||
import { customTrainDataDetector } from "../custom-train-data";
|
||||
import { useInterval } from "../../lib/useInterval";
|
||||
|
||||
let diagramData = undefined;
|
||||
|
||||
@ -58,6 +59,7 @@ export default function LED_vision(props) {
|
||||
const [finalSwitch, setFinalSwitch] = useState(false);
|
||||
const [trainIDSwitch, setTrainIDSwitch] = useState(false);
|
||||
const [trainDescriptionSwitch, setTrainDescriptionSwitch] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=traintimeinfo&arg3=dia",
|
||||
@ -66,117 +68,94 @@ export default function LED_vision(props) {
|
||||
.then((response) => response.text())
|
||||
.then((d) => {
|
||||
const val = d.replace("[\r\n", "").split(",\r\n");
|
||||
let returnData = {};
|
||||
let trainDiagram = {};
|
||||
val.forEach((element) => {
|
||||
try {
|
||||
let data = JSON.parse(element);
|
||||
Object.keys(data).forEach((key) => (returnData[key] = data[key]));
|
||||
Object.keys(data).forEach((key) => (trainDiagram[key] = data[key]));
|
||||
} catch (e) {}
|
||||
});
|
||||
return returnData;
|
||||
setTrainDiagram(trainDiagram);
|
||||
return trainDiagram;
|
||||
})
|
||||
.then((trainDiagram) => {
|
||||
let returnData = {};
|
||||
if (trainDiagram) {
|
||||
Object.keys(trainDiagram).forEach((key) => {
|
||||
if (trainDiagram[key].match(props.station.Station_JP)) {
|
||||
returnData[key] = trainDiagram[key];
|
||||
}
|
||||
});
|
||||
if (!trainDiagram) {
|
||||
setStationDiagram(returnData);
|
||||
return;
|
||||
}
|
||||
setTrainDiagram(trainDiagram);
|
||||
Object.keys(trainDiagram).forEach((key) => {
|
||||
if (trainDiagram[key].match(props.station.Station_JP)) {
|
||||
returnData[key] = trainDiagram[key];
|
||||
}
|
||||
});
|
||||
setStationDiagram(returnData);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const getTime = () => {
|
||||
const returnData = [];
|
||||
const date = new Date();
|
||||
Object.keys(stationDiagram).forEach((d) => {
|
||||
let a = (() => {
|
||||
let returnData = {};
|
||||
stationDiagram[d].split("#").forEach((data) => {
|
||||
if (data.match("着")) {
|
||||
returnData.lastStation = data.split(",着,")[0];
|
||||
let a = {};
|
||||
stationDiagram[d].split("#").forEach((data) => {
|
||||
if (data.match("着")) {
|
||||
a.lastStation = data.split(",着,")[0];
|
||||
}
|
||||
if (data.match(props.station.Station_JP)) {
|
||||
if (data.match(",発,")) {
|
||||
a.time = data.split(",発,")[1];
|
||||
} else {
|
||||
a.time = data.split(",着,")[1];
|
||||
a.lastStation = "当駅止";
|
||||
}
|
||||
if (data.match(props.station.Station_JP)) {
|
||||
if (data.match(",発,")) {
|
||||
returnData.time = data.split(",発,")[1];
|
||||
} else {
|
||||
returnData.time = data.split(",着,")[1];
|
||||
returnData.lastStation = "当駅止";
|
||||
}
|
||||
}
|
||||
});
|
||||
return returnData;
|
||||
})();
|
||||
}
|
||||
});
|
||||
returnData.push({ train: d, time: a.time, lastStation: a.lastStation });
|
||||
});
|
||||
|
||||
return returnData.sort((a, b) => {
|
||||
if (parseInt(a.time.split(":")[0]) < parseInt(b.time.split(":")[0])) {
|
||||
return -1;
|
||||
} else if (
|
||||
parseInt(a.time.split(":")[0]) > parseInt(b.time.split(":")[0])
|
||||
) {
|
||||
return 1;
|
||||
} else if (
|
||||
parseInt(a.time.split(":")[1]) < parseInt(b.time.split(":")[1])
|
||||
) {
|
||||
return -1;
|
||||
} else if (
|
||||
parseInt(a.time.split(":")[1]) > parseInt(b.time.split(":")[1])
|
||||
) {
|
||||
return 1;
|
||||
switch (true) {
|
||||
case parseInt(a.time.split(":")[0]) < parseInt(b.time.split(":")[0]):
|
||||
return -1;
|
||||
case parseInt(a.time.split(":")[0]) > parseInt(b.time.split(":")[0]):
|
||||
return 1;
|
||||
case parseInt(a.time.split(":")[1]) < parseInt(b.time.split(":")[1]):
|
||||
return -1;
|
||||
case parseInt(a.time.split(":")[1]) > parseInt(b.time.split(":")[1]):
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
};
|
||||
const trainTimeAndNumber = stationDiagram != null ? getTime() : null;
|
||||
useEffect(() => {
|
||||
const getCurrentTrain = () =>
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=train&arg2=train",
|
||||
HeaderConfig
|
||||
)
|
||||
.then((response) => response.json())
|
||||
.then((d) => d.map((x) => ({ num: x.TrainNum, delay: x.delay })))
|
||||
.then((d) => setCurrentTrain(d));
|
||||
getCurrentTrain();
|
||||
const currentTrainInterval = setInterval(() => getCurrentTrain(), 15000);
|
||||
return () => clearInterval(currentTrainInterval);
|
||||
}, []);
|
||||
const getCurrentTrain = () =>
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=train&arg2=train",
|
||||
HeaderConfig
|
||||
)
|
||||
.then((response) => response.json())
|
||||
.then((d) => d.map((x) => ({ num: x.TrainNum, delay: x.delay })))
|
||||
.then(setCurrentTrain);
|
||||
|
||||
useEffect(getCurrentTrain, []);
|
||||
|
||||
useInterval(getCurrentTrain, 15000);
|
||||
|
||||
const filtering = (d) => currentTrain.map((m) => m.num).includes(d.train);
|
||||
console.log(new Date());
|
||||
const timeFiltering = (d) => {
|
||||
const date = new Date();
|
||||
const newDate = new Date();
|
||||
let data = d.time.split(":");
|
||||
let delay = isNaN(
|
||||
currentTrain.filter((data) => data.num == d.train)[0].delay
|
||||
)
|
||||
let delay = isNaN(currentTrain.filter((t) => t.num == d.train)[0].delay)
|
||||
? 0
|
||||
: currentTrain.filter((data) => data.num == d.train)[0].delay;
|
||||
: currentTrain.filter((t) => t.num == d.train)[0].delay;
|
||||
|
||||
date.setHours(parseInt(data[0]));
|
||||
date.setMinutes(parseInt(data[1]) + parseInt(delay));
|
||||
console.log(date);
|
||||
console.log(newDate);
|
||||
if (!(newDate > date)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
const finalFiltering = (d) => {
|
||||
if (finalSwitch) {
|
||||
return true;
|
||||
} else {
|
||||
if (d.lastStation == "当駅止") {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
@ -208,122 +187,114 @@ export default function LED_vision(props) {
|
||||
{trainTimeAndNumber
|
||||
? currentTrain &&
|
||||
trainTimeAndNumber
|
||||
.filter(filtering)
|
||||
.filter((d) => currentTrain.map((m) => m.num).includes(d.train))
|
||||
.filter(timeFiltering)
|
||||
.filter(finalFiltering)
|
||||
.map((d, index) => [
|
||||
<View
|
||||
style={{
|
||||
alignContent: "center",
|
||||
alignItems: "center",
|
||||
width: "94%",
|
||||
marginVertical: 5,
|
||||
marginHorizontal: "3%",
|
||||
backgroundColor: "#000",
|
||||
flexDirection: "row",
|
||||
}}
|
||||
>
|
||||
<View style={{ flex: 9 }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: (() => {
|
||||
if (
|
||||
customTrainDataDetector(d.train).trainName.length > 6
|
||||
) {
|
||||
return 15;
|
||||
} else {
|
||||
return 20;
|
||||
}
|
||||
})(),
|
||||
color: (() => {
|
||||
switch (customTrainDataDetector(d.train).type) {
|
||||
case "Rapid":
|
||||
return "aqua";
|
||||
case "LTDEXP":
|
||||
return "red";
|
||||
case "NightLTDEXP":
|
||||
return "red";
|
||||
case "Normal":
|
||||
return "white";
|
||||
}
|
||||
})(),
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{trainIDSwitch
|
||||
? d.train
|
||||
: (() => {
|
||||
switch (customTrainDataDetector(d.train).type) {
|
||||
.filter((d) => !!finalSwitch || d.lastStation != "当駅止")
|
||||
.map((d, index) => {
|
||||
const train = customTrainDataDetector(d.train);
|
||||
return [
|
||||
<View
|
||||
style={{
|
||||
alignContent: "center",
|
||||
alignItems: "center",
|
||||
width: "94%",
|
||||
marginVertical: 5,
|
||||
marginHorizontal: "3%",
|
||||
backgroundColor: "#000",
|
||||
flexDirection: "row",
|
||||
}}
|
||||
>
|
||||
<View style={{ flex: 9 }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: train.trainName.length > 6 ? 15 : 20,
|
||||
color: (() => {
|
||||
switch (train.type) {
|
||||
case "Rapid":
|
||||
return "快速";
|
||||
return "aqua";
|
||||
case "LTDEXP":
|
||||
return "特急";
|
||||
return "red";
|
||||
case "NightLTDEXP":
|
||||
return "寝台特急";
|
||||
return "red";
|
||||
case "Normal":
|
||||
return "普通列車";
|
||||
return "white";
|
||||
}
|
||||
})() +
|
||||
" " +
|
||||
customTrainDataDetector(d.train).trainName +
|
||||
(() => {
|
||||
if (
|
||||
customTrainDataDetector(d.train).trainNumDistance !=
|
||||
null
|
||||
) {
|
||||
return (
|
||||
parseInt(
|
||||
})(),
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{trainIDSwitch
|
||||
? d.train
|
||||
: (() => {
|
||||
switch (train.type) {
|
||||
case "Rapid":
|
||||
return "快速";
|
||||
case "LTDEXP":
|
||||
return "特急";
|
||||
case "NightLTDEXP":
|
||||
return "寝台特急";
|
||||
case "Normal":
|
||||
return "普通列車";
|
||||
}
|
||||
})() +
|
||||
" " +
|
||||
train.trainName +
|
||||
(!train.trainNumDistance
|
||||
? ""
|
||||
: parseInt(
|
||||
d.train.replace("M", "").replace("D", "")
|
||||
) -
|
||||
customTrainDataDetector(d.train)
|
||||
.trainNumDistance +
|
||||
"号"
|
||||
);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
})()}
|
||||
</Text>
|
||||
</View>
|
||||
<View style={{ flex: 4, flexDirection: "row" }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: d.lastStation.length > 4 ? 15 : 20,
|
||||
color: "white",
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{d.lastStation}
|
||||
</Text>
|
||||
</View>
|
||||
<View style={{ flex: 3 }}>
|
||||
<Text
|
||||
style={{ fontSize: 20, color: "white", fontWeight: "bold" }}
|
||||
>
|
||||
{d.time}
|
||||
</Text>
|
||||
</View>
|
||||
<View style={{ flex: 4 }}>
|
||||
<Text
|
||||
style={{ fontSize: 20, color: "white", fontWeight: "bold" }}
|
||||
>
|
||||
{(() => {
|
||||
let data = currentTrain.filter(
|
||||
(data) => data.num == d.train
|
||||
)[0].delay;
|
||||
if (isNaN(data)) {
|
||||
return data;
|
||||
} else if (data == 0) {
|
||||
return "定刻通り";
|
||||
} else {
|
||||
return data + "分遅れ";
|
||||
}
|
||||
})()}
|
||||
</Text>
|
||||
</View>
|
||||
</View>,
|
||||
Boolean(trainDescriptionSwitch) &&
|
||||
Boolean(customTrainDataDetector(d.train).info) && (
|
||||
train.trainNumDistance +
|
||||
"号")}
|
||||
</Text>
|
||||
</View>
|
||||
<View style={{ flex: 4, flexDirection: "row" }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: d.lastStation.length > 4 ? 15 : 20,
|
||||
color: "white",
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{d.lastStation}
|
||||
</Text>
|
||||
</View>
|
||||
<View style={{ flex: 3 }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 20,
|
||||
color: "white",
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{d.time}
|
||||
</Text>
|
||||
</View>
|
||||
<View style={{ flex: 4 }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 20,
|
||||
color: "white",
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{(() => {
|
||||
const delay = currentTrain.filter(
|
||||
(a) => a.num == d.train
|
||||
)[0].delay;
|
||||
switch (true) {
|
||||
case isNaN(delay):
|
||||
return delay;
|
||||
case delay == 0:
|
||||
return "定刻通り";
|
||||
default:
|
||||
return delay + "分遅れ";
|
||||
}
|
||||
})()}
|
||||
</Text>
|
||||
</View>
|
||||
</View>,
|
||||
trainDescriptionSwitch && !!train.info && (
|
||||
<View
|
||||
style={{
|
||||
alignContent: "center",
|
||||
@ -344,12 +315,13 @@ export default function LED_vision(props) {
|
||||
}}
|
||||
>
|
||||
{" "}
|
||||
> {customTrainDataDetector(d.train).info}
|
||||
> {train.info}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
),
|
||||
])
|
||||
];
|
||||
})
|
||||
: null}
|
||||
<View style={{ flexDirection: "row", padding: 10 }}>
|
||||
<Text
|
||||
@ -363,10 +335,7 @@ export default function LED_vision(props) {
|
||||
>
|
||||
種別名 / 列番
|
||||
</Text>
|
||||
<Switch
|
||||
value={trainIDSwitch}
|
||||
onValueChange={(value) => setTrainIDSwitch(!trainIDSwitch)}
|
||||
/>
|
||||
<Switch value={trainIDSwitch} onValueChange={setTrainIDSwitch} />
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text
|
||||
style={{
|
||||
@ -381,9 +350,7 @@ export default function LED_vision(props) {
|
||||
</Text>
|
||||
<Switch
|
||||
value={trainDescriptionSwitch}
|
||||
onValueChange={(value) =>
|
||||
setTrainDescriptionSwitch(!trainDescriptionSwitch)
|
||||
}
|
||||
onValueChange={setTrainDescriptionSwitch}
|
||||
/>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text
|
||||
@ -397,10 +364,7 @@ export default function LED_vision(props) {
|
||||
>
|
||||
当駅止表示
|
||||
</Text>
|
||||
<Switch
|
||||
value={finalSwitch}
|
||||
onValueChange={(value) => setFinalSwitch(!finalSwitch)}
|
||||
/>
|
||||
<Switch value={finalSwitch} onValueChange={setFinalSwitch} />
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
|
@ -12,6 +12,7 @@ import {
|
||||
widthPercentageToDP as wp,
|
||||
heightPercentageToDP as hp,
|
||||
} from "react-native-responsive-screen";
|
||||
import { useInterval } from "../../lib/useInterval";
|
||||
|
||||
export default function Sign(props) {
|
||||
const { currentStation, originalStationList, oP } = props;
|
||||
@ -25,6 +26,7 @@ export default function Sign(props) {
|
||||
"高徳線",
|
||||
"徳島線",
|
||||
"鳴門線",
|
||||
"瀬戸大橋線",
|
||||
];
|
||||
let returnData;
|
||||
lineList.forEach((d) => {
|
||||
@ -41,271 +43,216 @@ export default function Sign(props) {
|
||||
return returnData;
|
||||
};
|
||||
const [nexPrePosition, setNexPrePosition] = useState(0);
|
||||
useEffect(() => {
|
||||
if (currentStation) {
|
||||
if (currentStation.length > 1) {
|
||||
let stationCount = setInterval(() => {
|
||||
LayoutAnimation.easeInEaseOut();
|
||||
if (nexPrePosition + 1 == currentStation.length) {
|
||||
setNexPrePosition(0);
|
||||
} else {
|
||||
setNexPrePosition(nexPrePosition + 1);
|
||||
}
|
||||
}, 1000);
|
||||
return () => clearInterval(stationCount);
|
||||
}
|
||||
}
|
||||
}, [currentStation]);
|
||||
useInterval(() => {
|
||||
LayoutAnimation.easeInEaseOut();
|
||||
setNexPrePosition(
|
||||
nexPrePosition + 1 == currentStation.length ? 0 : nexPrePosition + 1
|
||||
);
|
||||
}, 2000);
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
width: wp("80%"),
|
||||
height: (wp("80%") / 20) * 9,
|
||||
borderColor: "#2E94BB",
|
||||
borderWidth: 1,
|
||||
margin: 10,
|
||||
marginHorizontal: wp("10%"),
|
||||
}}
|
||||
/* onPress={()=> !stationName.今.JrHpUrl || Linking.openURL(stationName.今.JrHpUrl)} */ onPress={
|
||||
oP
|
||||
}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
position: "absolute",
|
||||
bottom: "0%",
|
||||
left: "0%",
|
||||
width: "100%",
|
||||
height: "30%",
|
||||
backgroundColor: "#2E94BB",
|
||||
}}
|
||||
/>
|
||||
<Text
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: "2%",
|
||||
left: "2%",
|
||||
fontWeight: "bold",
|
||||
fontSize: parseInt("30%"),
|
||||
color: "#2E94BB",
|
||||
}}
|
||||
>
|
||||
JR
|
||||
</Text>
|
||||
{currentStation.map((d, index, array) => (
|
||||
<View
|
||||
style={{
|
||||
position: "absolute",
|
||||
alignContent: "center",
|
||||
alignItems: "center",
|
||||
top:
|
||||
(() => {
|
||||
if (array.length == 1) return 20;
|
||||
else if (index == 0) return 5;
|
||||
else if (index == 1) return 35;
|
||||
else return 20;
|
||||
})() + "%",
|
||||
right: "10%",
|
||||
width: wp("10%"),
|
||||
height: wp("10%"),
|
||||
borderColor: "#2E94BB",
|
||||
borderWidth: parseInt("2%"),
|
||||
borderRadius: parseInt("100%"),
|
||||
}}
|
||||
>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: parseInt("20%") }}>{d.StationNumber}</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</View>
|
||||
))}
|
||||
<View
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: "10%",
|
||||
alignContent: "center",
|
||||
flexDirection: "row",
|
||||
}}
|
||||
>
|
||||
<View style={{ flex: 1 }} />
|
||||
<View style={{ alignItems: "center" }}>
|
||||
{/* <Text style={{fontWeight:"bold",fontSize:parseInt("15%"),color:"#005170"}}>{stationName.今.LineName}</Text> */}
|
||||
<Text
|
||||
style={{
|
||||
fontWeight: "bold",
|
||||
fontSize: parseInt("40%"),
|
||||
color: "#005170",
|
||||
}}
|
||||
>
|
||||
{currentStation[0].Station_JP}
|
||||
</Text>
|
||||
<Text
|
||||
style={{
|
||||
fontWeight: "bold",
|
||||
fontSize: parseInt("15%"),
|
||||
color: "#005170",
|
||||
}}
|
||||
>
|
||||
{currentStation[0].Station_EN}
|
||||
</Text>
|
||||
</View>
|
||||
<View style={{ flex: 1 }} />
|
||||
</View>
|
||||
<View
|
||||
style={{
|
||||
position: "absolute",
|
||||
bottom: "0%",
|
||||
height: "30%",
|
||||
width: "100%",
|
||||
alignItems: "center",
|
||||
flexDirection: "column",
|
||||
}}
|
||||
>
|
||||
<TouchableOpacity style={styleSheet.外枠} onPress={oP}>
|
||||
<StationNumberMaker currentStation={currentStation} />
|
||||
<StationNameArea currentStation={currentStation} />
|
||||
<Text style={styleSheet.JRStyle}>JR</Text>
|
||||
<View style={styleSheet.下帯} />
|
||||
<View style={styleSheet.下帯内容}>
|
||||
{(() => {
|
||||
return currentStation.map((currentStation) => {
|
||||
let [preStation, nexStation] = getPreNextStation(currentStation);
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
flexDirection: "row",
|
||||
alignContent: "center",
|
||||
}}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
flexDirection: "row",
|
||||
alignContent: "center",
|
||||
}}
|
||||
>
|
||||
{preStation && [
|
||||
<Text
|
||||
style={{
|
||||
fontWeight: "bold",
|
||||
fontSize: parseInt("20%"),
|
||||
color: "white",
|
||||
paddingHorizontal: 10,
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
◀
|
||||
</Text>,
|
||||
<View
|
||||
style={{
|
||||
alignContent: "center",
|
||||
alignItems: "center",
|
||||
width: wp("8%"),
|
||||
height: wp("8%"),
|
||||
margin: wp("1%"),
|
||||
borderColor: "white",
|
||||
borderWidth: parseInt("2%"),
|
||||
borderRadius: parseInt("100%"),
|
||||
}}
|
||||
>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text
|
||||
style={{ fontSize: parseInt("10%"), color: "white" }}
|
||||
>
|
||||
{preStation.StationNumber}
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</View>,
|
||||
<View style={{ flex: 1, alignItems: "flex-start" }}>
|
||||
<Text
|
||||
style={{
|
||||
fontWeight: "bold",
|
||||
fontSize: parseInt("15%"),
|
||||
color: "white",
|
||||
flex: 1,
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
{preStation.Station_JP}
|
||||
</Text>
|
||||
<Text
|
||||
style={{
|
||||
fontWeight: "bold",
|
||||
fontSize: parseInt("15%"),
|
||||
color: "white",
|
||||
flex: 1,
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
{preStation.Station_EN}
|
||||
</Text>
|
||||
</View>,
|
||||
]}
|
||||
</View>
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
flexDirection: "row",
|
||||
alignContent: "center",
|
||||
}}
|
||||
>
|
||||
{nexStation && [
|
||||
<View style={{ flex: 1, alignItems: "flex-end" }}>
|
||||
<Text
|
||||
style={{
|
||||
fontWeight: "bold",
|
||||
fontSize: parseInt("15%"),
|
||||
color: "white",
|
||||
flex: 1,
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
{nexStation.Station_JP}
|
||||
</Text>
|
||||
<Text
|
||||
style={{
|
||||
fontWeight: "bold",
|
||||
fontSize: parseInt("15%"),
|
||||
color: "white",
|
||||
flex: 1,
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
{nexStation.Station_EN}
|
||||
</Text>
|
||||
</View>,
|
||||
<View
|
||||
style={{
|
||||
alignContent: "center",
|
||||
alignItems: "center",
|
||||
width: wp("8%"),
|
||||
height: wp("8%"),
|
||||
margin: wp("1%"),
|
||||
borderColor: "white",
|
||||
borderWidth: parseInt("2%"),
|
||||
borderRadius: parseInt("100%"),
|
||||
}}
|
||||
>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text
|
||||
style={{ fontSize: parseInt("10%"), color: "white" }}
|
||||
>
|
||||
{nexStation.StationNumber}
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</View>,
|
||||
<Text
|
||||
style={{
|
||||
fontWeight: "bold",
|
||||
fontSize: parseInt("20%"),
|
||||
color: "white",
|
||||
paddingHorizontal: 10,
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
▶
|
||||
</Text>,
|
||||
]}
|
||||
</View>
|
||||
let [preStation, nexStation] = getPreNextStation(
|
||||
currentStation[nexPrePosition]
|
||||
);
|
||||
return (
|
||||
<View style={styleSheet.下枠フレーム}>
|
||||
<View style={styleSheet.下枠フレーム}>
|
||||
{preStation && (
|
||||
<>
|
||||
<Text style={styleSheet.下枠左右マーク}>◀</Text>
|
||||
{preStation.StationNumber && (
|
||||
<View style={styleSheet.下枠駅ナンバー}>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text
|
||||
style={{
|
||||
fontSize: parseInt("10%"),
|
||||
color: "white",
|
||||
}}
|
||||
>
|
||||
{preStation.StationNumber}
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</View>
|
||||
)}
|
||||
<StationName
|
||||
stringData={preStation}
|
||||
ss={{ flex: 1, alignItems: "flex-start" }}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
})[nexPrePosition];
|
||||
<View style={styleSheet.下枠フレーム}>
|
||||
{nexStation && (
|
||||
<>
|
||||
<StationName
|
||||
stringData={nexStation}
|
||||
ss={{ flex: 1, alignItems: "flex-end" }}
|
||||
/>
|
||||
{nexStation.StationNumber && (
|
||||
<View style={styleSheet.下枠駅ナンバー}>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text
|
||||
style={{ fontSize: parseInt("10%"), color: "white" }}
|
||||
>
|
||||
{nexStation.StationNumber}
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</View>
|
||||
)}
|
||||
<Text style={styleSheet.下枠左右マーク}>▶</Text>
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
})()}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
|
||||
const StationNumberMaker = (props) => {
|
||||
return props.currentStation
|
||||
.filter((d) => (d.StationNumber ? true : false))
|
||||
.map((d, index, array) => (
|
||||
<View
|
||||
style={{
|
||||
position: "absolute",
|
||||
alignContent: "center",
|
||||
alignItems: "center",
|
||||
top:
|
||||
(() => {
|
||||
if (array.length == 1) return 20;
|
||||
else if (index == 0) return 5;
|
||||
else if (index == 1) return 35;
|
||||
else return 20;
|
||||
})() + "%",
|
||||
right: "10%",
|
||||
width: wp("10%"),
|
||||
height: wp("10%"),
|
||||
borderColor: "#2E94BB",
|
||||
borderWidth: parseInt("2%"),
|
||||
borderRadius: parseInt("100%"),
|
||||
}}
|
||||
>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: parseInt("20%") }}>{d.StationNumber}</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</View>
|
||||
));
|
||||
};
|
||||
|
||||
const StationNameArea = (props) => {
|
||||
const { currentStation } = props;
|
||||
return (
|
||||
<View style={styleSheet.stationNameAreaOverWrap}>
|
||||
<View style={{ flex: 1 }} />
|
||||
<View style={{ alignItems: "center" }}>
|
||||
{/* <Text style={{fontWeight:"bold",fontSize:parseInt("15%"),color:"#005170"}}>{stationName.今.LineName}</Text> */}
|
||||
<Text style={styleSheet.Station_JP}>
|
||||
{currentStation[0].Station_JP}
|
||||
</Text>
|
||||
<Text style={styleSheet.Station_EN}>
|
||||
{currentStation[0].Station_EN}
|
||||
</Text>
|
||||
</View>
|
||||
<View style={{ flex: 1 }} />
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
const StationName = (props) => {
|
||||
const { stringData, ss } = props;
|
||||
return (
|
||||
<View style={ss}>
|
||||
<Text style={styleSheet.下枠駅名}>{stringData.Station_JP}</Text>
|
||||
<Text style={styleSheet.下枠駅名}>{stringData.Station_EN}</Text>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
const styleSheet = {
|
||||
外枠: {
|
||||
width: wp("80%"),
|
||||
height: (wp("80%") / 20) * 9,
|
||||
borderColor: "#2E94BB",
|
||||
borderWidth: 1,
|
||||
margin: 10,
|
||||
marginHorizontal: wp("10%"),
|
||||
},
|
||||
下帯: {
|
||||
position: "absolute",
|
||||
bottom: "0%",
|
||||
left: "0%",
|
||||
width: "100%",
|
||||
height: "30%",
|
||||
backgroundColor: "#2E94BB",
|
||||
},
|
||||
JRStyle: {
|
||||
position: "absolute",
|
||||
top: "2%",
|
||||
left: "2%",
|
||||
fontWeight: "bold",
|
||||
fontSize: parseInt("30%"),
|
||||
color: "#2E94BB",
|
||||
},
|
||||
stationNameAreaOverWrap: {
|
||||
position: "absolute",
|
||||
top: "10%",
|
||||
alignContent: "center",
|
||||
flexDirection: "row",
|
||||
},
|
||||
Station_JP: {
|
||||
fontWeight: "bold",
|
||||
fontSize: parseInt("40%"),
|
||||
color: "#005170",
|
||||
},
|
||||
Station_EN: {
|
||||
fontWeight: "bold",
|
||||
fontSize: parseInt("15%"),
|
||||
color: "#005170",
|
||||
},
|
||||
下帯内容: {
|
||||
position: "absolute",
|
||||
bottom: "0%",
|
||||
height: "30%",
|
||||
width: "100%",
|
||||
alignItems: "center",
|
||||
flexDirection: "column",
|
||||
},
|
||||
下枠フレーム: {
|
||||
flex: 1,
|
||||
flexDirection: "row",
|
||||
alignContent: "center",
|
||||
},
|
||||
下枠左右マーク: {
|
||||
fontWeight: "bold",
|
||||
fontSize: parseInt("20%"),
|
||||
color: "white",
|
||||
paddingHorizontal: 10,
|
||||
textAlignVertical: "center",
|
||||
},
|
||||
下枠駅ナンバー: {
|
||||
alignContent: "center",
|
||||
alignItems: "center",
|
||||
width: wp("8%"),
|
||||
height: wp("8%"),
|
||||
margin: wp("1%"),
|
||||
borderColor: "white",
|
||||
borderWidth: parseInt("2%"),
|
||||
borderRadius: parseInt("100%"),
|
||||
},
|
||||
下枠駅名: {
|
||||
fontWeight: "bold",
|
||||
fontSize: parseInt("15%"),
|
||||
color: "white",
|
||||
flex: 1,
|
||||
textAlignVertical: "center",
|
||||
},
|
||||
};
|
||||
|
218
lib/getStationList.js
Normal file
218
lib/getStationList.js
Normal file
@ -0,0 +1,218 @@
|
||||
import 予讃線 from "../assets/四国旅客鉄道予讃線.json";
|
||||
import 土讃線 from "../assets/四国旅客鉄道土讃線.json";
|
||||
import 高徳線 from "../assets/四国旅客鉄道高徳線.json";
|
||||
import 内子線 from "../assets/四国旅客鉄道内子線.json";
|
||||
import 徳島線 from "../assets/四国旅客鉄道徳島線.json";
|
||||
import 鳴門線 from "../assets/四国旅客鉄道鳴門線.json";
|
||||
|
||||
let status = undefined;
|
||||
|
||||
export const getStationList = async (props) => {
|
||||
if (status) return status;
|
||||
//駅リストイニシャライズ
|
||||
const HeaderConfig = {
|
||||
headers: {
|
||||
referer: "https://train.jr-shikoku.co.jp/sp.html",
|
||||
},
|
||||
};
|
||||
return await Promise.all([
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=yosan",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=uwajima",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=uwajima2",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=dosan",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=dosan2",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=koutoku",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=tokushima",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=naruto",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=seto",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=between",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=line&arg2=train_lang",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
]).then((values) => {
|
||||
let stationList = {};
|
||||
[
|
||||
stationList.予讃線,
|
||||
stationList.松宇線,
|
||||
stationList.伊予灘線,
|
||||
stationList.土讃線,
|
||||
stationList.窪川線,
|
||||
stationList.高徳線,
|
||||
stationList.徳島線,
|
||||
stationList.鳴門線,
|
||||
stationList.瀬戸大橋線,
|
||||
stationList.駅間リスト,
|
||||
stationList.日英対応表,
|
||||
] = values;
|
||||
const concatBetweenStations = (eachRouteData) => {
|
||||
let additional = [];
|
||||
eachRouteData.forEach((routeData, routeIndex) => {
|
||||
try {
|
||||
const currentStationID = parseInt(
|
||||
routeData.StationNumber.replace(/[A-Z]/g, "")
|
||||
);
|
||||
const nextStationID = parseInt(
|
||||
eachRouteData[routeIndex + 1].StationNumber.replace(/[A-Z]/g, "")
|
||||
);
|
||||
if (nextStationID - currentStationID != 1) {
|
||||
stationList.駅間リスト.forEach((betweenList) => {
|
||||
if (
|
||||
betweenList.BetweenStation ==
|
||||
routeData.Station_JP +
|
||||
"~" +
|
||||
eachRouteData[routeIndex + 1].Station_JP
|
||||
) {
|
||||
additional = additional.concat(betweenList.Datas);
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (e) {}
|
||||
});
|
||||
return eachRouteData
|
||||
.concat(additional)
|
||||
.sort((a, b) => (a.StationNumber > b.StationNumber ? 1 : -1));
|
||||
};
|
||||
const addStationPosition = (setDataBase, geoJson, EnJpList) => {
|
||||
return setDataBase.map((data) => {
|
||||
let stationName;
|
||||
if (data.hasOwnProperty("Station_JP")) stationName = data.Station_JP;
|
||||
else if (data.hasOwnProperty("StationName")) {
|
||||
stationName = data.StationName;
|
||||
data.Station_JP = data.StationName;
|
||||
data.Station_EN = EnJpList.find(
|
||||
(d) => d.Station_JP == data.Station_JP
|
||||
).Station_EN;
|
||||
}
|
||||
geoJson.features
|
||||
.filter((d) => d.geometry.type == "Point")
|
||||
.forEach((element) => {
|
||||
if (element.properties.name == stationName) {
|
||||
data.lat = element.geometry.coordinates[1];
|
||||
data.lng = element.geometry.coordinates[0];
|
||||
}
|
||||
});
|
||||
return data;
|
||||
});
|
||||
};
|
||||
stationList.予讃線 = addStationPosition(
|
||||
concatBetweenStations(stationList.予讃線),
|
||||
予讃線,
|
||||
stationList.日英対応表
|
||||
);
|
||||
stationList.松宇線 = addStationPosition(
|
||||
concatBetweenStations(stationList.松宇線),
|
||||
予讃線,
|
||||
stationList.日英対応表
|
||||
);
|
||||
stationList.伊予灘線 = addStationPosition(
|
||||
concatBetweenStations(stationList.伊予灘線),
|
||||
予讃線,
|
||||
stationList.日英対応表
|
||||
);
|
||||
stationList.土讃線 = addStationPosition(
|
||||
concatBetweenStations(stationList.土讃線),
|
||||
土讃線,
|
||||
stationList.日英対応表
|
||||
);
|
||||
stationList.窪川線 = addStationPosition(
|
||||
concatBetweenStations(stationList.窪川線),
|
||||
土讃線,
|
||||
stationList.日英対応表
|
||||
);
|
||||
stationList.高徳線 = addStationPosition(
|
||||
concatBetweenStations(stationList.高徳線),
|
||||
高徳線,
|
||||
stationList.日英対応表
|
||||
);
|
||||
stationList.鳴門線 = addStationPosition(
|
||||
concatBetweenStations(stationList.鳴門線),
|
||||
鳴門線,
|
||||
stationList.日英対応表
|
||||
);
|
||||
const tokushimaCurrent = addStationPosition(
|
||||
concatBetweenStations(stationList.徳島線),
|
||||
徳島線,
|
||||
stationList.日英対応表
|
||||
);
|
||||
stationList.徳島線 = [
|
||||
tokushimaCurrent[tokushimaCurrent.length - 1],
|
||||
...tokushimaCurrent,
|
||||
];
|
||||
stationList.徳島線.pop();
|
||||
stationList.瀬戸大橋線 = [
|
||||
{
|
||||
Station_JP: "坂出",
|
||||
Station_EN: "Sakaide",
|
||||
MyStation: "3",
|
||||
StationNumber: null,
|
||||
DispNum: "3",
|
||||
StationTimeTable:
|
||||
"http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/sakaide.pdf",
|
||||
StationMap: "https://www.google.co.jp/maps/place/34.313222,133.856325",
|
||||
JrHpUrl: "http://www.jr-shikoku.co.jp/01_trainbus/kakueki/sakaide/",
|
||||
lat: 34.313222,
|
||||
lng: 133.856325,
|
||||
},
|
||||
|
||||
{
|
||||
Station_JP: "児島",
|
||||
Station_EN: "Kojima",
|
||||
MyStation: "0",
|
||||
StationNumber: "M12",
|
||||
DispNum: "3",
|
||||
StationTimeTable:
|
||||
"http://www.jr-odekake.net/eki/timetable.php?id=0651304",
|
||||
StationMap: "https://www.google.co.jp/maps/place/34.462562,133.807809",
|
||||
JrHpUrl: "http://www.jr-odekake.net/eki/top.php?id=0651304",
|
||||
lat: 34.462562,
|
||||
lng: 133.807809,
|
||||
},
|
||||
{
|
||||
Station_JP: "宇多津",
|
||||
Station_EN: "Utazu",
|
||||
MyStation: "0",
|
||||
StationNumber: null,
|
||||
DispNum: "3",
|
||||
StationTimeTable:
|
||||
"http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/utazu.pdf",
|
||||
StationMap: "https://www.google.co.jp/maps/place/34.306379,133.813784",
|
||||
JrHpUrl: "http://www.jr-shikoku.co.jp/01_trainbus/kakueki/utazu/",
|
||||
lat: 34.306379,
|
||||
lng: 133.813784,
|
||||
},
|
||||
];
|
||||
status = stationList;
|
||||
return stationList;
|
||||
});
|
||||
};
|
55
lib/getStationList2.js
Normal file
55
lib/getStationList2.js
Normal file
@ -0,0 +1,55 @@
|
||||
let status = undefined;
|
||||
export const getStationList2 = async (props) => {
|
||||
if (status) return status;
|
||||
const HeaderConfig = {
|
||||
headers: { referer: "https://train.jr-shikoku.co.jp/sp.html" },
|
||||
};
|
||||
|
||||
return await Promise.all([
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=yosan",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=uwajima",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=uwajima2",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=dosan",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=dosan2",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=koutoku",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=tokushima",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=naruto",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
]).then((values) => {
|
||||
let stationList = {};
|
||||
[
|
||||
stationList.yosan,
|
||||
stationList.uwajima,
|
||||
stationList.uwajima2,
|
||||
stationList.dosan,
|
||||
stationList.dosan2,
|
||||
stationList.koutoku,
|
||||
stationList.tokushima,
|
||||
stationList.naruto,
|
||||
] = values;
|
||||
return stationList;
|
||||
});
|
||||
};
|
45
lib/useInterval.js
Normal file
45
lib/useInterval.js
Normal file
@ -0,0 +1,45 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
// type Control = {
|
||||
// start: () => void;
|
||||
// stop: () => void;
|
||||
// };
|
||||
|
||||
// type State = 'RUNNING' | 'STOPPED';
|
||||
|
||||
// type Fn = () => void;
|
||||
|
||||
export const useInterval = (fn, interval, autostart = true) => {
|
||||
const onUpdateRef = useRef();
|
||||
const [state, setState] = useState("RUNNING");
|
||||
const start = () => {
|
||||
setState("RUNNING");
|
||||
};
|
||||
const stop = () => {
|
||||
setState("STOPPED");
|
||||
};
|
||||
useEffect(() => {
|
||||
onUpdateRef.current = fn;
|
||||
}, [fn]);
|
||||
useEffect(() => {
|
||||
if (autostart) {
|
||||
setState("RUNNING");
|
||||
}
|
||||
}, [autostart]);
|
||||
useEffect(() => {
|
||||
let timerId;
|
||||
if (state === "RUNNING") {
|
||||
timerId = setInterval(() => {
|
||||
onUpdateRef.current?.();
|
||||
}, interval);
|
||||
} else {
|
||||
timerId && clearInterval(timerId);
|
||||
}
|
||||
return () => {
|
||||
timerId && clearInterval(timerId);
|
||||
};
|
||||
}, [interval, state]);
|
||||
return [state, { start, stop }];
|
||||
};
|
||||
|
||||
export default useInterval;
|
757
lib/webViewInjectjavascript.js
Normal file
757
lib/webViewInjectjavascript.js
Normal file
@ -0,0 +1,757 @@
|
||||
export const injectJavascriptData = (mapSwitch, iconSetting, stationMenu) => {
|
||||
const topMenu =
|
||||
mapSwitch != "true"
|
||||
? `
|
||||
document.getElementById('header').querySelector('a').style.display = 'none';
|
||||
document.getElementById('header').style.height = '50px';
|
||||
document.getElementById('main').style.paddingTop = '54px';
|
||||
|
||||
document.getElementById('headerStr').style.display = 'none';
|
||||
`
|
||||
: `
|
||||
document.getElementsByClassName('accordionClass')[0].style.display = 'none';
|
||||
document.getElementById('header').style.display = 'none';
|
||||
document.getElementById('main').style.paddingTop = '0px';
|
||||
document.getElementById('headerStr').style.display = 'none';
|
||||
`;
|
||||
const bootData =
|
||||
topMenu +
|
||||
`
|
||||
const setReload = () =>{
|
||||
try{
|
||||
document.getElementById('refreshIcon').click();
|
||||
setStrings();
|
||||
}catch{
|
||||
|
||||
}
|
||||
setTimeout(setReload, 10000);
|
||||
}
|
||||
setReload();
|
||||
`;
|
||||
|
||||
const trainIconMaker = `
|
||||
const setStationIcon = (行き先アイコン,img) =>{
|
||||
let newItem = document.createElement("div");
|
||||
if(行き先アイコン.getAttribute("style").includes("left")){
|
||||
行き先アイコン.insertAdjacentHTML('beforebegin', "<img src="+img+" style='float:left;height:20px;'>");
|
||||
}
|
||||
else{
|
||||
行き先アイコン.insertAdjacentHTML('beforebegin', "<img src="+img+" style='float:right;height:20px;'>");
|
||||
}
|
||||
行き先アイコン.remove();
|
||||
}
|
||||
`;
|
||||
|
||||
const trainIcon =
|
||||
iconSetting == "true"
|
||||
? `
|
||||
switch(列番データ){
|
||||
//しおかぜメイン
|
||||
//8000 ノーマル
|
||||
case "2M":
|
||||
case "4M":
|
||||
case "6M":
|
||||
case "14M":
|
||||
case "16M":
|
||||
case "18M":
|
||||
case "26M":
|
||||
case "28M":
|
||||
case "30M":
|
||||
case "1M":
|
||||
case "3M":
|
||||
case "5M":
|
||||
case "13M":
|
||||
case "15M":
|
||||
case "17M":
|
||||
case "25M":
|
||||
case "27M":
|
||||
case "29M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s8000nr.png');
|
||||
break;
|
||||
//8000 アンパン
|
||||
case "10M":
|
||||
case "22M":
|
||||
case "9M":
|
||||
case "21M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/f/s8000ap.png');
|
||||
break;
|
||||
|
||||
|
||||
//8600
|
||||
case "8M":
|
||||
case "12M":
|
||||
case "20M":
|
||||
case "24M":
|
||||
case "7M":
|
||||
case "11M":
|
||||
case "19M":
|
||||
case "23M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s8600.png');
|
||||
break;
|
||||
|
||||
//いしづちメイン
|
||||
//8000 ノーマル
|
||||
|
||||
case "1004M":
|
||||
case "1006M":
|
||||
case "1014M":
|
||||
case "1016M":
|
||||
case "1018M":
|
||||
case "1026M":
|
||||
case "1028M":
|
||||
case "1030M":
|
||||
case "1001M":
|
||||
case "1003M":
|
||||
case "1005M":
|
||||
case "1013M":
|
||||
case "1015M":
|
||||
case "1017M":
|
||||
case "1025M":
|
||||
case "1027M":
|
||||
case "1029M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s8000no.png');
|
||||
break;
|
||||
|
||||
//8000 アンパン
|
||||
case "1010M":
|
||||
case "1022M":
|
||||
case "1009M":
|
||||
case "1021M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/f/s8000ap.png');
|
||||
break;
|
||||
|
||||
//8600
|
||||
case "1008M":
|
||||
case "1012M":
|
||||
case "1020M":
|
||||
case "1024M":
|
||||
case "1007M":
|
||||
case "1011M":
|
||||
case "1019M":
|
||||
case "1023M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s8600_isz.png');
|
||||
break;
|
||||
|
||||
//MEXP
|
||||
//8000
|
||||
case "1092M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s8000no.png');
|
||||
break;
|
||||
//8600
|
||||
case "1091M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s8600_isz.png');
|
||||
break;
|
||||
//三桁いしづち
|
||||
//8000 アンパン
|
||||
case "1041M":
|
||||
case "1044M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/f/s8000ap.png');
|
||||
break;
|
||||
//8600
|
||||
case "1043M":
|
||||
case "1042M":
|
||||
case "1046M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s8600_isz.png');
|
||||
break;
|
||||
|
||||
|
||||
//南風 2700ノーマル
|
||||
case "34D":
|
||||
case "38D":
|
||||
case "40D":
|
||||
case "42D":
|
||||
case "46D":
|
||||
case "50D":
|
||||
case "52D":
|
||||
case "54D":
|
||||
case "58D":
|
||||
case "31D":
|
||||
case "35D":
|
||||
case "39D":
|
||||
case "41D":
|
||||
case "43D":
|
||||
case "47D":
|
||||
case "51D":
|
||||
case "53D":
|
||||
case "55D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s2700.png');
|
||||
break;
|
||||
//2700アンパン
|
||||
case "32D":
|
||||
case "36D":
|
||||
case "44D":
|
||||
case "48D":
|
||||
case "56D":
|
||||
case "33D":
|
||||
case "37D":
|
||||
case "45D":
|
||||
case "49D":
|
||||
case "57D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/f/s2700apr.png');
|
||||
break;
|
||||
|
||||
|
||||
|
||||
//うずしお
|
||||
//2700
|
||||
case "5006D":
|
||||
case "5022D":
|
||||
case "5013D":
|
||||
case "5029D":
|
||||
case "3002D":
|
||||
case "3004D":
|
||||
case "3010D":
|
||||
case "3012D":
|
||||
case "3016D":
|
||||
case "3018D":
|
||||
case "3024D":
|
||||
case "3028D":
|
||||
case "3030D":
|
||||
case "3003D":
|
||||
case "3005D":
|
||||
case "3007D":
|
||||
case "3015D":
|
||||
case "3019D":
|
||||
case "3021D":
|
||||
case "3025D":
|
||||
case "3027D":
|
||||
case "3031D":
|
||||
case "3033D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s2700_uzu.png');
|
||||
break;
|
||||
|
||||
//2600
|
||||
case "3008D":
|
||||
case "3014D":
|
||||
case "3020D":
|
||||
case "3026D":
|
||||
case "3001D":
|
||||
case "3011D":
|
||||
case "3017D":
|
||||
case "3023D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s2600.png');
|
||||
break;
|
||||
|
||||
//キハ185
|
||||
case "3009D":
|
||||
case "3032D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s185tu_uzu.png');
|
||||
break;
|
||||
|
||||
//マリンライナー
|
||||
case "3104M":
|
||||
case "3106M":
|
||||
case "3108M":
|
||||
case "3110M":
|
||||
case "3112M":
|
||||
case "3114M":
|
||||
case "3116M":
|
||||
case "3118M":
|
||||
case "3120M":
|
||||
case "3122M":
|
||||
case "3124M":
|
||||
case "3126M":
|
||||
case "3128M":
|
||||
case "3130M":
|
||||
case "3132M":
|
||||
case "3134M":
|
||||
case "3136M":
|
||||
case "3138M":
|
||||
case "3140M":
|
||||
case "3142M":
|
||||
case "3144M":
|
||||
case "3146M":
|
||||
case "3148M":
|
||||
case "3150M":
|
||||
case "3152M":
|
||||
case "3154M":
|
||||
case "3156M":
|
||||
case "3158M":
|
||||
case "3160M":
|
||||
case "3162M":
|
||||
case "3164M":
|
||||
case "3166M":
|
||||
case "3168M":
|
||||
case "3170M":
|
||||
case "3105M":
|
||||
case "3107M":
|
||||
case "3109M":
|
||||
case "3111M":
|
||||
case "3113M":
|
||||
case "3115M":
|
||||
case "3117M":
|
||||
case "3119M":
|
||||
case "3121M":
|
||||
case "3123M":
|
||||
case "3125M":
|
||||
case "3127M":
|
||||
case "3129M":
|
||||
case "3131M":
|
||||
case "3133M":
|
||||
case "3135M":
|
||||
case "3137M":
|
||||
case "3139M":
|
||||
case "3141M":
|
||||
case "3143M":
|
||||
case "3145M":
|
||||
case "3147M":
|
||||
case "3149M":
|
||||
case "3151M":
|
||||
case "3153M":
|
||||
case "3155M":
|
||||
case "3157M":
|
||||
case "3159M":
|
||||
case "3161M":
|
||||
case "3163M":
|
||||
case "3165M":
|
||||
case "3167M":
|
||||
case "3169M":
|
||||
case "3175M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s5001.png');
|
||||
break;
|
||||
case "3102M":
|
||||
case "3101M":
|
||||
case "3103M":
|
||||
case "3171M":
|
||||
case "3173M":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s5001k.png');
|
||||
break;
|
||||
|
||||
//サンライズ瀬戸
|
||||
case "5032M":
|
||||
case "5031M":
|
||||
case "8041M": //琴平延長高松迄
|
||||
case "8031M": //琴平延長高松以降
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/w285.png');
|
||||
break;
|
||||
|
||||
//宇和海
|
||||
//2000 ノーマル
|
||||
case "1052D":
|
||||
case "1056D":
|
||||
case "1058D":
|
||||
case "1064D":
|
||||
case "1070D":
|
||||
case "1074D":
|
||||
case "1076D":
|
||||
case "1078D":
|
||||
case "1080D":
|
||||
case "1082D":
|
||||
case "1051D":
|
||||
case "1059D":
|
||||
case "1065D":
|
||||
case "1069D":
|
||||
case "1071D":
|
||||
case "1073D":
|
||||
case "1075D":
|
||||
case "1077D":
|
||||
case "1079D":
|
||||
case "1053D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s2000_uwa.png');
|
||||
break;
|
||||
//2000 アンパン込み
|
||||
case "1054D":
|
||||
case "1060D":
|
||||
case "1062D":
|
||||
case "1066D":
|
||||
case "1068D":
|
||||
case "1072D":
|
||||
case "1055D":
|
||||
case "1057D":
|
||||
case "1061D":
|
||||
case "1063D":
|
||||
case "1067D":
|
||||
case "1081D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/f/s2002a.png');
|
||||
break;
|
||||
//しまんと
|
||||
case "2002D":
|
||||
case "2004D":
|
||||
case "2006D":
|
||||
case "2008D":
|
||||
case "2001D":
|
||||
case "2003D":
|
||||
case "2005D":
|
||||
case "2007D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s2700_smn.png');
|
||||
break;
|
||||
|
||||
//あしずり 2000
|
||||
case "2074D":
|
||||
case "2076D":
|
||||
case "2080D":
|
||||
case "2084D":
|
||||
case "2086D":
|
||||
case "2071D":
|
||||
case "2075D":
|
||||
case "2077D":
|
||||
case "2081D":
|
||||
case "2083D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s2000_asi.png');
|
||||
break;
|
||||
|
||||
//あしずり 2700
|
||||
case "2078D":
|
||||
case "2082D":
|
||||
case "2088D":
|
||||
case "2073D":
|
||||
case "2079D":
|
||||
case "2085D":
|
||||
case "2072D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s2700_asi.png');
|
||||
break;
|
||||
//剣山
|
||||
case "4002D":
|
||||
case "4004D":
|
||||
case "4006D":
|
||||
case "4008D":
|
||||
case "4010D":
|
||||
case "4001D":
|
||||
case "4003D":
|
||||
case "4005D":
|
||||
case "4007D":
|
||||
case "4009D":
|
||||
case "4011D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s185tu.png');
|
||||
break;
|
||||
//むろと
|
||||
case "5051D":
|
||||
case "5052D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s185_mrt.png');
|
||||
break;
|
||||
|
||||
|
||||
//よしのがわトロッコ
|
||||
case "8452D":
|
||||
case "8451D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/f/s185to_ai.png');
|
||||
break;
|
||||
|
||||
//岡山高松アントロ
|
||||
case "8176D":
|
||||
case "8179D":
|
||||
//岡山琴平アントロ
|
||||
case "8277D":
|
||||
case "8278D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/f/s32to4.png');
|
||||
break;
|
||||
|
||||
//伊予灘ものがたり
|
||||
case "8901D":
|
||||
case "8903D":
|
||||
case "8902D":
|
||||
case "8904D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s185iyoy.png');
|
||||
break;
|
||||
|
||||
|
||||
//千年ものがたり
|
||||
case "8011D":
|
||||
case "8012D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s185mm1.png');
|
||||
break;
|
||||
|
||||
//夜明けものがたり
|
||||
case "8053D":
|
||||
case "8054D":
|
||||
case "8062D":
|
||||
case "8063D":
|
||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s185ym1.png');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
`
|
||||
: ``;
|
||||
|
||||
const JRF_icon =
|
||||
iconSetting == "true"
|
||||
? `
|
||||
JRF || setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/f/ef210a.png');
|
||||
`
|
||||
: ``;
|
||||
const normal_train_name = `
|
||||
if(new RegExp(/^4[1-9]\\d\\d[DM]$/).test(列番データ) || new RegExp(/^5[1-7]\\d\\d[DM]$/).test(列番データ)){
|
||||
行き先情報.innerText = "ワンマン\\n"+行き先情報.innerText;
|
||||
flag=true;
|
||||
}
|
||||
if(new RegExp(/^49[0-4]\\dD$/).test(列番データ) || new RegExp(/^9[0-4]\\dD$/).test(列番データ)){
|
||||
行き先情報.innerText = "(海経由)"+(flag ? "" : "\\n")+行き先情報.innerText;
|
||||
}
|
||||
if(new RegExp(/^46\\d\\dD$/).test(列番データ) || new RegExp(/^6\\d\\dD$/).test(列番データ)){
|
||||
行き先情報.innerText = "(内子経由)"+(flag ? "" : "\\n")+行き先情報.innerText;
|
||||
}
|
||||
if(列番データ.indexOf("H") != -1){
|
||||
行き先情報.innerText = 行き先情報.innerText+"試運転\\n";
|
||||
}
|
||||
else if(列番データ.indexOf("R") != -1){
|
||||
行き先情報.innerText = 行き先情報.innerText+"回送\\n";
|
||||
}
|
||||
else if(列番データ.indexOf("S") != -1){
|
||||
行き先情報.innerText = 行き先情報.innerText+"臨時列車\\n";
|
||||
}
|
||||
`;
|
||||
const JRF_name =
|
||||
`
|
||||
let JRF = false;
|
||||
switch(列番データ){
|
||||
case "71":
|
||||
行き先情報.innerText = "東京(タ)→高松(タ)"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "73":
|
||||
case "75":
|
||||
行き先情報.innerText = "大阪(タ)→高松(タ)"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "3079":
|
||||
行き先情報.innerText = "高松(タ)→伊予三島"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "3071":
|
||||
case "3077":
|
||||
行き先情報.innerText = "高松(タ)→新居浜"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "3073":
|
||||
行き先情報.innerText = "高松(タ)→松山貨物"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "70":
|
||||
行き先情報.innerText = "高松(タ)→東京(タ)"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "74":
|
||||
case "76":
|
||||
行き先情報.innerText = "高松(タ)→大阪(タ)"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "3078":
|
||||
行き先情報.innerText = "伊予三島→高松(タ)"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "3070":
|
||||
行き先情報.innerText = "新居浜→高松(タ)"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "3076":
|
||||
行き先情報.innerText = "新居浜→高松(タ)"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "3072":
|
||||
行き先情報.innerText = "松山貨物→高松(タ)"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
case "9070":
|
||||
行き先情報.innerText = "臨時貨物"+"\\n"+行き先情報.innerText;
|
||||
break;
|
||||
default:
|
||||
JRF = true;
|
||||
}
|
||||
` + JRF_icon;
|
||||
|
||||
const TKT_name = `
|
||||
//安芸行と併結列車を個別に表示、それ以外をdefaultで下りなら既定の行き先を、上りなら奈半利行を設定
|
||||
switch(列番データ){
|
||||
case "5814D":
|
||||
case "5816D":
|
||||
行き先情報.innerText = "ごめん・なはり線直通\\n快速 奈半利行";
|
||||
break;
|
||||
case "5812D":
|
||||
行き先情報.innerText = "ごめん・なはり線直通\\n快速 安芸行";
|
||||
break;
|
||||
case "5874D":
|
||||
case "5882D":
|
||||
行き先情報.innerText = "ごめん・なはり線直通\\n各停 安芸行";
|
||||
break;
|
||||
case "742D":
|
||||
case "746D":
|
||||
行き先情報.innerText = "土佐山田/奈半利行\\n(後免にて解結)\\nごめん・なはり線快速";
|
||||
break;
|
||||
default:
|
||||
if(new RegExp(/^58[1-3][1,3,5,7,9][DM]$/).test(列番データ)){
|
||||
行き先情報.innerText = "ごめん・なはり線直通\\n快速 "+行き先情報.innerText;
|
||||
}
|
||||
else if(new RegExp(/^58[4-9][1,3,5,7,9][DM]$/).test(列番データ)){
|
||||
行き先情報.innerText = "ごめん・なはり線直通\\n各停 "+行き先情報.innerText;
|
||||
}
|
||||
|
||||
else if(new RegExp(/^58[3-4][0,2,4,6,8][DM]$/).test(列番データ)){
|
||||
行き先情報.innerText = "ごめん・なはり線直通\\n快速 奈半利行";
|
||||
}
|
||||
else if(new RegExp(/^58[5-9][0,2,4,6,8][DM]$/).test(列番データ)){
|
||||
行き先情報.innerText = "ごめん・なはり線直通\\n各停 奈半利行";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
`;
|
||||
|
||||
const textInsert =
|
||||
`
|
||||
const setStrings = () =>{
|
||||
try {
|
||||
var elements = document.querySelectorAll('[onclick]');
|
||||
for (let element of elements) {
|
||||
if(element.getAttribute('onclick').indexOf('ShowTrainTimeInfo') == -1) continue;
|
||||
var 行き先情報 = element.getElementsByTagName("p")[0];
|
||||
var 列番データ = element.getAttribute('onclick').split('"')[1];
|
||||
var flag=false;
|
||||
var TrainType = undefined;
|
||||
if(行き先情報.innerText.includes(列番データ))continue; //回避
|
||||
` +
|
||||
trainIcon +
|
||||
normal_train_name +
|
||||
JRF_name +
|
||||
TKT_name +
|
||||
`
|
||||
//列番付与
|
||||
行き先情報.innerText = 行き先情報.innerText+列番データ+(JRF ? "":"レ");
|
||||
}
|
||||
try{
|
||||
for(let d of document.getElementById('disp').childNodes){
|
||||
switch(d.id){
|
||||
case 'pMENU_2':
|
||||
case 'pMENU_2_En':
|
||||
case 'pMENU_3':
|
||||
case 'pMENU_3_En':
|
||||
case 'pMENU_k':
|
||||
case 'pMENU_k_En':
|
||||
continue;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
d.style.width = '100vw';
|
||||
for(let f of d.childNodes){
|
||||
try{
|
||||
if(f.style.alignItems || f.style.textAlign){
|
||||
f.style.width = '38vw';
|
||||
}
|
||||
else{
|
||||
if(f.id == 'upTrainCrossBar'){
|
||||
f.style.width = '38vw';
|
||||
}
|
||||
else if(f.id == 'dwTrainCrossBar'){
|
||||
f.style.left = '62vw';
|
||||
f.style.width = '38vw';
|
||||
|
||||
}
|
||||
else {
|
||||
f.style.width = '0vw';
|
||||
}
|
||||
}
|
||||
if(f.style.textAlign == 'center'){
|
||||
f.style.width = '24vw';
|
||||
f.style.display = 'flex';
|
||||
f.childNodes.forEach(i =>{
|
||||
i.style.width = 'unset';
|
||||
i.style.left = 'unset';
|
||||
i.style.top = 'unset';
|
||||
i.style.position = 'unset';
|
||||
i.style.flex = '1';
|
||||
i.style.margin = '5px'
|
||||
|
||||
if(i.style.backgroundColor != 'rgb(247, 247, 247)'){
|
||||
i.childNodes.forEach(m=> m.style.width = '20vw')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}catch(e){}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
document.querySelector('#pMENU_2').style.borderStyle='solid';
|
||||
document.querySelector('#pMENU_2').style.borderColor='#00d3e8';
|
||||
document.querySelector('#pMENU_2').style.borderWidth='2px';
|
||||
document.querySelector('#pMENU_2').style.borderRadius='10%';
|
||||
document.querySelector('#pMENU_3').style.borderStyle='solid';
|
||||
document.querySelector('#pMENU_3').style.borderColor='#00d3e8';
|
||||
document.querySelector('#pMENU_3').style.borderWidth='2px';
|
||||
document.querySelector('#pMENU_3').style.borderRadius='10%';
|
||||
document.querySelectorAll('#pMENU_2 div').forEach((d)=>d.style.padding = '10px');
|
||||
document.querySelectorAll('#pMENU_3 div').forEach((d)=>d.style.padding = '10px');
|
||||
document.querySelectorAll('#topHeader div').forEach((d)=>d.style.width = '100vw');
|
||||
document.querySelectorAll('#disp div')[0].style.width = '100vw';
|
||||
document.getElementById('disp').style.width = '100vw';
|
||||
document.getElementById('disp').style.overflowX = 'hidden';
|
||||
|
||||
|
||||
|
||||
}catch(e){
|
||||
alert("にゃーん");
|
||||
}
|
||||
} catch (e) {}
|
||||
//setTimeout(setStrings,500);
|
||||
}
|
||||
const target = document.getElementById('disp'); // body要素を監視
|
||||
const observer = new MutationObserver( (mutations) => {
|
||||
// observer.disconnect(); // 監視を終了
|
||||
setStrings();
|
||||
});
|
||||
|
||||
// 監視を開始
|
||||
observer.observe(target, {
|
||||
attributes: true, // 属性変化の監視
|
||||
//attributeOldValue: true, // 変化前の属性値を matation.oldValue に格納する
|
||||
//characterData: true, // テキストノードの変化を監視
|
||||
//characterDataOldValue: true, // 変化前のテキストを matation.oldValue に格納する
|
||||
childList: true, // 子ノードの変化を監視
|
||||
//subtree: true // 子孫ノードも監視対象に含める
|
||||
});
|
||||
`;
|
||||
|
||||
const makeTrainView = `
|
||||
|
||||
const modal_content = document.getElementById('modal_content'); // body要素を監視
|
||||
const modal_observer = new MutationObserver( (mutations) => {
|
||||
// observer.disconnect(); // 監視を終了
|
||||
for(let d of modal_content.getElementsByTagName("button") ){
|
||||
const data = d.onclick.toString().split("\\"")[1];
|
||||
d.onclick = () => window.ReactNativeWebView.postMessage(data)
|
||||
}
|
||||
});
|
||||
|
||||
// 監視を開始
|
||||
modal_observer.observe(modal_content, {
|
||||
//attributes: true, // 属性変化の監視
|
||||
//attributeOldValue: true, // 変化前の属性値を matation.oldValue に格納する
|
||||
//characterData: true, // テキストノードの変化を監視
|
||||
//characterDataOldValue: true, // 変化前のテキストを matation.oldValue に格納する
|
||||
childList: true, // 子ノードの変化を監視
|
||||
//subtree: true // 子孫ノードも監視対象に含める
|
||||
});
|
||||
`;
|
||||
const makeStationMenu =
|
||||
stationMenu == "true"
|
||||
? `
|
||||
const setStationMenuDialog = () =>{
|
||||
document.querySelector('#pMENU_2').style.display='none';
|
||||
document.querySelector('#pMENU_3').style.display='none';
|
||||
document.querySelector('#pMENU_2').style.display='none';
|
||||
const data =[];
|
||||
document.querySelectorAll('#disp div div').forEach(d=>d.id.indexOf("st")!= -1 && data.push(d));
|
||||
|
||||
for(let d of data ){
|
||||
if(!d.offclick){
|
||||
d.offclick = d.onclick.toString();
|
||||
}
|
||||
d.onclick = () =>{
|
||||
window.ReactNativeWebView.postMessage(d.offclick);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const observer3 = new MutationObserver( (mutations) => {
|
||||
// observer3.disconnect(); // 監視を終了
|
||||
setStationMenuDialog();
|
||||
});
|
||||
|
||||
// 監視を開始
|
||||
observer3.observe(target, {
|
||||
attributes: true, // 属性変化の監視
|
||||
//attributeOldValue: true, // 変化前の属性値を matation.oldValue に格納する
|
||||
//characterData: true, // テキストノードの変化を監視
|
||||
//characterDataOldValue: true, // 変化前のテキストを matation.oldValue に格納する
|
||||
childList: true, // 子ノードの変化を監視
|
||||
//subtree: true // 子孫ノードも監視対象に含める
|
||||
});
|
||||
`
|
||||
: ``;
|
||||
return (
|
||||
bootData + makeTrainView + trainIconMaker + textInsert + makeStationMenu
|
||||
);
|
||||
};
|
620
menu.js
620
menu.js
@ -15,7 +15,6 @@ import { List, ListItem } from "native-base";
|
||||
import Icon from "react-native-vector-icons/Entypo";
|
||||
import * as Location from "expo-location";
|
||||
import StatusbarDetect from "./StatusbarDetect";
|
||||
var Status = StatusbarDetect();
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import AutoHeightImage from "react-native-auto-height-image";
|
||||
import {
|
||||
@ -33,6 +32,7 @@ import * as WebBrowser from "expo-web-browser";
|
||||
import ActionSheet from "react-native-actions-sheet";
|
||||
import LottieView from "lottie-react-native";
|
||||
import SvgUri from "react-native-svg-uri";
|
||||
import { StationDeteilView } from "./components/ActionSheetComponents/StationDeteilView";
|
||||
|
||||
import 予讃線 from "./assets/四国旅客鉄道予讃線.json";
|
||||
import 土讃線 from "./assets/四国旅客鉄道土讃線.json";
|
||||
@ -43,70 +43,11 @@ import 鳴門線 from "./assets/四国旅客鉄道鳴門線.json";
|
||||
import LED_vision from "./components/発車時刻表/LED_vidion";
|
||||
import Sign from "./components/駅名表/Sign";
|
||||
|
||||
const UsefulBox = (props) => {
|
||||
const { icon, backgroundColor, flex, onPressButton, children } = props;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
flex: flex,
|
||||
backgroundColor: backgroundColor,
|
||||
padding: 10,
|
||||
alignItems: "center",
|
||||
margin: 2,
|
||||
}}
|
||||
onPress={onPressButton}
|
||||
>
|
||||
<MaterialCommunityIcons name={icon} color="white" size={50} />
|
||||
<Text style={{ color: "white", fontWeight: "bold", fontSize: 18 }}>
|
||||
{children}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
||||
const TicketBox = (props) => {
|
||||
const { icon, backgroundColor, flex, onPressButton, children } = props;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
flex: flex,
|
||||
backgroundColor: backgroundColor,
|
||||
borderColor: "#0099CC",
|
||||
padding: 10,
|
||||
borderWidth: 1,
|
||||
margin: 2,
|
||||
alignItems: "center",
|
||||
}}
|
||||
onPress={onPressButton}
|
||||
>
|
||||
<Text style={{ color: "white", fontWeight: "bold", fontSize: 18 }}>
|
||||
{children}
|
||||
</Text>
|
||||
{icon}
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
||||
|
||||
const TextBox = (props) => {
|
||||
const { backgroundColor, flex, onPressButton, children } = props;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
flex: flex,
|
||||
backgroundColor: backgroundColor,
|
||||
padding: 10,
|
||||
height: 70,
|
||||
alignItems: "center",
|
||||
alignContent: "center",
|
||||
margin: 2,
|
||||
}}
|
||||
onPress={onPressButton}
|
||||
>
|
||||
<View style={{ flex: 1 }} />
|
||||
{children}
|
||||
<View style={{ flex: 1 }} />
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
||||
import { UsefulBox } from "./components/atom/UsefulBox";
|
||||
import { TicketBox } from "./components/atom/TicketBox";
|
||||
import { TextBox } from "./components/atom/TextBox";
|
||||
import { getStationList } from "./lib/getStationList";
|
||||
import { JRSTraInfo } from "./components/ActionSheetComponents/JRSTraInfo";
|
||||
|
||||
export default function Menu(props) {
|
||||
const {
|
||||
@ -138,159 +79,7 @@ export default function Menu(props) {
|
||||
|
||||
const [originalStationList, setOriginalStationList] = useState();
|
||||
useEffect(() => {
|
||||
//駅リストイニシャライズ
|
||||
const HeaderConfig = {
|
||||
headers: {
|
||||
referer: "https://train.jr-shikoku.co.jp/sp.html",
|
||||
},
|
||||
};
|
||||
Promise.all([
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=yosan",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=uwajima",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=uwajima2",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=dosan",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=dosan2",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=koutoku",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=tokushima",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=naruto",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=between",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=line&arg2=train_lang",
|
||||
HeaderConfig
|
||||
).then((response) => response.json()),
|
||||
]).then((values) => {
|
||||
let stationList = {};
|
||||
[
|
||||
stationList.予讃線,
|
||||
stationList.松宇線,
|
||||
stationList.伊予灘線,
|
||||
stationList.土讃線,
|
||||
stationList.窪川線,
|
||||
stationList.高徳線,
|
||||
stationList.徳島線,
|
||||
stationList.鳴門線,
|
||||
stationList.駅間リスト,
|
||||
stationList.日英対応表,
|
||||
] = values;
|
||||
|
||||
const concatBetweenStations = (eachRouteData) => {
|
||||
let additional = [];
|
||||
eachRouteData.forEach((routeData, routeIndex) => {
|
||||
try {
|
||||
const currentStationID = parseInt(
|
||||
routeData.StationNumber.replace(/[A-Z]/g, "")
|
||||
);
|
||||
const nextStationID = parseInt(
|
||||
eachRouteData[routeIndex + 1].StationNumber.replace(/[A-Z]/g, "")
|
||||
);
|
||||
if (nextStationID - currentStationID != 1) {
|
||||
stationList.駅間リスト.forEach((betweenList) => {
|
||||
if (
|
||||
betweenList.BetweenStation ==
|
||||
routeData.Station_JP +
|
||||
"~" +
|
||||
eachRouteData[routeIndex + 1].Station_JP
|
||||
) {
|
||||
additional = additional.concat(betweenList.Datas);
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (e) {}
|
||||
});
|
||||
return eachRouteData
|
||||
.concat(additional)
|
||||
.sort((a, b) => (a.StationNumber > b.StationNumber ? 1 : -1));
|
||||
};
|
||||
const addStationPosition = (setDataBase, geoJson, EnJpList) => {
|
||||
return setDataBase.map((data) => {
|
||||
let stationName;
|
||||
if (data.hasOwnProperty("Station_JP")) stationName = data.Station_JP;
|
||||
else if (data.hasOwnProperty("StationName")) {
|
||||
stationName = data.StationName;
|
||||
data.Station_JP = data.StationName;
|
||||
data.Station_EN = EnJpList.find(
|
||||
(d) => d.Station_JP == data.Station_JP
|
||||
).Station_EN;
|
||||
}
|
||||
geoJson.features
|
||||
.filter((d) => d.geometry.type == "Point")
|
||||
.forEach((element) => {
|
||||
if (element.properties.name == stationName) {
|
||||
data.lat = element.geometry.coordinates[1];
|
||||
data.lng = element.geometry.coordinates[0];
|
||||
}
|
||||
});
|
||||
return data;
|
||||
});
|
||||
};
|
||||
stationList.予讃線 = addStationPosition(
|
||||
concatBetweenStations(stationList.予讃線),
|
||||
予讃線,
|
||||
stationList.日英対応表
|
||||
);
|
||||
stationList.松宇線 = addStationPosition(
|
||||
concatBetweenStations(stationList.松宇線),
|
||||
予讃線,
|
||||
stationList.日英対応表
|
||||
);
|
||||
stationList.伊予灘線 = addStationPosition(
|
||||
concatBetweenStations(stationList.伊予灘線),
|
||||
予讃線,
|
||||
stationList.日英対応表
|
||||
);
|
||||
stationList.土讃線 = addStationPosition(
|
||||
concatBetweenStations(stationList.土讃線),
|
||||
土讃線,
|
||||
stationList.日英対応表
|
||||
);
|
||||
stationList.窪川線 = addStationPosition(
|
||||
concatBetweenStations(stationList.窪川線),
|
||||
土讃線,
|
||||
stationList.日英対応表
|
||||
);
|
||||
stationList.高徳線 = addStationPosition(
|
||||
concatBetweenStations(stationList.高徳線),
|
||||
高徳線,
|
||||
stationList.日英対応表
|
||||
);
|
||||
stationList.徳島線 = addStationPosition(
|
||||
concatBetweenStations(stationList.徳島線),
|
||||
徳島線,
|
||||
stationList.日英対応表
|
||||
);
|
||||
stationList.鳴門線 = addStationPosition(
|
||||
concatBetweenStations(stationList.鳴門線),
|
||||
鳴門線,
|
||||
stationList.日英対応表
|
||||
);
|
||||
|
||||
getStationList().then((stationList) => {
|
||||
setOriginalStationList(stationList);
|
||||
});
|
||||
}, []);
|
||||
@ -326,16 +115,8 @@ export default function Menu(props) {
|
||||
"高徳線",
|
||||
"徳島線",
|
||||
"鳴門線",
|
||||
"瀬戸大橋線",
|
||||
];
|
||||
console.log(
|
||||
lineList
|
||||
.map((d) => findStationEachLine(originalStationList[d]))
|
||||
.filter((d) => d.length > 0)
|
||||
.reduce((pre, current) => {
|
||||
pre.push(...current);
|
||||
return pre;
|
||||
}, [])
|
||||
);
|
||||
let returnDataBase = lineList
|
||||
.map((d) => findStationEachLine(originalStationList[d]))
|
||||
.filter((d) => d.length > 0)
|
||||
@ -355,13 +136,6 @@ export default function Menu(props) {
|
||||
}
|
||||
}, [location, originalStationList]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("test");
|
||||
console.log(currentStation);
|
||||
}, [currentStation]);
|
||||
|
||||
const LottieRef = useRef(null);
|
||||
const LottieRef2 = useRef(null);
|
||||
const [count, setCount] = useState(0);
|
||||
const [delayData, setDelayData] = useState(undefined);
|
||||
const [getTime, setGetTime] = useState(new Date());
|
||||
@ -372,22 +146,12 @@ export default function Menu(props) {
|
||||
"https://script.google.com/macros/s/AKfycbyKxch7z7l8e07LXulRHqxjVoIiB13kcgvoToLE-rqlxLmLSKdlmqz0FI1F2EuA7Zfg/exec"
|
||||
)
|
||||
.then((response) => response.text())
|
||||
.then((data) => {
|
||||
if (data != "") {
|
||||
setDelayData(data.split("^"));
|
||||
} else setDelayData(null);
|
||||
})
|
||||
.then((data) => LayoutAnimation.easeInEaseOut())
|
||||
.then((data) => setDelayData(data !== "" ? data.split("^") : null))
|
||||
.then(() => LayoutAnimation.easeInEaseOut())
|
||||
.then(() => setGetTime(new Date()))
|
||||
.finally(() => setLoadingDelayData(false));
|
||||
}, [loadingDelayData]);
|
||||
|
||||
useEffect(() => {
|
||||
try {
|
||||
LottieRef?.current.play();
|
||||
LottieRef2?.current.play();
|
||||
} catch (e) {}
|
||||
});
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
@ -396,7 +160,7 @@ export default function Menu(props) {
|
||||
paddingTop: Platform.OS == "ios" ? Constants.statusBarHeight : 0,
|
||||
}}
|
||||
>
|
||||
{Status}
|
||||
<StatusbarDetect />
|
||||
<View style={{ alignItems: "center" }}>
|
||||
<TouchableOpacity
|
||||
onPress={() => Linking.openURL("https://www.jr-shikoku.co.jp")}
|
||||
@ -460,18 +224,16 @@ export default function Menu(props) {
|
||||
</Text>
|
||||
</TextBox>
|
||||
{currentStation && (
|
||||
<Sign
|
||||
currentStation={currentStation}
|
||||
originalStationList={originalStationList}
|
||||
oP={() => StationBoardAcSR.current?.setModalVisible()}
|
||||
/>
|
||||
<>
|
||||
<Sign
|
||||
currentStation={currentStation}
|
||||
originalStationList={originalStationList}
|
||||
oP={StationBoardAcSR.current?.setModalVisible}
|
||||
/>
|
||||
<LED_vision station={currentStation[0]} />
|
||||
</>
|
||||
)}
|
||||
{currentStation && <LED_vision station={currentStation[0]} />}
|
||||
<TouchableOpacity
|
||||
onPress={() => {
|
||||
JRSTraInfoEXAcSR.current?.setModalVisible();
|
||||
}}
|
||||
>
|
||||
<TouchableOpacity onPress={JRSTraInfoEXAcSR.current?.setModalVisible}>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: "#0099CC",
|
||||
@ -518,7 +280,8 @@ export default function Menu(props) {
|
||||
size={30}
|
||||
style={{ margin: 5 }}
|
||||
onPress={() => {
|
||||
LayoutAnimation.easeInEaseOut(), setLoadingDelayData(true);
|
||||
LayoutAnimation.easeInEaseOut();
|
||||
setLoadingDelayData(true);
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
@ -533,7 +296,8 @@ export default function Menu(props) {
|
||||
{loadingDelayData ? (
|
||||
<View style={{ alignItems: "center" }}>
|
||||
<LottieView
|
||||
ref={LottieRef}
|
||||
autoPlay
|
||||
loop
|
||||
style={{
|
||||
width: 150,
|
||||
height: 150,
|
||||
@ -737,7 +501,7 @@ export default function Menu(props) {
|
||||
size={30}
|
||||
/>
|
||||
<Text style={{ fontSize: 30, fontWeight: "bold", color: "white" }}>
|
||||
公式Twitter一族
|
||||
JR四国公式Twitter一族
|
||||
</Text>
|
||||
</View>
|
||||
<View
|
||||
@ -748,65 +512,63 @@ export default function Menu(props) {
|
||||
borderBottomRightRadius: 10,
|
||||
}}
|
||||
>
|
||||
<ListItem
|
||||
onPress={() =>
|
||||
Linking.openURL("https://twitter.com/JRshikoku_tokyo")
|
||||
}
|
||||
>
|
||||
<Text>JR四国 東京営業情報【公式】</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Icon name="chevron-right" size={20} />
|
||||
</ListItem>
|
||||
<ListItem
|
||||
onPress={() =>
|
||||
Linking.openURL("https://twitter.com/JRshikoku_osaka")
|
||||
}
|
||||
>
|
||||
<Text>JR四国 大阪営業部【公式】</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Icon name="chevron-right" size={20} />
|
||||
</ListItem>
|
||||
<ListItem
|
||||
onPress={() => Linking.openURL("https://twitter.com/shikoku_DC")}
|
||||
>
|
||||
<Text>JR四国営業部 四国DC情報【公式】</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Icon name="chevron-right" size={20} />
|
||||
</ListItem>
|
||||
<ListItem
|
||||
onPress={() =>
|
||||
Linking.openURL("https://twitter.com/jr_shikoku_info")
|
||||
}
|
||||
>
|
||||
<Text>JR四国運行情報Twitter</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Icon name="chevron-right" size={20} />
|
||||
</ListItem>
|
||||
<ListItem
|
||||
onPress={() =>
|
||||
Linking.openURL("https://twitter.com/Smile_Eki_Chan")
|
||||
}
|
||||
>
|
||||
<Text>JR四国いそうろう妖精 すまいるえきちゃん♡【公式】</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Icon name="chevron-right" size={20} />
|
||||
</ListItem>
|
||||
<ListItem
|
||||
onPress={() =>
|
||||
Linking.openURL("https://twitter.com/JR_Shikoku_DPT")
|
||||
}
|
||||
>
|
||||
<Text>JR四国デザインPT♡</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Icon name="chevron-right" size={20} />
|
||||
</ListItem>
|
||||
<ListItem
|
||||
onPress={() => Linking.openURL("https://twitter.com/PT2nd_Yuki")}
|
||||
>
|
||||
<Text>JR四国デザインPT弐号◇</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Icon name="chevron-right" size={20} />
|
||||
</ListItem>
|
||||
{((data) =>
|
||||
data.map((d) => (
|
||||
<ListItem onPress={() => Linking.openURL(d.url)}>
|
||||
<Text>{d.name}</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Icon name="chevron-right" size={20} />
|
||||
</ListItem>
|
||||
)))([
|
||||
{
|
||||
url: "https://twitter.com/JRshikoku_eigyo",
|
||||
name: "JR四国営業部【公式】",
|
||||
},
|
||||
{
|
||||
url: "https://twitter.com/JRshikoku_tokyo",
|
||||
name: "JR四国 東京営業情報【公式】",
|
||||
},
|
||||
{
|
||||
url: "https://twitter.com/JRshikoku_osaka",
|
||||
name: "JR四国 大阪営業部【公式】",
|
||||
},
|
||||
{
|
||||
url: "https://twitter.com/jr_shikoku_info",
|
||||
name: "JR四国列車運行情報【公式】",
|
||||
},
|
||||
{
|
||||
url: "https://twitter.com/Smile_Eki_Chan",
|
||||
name: "すまいるえきちゃん♡JR四国【公式】",
|
||||
},
|
||||
{
|
||||
url: "https://twitter.com/jrs_matsuyama",
|
||||
name: "JR四国 松山駅 【公式】",
|
||||
},
|
||||
{
|
||||
url: "https://twitter.com/jrshikoku_kochi",
|
||||
name: "JR四国 高知駅【公式】",
|
||||
},
|
||||
{
|
||||
url: "https://twitter.com/jr_tokust",
|
||||
name: "JR四国 徳島駅【公式】",
|
||||
},
|
||||
{
|
||||
url: "https://twitter.com/jrshikoku_uwjm",
|
||||
name: "JR四国 宇和島駅【公式】",
|
||||
},
|
||||
{
|
||||
url: "https://twitter.com/JRshikoku_wkoch",
|
||||
name: "JR四国 ワープ高知支店【公式】",
|
||||
},
|
||||
{
|
||||
url: "https://twitter.com/jrshikoku_nihaw",
|
||||
name: "JR四国 ワープ新居浜営業所【公式】",
|
||||
},
|
||||
{
|
||||
url: "https://twitter.com/Yoakemonogatari",
|
||||
name: "志国土佐 時代の夜明けのものがたり【公式】",
|
||||
},
|
||||
])}
|
||||
</View>
|
||||
</View>
|
||||
<Text style={{ fontWeight: "bold", fontSize: 20 }}>
|
||||
@ -815,8 +577,6 @@ export default function Menu(props) {
|
||||
<Text>
|
||||
このアプリはXprocess(HARUKIN)が製作しているJR四国の完全非公式アシストアプリケーションです。このアプリに関することでのJR四国公式へ問合せすることはお控えください。以下のTwitterよりお願いします。
|
||||
</Text>
|
||||
<Text>2022/4/14 4.1公開!列車アイコン表示が開始しました。</Text>
|
||||
<Text>2021/6/23 4.0公開!ホーム画面を大改造しました。</Text>
|
||||
<TextBox
|
||||
backgroundColor="#CC0000"
|
||||
flex={1}
|
||||
@ -850,210 +610,18 @@ export default function Menu(props) {
|
||||
source={require("./assets/トレインビジョン関係/1.svg")}
|
||||
/> */}
|
||||
</ScrollView>
|
||||
<ActionSheet
|
||||
ref={JRSTraInfoEXAcSR}
|
||||
gestureEnabled
|
||||
CustomHeaderComponent={() => {}}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: "#0099CC",
|
||||
borderRadius: 5,
|
||||
borderColor: "dark",
|
||||
borderWidth: 1,
|
||||
}}
|
||||
>
|
||||
<View style={{ height: 26, width: "100%" }}>
|
||||
<View
|
||||
style={{
|
||||
height: 6,
|
||||
width: 45,
|
||||
borderRadius: 100,
|
||||
backgroundColor: "#f0f0f0",
|
||||
marginVertical: 10,
|
||||
alignSelf: "center",
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<View
|
||||
style={{ padding: 10, flexDirection: "row", alignItems: "center" }}
|
||||
>
|
||||
<Text style={{ fontSize: 30, fontWeight: "bold", color: "white" }}>
|
||||
列車遅延速報EX
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
{/* <TouchableOpacity style={{padding:10,backgroundColor:"white",alignContent:"center"}} onPress={() => {doFetch()}}>
|
||||
<Text style={{fontSize:20,fontWeight:"bold",color:"#0099CC"}}>最新の情報へ更新</Text>
|
||||
</TouchableOpacity> */}
|
||||
<Text style={{ fontSize: 30, fontWeight: "bold", color: "white" }}>
|
||||
{getTime
|
||||
? getTime.toLocaleTimeString("ja-JP").split(":")[0] +
|
||||
":" +
|
||||
getTime.toLocaleTimeString("ja-JP").split(":")[1]
|
||||
: NaN}{" "}
|
||||
</Text>
|
||||
<Ionicons
|
||||
name="reload"
|
||||
color="white"
|
||||
size={30}
|
||||
style={{ margin: 5 }}
|
||||
onPress={() => {
|
||||
LayoutAnimation.easeInEaseOut(), setLoadingDelayData(true);
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<ScrollView>
|
||||
<View
|
||||
style={{
|
||||
padding: 10,
|
||||
backgroundColor: "white",
|
||||
borderBottomLeftRadius: 5,
|
||||
borderBottomRightRadius: 5,
|
||||
}}
|
||||
>
|
||||
{loadingDelayData ? (
|
||||
<View style={{ alignItems: "center" }}>
|
||||
<LottieView
|
||||
ref={LottieRef2}
|
||||
style={{ width: 150, height: 150, backgroundColor: "#fff" }}
|
||||
source={require("./assets/51690-loading-diamonds.json")}
|
||||
/>
|
||||
</View>
|
||||
) : delayData ? (
|
||||
delayData.map((d) => {
|
||||
let data = d.split(" ");
|
||||
return (
|
||||
<View style={{ flexDirection: "row" }}>
|
||||
<Text style={{ flex: 15, fontSize: 20 }}>
|
||||
{data[0].replace("\n", "")}
|
||||
</Text>
|
||||
<Text style={{ flex: 5, fontSize: 20 }}>{data[1]}</Text>
|
||||
<Text style={{ flex: 6, fontSize: 20 }}>{data[3]}</Text>
|
||||
</View>
|
||||
);
|
||||
})
|
||||
) : (
|
||||
<Text>現在、5分以上の遅れはありません。</Text>
|
||||
)}
|
||||
</View>
|
||||
|
||||
<View style={{ padding: 10 }}>
|
||||
<Text
|
||||
style={{ fontSize: 20, fontWeight: "bold", color: "white" }}
|
||||
>
|
||||
列車遅延情報EXについて
|
||||
</Text>
|
||||
<Text style={{ color: "white" }}>
|
||||
列車遅延情報をJR四国公式列車運行情報より5分毎に取得します。Twitterにて投稿している内容と同一のものとなります。
|
||||
</Text>
|
||||
</View>
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
padding: 10,
|
||||
flexDirection: "row",
|
||||
borderColor: "white",
|
||||
borderWidth: 1,
|
||||
margin: 10,
|
||||
borderRadius: 5,
|
||||
alignItems: "center",
|
||||
}}
|
||||
onPress={() =>
|
||||
Linking.openURL("https://twitter.com/JRSTrainfoEX")
|
||||
}
|
||||
>
|
||||
<MaterialCommunityIcons name="twitter" color="white" size={30} />
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text
|
||||
style={{ fontSize: 25, fontWeight: "bold", color: "white" }}
|
||||
>
|
||||
TwitterBOTはこちら!
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text
|
||||
style={{ fontSize: 25, fontWeight: "bold", color: "white" }}
|
||||
>
|
||||
→
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</ActionSheet>
|
||||
<ActionSheet
|
||||
ref={StationBoardAcSR}
|
||||
gestureEnabled
|
||||
CustomHeaderComponent={() => {}}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: "white",
|
||||
borderRadius: 5,
|
||||
borderColor: "dark",
|
||||
borderWidth: 1,
|
||||
}}
|
||||
>
|
||||
<View style={{ height: 26, width: "100%" }}>
|
||||
<View
|
||||
style={{
|
||||
height: 6,
|
||||
width: 45,
|
||||
borderRadius: 100,
|
||||
backgroundColor: "#f0f0f0",
|
||||
marginVertical: 10,
|
||||
alignSelf: "center",
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<ScrollView>
|
||||
{currentStation && (
|
||||
<Sign
|
||||
currentStation={currentStation}
|
||||
originalStationList={originalStationList}
|
||||
oP={() => Linking.openURL(currentStation[0].StationTimeTable)}
|
||||
/>
|
||||
)}
|
||||
{currentStation && (
|
||||
<View style={{ flexDirection: "row" }}>
|
||||
{!currentStation[0].JrHpUrl || (
|
||||
<TicketBox
|
||||
backgroundColor={"#AD7FA8"}
|
||||
icon={<Foundation name="web" color="white" size={50} />}
|
||||
flex={1}
|
||||
onPressButton={() =>
|
||||
Linking.openURL(currentStation[0].JrHpUrl)
|
||||
}
|
||||
>
|
||||
web
|
||||
</TicketBox>
|
||||
)}
|
||||
{!currentStation[0].StationTimeTable || (
|
||||
<TicketBox
|
||||
backgroundColor={"#8F5902"}
|
||||
icon={<FontAwesome name="table" color="white" size={50} />}
|
||||
flex={1}
|
||||
onPressButton={() =>
|
||||
Linking.openURL(currentStation[0].StationTimeTable)
|
||||
}
|
||||
>
|
||||
時刻表
|
||||
</TicketBox>
|
||||
)}
|
||||
{!currentStation[0].StationMap || (
|
||||
<TicketBox
|
||||
backgroundColor={"#888A85"}
|
||||
icon={<Ionicons name="map" color="white" size={50} />}
|
||||
flex={1}
|
||||
onPressButton={() =>
|
||||
Linking.openURL(currentStation[0].StationMap)
|
||||
}
|
||||
>
|
||||
GoogleMap
|
||||
</TicketBox>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
</ScrollView>
|
||||
</View>
|
||||
</ActionSheet>
|
||||
<StationDeteilView
|
||||
StationBoardAcSR={StationBoardAcSR}
|
||||
currentStation={currentStation}
|
||||
originalStationList={originalStationList}
|
||||
/>
|
||||
<JRSTraInfo
|
||||
JRSTraInfoEXAcSR={JRSTraInfoEXAcSR}
|
||||
getTime={getTime}
|
||||
loadingDelayData={loadingDelayData}
|
||||
setLoadingDelayData={setLoadingDelayData}
|
||||
delayData={delayData}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ export default function TrainBase({ route }) {
|
||||
`document.getElementsByTagName("html")[0].style['font-size'] = '11px';`
|
||||
}`;
|
||||
//const jss = `alert("ほげ")`;
|
||||
console.log(info);
|
||||
return (
|
||||
<View style={{ height: "100%" }}>
|
||||
{Platform.OS == "ios" && <StatusBar barStyle="dark-content" />}
|
||||
|
Loading…
Reference in New Issue
Block a user