diff --git a/components/Menu/RailScope/SearchUnitBox.tsx b/components/Menu/RailScope/SearchUnitBox.tsx index 1a7af13..01cf4be 100644 --- a/components/Menu/RailScope/SearchUnitBox.tsx +++ b/components/Menu/RailScope/SearchUnitBox.tsx @@ -50,26 +50,10 @@ export const SearchUnitBox = ({ flexDirection: "column", display: "flex", flex: 1, + alignContent: "center", + justifyContent: "flex-end", }} > - - {}} - onChange={(ret) => setInput(ret.nativeEvent.text)} - value={input} - style={{ flex: 1 }} - /> - { @@ -87,43 +71,88 @@ export const SearchUnitBox = ({ style={{ marginRight: 10 }} /> - {Object.keys(lineList_LineWebID).map((d) => ( - { - const id = stationIDPair[lineList_LineWebID[d]]; - const s = isSearchMode == id ? undefined : id; - if (!s) return; - setisSearchMode(s); - }} - key={stationIDPair[lineList_LineWebID[d]]} - > - + {}} + onChange={(ret) => setInput(ret.nativeEvent.text)} + value={input} + style={{ flex: 1 }} + /> + {input && ( + setInput("") } + style={{ + padding: 3, + borderRadius: 15, + backgroundColor: "lightgray", + }} > - {stationIDPair[lineList_LineWebID[d]]} - - - ))} + + + )} + + {!input && ( + + {Object.keys(lineList_LineWebID).map((d) => ( + { + const id = stationIDPair[lineList_LineWebID[d]]; + const s = isSearchMode == id ? undefined : id; + if (!s) return; + setisSearchMode(s); + }} + key={stationIDPair[lineList_LineWebID[d]]} + > + + {stationIDPair[lineList_LineWebID[d]]} + + + ))} + + )} )} diff --git a/lib/webViewInjectjavascript.ts b/lib/webViewInjectjavascript.ts index a7f920e..088bd84 100644 --- a/lib/webViewInjectjavascript.ts +++ b/lib/webViewInjectjavascript.ts @@ -73,7 +73,8 @@ export const injectJavascriptData: InjectJavascriptData = ( const trainIcon = ` const setStationIcon = (setIconElem,img,hasProblem) =>{ const position = setIconElem.getAttribute("style").includes("left"); - setIconElem.insertAdjacentHTML('beforebegin', ""); + const marginData = ${uiSetting === "tokyo" ? `"5px"`: `"2px"`} + setIconElem.insertAdjacentHTML('beforebegin', ""); setIconElem.remove(); } @@ -1052,7 +1053,7 @@ export const injectJavascriptData: InjectJavascriptData = ( return undefined; } } - const nameReplace = (列車名データ,列番データ,行き先情報,hasProblem) =>{ + const nameReplace = (列車名データ,列番データ,行き先情報,hasProblem,isLeft) =>{ let isWanman = false; let trainName = ""; let trainType = ""; @@ -1344,14 +1345,9 @@ export const injectJavascriptData: InjectJavascriptData = ( } const gradient = getColors.length > 1 ? "linear-gradient(130deg, " + getColors[0] + " 0%, "+ getColors[0]+"50%, "+ getColors[1]+"50%, " + getColors[1] + " 100%)" : getColors[0]; - 行き先情報.insertAdjacentHTML('beforebegin', "

" + TrainNumber + (JRF ? "":"レ") + "

"); - 行き先情報.insertAdjacentHTML('beforebegin', "

" + (isWanman ? "ワンマン " : "") + "

"); - 行き先情報.insertAdjacentHTML('beforebegin', "

" + viaData + "

"); - 行き先情報.insertAdjacentHTML('beforebegin', "

" + trainName + "

"); - 行き先情報.insertAdjacentHTML('beforebegin', "

" + (ToData ? ToData + "行" : ToData) + "

"); - 行き先情報.insertAdjacentHTML('beforebegin', "

" + trainType + "

"); - 行き先情報.insertAdjacentHTML('beforebegin', "

" + (hasProblem ? "‼️停止中‼️" : "") + "

"); - `: ` + + 行き先情報.insertAdjacentHTML('beforebegin', "

" + TrainNumber + (JRF ? "":"レ") + "

" + (isWanman ? "ワンマン " : "") + "

" + viaData + "

" + trainName + "

" + (ToData ? ToData + "行" : ToData) + "

" + trainType + "

" + (hasProblem ? "‼️停止中‼️" : "") + "

"); +`: ` 行き先情報.insertAdjacentHTML('beforebegin', "

" + returnText1 + "

"); 行き先情報.insertAdjacentHTML('beforebegin', "

" + (ToData ? ToData + "行 " : ToData) + "

" + TrainNumber + (JRF ? "":"レ") + "

"); 行き先情報.insertAdjacentHTML('beforebegin', "

" + (hasProblem ? "‼️停止中‼️" : "") + "

"); @@ -1373,7 +1369,7 @@ const setNewTrainItem = (element,hasProblem)=>{ }else if(JRFTemp){ element.style.borderColor = 'rgba(0, 134, 158, 0.8)'; }else{ - element.style.borderColor = 'white'; + element.style.borderColor = 'black'; } element.style.borderWidth = '2px'; element.style.borderStyle = 'solid'; @@ -1410,12 +1406,12 @@ const setNewTrainItem = (element,hasProblem)=>{ element.addEventListener('touchend', () => element.style.transform = 'scale(1)'); if(element.getAttribute("style").includes("left")){ // borderを使って五角形を生成 下り - element.style.borderRadius = '10% 10% 40% 40%'; + element.style.borderRadius = '30px 30px 120px 120px'; element.style.flexDirection = 'column-reverse'; } else if(element.getAttribute("style").includes("right")){ // borderを使って五角形を生成 上り - element.style.borderRadius = '40% 40% 10% 10%'; + element.style.borderRadius = '120px 120px 30px 30px'; element.style.flexDirection = 'column'; } @@ -1425,57 +1421,70 @@ const setStrings = () =>{ try { const elements = document.querySelectorAll('#disp > div > div > div[onclick]'); const setNewTrainItemUI = ()=>{ - const elementBaseBase = document.querySelectorAll('[id^="stationBlock"]'); - elementBaseBase.forEach(e=>{ //それぞれの駅ブロック横一列 + const aaa = (x2,pos) => { + x2.style.display = 'flex'; + x2.style.flexDirection = 'row'; + if(pos == "right"){ + x2.style.alignItems = 'flex-start'; + x2.style.justifyContent = 'flex-start'; + }else if(pos == "left"){ + x2.style.alignItems = 'flex-end'; + x2.style.justifyContent = 'flex-end'; + } + x2.style.flexWrap = 'wrap'; + x2.style.width = '100%'; + x2.style.height = "100%"; + + } + const aaa2 = (x2) => { + x2.style.display = 'flex'; + x2.style.flexDirection = 'row'; + x2.style.alignItems = 'center'; + x2.style.justifyContent = 'center'; + x2.style.flexWrap = 'wrap'; + x2.style.width = '100%'; + x2.style.height = "unset"; + const x3 = x2.querySelectorAll(":scope > div"); + x3.forEach(i=>{ + i.style.position = "unset"; + i.style.display = "flex"; + i.style.flexDirection = "column"; + i.style.flex = "1"; + i.style.backgroundColor = "#00000000"; + i.querySelectorAll(":scope > *").forEach(j=>{ + j.style.width = "100%"; + j.style.textAlign = "center"; + j.style.margin = "5px"; + j.style.padding = "5px"; + }); + }); + } + const layoutBase = (e)=>{ e.style.display = 'flex'; e.style.height = "unset"; e.style.flexDirection = 'row'; - //e.style.alignItems = "left"; e.style.justifyContent = 'center'; - const x = e.querySelectorAll(':scope > div');//配下のdiv要素を選択 - //x[0] 登りブロック x[2] 下りブロック x[1] 駅ブロック - const aaa = (x2,pos) => { - x2.style.display = 'flex'; - x2.style.flexDirection = 'row'; - if(pos == "right"){ - x2.style.alignItems = 'flex-start'; - x2.style.justifyContent = 'flex-start'; - }else if(pos == "left"){ - x2.style.alignItems = 'flex-end'; - x2.style.justifyContent = 'flex-end'; - } - x2.style.flexWrap = 'wrap'; - x2.style.width = '100%'; - x2.style.height = "100%"; - - } - const aaa2 = (x2) => { - x2.style.display = 'flex'; - x2.style.flexDirection = 'row'; - x2.style.alignItems = 'center'; - x2.style.justifyContent = 'center'; - x2.style.flexWrap = 'wrap'; - x2.style.width = '100%'; - x2.style.height = "unset"; - const x3 = x2.querySelectorAll(":scope > div"); - x3.forEach(i=>{ - i.style.position = "unset"; - i.style.display = "flex"; - i.style.flexDirection = "column"; - i.style.flex = "1"; - i.style.backgroundColor = "#00000000"; - i.querySelectorAll(":scope > *").forEach(j=>{ - j.style.width = "100%"; - j.style.textAlign = "center"; - j.style.margin = "5px"; - j.style.padding = "5px"; - }); - }); - } + } + const elementBaseBase = document.querySelectorAll('[id^="stationBlock"]'); + const elementNotBase = document.querySelectorAll('#disp > [id*="~"]'); + elementNotBase.forEach(e=>{ + layoutBase(e); + const x = e.querySelectorAll(':scope > [id^="Up"], :scope > [id^="Id"], :scope > [id^="Down"]');//配下のdiv要素を選択 + aaa(x[0],"left"); + aaa2(x[1]); + aaa(x[2],"right"); + const upTrainCrossBarElement = e.querySelector(':scope > [id="upTrainCrossBar"]'); + if (upTrainCrossBarElement) { + upTrainCrossBarElement.style.left = '0px'; + } + }); + elementBaseBase.forEach(e=>{ //それぞれの駅ブロック横一列 + layoutBase(e); + const x = e.querySelectorAll(':scope > div');//配下のdiv要素を選択 + //x[0] 登りブロック x[2] 下りブロック x[1] 駅ブロック aaa(x[0],"left"); aaa2(x[1]); aaa(x[2],"right"); - }); } @@ -1486,6 +1495,9 @@ const setStrings = () =>{ var 行き先情報 = element.getElementsByTagName("p")[0]; ${uiSetting === "tokyo" ? ` + element.querySelector("img").insertAdjacentHTML('beforebegin',"
"); + element.querySelector("img").insertAdjacentHTML('afterend',"
"); + element.querySelector("img").style.padding = '5px'; element.style.position = 'relative'; if(element.getElementsByTagName("p")[1] != undefined){ element.getElementsByTagName("p")[1].innerText = element.getElementsByTagName("p")[1].innerText.replace("(","").replace(")",""); @@ -1506,6 +1518,7 @@ const setStrings = () =>{ element.getElementsByTagName("p")[1].style.top = '0px'; } }`: ``} + const isLeft = element.getAttribute("style").includes("left"); var 列番データ = element.getAttribute('offclick').split('"')[1]; var 列車名データ = element.getAttribute('offclick').split('"')[3]; const trainData = trainPositionDatas.filter(e=>!(e.Pos && e.Pos.includes("予告窓"))).find(e => e.TrainNum == 列番データ); @@ -1530,7 +1543,7 @@ const setStrings = () =>{ } } ` : ""} - nameReplace(列車名データ,列番データ,行き先情報,hasProblem); + nameReplace(列車名データ,列番データ,行き先情報,hasProblem,isLeft); ${uiSetting === "tokyo" ? `setNewTrainItem(element,hasProblem);`: ``} } try{