From 07adaf2ef56574fd9dfef85e951e2acf34bcfe6e Mon Sep 17 00:00:00 2001 From: harukin-OneMix4 Date: Mon, 26 Jun 2023 22:41:00 +0900 Subject: [PATCH] =?UTF-8?q?=E9=A7=85=E3=83=A1=E3=83=8B=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E6=A9=9F=E8=83=BD=E3=81=AE=E3=82=B9=E3=82=AF?= =?UTF-8?q?=E3=83=AA=E3=83=97=E3=83=88=E5=81=B4=E3=81=AE=E6=8A=9C=E6=9C=AC?= =?UTF-8?q?=E7=9A=84=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Apps.js | 50 +++++++++++++------------- lib/webViewInjectjavascript.js | 65 +++++++++------------------------- 2 files changed, 41 insertions(+), 74 deletions(-) diff --git a/Apps.js b/Apps.js index df1dd6b..9acea69 100644 --- a/Apps.js +++ b/Apps.js @@ -112,34 +112,32 @@ export default function Apps({ alert("駅名標データを取得中..."); return; } - const selectedStationPDFAddress = event.nativeEvent.data - .split(",")[3] - .replace("'", "") - .replace("'", ""); + const dataSet = JSON.parse(event.nativeEvent.data); + if (dataSet.type == "PopUpMenu") { + const selectedStationPDFAddress = dataSet.pdf; + 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) => { - 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; - }, []); - if (returnDataBase.length) { - setStationBoardData(returnDataBase); - StationBoardAcSR.current?.setModalVisible(); - } else { - setStationBoardData(undefined); - StationBoardAcSR.current?.hide(); + if (returnDataBase.length) { + setStationBoardData(returnDataBase); + StationBoardAcSR.current?.setModalVisible(); + } else { + setStationBoardData(undefined); + StationBoardAcSR.current?.hide(); + } + return; } - - return; }; const onNavigationStateChange = (event) => { diff --git a/lib/webViewInjectjavascript.js b/lib/webViewInjectjavascript.js index 4336c50..73d3dc5 100644 --- a/lib/webViewInjectjavascript.js +++ b/lib/webViewInjectjavascript.js @@ -597,7 +597,6 @@ const setStrings = () =>{ var TrainType = undefined; if(行き先情報.innerText.includes(列番データ))continue; //回避 ` + - //makeTrainMenu + trainIcon + normal_train_name + JRF_name + @@ -723,57 +722,27 @@ modal_observer.observe(modal_content, { `; 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 // 子孫ノードも監視対象に含める -}); -` + ? 'function PopUpMenu(event,id,name,pdf,map,url,chk){window.ReactNativeWebView.postMessage(JSON.stringify({type:"PopUpMenu",event,id,name,pdf,map,url,chk}));}' : ``; - // const makeTrainMenu = - // //trainMenu == "true" - // true - // ? ` - - // if(!element.offclick){ - // element.offclick = element.onclick.toString(); - // } - // element.onclick = () =>{ - // console.log("hoge") - // window.ReactNativeWebView.postMessage(element.offclick); - // } + // const makeTrainMenu = + // //trainMenu == "true" + // true + // ? ` + // function ShowTrainTimeInfo(trainNum,limited){ + // alert("hoge") + // }; + // // if(!element.offclick){ + // // element.offclick = element.onclick.toString(); + // // } + // // element.onclick = () =>{ + // // console.log("hoge") + // // window.ReactNativeWebView.postMessage(element.offclick); + // // } // ` - // : ``; + // : ``; return ( bootData + makeTrainView + trainIconMaker + textInsert + makeStationMenu + //makeTrainMenu ); };