駅名標+在線状況LED

This commit is contained in:
harukin-DeskMini 2022-03-28 01:47:03 +09:00
parent 9580425958
commit f73d57e93e
15 changed files with 38204 additions and 37 deletions

120
Apps.js
View File

@ -1,4 +1,4 @@
import React from 'react';
import React, { useRef } from 'react';
import {View, Platform} from 'react-native';
import {WebView} from 'react-native-webview';
import Constants from 'expo-constants';
@ -7,12 +7,13 @@ var Status = StatusbarDetect();
export var webview = null;
export default function Apps ({ navigation: { navigate } }) {
var urlcache="";
const webview = useRef();
return (
<View style={{height:"100%",paddingTop: Constants.statusBarHeight,}}>
{Status}
<WebView
useWebKit={true}
ref={ref => (this.webview = ref)}
ref={webview}
source={{uri: 'https://train.jr-shikoku.co.jp/sp.html'}}
originWhitelist={['https://train.jr-shikoku.co.jp','https://train.jr-shikoku.co.jp/sp.html']}
mixedContentMode={'compatibility'}
@ -27,13 +28,13 @@ export default function Apps ({ navigation: { navigate } }) {
if (event.url.includes("https://train.jr-shikoku.co.jp/usage.htm")) {
if(Platform.OS==="android")navigate('howto');
this.webview.goBack();
webview?.current.goBack();
//Actions.howto();
}
else if (event.url.includes("https://train.jr-shikoku.co.jp/train.html")) {
//Actions.trainbase({info: event.url});
if(Platform.OS==="android")navigate('trainbase', {info: event.url});
this.webview.goBack();
webview?.current.goBack();
}
}
}
@ -54,12 +55,12 @@ const INJECTED_JAVASCRIPT = `
};
observer.observe(elem, config);
document.getElementById('headerStr').style.display = 'none';
document.getElementById('modal_info').style.display = 'none';
document.getElementById('header').querySelector('a').style.display = 'none';
document.getElementById('header').style.height = '50px';
document.getElementById('main').style.paddingTop = '54px';
document.querySelector('#header a').style.display = 'none';
document.getElementById('headerStr').style.display = 'none';
setStrings();
function setStrings(){
try {
@ -83,13 +84,13 @@ const INJECTED_JAVASCRIPT = `
行き先情報.innerText = "(内子経由)"+(flag ? "" : "\\n")+行き先情報.innerText;
}
if(列番データ.indexOf("H") != -1){
行き先情報.innerText = 行き先情報.innerText+"\\n試運転";
行き先情報.innerText = 行き先情報.innerText+"試運転\\n";
}
else if(列番データ.indexOf("R") != -1){
行き先情報.innerText = 行き先情報.innerText+"\\n回送";
行き先情報.innerText = 行き先情報.innerText+"回送\\n";
}
else if(列番データ.indexOf("S") != -1){
行き先情報.innerText = 行き先情報.innerText+"\\n臨時列車";
行き先情報.innerText = 行き先情報.innerText+"臨時列車\\n";
}
//貨物データ
@ -141,12 +142,21 @@ const INJECTED_JAVASCRIPT = `
//土佐くろ
//安芸行と併結列車を個別に表示、それ以外をdefaultで下りなら既定の行き先を、上りなら奈半利行を設定
switch(列番データ){
case "5832D":
case "2086D":
行き先情報.innerText = "[特]あしずり16号\\n高知行";
break;
case "2088D":
行き先情報.innerText = "[特]あしずり18号\\n高知行";
break;
case "5814D":
case "5816D":
行き先情報.innerText = "ごめん・なはり線直通\\n快速 奈半利行";
break;
case "5812D":
行き先情報.innerText = "ごめん・なはり線直通\\n快速 安芸行";
break;
case "5866D":
case "5884D":
case "5892D":
case "5874D":
case "5882D":
行き先情報.innerText = "ごめん・なはり線直通\\n各停 安芸行";
break;
case "742D":
@ -154,12 +164,13 @@ const INJECTED_JAVASCRIPT = `
行き先情報.innerText = "土佐山田/奈半利行\\n(御免にて解結)\\nごめん・なはり線快速";
break;
default:
if(new RegExp(/^58[3-4][1,3,5,7,9][DM]$/).test(列番データ)){
if(new RegExp(/^58[1-3][1,3,5,7,9][DM]$/).test(列番データ)){
行き先情報.innerText = "ごめん・なはり線直通\\n快速 "+行き先情報.innerText;
}
else if(new RegExp(/^58[5-9][1,3,5,7,9][DM]$/).test(列番データ)){
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快速 奈半利行";
}
@ -174,6 +185,72 @@ const INJECTED_JAVASCRIPT = `
}
}
try{
for(let d of document.getElementById('disp').childNodes){
if(d.id == 'pMENU_2'){
continue;
}
if(d.id == 'pMENU_2_En'){
continue;
}
if(d.id == 'pMENU_3'){
continue;
}
if(d.id == 'pMENU_3_En'){
continue;
}
if(d.id == 'pMENU_k'){
continue;
}
if(d.id == 'pMENU_k_En'){
continue;
}
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';
for(let i of f.childNodes){
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)'){
for(let m of i.childNodes){
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';
@ -183,7 +260,14 @@ const INJECTED_JAVASCRIPT = `
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('#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("にゃー");
}

View File

@ -7,7 +7,7 @@
"ios",
"android"
],
"version": "4.0",
"version": "4.1",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
@ -22,14 +22,14 @@
"**/*"
],
"ios": {
"buildNumber": "15",
"buildNumber": "19",
"supportsTablet": true,
"bundleIdentifier": "jrshikokuinfo.xprocess.hrkn"
},
"android": {
"package": "jrshikokuinfo.xprocess.hrkn",
"versionCode": 11,
"permissions": [],
"versionCode": 12,
"permissions": ["ACCESS_FINE_LOCATION"],
"googleServicesFile": "./google-services.json"
}
}

1
assets/予讃線.json Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
{"type":"FeatureCollection","features":[{"properties":{"name":"五十崎","uri":"https://uedayou.net/jrslod/四国旅客鉄道/内子線/五十崎","color":"FBAF18"},"type":"Feature","geometry":{"type":"LineString","coordinates":[[132.63672,33.53833],[132.63599,33.53782]]}},{"properties":{"name":"五十崎","uri":"https://uedayou.net/jrslod/四国旅客鉄道/内子線/五十崎"},"type":"Feature","geometry":{"type":"Point","coordinates":[132.63599,33.53782]}},{"properties":{"name":"内子","uri":"https://uedayou.net/jrslod/四国旅客鉄道/内子線/内子","color":"FBAF18"},"type":"Feature","geometry":{"type":"LineString","coordinates":[[132.64634,33.55023],[132.64618,33.54873]]}},{"properties":{"name":"内子","uri":"https://uedayou.net/jrslod/四国旅客鉄道/内子線/内子"},"type":"Feature","geometry":{"type":"Point","coordinates":[132.64634,33.55023]}},{"properties":{"name":"喜多山","uri":"https://uedayou.net/jrslod/四国旅客鉄道/内子線/喜多山","color":"FBAF18"},"type":"Feature","geometry":{"type":"LineString","coordinates":[[132.61103,33.53326],[132.61184,33.53359]]}},{"properties":{"name":"喜多山","uri":"https://uedayou.net/jrslod/四国旅客鉄道/内子線/喜多山"},"type":"Feature","geometry":{"type":"Point","coordinates":[132.61103,33.53326]}},{"properties":{"name":"新谷","uri":"https://uedayou.net/jrslod/四国旅客鉄道/内子線/新谷","color":"FBAF18"},"type":"Feature","geometry":{"type":"LineString","coordinates":[[132.59812,33.53417],[132.59894,33.53414]]}},{"properties":{"name":"新谷","uri":"https://uedayou.net/jrslod/四国旅客鉄道/内子線/新谷"},"type":"Feature","geometry":{"type":"Point","coordinates":[132.59812,33.53417]}},{"properties":{"name":"内子線","uri":"https://uedayou.net/jrslod/四国旅客鉄道/内子線","color":"FBAF18"},"type":"Feature","geometry":{"type":"MultiLineString","coordinates":[[[132.61103,33.53326],[132.61184,33.53359]],[[132.63672,33.53833],[132.63599,33.53782]],[[132.59894,33.53414],[132.60008,33.53411],[132.60062,33.5341],[132.60165,33.53407],[132.60238,33.53402],[132.603,33.53393],[132.60436,33.53374],[132.60653,33.53343],[132.60837,33.53317],[132.60913,33.53306],[132.60942,33.53306],[132.60975,33.53306],[132.6103,33.53312],[132.61055,33.53315],[132.61086,33.53321],[132.61103,33.53326]],[[132.64634,33.55023],[132.64618,33.54873]],[[132.59812,33.53417],[132.59894,33.53414]],[[132.64618,33.54873],[132.64615,33.54836],[132.64606,33.5477],[132.64603,33.54735],[132.64593,33.54665],[132.64581,33.54616],[132.64569,33.54575],[132.64547,33.54524],[132.64527,33.54496],[132.64488,33.54449],[132.64463,33.54425],[132.64453,33.54415],[132.64379,33.54359],[132.64294,33.54293],[132.64204,33.54222],[132.64181,33.54204],[132.64106,33.54147],[132.63989,33.54055],[132.63898,33.53985],[132.63788,33.53906],[132.63691,33.53844],[132.6368,33.53838],[132.63672,33.53833]],[[132.63599,33.53782],[132.63492,33.53712],[132.63383,33.53646],[132.63354,33.53631],[132.63319,33.53621],[132.6323,33.53609],[132.63157,33.53597],[132.63102,33.53585],[132.63058,33.53569],[132.63016,33.53549],[132.62986,33.53527],[132.6297,33.53515],[132.62939,33.5348],[132.62913,33.53449],[132.62893,33.5343],[132.62862,33.53407],[132.62839,33.53393],[132.62791,33.53379],[132.62699,33.53356],[132.62575,33.53327],[132.62491,33.53313],[132.62449,33.53306],[132.62386,33.53307],[132.62341,33.53308],[132.6231,33.53306],[132.62248,33.53291],[132.62207,33.5328],[132.62171,33.53272],[132.62149,33.53271],[132.62126,33.53273],[132.62069,33.53283],[132.6203,33.53286],[132.61996,33.53288],[132.61954,33.5329],[132.61937,33.53292],[132.61913,33.53298],[132.6187,33.53311],[132.61841,33.53319],[132.61808,33.53329],[132.61675,33.53368],[132.6161,33.53387],[132.61546,33.53407],[132.615,33.53419],[132.61486,33.53421],[132.61474,33.53419],[132.61458,33.53417],[132.61428,33.5341],[132.61409,33.53407],[132.61341,33.53401],[132.6131,33.53397],[132.61285,33.5339],[132.61221,33.53373],[132.61184,33.53359]]]}}]}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,160 @@
import React, { Component, useRef, useState, useEffect } from 'react';
import {StatusBar,View,LayoutAnimation,ScrollView,Linking,Text,TouchableOpacity } from 'react-native';
import {widthPercentageToDP as wp, heightPercentageToDP as hp} from 'react-native-responsive-screen';
let diagramData = undefined;
/**
*
* 1-30M しおかぜ
* 31-58D 南風
* 1001-1030M いしづち(併結)
* 1041-1046M いしづち(単独)
* 1051-1082D 宇和海
* 1091M MX松山
* 1092M MX高松
* 2001-2010D しまんと
* 2071-2086D あしずり
* 3001-3033D うずしお
* 3101-3177M マリンライナー
* 4001-4011D 剣山
* 5006,13,22,29 うずしお(岡山直通南風併結)
* 5831-5843D 土佐くろしお鉄道ごめんなはり線直通快速
* 5853-5892D 土佐くろしお鉄道ごめんなはり線直通普通
* 8011,8012D 四国まんなか千年ものがたり
* 8031,(8041) サンライズ瀬戸, 琴平(延長)
* 8053,8054D トキの夜明けのものがたり
* 8176,8179D アンパントロッコタカマツ
* 8277,8278D アンパントロッココトヒラ
* 8451,8452D よしの川トロッコ
* 8814,8819D しまんトロッコ
* 8911-8914D 伊予灘ものがたり
* 9001-9030* いしづち(リレー)
* 9031M サンライズ瀬戸琴平(延長)(臨時)
* 9062D 四国まんなか千年ものがたり(臨時)
*/
export default function LED_vision(props){
const HeaderConfig = {
headers:{
'referer': 'https://train.jr-shikoku.co.jp/sp.html'
}
}
const [trainDiagram,setTrainDiagram] = useState(null);
const [stationDiagram,setStationDiagram] = useState(null);
const [currentTrain, setCurrentTrain] = useState(null);
useEffect(()=>{
fetch('https://train.jr-shikoku.co.jp/g?arg1=station&arg2=traintimeinfo&arg3=dia', HeaderConfig).then(response => response.text()).then(d=>{
const val = d.replace("[\r\n","").split(',\r\n');
let returnData = {};
val.forEach(element =>{
try{
let data = JSON.parse(element);
Object.keys(data).forEach( key => returnData[key] = data[key] );
}catch(e){
}
})
return(returnData);
}).then((trainDiagram)=>{
let returnData = {};
if(trainDiagram){
Object.keys(trainDiagram).forEach( key => {
if(trainDiagram[key].match(props.stationName..name) ){
returnData[key] = trainDiagram[key];
}
});
}
setTrainDiagram(trainDiagram);
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];
}
if(data.match(props.stationName..name)){
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;
}
}))
};
const trainTimeAndNumber = stationDiagram != null ? getTime() : null;
useEffect(()=>{
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)});
},[])
const filtering = d => currentTrain.map(m=>m.num).includes(d.train)
return(
<View style={{ width: wp("98%"),/* height: wp("98%")/10*9, */backgroundColor:"#432",borderWidth:1,margin:10,marginHorizontal:wp("1%")}} >
<View style={{alignContent:"center",alignItems:"center",width:"100%",marginVertical:10}}>
<Text style={{fontSize:parseInt("25%"),color:"white",fontWeight:"bold"}}>次の列車</Text>
<Text style={{fontSize:parseInt("15%"),color:"white"}}>Next Train</Text>
</View>
{trainTimeAndNumber ? currentTrain && trainTimeAndNumber.filter(filtering).map((d,index)=>
<View style={{alignContent:"center",alignItems:"center",width:"94%",marginVertical:5,marginHorizontal:"3%",backgroundColor:"#000",flexDirection:"row"}}>
<View style={{flex:6,flexDirection:"row"}}>
{/* <Text style={{fontSize:parseInt("25%"),color:"red",fontWeight:"bold"}}>検証中</Text> */}
<Text style={{fontSize:parseInt("22%"),color:"white",fontWeight:"bold"}}>{d.lastStation}</Text>
</View>
<View style={{flex:3}}>
<Text style={{fontSize:parseInt("22%"),color:"white",fontWeight:"bold"}}>{d.time}</Text>
</View>
<View style={{flex:4}}>
<Text style={{fontSize:parseInt("22%"),color:"white",fontWeight:"bold"}}>{d.train}</Text>
</View>
<View style={{flex:5}}>
<Text style={{fontSize:parseInt("22%"),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>
)
: null}
</View>
)
}

286
menu.js
View File

@ -4,6 +4,7 @@ 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';
@ -14,6 +15,36 @@ 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 予讃線 from './assets/四国旅客鉄道予讃線.json';
import 土讃線 from './assets/四国旅客鉄道土讃線.json';
import 高徳線 from './assets/四国旅客鉄道高徳線.json';
import 内子線 from './assets/四国旅客鉄道内子線.json';
import 徳島線 from './assets/四国旅客鉄道徳島線.json';
import 鳴門線 from './assets/四国旅客鉄道鳴門線.json'
import LED_vision from './components/発車時刻表/LED_vidion';
const makeLineStationListValiable = (base,lineName)=>{
let returnData =[];
base.features.forEach(element =>{
if(element.geometry.type=="Point"){
returnData.push({
lat:element.geometry.coordinates[1],
lng:element.geometry.coordinates[0],
name:element.properties.name,
lineName:lineName
})
}
});
return returnData;
}
const yosanLineStation = makeLineStationListValiable(予讃線,"予讃線");
const DosanLineStation = makeLineStationListValiable(土讃線,"土讃線");
const KotokuLineStation = makeLineStationListValiable(高徳線,"高徳線");
const UchikoLineStation = makeLineStationListValiable(内子線,"(予讃)内子線");
const TokushimaLineStation = makeLineStationListValiable(徳島線,"徳島線");
const NarutoLineStation = makeLineStationListValiable(鳴門線,"鳴門線");
const stationList = {};
export default function(props) {
const navigation = useNavigation();
@ -25,6 +56,194 @@ export function Menu(props) {
let result = await WebBrowser.openBrowserAsync(link);
};
const [stationName,setStationName] = useState(undefined);
const getCurrentStation = (location) =>{
const findStationEachLine = (selectLine,selectLineName) => {
const searchArea = 0.005;
for( let selectLineData of selectLine){
let latBool = false;
let lngBool = false;
if(location.latitude < selectLineData.lat){
if((selectLineData.lat - location.latitude) < searchArea)latBool = true;
}
else{
if((location.latitude - selectLineData.lat) < searchArea)latBool = true;
}
if(location.longitude < selectLineData.lng){
if((selectLineData.lng - location.longitude) < searchArea)lngBool = true;
}
else{
if((location.longitude - selectLineData.lng) < searchArea)lngBool = true;
}
if(latBool && lngBool){
for(let data of stationList.日英対応表){
if(data.Station_JP == selectLineData.name){
let pre = undefined;
let nex = undefined;
let now = undefined;
let index =0;
for(let da of stationList[selectLineName]){
if((data.Station_JP == da.Station_JP) || (data.Station_JP == da.StationName)){
try{
let preEn = undefined;
stationList.日英対応表.forEach((j,l)=>{
if(j.Station_JP == (stationList[selectLineName][index-1].Station_JP ? stationList[selectLineName][index-1].Station_JP : stationList[selectLineName][index-1].StationName)){
preEn = j.Station_EN;
}
})
pre = {
name:stationList[selectLineName][index-1].Station_JP ? stationList[selectLineName][index-1].Station_JP : stationList[selectLineName][index-1].StationName,
en:preEn,
StationNumber:stationList[selectLineName][index-1].StationNumber,
StationTimeTable:stationList[selectLineName][index-1].StationTimeTable
}
}catch(e){
pre = {
name:null,
en:null,
StationNumber:null
}
}
now = {
LineName:selectLineData.lineName,
name:selectLineData.name,
en:data.Station_EN,
StationNumber:da.StationNumber,
JrHpUrl:da.JrHpUrl,
StationTimeTable:da.StationTimeTable
}
try{
let nexEn = undefined;
stationList.日英対応表.forEach((j,l)=>{
if(j.Station_JP == (stationList[selectLineName][index+1].Station_JP ? stationList[selectLineName][index+1].Station_JP : stationList[selectLineName][index+1].StationName)){
nexEn = j.Station_EN;
}
})
nex = {
name:stationList[selectLineName][index+1].Station_JP ? stationList[selectLineName][index+1].Station_JP : stationList[selectLineName][index+1].StationName,
en:nexEn,
StationNumber:stationList[selectLineName][index+1].StationNumber,
StationTimeTable:stationList[selectLineName][index+1].StationTimeTable
}
}catch(e){
nex = {
name:null,
en:null,
StationNumber:null,
StationTimeTable:null
}
}
}
index++;
}
if(now){
setStationName({
"前":pre,
"今":now,
"次":nex
});
return true;
}
}
}
}
}
return false;
}
findStationEachLine(yosanLineStation,"予讃線") ? null :
findStationEachLine(yosanLineStation,"松宇線") ? null :
findStationEachLine(UchikoLineStation,"松宇線") ? null :
findStationEachLine(DosanLineStation,"土讃線") ? null :
findStationEachLine(DosanLineStation,"窪川線") ? null :
findStationEachLine(KotokuLineStation,"高徳線") ? null :
findStationEachLine(TokushimaLineStation,"徳島線") ? null :
findStationEachLine(NarutoLineStation,"鳴門線") ? null : console.log("not found");
}
async function loadOfficialStationList(){
const HeaderConfig = {
headers:{
'referer':'https://train.jr-shikoku.co.jp/sp.html'
}
}
Promise.all([
await fetch('https://train.jr-shikoku.co.jp/g?arg1=station&arg2=yosan', HeaderConfig).then(response => response.json()),
await fetch('https://train.jr-shikoku.co.jp/g?arg1=station&arg2=uwajima',HeaderConfig).then(response => response.json()),
await fetch('https://train.jr-shikoku.co.jp/g?arg1=station&arg2=uwajima2',HeaderConfig).then(response => response.json()),
await fetch('https://train.jr-shikoku.co.jp/g?arg1=station&arg2=dosan',HeaderConfig).then(response => response.json()),
await fetch('https://train.jr-shikoku.co.jp/g?arg1=station&arg2=dosan2',HeaderConfig).then(response => response.json()),
await fetch('https://train.jr-shikoku.co.jp/g?arg1=station&arg2=koutoku',HeaderConfig).then(response => response.json()),
await fetch('https://train.jr-shikoku.co.jp/g?arg1=station&arg2=tokushima',HeaderConfig).then(response => response.json()),
await fetch('https://train.jr-shikoku.co.jp/g?arg1=station&arg2=naruto',HeaderConfig).then(response => response.json()),
await fetch('https://train.jr-shikoku.co.jp/g?arg1=station&arg2=between',HeaderConfig).then(response => response.json()),
await fetch('https://train.jr-shikoku.co.jp/g?arg1=line&arg2=train_lang',HeaderConfig).then(response => response.json())
]).then((values)=>{
[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 ))
}
stationList.予讃線 = concatBetweenStations(stationList.予讃線);
stationList.松宇線 = concatBetweenStations(stationList.松宇線);
stationList.伊予灘線 = concatBetweenStations(stationList.伊予灘線);
stationList.土讃線 = concatBetweenStations(stationList.土讃線);
stationList.窪川線 = concatBetweenStations(stationList.窪川線);
stationList.高徳線 = concatBetweenStations(stationList.高徳線);
stationList.徳島線 = concatBetweenStations(stationList.徳島線);
stationList.鳴門線 = concatBetweenStations(stationList.鳴門線);
});
}
const [location, setLocation] = useState(null);
const [errorMsg, setErrorMsg] = useState(null);
useEffect(() => {
(async () => {
let { status } = await Location.requestForegroundPermissionsAsync();
if (status !== 'granted') {
setErrorMsg('Permission to access location was denied');
return;
}
let location = await Location.getCurrentPositionAsync({});
console.log(location);
setLocation(location);
loadOfficialStationList().then(()=>getCurrentStation(location.coords));
})();
}, []);
let text = 'Waiting..';
if (errorMsg) {
text = errorMsg;
} else if (location) {
text = JSON.stringify(location);
}
const LottieRef = useRef(null);
const LottieRef2 = useRef(null);
const [count,setCount] =useState(0);
@ -77,20 +296,59 @@ export function Menu(props) {
<Text style={{color:"white",fontSize:18}}>列車の運行計画混雑状況感染症対策への取り組み</Text>
<View style={{flex:1}} />
</TouchableOpacity>
<View style={{alignItems:"center"}}>
<Image source={require('./assets/トレインビジョン関係/1.svg')}style={{ width: wp("80%"), height: wp("80%")/16*9}}/>
<View style={{ position:"absolute",top:0,left:(wp("100%")-wp("80%"))/2,width: wp("80%"), height: wp("80%")/16*9}}>
<Text style={{position:"absolute",top:"2%",left:"2%",fontStyle:"italic",fontWeight:"bold",fontSize:parseInt("20%"),color:"blue"}}>快速 マリンライナー</Text>
<View style={{position:"absolute",top:"18%",alignContent:"center",flexDirection:"row"}}>
<View style={{flex:1}}/>
<Text style={{fontWeight:"bold",fontSize:parseInt("40%"),color:"dark"}}>坂出</Text>
<View style={{flex:1}}/>
</View>
{stationName ? stationName. ?
<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)}>
<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>
<View style={{position:"absolute",alignContent:"center",alignItems:"center",top:"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%")}}>{stationName..StationNumber}</Text>
<View style={{flex:1}} />
</View>
</View>
<TouchableOpacity /* onPress={()=>alert("まだうごかないよ〜♡ごめんね!!")} */ onPress={() => {actionSheetRef.current?.setModalVisible()}}>
<View style={{backgroundColor:"#0099CC",borderRadius:5,margin:5,borderColor:"black",borderWidth:2,overflow:"hidden"}}>
<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"}}>{stationName..name}</Text>
<Text style={{fontWeight:"bold",fontSize:parseInt("15%"),color:"#005170"}}>{stationName..en}</Text>
</View>
<View style={{flex:1}}/>
</View>
<View style={{position:"absolute",bottom:"0%",height:"30%",width:"100%",alignItems:"center",flexDirection:"row"}}>
{stationName. ? <Text style={{fontWeight:"bold",fontSize:parseInt("20%"),color:"white",paddingHorizontal:10}}></Text> : null}
{stationName. ?
<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"}}>{stationName..StationNumber}</Text>
<View style={{flex:1}} />
</View> : null}
<View style={{flex:1,alignItems:"flex-start"}}>
<Text style={{fontWeight:"bold",fontSize:parseInt("15%"),color:"white"}}>{stationName..name}</Text>
<Text style={{fontWeight:"bold",fontSize:parseInt("15%"),color:"white"}}>{stationName..en}</Text>
</View>
<TouchableOpacity style={{alignItems:"center"}} onPress={()=>_handlePressButtonAsync(stationName..StationTimeTable)}>
<Text style={{fontWeight:"bold",fontSize:parseInt("15%"),backgroundColor:"white",color:"#005170",padding:5}}>時刻表</Text>
</TouchableOpacity>
<View style={{flex:1,alignItems:"flex-end"}}>
<Text style={{fontWeight:"bold",fontSize:parseInt("15%"),color:"white"}}>{stationName..name}</Text>
<Text style={{fontWeight:"bold",fontSize:parseInt("15%"),color:"white"}}>{stationName..en}</Text>
</View>
{stationName..name != null ?
<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"}}>{stationName..StationNumber}</Text>
<View style={{flex:1}} />
</View> : null}
{stationName..name != null ? <Text style={{fontWeight:"bold",fontSize:parseInt("20%"),color:"white",paddingHorizontal:10}}></Text>: null}
</View>
</TouchableOpacity>: null : null}
{stationName ? stationName. ?
<LED_vision stationName={stationName} />
: null : null}
<TouchableOpacity onPress={() => {actionSheetRef.current?.setModalVisible()}}>
<View style={{backgroundColor:"#0099CC",borderRadius:5,margin:10,borderColor:"black",borderWidth:2,overflow:"hidden"}}>
<ScrollView scrollEnabled={false} style={{backgroundColor:"#0099CC",borderRadius:5,maxHeight:300,}}>
<View style={{padding:10,flexDirection:"row",alignItems:"center"}}>
<Text style={{fontSize:30,fontWeight:"bold",color:"white"}}>列車遅延速報EX</Text>
@ -108,7 +366,6 @@ export function Menu(props) {
</View>
: delayData ? delayData.map((d)=>{
let data = d.split(" ");
console.log(data);
return (
<View style={{flexDirection:"row"}}>
<Text style={{flex:15,fontSize:20}}>{data[0].replace("\n","")}</Text>
@ -264,7 +521,6 @@ export function Menu(props) {
</View>
: delayData ? delayData.map((d)=>{
let data = d.split(" ");
console.log(data);
return (
<View style={{flexDirection:"row"}}>
<Text style={{flex:15,fontSize:20}}>{data[0].replace("\n","")}</Text>

View File

@ -14,6 +14,7 @@
"@react-navigation/stack": "^5.14.5",
"expo": "^41.0.0",
"expo-font": "~9.1.0",
"expo-location": "~12.0.4",
"expo-updates": "~0.5.4",
"expo-web-browser": "~9.1.0",
"firebase": "8.2.3",

View File

@ -4860,6 +4860,14 @@ expo-keep-awake@~9.1.2:
resolved "https://registry.yarnpkg.com/expo-keep-awake/-/expo-keep-awake-9.1.2.tgz#b3e52c7bef0ade975ae88637a2bf980f6b573368"
integrity sha512-CCuEOQUNLYtMA0rt0sQ9u5LlIMH7lDJG7dImoorfKMsP95yHXy8dl3oCdtaz2zbsPgggVYeom9gE+gQu+Ki4rQ==
expo-location@~12.0.4:
version "12.0.4"
resolved "https://registry.yarnpkg.com/expo-location/-/expo-location-12.0.4.tgz#718b69516d5efdf8dec6d301c72b791df2da7f24"
integrity sha512-IZaqdBefD8VYmr6hoewQBA4yGfJ5seP1N1UfdwMnH/+l04KJIDfeJZqcV4f9srNnWofxM+aIf1VURPfjS7hkEA==
dependencies:
"@expo/config-plugins" "^1.0.18"
unimodules-permissions-interface "~6.1.0"
expo-structured-headers@~1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/expo-structured-headers/-/expo-structured-headers-1.0.1.tgz#2f3117fc9480e01aa6705493d3213060c2dcf683"
@ -9622,6 +9630,11 @@ unicode-property-aliases-ecmascript@^1.0.4:
resolved "https://registry.yarnpkg.com/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.1.0.tgz#dd57a99f6207bedff4628abefb94c50db941c8f4"
integrity sha512-PqSoPh/pWetQ2phoj5RLiaqIk4kCNwoV3CI+LfGmWLKI3rE3kl1h59XpX2BjgDrmbxD9ARtQobPGU1SguCYuQg==
unimodules-permissions-interface@~6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/unimodules-permissions-interface/-/unimodules-permissions-interface-6.1.0.tgz#fd5589945e3b8fc9d2c80c52521853caea85a9ca"
integrity sha512-jeJx/y+Vn/Cp1/4su5XJ06UBul83MpXkYEqIOAb2jwaikhmj6tNwko7HpKy9OhfGfrhddCzwtedlro8xxZUk9A==
union-value@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.1.tgz#0b6fe7b835aecda61c6ea4d4f02c14221e109847"