駅メニュー表示機能のスクリプト側の抜本的改造

This commit is contained in:
harukin-OneMix4 2023-06-26 22:41:00 +09:00
parent 34f907ef9b
commit 07adaf2ef5
2 changed files with 41 additions and 74 deletions

50
Apps.js
View File

@ -112,34 +112,32 @@ export default function Apps({
alert("駅名標データを取得中..."); alert("駅名標データを取得中...");
return; return;
} }
const selectedStationPDFAddress = event.nativeEvent.data const dataSet = JSON.parse(event.nativeEvent.data);
.split(",")[3] if (dataSet.type == "PopUpMenu") {
.replace("'", "") const selectedStationPDFAddress = dataSet.pdf;
.replace("'", ""); const findStationEachLine = (selectLine) => {
let NearStation = selectLine.filter(
(d) => d.StationTimeTable == selectedStationPDFAddress
);
return NearStation;
};
let returnDataBase = lineList
.map((d) => findStationEachLine(originalStationList[d]))
.filter((d) => d.length > 0)
.reduce((pre, current) => {
pre.push(...current);
return pre;
}, []);
const findStationEachLine = (selectLine) => { if (returnDataBase.length) {
let NearStation = selectLine.filter( setStationBoardData(returnDataBase);
(d) => d.StationTimeTable == selectedStationPDFAddress StationBoardAcSR.current?.setModalVisible();
); } else {
return NearStation; setStationBoardData(undefined);
}; StationBoardAcSR.current?.hide();
}
let returnDataBase = lineList return;
.map((d) => findStationEachLine(originalStationList[d]))
.filter((d) => d.length > 0)
.reduce((pre, current) => {
pre.push(...current);
return pre;
}, []);
if (returnDataBase.length) {
setStationBoardData(returnDataBase);
StationBoardAcSR.current?.setModalVisible();
} else {
setStationBoardData(undefined);
StationBoardAcSR.current?.hide();
} }
return;
}; };
const onNavigationStateChange = (event) => { const onNavigationStateChange = (event) => {

View File

@ -597,7 +597,6 @@ const setStrings = () =>{
var TrainType = undefined; var TrainType = undefined;
if(行き先情報.innerText.includes(列番データ))continue; //回避 if(行き先情報.innerText.includes(列番データ))continue; //回避
` + ` +
//makeTrainMenu +
trainIcon + trainIcon +
normal_train_name + normal_train_name +
JRF_name + JRF_name +
@ -723,57 +722,27 @@ modal_observer.observe(modal_content, {
`; `;
const makeStationMenu = const makeStationMenu =
stationMenu == "true" stationMenu == "true"
? ` ? 'function PopUpMenu(event,id,name,pdf,map,url,chk){window.ReactNativeWebView.postMessage(JSON.stringify({type:"PopUpMenu",event,id,name,pdf,map,url,chk}));}'
//駅メニューダイアログの配置
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 // 子孫ノードも監視対象に含める
});
`
: ``; : ``;
// const makeTrainMenu = // const makeTrainMenu =
// //trainMenu == "true" // //trainMenu == "true"
// true // true
// ? ` // ? `
// function ShowTrainTimeInfo(trainNum,limited){
// if(!element.offclick){ // alert("hoge")
// element.offclick = element.onclick.toString(); // };
// } // // if(!element.offclick){
// element.onclick = () =>{ // // element.offclick = element.onclick.toString();
// console.log("hoge") // // }
// window.ReactNativeWebView.postMessage(element.offclick); // // element.onclick = () =>{
// } // // console.log("hoge")
// // window.ReactNativeWebView.postMessage(element.offclick);
// // }
// ` // `
// : ``; // : ``;
return ( return (
bootData + makeTrainView + trainIconMaker + textInsert + makeStationMenu bootData + makeTrainView + trainIconMaker + textInsert + makeStationMenu
//makeTrainMenu
); );
}; };