From 7004eeefad5fefeda44f409b4f0e96fb4dc10458 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Mon, 2 Mar 2026 12:38:43 +0000 Subject: [PATCH] Add station data, train icon mapping, and train type configuration - Introduced `stationData.ts` to store station information including names, numbers, and features. - Created `trainIconMap.ts` for mapping train numbers to their respective image URLs, including dynamic URLs for special trains. - Added `trainTypeConfig.ts` to define display settings for various train types, including colors and labels for different categories. --- lib/webViewInjectjavascript.ts | 739 ++------------------------------- lib/webview/stationData.ts | 72 ++++ lib/webview/trainIconMap.ts | 455 ++++++++++++++++++++ lib/webview/trainTypeConfig.ts | 35 ++ 4 files changed, 594 insertions(+), 707 deletions(-) create mode 100644 lib/webview/stationData.ts create mode 100644 lib/webview/trainIconMap.ts create mode 100644 lib/webview/trainTypeConfig.ts diff --git a/lib/webViewInjectjavascript.ts b/lib/webViewInjectjavascript.ts index c7b5eae..9b7335c 100644 --- a/lib/webViewInjectjavascript.ts +++ b/lib/webViewInjectjavascript.ts @@ -1,4 +1,7 @@ import { INTERVALS, API_ENDPOINTS } from '@/constants'; +import { TRAIN_TYPE_CONFIG } from './webview/trainTypeConfig'; +import { TRAIN_ICON_MAP, TRAIN_ICON_REGEX } from './webview/trainIconMap'; +import { STATION_DATA } from './webview/stationData'; export interface InjectJavascriptOptions { /** 地図スイッチ ("true" | "false") */ @@ -65,6 +68,17 @@ export const injectJavascriptData = ({ let unyohubData = []; const useUnyohubSetting = ${useUnyohub === "true"}; + // 列車種別設定 (typeColor / borderColor / bgColor / label / isWanman) + const TRAIN_TYPE_CFG = ${JSON.stringify(TRAIN_TYPE_CONFIG)}; + + // operationList から列番が一致する運行情報を返すヘルパー + const getOperationsByTrainId = (trainId) => { + return operationList.filter(e => { + const ids = [...(e.train_ids||[]),...(e.related_train_ids||[])].map(x=>x.split(",")[0]); + return ids.includes(String(trainId)); + }); + }; + // --- localStorage キャッシュヘルパー(起動直後の即時表示用)--- // データ種別ごとの有効期限(ミリ秒) const CACHE_TTL = { @@ -368,497 +382,16 @@ export const injectJavascriptData = ({ if (backCount == 0 || backCount == 100) setIconElem.remove(); } + const _TIM = ${JSON.stringify(TRAIN_ICON_MAP)}; + const _TIR = ${JSON.stringify(TRAIN_ICON_REGEX)}; + const _AP = "https://n8n.haruk.in/webhook/anpanman-pictures.png?trainNum="; const setTrainIcon = (列番データ) => { - 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": - return "https://storage.haruk.in/s8000nr.png"; - //8000 アンパン - case "10M": - case "22M": - case "9M": - case "21M": - return "https://n8n.haruk.in/webhook/anpanman-pictures.png?trainNum=" + - 列番データ; - - //8600 - case "8M": - case "12M": - case "20M": - case "24M": - case "7M": - case "11M": - case "19M": - case "23M": - return "https://storage.haruk.in/s8600.png"; - - //いしづちメイン - //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": - return "https://storage.haruk.in/s8000no.png"; - - //8000 アンパン - case "1010M": - case "1022M": - case "1009M": - case "1021M": - return "https://n8n.haruk.in/webhook/anpanman-pictures.png?trainNum=" + - 列番データ; - //8600 - case "1008M": - case "1012M": - case "1020M": - case "1024M": - case "1007M": - case "1011M": - case "1019M": - case "1023M": - return "https://storage.haruk.in/s8600_isz.png"; - - //MEXP - //8000 - case "1092M": - return "https://storage.haruk.in/s8000nr.png"; - //8600 - case "1091M": - return "https://storage.haruk.in/s8600_isz.png"; - //三桁いしづち - //8000 アンパン - case "1041M": - case "1044M": - return "https://n8n.haruk.in/webhook/anpanman-pictures.png?trainNum=" + - 列番データ; - //8600 - case "1043M": - case "1042M": - case "1046M": - return "https://storage.haruk.in/s8600_isz.png"; - //南風 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": - return "https://storage.haruk.in/s2700.png"; - //2700アンパン - case "32D": - case "36D": - case "44D": - case "48D": - case "56D": - case "33D": - case "37D": - case "45D": - case "49D": - case "57D": - return "https://n8n.haruk.in/webhook/anpanman-pictures.png?trainNum=" + - 列番データ; - //うずしお - //2700 - case "3004D": - case "3006D": - case "3010D": - case "3014D": - case "3016D": - case "3022D": - case "3028D": - case "3003D": - case "3007D": - case "3013D": - case "3019D": - case "3025D": - case "3031D": - return "https://storage.haruk.in/s2700_uzu.png"; - //2700 二両編成 - - case "3008D": - case "3020D": - case "3026D": - case "3001D": - case "3005D": - case "3011D": - case "3017D": - case "3023D": - case "3029D": - return "https://storage.haruk.in/s2700_uzu.png"; - //2600 - case "3002D": - case "3012D": - case "3018D": - case "3024D": - case "3030D": - case "3009D": - case "3015D": - case "3021D": - case "3027D": - case "3033D": - return "https://storage.haruk.in/s2600.png"; - //マリンライナー - 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": - return "https://storage.haruk.in/s5001.png"; - case "3102M": - case "3101M": - case "3103M": - case "3171M": - case "3173M": - return "https://storage.haruk.in/s5001k.png"; - - //サンライズ瀬戸 - case "5032M": - case "5031M": - case "8041M": //琴平延長高松迄 - case "8031M": //琴平延長高松以降 - return "https://storage.haruk.in/w285.png"; - //宇和海 - //2000 ノーマル - case "1052D": - case "1054D": - case "1056D": - case "1060D": - case "1062D": - case "1064D": - case "1068D": - case "1070D": - case "1072D": - case "1076D": - case "1078D": - case "1080D": - case "1082D": - case "1051D": - case "1055D": - case "1057D": - case "1061D": - case "1063D": - case "1065D": - case "1069D": - case "1071D": - case "1073D": - case "1075D": - case "1077D": - case "1079D": - case "1081D": - return "https://storage.haruk.in/s2000_uwa.png"; - //2000 アンパン込み - case "1058D": - case "1066D": - case "1074D": - case "1053D": - case "1059D": - case "1067D": - return "https://n8n.haruk.in/webhook/anpanman-pictures.png?trainNum=" + - 列番データ; - //しまんと - case "2002D": - case "2004D": - case "2001D": - case "2003D": - return "https://storage.haruk.in/s2000_smn.png"; - //あしずり 2000 - case "2074D": - case "2076D": - case "2080D": - case "2082D": - case "2071D": - case "2073D": - case "2079D": - case "2081D": - return "https://n8n.haruk.in/webhook/anpanman-pictures.png?trainNum=" + - 列番データ; - - //あしずり 2700 - case "2072D": - case "2078D": - case "2084D": - case "2075D": - case "2077D": - case "2083D": - return "https://storage.haruk.in/s2700_asi.png"; - //剣山 - case "4002D": - case "4004D": - case "4006D": - case "4001D": - case "4003D": - case "4005D": - case "4007D": - return "https://storage.haruk.in/s185tu.png"; - - //よしのがわトロッコ - case "8452D": - case "8451D": - return "https://storage.haruk.in/s185to_ai.png"; - - //岡山高松アントロ - case "8176D": - case "8179D": - //岡山琴平アントロ - case "8277D": - case "8278D": - return "https://storage.haruk.in/s32to4.png"; - - //千年ものがたり - case "8021D": - case "8022D": - return "https://storage.haruk.in/s185mm1.png"; - - //夜明けものがたり - case "8082D": - case "8083D": - case "8073D": - case "8074D": - return "https://storage.haruk.in/s185ym1.png"; - //ラマルドボア - case "9253M": - case "9256M": - return "https://storage.haruk.in/w213w.png"; - - // 貨物 - case "74": - case "75": - case "70": - case "71": - case "73": - case "76": - case "3070": - case "3071": - case "3072": - case "3073": - case "3076": - case "3077": - case "3078": - case "3079": - case "8070": - case "8071": - case "8072": - case "8077": - return "https://storage.haruk.in/ef210a.png"; - - // 伊予灘ものがたり 赤 - case "8091D": - case "8093D": - return "https://storage.haruk.in/s185iyor.png"; - // 伊予灘ものがたり 黄 - case "8092D": - case "8094D": - return "https://storage.haruk.in/s185iyoy.png"; - - // 高徳線、徳島線、牟岐線、鳴門線普通列車系統 - // キハ40・47 - case "4303D": - case "371D": - case "316D": - case "362D": - case "4376D": - case "951D": - case "953D": - case "955D": - case "973D": - case "975D": - case "977D": - case "979D": - case "981D": - case "950D": - case "968D": - case "970D": - case "972D": - case "974D": - case "976D": - case "980D": - case "982D": - return "https://storage.haruk.in/s40.png"; - // 1000形 - case "4311D": - case "363D": - case "356D": - case "4374D": - case "433D": - case "4447D": - case "451D": - case "450D": - case "4458D": - case "474D": - return "https://storage.haruk.in/s1000.png"; - // 1200形 - case "4301D": - case "4327D": - case "4329D": - case "4343D": - case "353D": - case "355D": - case "367D": - case "310D": - case "4326D": - case "4334D": - case "4342D": - case "358D": - case "364D": - case "4453D": - case "4455D": - case "4457D": - case "463D": - case "475D": - case "477D": - case "485D": - case "4430D": - case "434D": - case "438D": - case "4460D": - case "4464D": - case "4466D": - case "478D": - case "484D": - case "957D": - case "4959D": - case "4963D": - case "4967D": - case "4971D": - case "952D": - case "4954D": - case "4958D": - case "4962D": - case "4966D": - return "https://storage.haruk.in/s1200n.png"; - // 半定期臨時列車 - case "9174M": - return "https://storage.haruk.in/s5001.png"; - case "9395D": - return "https://storage.haruk.in/s1500.png"; - - default: //指定車両でなく、Regexでの指定に移動 - // 高徳線 普通列車系統 - if (new RegExp(/^(4|5)3\\d\\dD$/).test(列番データ)) { - return "https://storage.haruk.in/s1500.png"; - } else if (new RegExp(/^3\\d\\dD$/).test(列番データ)) { - return "https://storage.haruk.in/s1500.png"; - } // 徳島線 普通列車系統 - else if (new RegExp(/^(4|5)4\\d\\dD$/).test(列番データ)) { - return "https://storage.haruk.in/s1500.png"; - } else if (new RegExp(/^4\\d\\dD$/).test(列番データ)) { - return "https://storage.haruk.in/s1500.png"; - } // 鳴門線普通列車系統 - else if (new RegExp(/^(4|5)9(5|6|7|8)\\dD$/).test(列番データ)) { - return "https://storage.haruk.in/s1500.png"; - } else if (new RegExp(/^9(5|6|7|8)\\dD$/).test(列番データ)) { - return "https://storage.haruk.in/s1500.png"; - } - break; + const _u = _TIM[列番データ]; + if (_u != null) return _u === "__anpanman__" ? _AP + 列番データ : _u; + for (const {pattern, url} of _TIR) { + if (new RegExp(pattern).test(列番データ)) return url; } - } + }; `; const normal_train_name = ` @@ -1027,107 +560,15 @@ export const injectJavascriptData = ({ if(trainDataList.find(e => e.train_id === 列番データ) !== undefined){ const data = trainDataList.find(e => e.train_id === 列番データ); - switch(data.type){ - case "Normal": - trainTypeColor = "black"; - isWanman = false; - trainType = "普通"; - break; - case "OneMan": - trainTypeColor = "black"; - isWanman = true; - trainType = "普通"; - break; - case "Rapid": - trainTypeColor = "rgba(0, 140, 255, 1)"; - isWanman = false; - trainType = "快速"; - break; - case "OneManRapid": - trainTypeColor = "rgba(0, 140, 255, 1)"; - isWanman = true; - trainType = "快速"; - break; - case "LTDEXP": - trainTypeColor = "red"; - isWanman = false; - trainType = "特急"; - break; - case "NightLTDEXP": - trainTypeColor = "#d300b0ff"; - isWanman = false; - trainType = "寝台特急"; - break; - case "SPCL": - case "SPCL_Normal": - trainTypeColor = "#008d07ff"; - isWanman = false; - trainType = "臨時"; - break; - case "SPCL_Rapid": - trainTypeColor = "rgba(0, 81, 255, 1)"; - isWanman = false; - trainType = "臨時快速"; - break; - case "SPCL_EXP": - trainTypeColor = "#a52e2eff"; - isWanman = false; - trainType = "臨時特急"; - break; - case "Party": - trainTypeColor = "#ff7300ff"; - isWanman = false; - trainType = "団体臨時"; - break; - case "Freight": - trainTypeColor = "#00869ecc"; - isWanman = false; - trainType = "貨物"; - break; - case "Forwarding": - trainTypeColor = "#727272cc"; - isWanman = false; - trainType = "回送"; - break; - case "Trial": - trainTypeColor = "#727272cc"; - isWanman = false; - trainType = "試運転"; - break; - case "Construction": - trainTypeColor = "#727272cc"; - isWanman = false; - trainType = "工事"; - break; - case "FreightForwarding": - trainTypeColor = "#727272cc"; - isWanman = false; - trainType = "単機回送"; - break; - default: - break; + const _tCfg = TRAIN_TYPE_CFG[data.type]; + if (_tCfg) { + trainTypeColor = _tCfg.typeColor; + isWanman = _tCfg.isWanman; + trainType = _tCfg.label; } isEdit = data.priority == 400; isSeason = data.priority == 300; - operationList - .sort((a,b)=>sortOperationalList(a,b,data.train_id)) - .forEach(e => { - if (e.train_ids?.length > 0) { - const trainIds = e.train_ids.map((x) => x.split(",")[0]); - if (trainIds.includes(data.train_id.toString())) { - //returnData.push(e); - isEdit = true; - } - } else if (e.related_train_ids?.length > 0) { - const trainIds = e.related_train_ids.map( - (x) => x.split(",")[0] - ); - if (trainIds.includes(data.train_id.toString())) { - //returnData.push(e); - isEdit = true; - } - } - }); + if (getOperationsByTrainId(data.train_id).length > 0) isEdit = true; if(data.train_name != ""){ trainName = data.train_name; if(data.train_num_distance != ""){ @@ -1266,73 +707,9 @@ const setNewTrainItem = (element,hasProblem,type)=>{ var 列番データ = element.getAttribute('offclick').split('"')[1]; if(trainDataList.find(e => e.train_id === 列番データ) !== undefined){ const data = trainDataList.find(e => e.train_id === 列番データ); - switch (data.type) { - case "Normal": - element.style.borderColor = "black"; - element.style.backgroundColor = '#ffffffcc'; - break; - case "OneMan": - element.style.borderColor = "black"; - element.style.backgroundColor = '#ffffffcc'; - break; - case "Rapid": - element.style.borderColor = "rgba(0, 140, 255, 1)"; - element.style.backgroundColor = '#ffffffcc'; - break; - case "OneManRapid": - element.style.borderColor = "rgba(0, 140, 255, 1)"; - element.style.backgroundColor = '#ffffffcc'; - break; - case "LTDEXP": - element.style.borderColor = "red"; - element.style.backgroundColor = '#ffffffcc'; - break; - case "NightLTDEXP": - element.style.borderColor = "#d300b0ff"; - element.style.backgroundColor = '#ffffffcc'; - break; - case "SPCL": - case "SPCL_Normal": - element.style.borderColor = "#008d07ff"; - element.style.backgroundColor = '#ffffffcc'; - break; - case "SPCL_Rapid": - element.style.borderColor = "#0051ffff"; - element.style.backgroundColor = '#ffffffcc'; - break; - case "SPCL_EXP": - element.style.borderColor = "#a52e2eff"; - element.style.backgroundColor = '#ffffffcc'; - break; - case "Party": - element.style.borderColor = "#ff7300ff"; - element.style.backgroundColor = '#ffd0a9ff'; - break; - case "Freight": - element.style.borderColor = "#00869ecc"; - element.style.backgroundColor = '#c7c7c7cc'; - break; - case "Forwarding": - element.style.borderColor = "#727272cc"; - element.style.backgroundColor = '#c7c7c7cc'; - break; - case "Trial": - element.style.borderColor = "#727272cc"; - element.style.backgroundColor = '#c7c7c7cc'; - break; - case "Construction": - element.style.borderColor = "#727272cc"; - element.style.backgroundColor = '#c7c7c7cc'; - break; - case "FreightForwarding": - element.style.borderColor = "#727272cc"; - element.style.backgroundColor = '#c7c7c7cc'; - break; - default: - element.style.borderColor = 'black'; - element.style.backgroundColor = '#ffffffcc'; - break; - } + const _bc = TRAIN_TYPE_CFG[data.type]; + element.style.borderColor = _bc ? _bc.borderColor : 'black'; + element.style.backgroundColor = _bc ? _bc.bgColor : '#ffffffcc'; }else{ if(element.getAttribute('offclick').includes("express")){ element.style.borderColor = '#ff0000ff'; @@ -1738,59 +1115,7 @@ textInsert.observe(document.getElementById('disp'), { } }); } catch(e) { /* 既にnon-configurableで定義済みの場合は無視 */ } -const StationData = [ -{"StationName":"高松","StationNumber":"Y00","Feature":'{"Midori":{"style":"normal"},"IC":true}'}, -{"StationName":"香西","StationNumber":"Y01","Feature":'{"Midori":{"style":"none"},"IC":true}'}, -{"StationName":"鬼無","StationNumber":"Y02","Feature":'{"Midori":{"style":"none"},"IC":true}'}, -{"StationName":"端岡","StationNumber":"Y03","Feature":'{"Midori":{"style":"none"},"IC":true}'}, -{"StationName":"国分","StationNumber":"Y04","Feature":'{"Midori":{"style":"none"},"IC":true}'}, -{"StationName":"讃岐府中","StationNumber":"Y05","Feature":'{"Midori":{"style":"none"},"IC":true}'}, -{"StationName":"鴨川","StationNumber":"Y06","Feature":'{"Midori":{"style":"none"},"IC":true}'}, -{"StationName":"八十場","StationNumber":"Y07","Feature":'{"Midori":{"style":"none"},"IC":true}'}, -{"StationName":"坂出","StationNumber":"Y08","Feature":'{"Midori":{"style":"normal"},"IC":true}'}, -{"StationName":"宇多津","StationNumber":"Y09","Feature":'{"Midori":{"style":"normal"},"IC":true}'}, -{"StationName":"丸亀","StationNumber":"Y10","Feature":'{"Midori":{"style":"normal"},"IC":true}'}, -{"StationName":"讃岐塩屋","StationNumber":"Y11","Feature":'{"Midori":{"style":"none"},"IC":true}'}, -{"StationName":"多度津","StationNumber":"Y12","Feature":'{"Midori":{"style":"normal"},"IC":true}'}, -{"StationName":"詫間","StationNumber":"Y14","Feature":'{"Midori":{"style":"plus"},"IC":true}'}, -{"StationName":"観音寺","StationNumber":"Y19","Feature":'{"Midori":{"style":"normal"},"IC":true}'}, -{"StationName":"川之江","StationNumber":"Y22","Feature":'{"Midori":{"style":"plus"},"IC":false}'}, -{"StationName":"伊予三島","StationNumber":"Y23","Feature":'{"Midori":{"style":"normal"},"IC":false}'}, -{"StationName":"新居浜","StationNumber":"Y29","Feature":'{"Midori":{"style":"normal"},"IC":false}'}, -{"StationName":"伊予西条","StationNumber":"Y31","Feature":'{"Midori":{"style":"normal"},"IC":false}'}, -{"StationName":"壬生川","StationNumber":"Y36","Feature":'{"Midori":{"style":"plus"},"IC":false}'}, -{"StationName":"今治","StationNumber":"Y40","Feature":'{"Midori":{"style":"plus"},"IC":false}'}, -{"StationName":"伊予北条","StationNumber":"Y48","Feature":'{"Midori":{"style":"plus"},"IC":false}'}, -{"StationName":"松山","StationNumber":"Y55","Feature":'{"Midori":{"style":"normal"},"IC":false}'}, -{"StationName":"内子","StationNumber":"U10","Feature":'{"Midori":{"style":"plus"},"IC":false}'}, -{"StationName":"伊予大洲","StationNumber":"U14","Feature":'{"Midori":{"style":"plus"},"IC":false}'}, -{"StationName":"伊予大洲","StationNumber":"S18","Feature":'{"Midori":{"style":"plus"},"IC":false}'}, -{"StationName":"八幡浜","StationNumber":"U18","Feature":'{"Midori":{"style":"normal"},"IC":false}'}, -{"StationName":"宇和島","StationNumber":"U28","Feature":'{"Midori":{"style":"plus"},"IC":false}'}, -{"StationName":"多度津","StationNumber":"D12","Feature":'{"Midori":{"style":"normal"},"IC":true}'}, -{"StationName":"善通寺","StationNumber":"D14","Feature":'{"Midori":{"style":"plus"},"IC":true}'}, -{"StationName":"琴平","StationNumber":"D15","Feature":'{"Midori":{"style":"plus"},"IC":true}'}, -{"StationName":"阿波池田","StationNumber":"D22","Feature":'{"Midori":{"style":"plus"},"IC":false}'}, -{"StationName":"土佐山田","StationNumber":"D37","Feature":'{"Midori":{"style":"plus"},"IC":false}'}, -{"StationName":"後免","StationNumber":"D40","Feature":'{"Midori":{"style":"plus"},"IC":false}'}, -{"StationName":"高知","StationNumber":"D45","Feature":'{"Midori":{"style":"normal"},"IC":false}'}, -{"StationName":"高知","StationNumber":"K00","Feature":'{"Midori":{"style":"normal"},"IC":false}'}, -{"StationName":"朝倉","StationNumber":"K05","Feature":'{"Midori":{"style":"plus"},"IC":false}'}, -{"StationName":"須崎","StationNumber":"K19","Feature":'{"Midori":{"style":"plus"},"IC":false}'}, -{"StationName":"窪川","StationNumber":"K26","Feature":'{"Midori":{"style":"normal"},"IC":false}'}, -{"StationName":"高松","StationNumber":"T28","Feature":'{"Midori":{"style":"normal"},"IC":true}'}, -{"StationName":"栗林公園北口","StationNumber":"T26","Feature":'{"Midori":{"style":"none"},"IC":true}'}, -{"StationName":"栗林","StationNumber":"T25","Feature":'{"Midori":{"style":"plus"},"IC":true}'}, -{"StationName":"屋島","StationNumber":"T24","Feature":'{"Midori":{"style":"none"},"IC":true}'}, -{"StationName":"志度","StationNumber":"T19","Feature":'{"Midori":{"style":"plus"},"IC":false}'}, -{"StationName":"三本松","StationNumber":"T12","Feature":'{"Midori":{"style":"plus"},"IC":false}'}, -{"StationName":"徳島","StationNumber":"T00","Feature":'{"Midori":{"style":"normal"},"IC":false}'}, -{"StationName":"鳴門","StationNumber":"N10","Feature":'{"Midori":{"style":"plus"},"IC":false}'}, -{"StationName":"阿南","StationNumber":"","Feature":'{"Midori":{"style":"normal"},"IC":false}'}, -{"StationName":"牟岐","StationNumber":"","Feature":'{"Midori":{"style":"normal"},"IC":false}'}, -{"StationName":"鴨島","StationNumber":"B09","Feature":'{"Midori":{"style":"plus"},"IC":false}'}, -{"StationName":"穴吹","StationNumber":"B16","Feature":'{"Midori":{"style":"plus"},"IC":false}'}, -]; +const StationData = ${JSON.stringify(STATION_DATA)}; const setStationMenuDialog = new MutationObserver( (mutations) => { const data =[]; document.querySelectorAll('#disp div div').forEach(d=>d.id.indexOf("st")!= -1 && data.push(d)); diff --git a/lib/webview/stationData.ts b/lib/webview/stationData.ts new file mode 100644 index 0000000..0b36097 --- /dev/null +++ b/lib/webview/stationData.ts @@ -0,0 +1,72 @@ +/** + * 駅情報データ (みどりの窓口・ICカード対応状況) + * Feature フィールドは WebView 内で JSON.parse() して使用する。 + */ +export interface StationDataItem { + StationName: string; + StationNumber: string; + /** JSON文字列: { Midori: { style: "normal"|"plus"|"none" }, IC: boolean } */ + Feature: string; +} + +export const STATION_DATA: StationDataItem[] = [ + // ── 予讃線 ───────────────────────────── + { StationName: "高松", StationNumber: "Y00", Feature: '{"Midori":{"style":"normal"},"IC":true}' }, + { StationName: "香西", StationNumber: "Y01", Feature: '{"Midori":{"style":"none"},"IC":true}' }, + { StationName: "鬼無", StationNumber: "Y02", Feature: '{"Midori":{"style":"none"},"IC":true}' }, + { StationName: "端岡", StationNumber: "Y03", Feature: '{"Midori":{"style":"none"},"IC":true}' }, + { StationName: "国分", StationNumber: "Y04", Feature: '{"Midori":{"style":"none"},"IC":true}' }, + { StationName: "讃岐府中", StationNumber: "Y05", Feature: '{"Midori":{"style":"none"},"IC":true}' }, + { StationName: "鴨川", StationNumber: "Y06", Feature: '{"Midori":{"style":"none"},"IC":true}' }, + { StationName: "八十場", StationNumber: "Y07", Feature: '{"Midori":{"style":"none"},"IC":true}' }, + { StationName: "坂出", StationNumber: "Y08", Feature: '{"Midori":{"style":"normal"},"IC":true}' }, + { StationName: "宇多津", StationNumber: "Y09", Feature: '{"Midori":{"style":"normal"},"IC":true}' }, + { StationName: "丸亀", StationNumber: "Y10", Feature: '{"Midori":{"style":"normal"},"IC":true}' }, + { StationName: "讃岐塩屋", StationNumber: "Y11", Feature: '{"Midori":{"style":"none"},"IC":true}' }, + { StationName: "多度津", StationNumber: "Y12", Feature: '{"Midori":{"style":"normal"},"IC":true}' }, + { StationName: "詫間", StationNumber: "Y14", Feature: '{"Midori":{"style":"plus"},"IC":true}' }, + { StationName: "観音寺", StationNumber: "Y19", Feature: '{"Midori":{"style":"normal"},"IC":true}' }, + { StationName: "川之江", StationNumber: "Y22", Feature: '{"Midori":{"style":"plus"},"IC":false}' }, + { StationName: "伊予三島", StationNumber: "Y23", Feature: '{"Midori":{"style":"normal"},"IC":false}' }, + { StationName: "新居浜", StationNumber: "Y29", Feature: '{"Midori":{"style":"normal"},"IC":false}' }, + { StationName: "伊予西条", StationNumber: "Y31", Feature: '{"Midori":{"style":"normal"},"IC":false}' }, + { StationName: "壬生川", StationNumber: "Y36", Feature: '{"Midori":{"style":"plus"},"IC":false}' }, + { StationName: "今治", StationNumber: "Y40", Feature: '{"Midori":{"style":"plus"},"IC":false}' }, + { StationName: "伊予北条", StationNumber: "Y48", Feature: '{"Midori":{"style":"plus"},"IC":false}' }, + { StationName: "松山", StationNumber: "Y55", Feature: '{"Midori":{"style":"normal"},"IC":false}' }, + // ── 内子線・海線 ───────────────────────── + { StationName: "内子", StationNumber: "U10", Feature: '{"Midori":{"style":"plus"},"IC":false}' }, + { StationName: "伊予大洲", StationNumber: "U14", Feature: '{"Midori":{"style":"plus"},"IC":false}' }, + { StationName: "伊予大洲", StationNumber: "S18", Feature: '{"Midori":{"style":"plus"},"IC":false}' }, + { StationName: "八幡浜", StationNumber: "U18", Feature: '{"Midori":{"style":"normal"},"IC":false}' }, + { StationName: "宇和島", StationNumber: "U28", Feature: '{"Midori":{"style":"plus"},"IC":false}' }, + // ── 土讃線 ───────────────────────────── + { StationName: "多度津", StationNumber: "D12", Feature: '{"Midori":{"style":"normal"},"IC":true}' }, + { StationName: "善通寺", StationNumber: "D14", Feature: '{"Midori":{"style":"plus"},"IC":true}' }, + { StationName: "琴平", StationNumber: "D15", Feature: '{"Midori":{"style":"plus"},"IC":true}' }, + { StationName: "阿波池田", StationNumber: "D22", Feature: '{"Midori":{"style":"plus"},"IC":false}' }, + { StationName: "土佐山田", StationNumber: "D37", Feature: '{"Midori":{"style":"plus"},"IC":false}' }, + { StationName: "後免", StationNumber: "D40", Feature: '{"Midori":{"style":"plus"},"IC":false}' }, + { StationName: "高知", StationNumber: "D45", Feature: '{"Midori":{"style":"normal"},"IC":false}' }, + // ── 予土線 ───────────────────────────── + { StationName: "高知", StationNumber: "K00", Feature: '{"Midori":{"style":"normal"},"IC":false}' }, + { StationName: "朝倉", StationNumber: "K05", Feature: '{"Midori":{"style":"plus"},"IC":false}' }, + { StationName: "須崎", StationNumber: "K19", Feature: '{"Midori":{"style":"plus"},"IC":false}' }, + { StationName: "窪川", StationNumber: "K26", Feature: '{"Midori":{"style":"normal"},"IC":false}' }, + // ── 高徳線 ───────────────────────────── + { StationName: "高松", StationNumber: "T28", Feature: '{"Midori":{"style":"normal"},"IC":true}' }, + { StationName: "栗林公園北口", StationNumber: "T26", Feature: '{"Midori":{"style":"none"},"IC":true}' }, + { StationName: "栗林", StationNumber: "T25", Feature: '{"Midori":{"style":"plus"},"IC":true}' }, + { StationName: "屋島", StationNumber: "T24", Feature: '{"Midori":{"style":"none"},"IC":true}' }, + { StationName: "志度", StationNumber: "T19", Feature: '{"Midori":{"style":"plus"},"IC":false}' }, + { StationName: "三本松", StationNumber: "T12", Feature: '{"Midori":{"style":"plus"},"IC":false}' }, + { StationName: "徳島", StationNumber: "T00", Feature: '{"Midori":{"style":"normal"},"IC":false}' }, + // ── 鳴門線 ───────────────────────────── + { StationName: "鳴門", StationNumber: "N10", Feature: '{"Midori":{"style":"plus"},"IC":false}' }, + // ── 牟岐線 ───────────────────────────── + { StationName: "阿南", StationNumber: "", Feature: '{"Midori":{"style":"normal"},"IC":false}' }, + { StationName: "牟岐", StationNumber: "", Feature: '{"Midori":{"style":"normal"},"IC":false}' }, + // ── 徳島線 ───────────────────────────── + { StationName: "鴨島", StationNumber: "B09", Feature: '{"Midori":{"style":"plus"},"IC":false}' }, + { StationName: "穴吹", StationNumber: "B16", Feature: '{"Midori":{"style":"plus"},"IC":false}' }, +]; diff --git a/lib/webview/trainIconMap.ts b/lib/webview/trainIconMap.ts new file mode 100644 index 0000000..4777831 --- /dev/null +++ b/lib/webview/trainIconMap.ts @@ -0,0 +1,455 @@ +/** + * 列番号 → 列車画像URL のマッピングデータ + * + * "__anpanman__" は動的URLのセンチネル値。 + * WebView inject 側で アンパンマン列車判定 URL に変換される。 + * (https://n8n.haruk.in/webhook/anpanman-pictures.png?trainNum=<列番>) + */ + +const AP = "__anpanman__"; + +/** 完全一致マッピング (列番 → URL | "__anpanman__") */ +export const TRAIN_ICON_MAP: Record = { + // ── しおかぜ ─────────────────────────────────────── + // 8000 ノーマル + "2M": "https://storage.haruk.in/s8000nr.png", + "4M": "https://storage.haruk.in/s8000nr.png", + "6M": "https://storage.haruk.in/s8000nr.png", + "14M": "https://storage.haruk.in/s8000nr.png", + "16M": "https://storage.haruk.in/s8000nr.png", + "18M": "https://storage.haruk.in/s8000nr.png", + "26M": "https://storage.haruk.in/s8000nr.png", + "28M": "https://storage.haruk.in/s8000nr.png", + "30M": "https://storage.haruk.in/s8000nr.png", + "1M": "https://storage.haruk.in/s8000nr.png", + "3M": "https://storage.haruk.in/s8000nr.png", + "5M": "https://storage.haruk.in/s8000nr.png", + "13M": "https://storage.haruk.in/s8000nr.png", + "15M": "https://storage.haruk.in/s8000nr.png", + "17M": "https://storage.haruk.in/s8000nr.png", + "25M": "https://storage.haruk.in/s8000nr.png", + "27M": "https://storage.haruk.in/s8000nr.png", + "29M": "https://storage.haruk.in/s8000nr.png", + // 8000 アンパン + "10M": AP, + "22M": AP, + "9M": AP, + "21M": AP, + // 8600 + "8M": "https://storage.haruk.in/s8600.png", + "12M": "https://storage.haruk.in/s8600.png", + "20M": "https://storage.haruk.in/s8600.png", + "24M": "https://storage.haruk.in/s8600.png", + "7M": "https://storage.haruk.in/s8600.png", + "11M": "https://storage.haruk.in/s8600.png", + "19M": "https://storage.haruk.in/s8600.png", + "23M": "https://storage.haruk.in/s8600.png", + + // ── いしづち ─────────────────────────────────────── + // 8000 ノーマル + "1004M": "https://storage.haruk.in/s8000no.png", + "1006M": "https://storage.haruk.in/s8000no.png", + "1014M": "https://storage.haruk.in/s8000no.png", + "1016M": "https://storage.haruk.in/s8000no.png", + "1018M": "https://storage.haruk.in/s8000no.png", + "1026M": "https://storage.haruk.in/s8000no.png", + "1028M": "https://storage.haruk.in/s8000no.png", + "1030M": "https://storage.haruk.in/s8000no.png", + "1001M": "https://storage.haruk.in/s8000no.png", + "1003M": "https://storage.haruk.in/s8000no.png", + "1005M": "https://storage.haruk.in/s8000no.png", + "1013M": "https://storage.haruk.in/s8000no.png", + "1015M": "https://storage.haruk.in/s8000no.png", + "1017M": "https://storage.haruk.in/s8000no.png", + "1025M": "https://storage.haruk.in/s8000no.png", + "1027M": "https://storage.haruk.in/s8000no.png", + "1029M": "https://storage.haruk.in/s8000no.png", + // 8000 アンパン + "1010M": AP, + "1022M": AP, + "1009M": AP, + "1021M": AP, + // 8600 + "1008M": "https://storage.haruk.in/s8600_isz.png", + "1012M": "https://storage.haruk.in/s8600_isz.png", + "1020M": "https://storage.haruk.in/s8600_isz.png", + "1024M": "https://storage.haruk.in/s8600_isz.png", + "1007M": "https://storage.haruk.in/s8600_isz.png", + "1011M": "https://storage.haruk.in/s8600_isz.png", + "1019M": "https://storage.haruk.in/s8600_isz.png", + "1023M": "https://storage.haruk.in/s8600_isz.png", + // MEXP + "1092M": "https://storage.haruk.in/s8000nr.png", + "1091M": "https://storage.haruk.in/s8600_isz.png", + // 三桁いしづち アンパン + "1041M": AP, + "1044M": AP, + // 三桁いしづち 8600 + "1043M": "https://storage.haruk.in/s8600_isz.png", + "1042M": "https://storage.haruk.in/s8600_isz.png", + "1046M": "https://storage.haruk.in/s8600_isz.png", + + // ── 南風 ─────────────────────────────────────────── + // 2700 ノーマル + "34D": "https://storage.haruk.in/s2700.png", + "38D": "https://storage.haruk.in/s2700.png", + "40D": "https://storage.haruk.in/s2700.png", + "42D": "https://storage.haruk.in/s2700.png", + "46D": "https://storage.haruk.in/s2700.png", + "50D": "https://storage.haruk.in/s2700.png", + "52D": "https://storage.haruk.in/s2700.png", + "54D": "https://storage.haruk.in/s2700.png", + "58D": "https://storage.haruk.in/s2700.png", + "31D": "https://storage.haruk.in/s2700.png", + "35D": "https://storage.haruk.in/s2700.png", + "39D": "https://storage.haruk.in/s2700.png", + "41D": "https://storage.haruk.in/s2700.png", + "43D": "https://storage.haruk.in/s2700.png", + "47D": "https://storage.haruk.in/s2700.png", + "51D": "https://storage.haruk.in/s2700.png", + "53D": "https://storage.haruk.in/s2700.png", + "55D": "https://storage.haruk.in/s2700.png", + // 2700 アンパン + "32D": AP, + "36D": AP, + "44D": AP, + "48D": AP, + "56D": AP, + "33D": AP, + "37D": AP, + "45D": AP, + "49D": AP, + "57D": AP, + + // ── うずしお ─────────────────────────────────────── + // 2700 + "3004D": "https://storage.haruk.in/s2700_uzu.png", + "3006D": "https://storage.haruk.in/s2700_uzu.png", + "3010D": "https://storage.haruk.in/s2700_uzu.png", + "3014D": "https://storage.haruk.in/s2700_uzu.png", + "3016D": "https://storage.haruk.in/s2700_uzu.png", + "3022D": "https://storage.haruk.in/s2700_uzu.png", + "3028D": "https://storage.haruk.in/s2700_uzu.png", + "3003D": "https://storage.haruk.in/s2700_uzu.png", + "3007D": "https://storage.haruk.in/s2700_uzu.png", + "3013D": "https://storage.haruk.in/s2700_uzu.png", + "3019D": "https://storage.haruk.in/s2700_uzu.png", + "3025D": "https://storage.haruk.in/s2700_uzu.png", + "3031D": "https://storage.haruk.in/s2700_uzu.png", + "3008D": "https://storage.haruk.in/s2700_uzu.png", + "3020D": "https://storage.haruk.in/s2700_uzu.png", + "3026D": "https://storage.haruk.in/s2700_uzu.png", + "3001D": "https://storage.haruk.in/s2700_uzu.png", + "3005D": "https://storage.haruk.in/s2700_uzu.png", + "3011D": "https://storage.haruk.in/s2700_uzu.png", + "3017D": "https://storage.haruk.in/s2700_uzu.png", + "3023D": "https://storage.haruk.in/s2700_uzu.png", + "3029D": "https://storage.haruk.in/s2700_uzu.png", + // 2600 + "3002D": AP, + "3012D": AP, + "3018D": AP, + "3024D": AP, + "3030D": AP, + "3009D": AP, + "3015D": AP, + "3021D": AP, + "3027D": AP, + "3033D": AP, + + // ── マリンライナー ───────────────────────────────── + "3104M": "https://storage.haruk.in/s5001.png", + "3106M": "https://storage.haruk.in/s5001.png", + "3108M": "https://storage.haruk.in/s5001.png", + "3110M": "https://storage.haruk.in/s5001.png", + "3112M": "https://storage.haruk.in/s5001.png", + "3114M": "https://storage.haruk.in/s5001.png", + "3116M": "https://storage.haruk.in/s5001.png", + "3118M": "https://storage.haruk.in/s5001.png", + "3120M": "https://storage.haruk.in/s5001.png", + "3122M": "https://storage.haruk.in/s5001.png", + "3124M": "https://storage.haruk.in/s5001.png", + "3126M": "https://storage.haruk.in/s5001.png", + "3128M": "https://storage.haruk.in/s5001.png", + "3130M": "https://storage.haruk.in/s5001.png", + "3132M": "https://storage.haruk.in/s5001.png", + "3134M": "https://storage.haruk.in/s5001.png", + "3136M": "https://storage.haruk.in/s5001.png", + "3138M": "https://storage.haruk.in/s5001.png", + "3140M": "https://storage.haruk.in/s5001.png", + "3142M": "https://storage.haruk.in/s5001.png", + "3144M": "https://storage.haruk.in/s5001.png", + "3146M": "https://storage.haruk.in/s5001.png", + "3148M": "https://storage.haruk.in/s5001.png", + "3150M": "https://storage.haruk.in/s5001.png", + "3152M": "https://storage.haruk.in/s5001.png", + "3154M": "https://storage.haruk.in/s5001.png", + "3156M": "https://storage.haruk.in/s5001.png", + "3158M": "https://storage.haruk.in/s5001.png", + "3160M": "https://storage.haruk.in/s5001.png", + "3162M": "https://storage.haruk.in/s5001.png", + "3164M": "https://storage.haruk.in/s5001.png", + "3166M": "https://storage.haruk.in/s5001.png", + "3168M": "https://storage.haruk.in/s5001.png", + "3170M": "https://storage.haruk.in/s5001.png", + "3105M": "https://storage.haruk.in/s5001.png", + "3107M": "https://storage.haruk.in/s5001.png", + "3109M": "https://storage.haruk.in/s5001.png", + "3111M": "https://storage.haruk.in/s5001.png", + "3113M": "https://storage.haruk.in/s5001.png", + "3115M": "https://storage.haruk.in/s5001.png", + "3117M": "https://storage.haruk.in/s5001.png", + "3119M": "https://storage.haruk.in/s5001.png", + "3121M": "https://storage.haruk.in/s5001.png", + "3123M": "https://storage.haruk.in/s5001.png", + "3125M": "https://storage.haruk.in/s5001.png", + "3127M": "https://storage.haruk.in/s5001.png", + "3129M": "https://storage.haruk.in/s5001.png", + "3131M": "https://storage.haruk.in/s5001.png", + "3133M": "https://storage.haruk.in/s5001.png", + "3135M": "https://storage.haruk.in/s5001.png", + "3137M": "https://storage.haruk.in/s5001.png", + "3139M": "https://storage.haruk.in/s5001.png", + "3141M": "https://storage.haruk.in/s5001.png", + "3143M": "https://storage.haruk.in/s5001.png", + "3145M": "https://storage.haruk.in/s5001.png", + "3147M": "https://storage.haruk.in/s5001.png", + "3149M": "https://storage.haruk.in/s5001.png", + "3151M": "https://storage.haruk.in/s5001.png", + "3153M": "https://storage.haruk.in/s5001.png", + "3155M": "https://storage.haruk.in/s5001.png", + "3157M": "https://storage.haruk.in/s5001.png", + "3159M": "https://storage.haruk.in/s5001.png", + "3161M": "https://storage.haruk.in/s5001.png", + "3163M": "https://storage.haruk.in/s5001.png", + "3165M": "https://storage.haruk.in/s5001.png", + "3167M": "https://storage.haruk.in/s5001.png", + "3169M": "https://storage.haruk.in/s5001.png", + "3175M": "https://storage.haruk.in/s5001.png", + // マリンライナー(快速) + "3102M": "https://storage.haruk.in/s5001k.png", + "3101M": "https://storage.haruk.in/s5001k.png", + "3103M": "https://storage.haruk.in/s5001k.png", + "3171M": "https://storage.haruk.in/s5001k.png", + "3173M": "https://storage.haruk.in/s5001k.png", + + // ── サンライズ瀬戸 ───────────────────────────────── + "5032M": "https://storage.haruk.in/w285.png", + "5031M": "https://storage.haruk.in/w285.png", + "8041M": "https://storage.haruk.in/w285.png", + "8031M": "https://storage.haruk.in/w285.png", + + // ── 宇和海 ───────────────────────────────────────── + // 2000 ノーマル + "1052D": "https://storage.haruk.in/s2000_uwa.png", + "1054D": "https://storage.haruk.in/s2000_uwa.png", + "1056D": "https://storage.haruk.in/s2000_uwa.png", + "1060D": "https://storage.haruk.in/s2000_uwa.png", + "1062D": "https://storage.haruk.in/s2000_uwa.png", + "1064D": "https://storage.haruk.in/s2000_uwa.png", + "1068D": "https://storage.haruk.in/s2000_uwa.png", + "1070D": "https://storage.haruk.in/s2000_uwa.png", + "1072D": "https://storage.haruk.in/s2000_uwa.png", + "1076D": "https://storage.haruk.in/s2000_uwa.png", + "1078D": "https://storage.haruk.in/s2000_uwa.png", + "1080D": "https://storage.haruk.in/s2000_uwa.png", + "1082D": "https://storage.haruk.in/s2000_uwa.png", + "1051D": "https://storage.haruk.in/s2000_uwa.png", + "1055D": "https://storage.haruk.in/s2000_uwa.png", + "1057D": "https://storage.haruk.in/s2000_uwa.png", + "1061D": "https://storage.haruk.in/s2000_uwa.png", + "1063D": "https://storage.haruk.in/s2000_uwa.png", + "1065D": "https://storage.haruk.in/s2000_uwa.png", + "1069D": "https://storage.haruk.in/s2000_uwa.png", + "1071D": "https://storage.haruk.in/s2000_uwa.png", + "1073D": "https://storage.haruk.in/s2000_uwa.png", + "1075D": "https://storage.haruk.in/s2000_uwa.png", + "1077D": "https://storage.haruk.in/s2000_uwa.png", + "1079D": "https://storage.haruk.in/s2000_uwa.png", + "1081D": "https://storage.haruk.in/s2000_uwa.png", + // 2000 アンパン + "1058D": AP, + "1066D": AP, + "1074D": AP, + "1053D": AP, + "1059D": AP, + "1067D": AP, + + // ── しまんと ─────────────────────────────────────── + "2002D": "https://storage.haruk.in/s2000_smn.png", + "2004D": "https://storage.haruk.in/s2000_smn.png", + "2001D": "https://storage.haruk.in/s2000_smn.png", + "2003D": "https://storage.haruk.in/s2000_smn.png", + + // ── あしずり ─────────────────────────────────────── + // 2000 + "2074D": "https://storage.haruk.in/s2000_smn.png", + "2076D": "https://storage.haruk.in/s2000_smn.png", + "2080D": "https://storage.haruk.in/s2000_smn.png", + "2082D": "https://storage.haruk.in/s2000_smn.png", + "2071D": "https://storage.haruk.in/s2000_smn.png", + "2073D": "https://storage.haruk.in/s2000_smn.png", + "2079D": "https://storage.haruk.in/s2000_smn.png", + "2081D": "https://storage.haruk.in/s2000_smn.png", + // 2700 + "2072D": "https://storage.haruk.in/s2700_asi.png", + "2078D": "https://storage.haruk.in/s2700_asi.png", + "2084D": "https://storage.haruk.in/s2700_asi.png", + "2075D": "https://storage.haruk.in/s2700_asi.png", + "2077D": "https://storage.haruk.in/s2700_asi.png", + "2083D": "https://storage.haruk.in/s2700_asi.png", + + // ── 剣山 ─────────────────────────────────────────── + "4002D": "https://storage.haruk.in/s185tu.png", + "4004D": "https://storage.haruk.in/s185tu.png", + "4006D": "https://storage.haruk.in/s185tu.png", + "4001D": "https://storage.haruk.in/s185tu.png", + "4003D": "https://storage.haruk.in/s185tu.png", + "4005D": "https://storage.haruk.in/s185tu.png", + "4007D": "https://storage.haruk.in/s185tu.png", + + // ── よしのがわトロッコ ───────────────────────────── + "8452D": "https://storage.haruk.in/s185to_ai.png", + "8451D": "https://storage.haruk.in/s185to_ai.png", + + // ── 岡山高松/琴平アントロ ────────────────────────── + "8176D": "https://storage.haruk.in/s32to4.png", + "8179D": "https://storage.haruk.in/s32to4.png", + "8277D": "https://storage.haruk.in/s32to4.png", + "8278D": "https://storage.haruk.in/s32to4.png", + + // ── 千年ものがたり ───────────────────────────────── + "8021D": "https://storage.haruk.in/s185mm1.png", + "8022D": "https://storage.haruk.in/s185mm1.png", + + // ── 夜明けものがたり ─────────────────────────────── + "8082D": "https://storage.haruk.in/s185ym1.png", + "8083D": "https://storage.haruk.in/s185ym1.png", + "8073D": "https://storage.haruk.in/s185ym1.png", + "8074D": "https://storage.haruk.in/s185ym1.png", + + // ── ラ・マルどこまでも ───────────────────────────── + "9253M": "https://storage.haruk.in/w213w.png", + "9256M": "https://storage.haruk.in/w213w.png", + + // ── 貨物 ─────────────────────────────────────────── + "74": "https://storage.haruk.in/ef210a.png", + "75": "https://storage.haruk.in/ef210a.png", + "70": "https://storage.haruk.in/ef210a.png", + "71": "https://storage.haruk.in/ef210a.png", + "73": "https://storage.haruk.in/ef210a.png", + "76": "https://storage.haruk.in/ef210a.png", + "3070": "https://storage.haruk.in/ef210a.png", + "3071": "https://storage.haruk.in/ef210a.png", + "3072": "https://storage.haruk.in/ef210a.png", + "3073": "https://storage.haruk.in/ef210a.png", + "3076": "https://storage.haruk.in/ef210a.png", + "3077": "https://storage.haruk.in/ef210a.png", + "3078": "https://storage.haruk.in/ef210a.png", + "3079": "https://storage.haruk.in/ef210a.png", + "8070": "https://storage.haruk.in/ef210a.png", + "8071": "https://storage.haruk.in/ef210a.png", + "8072": "https://storage.haruk.in/ef210a.png", + "8077": "https://storage.haruk.in/ef210a.png", + + // ── 伊予灘ものがたり ─────────────────────────────── + "8091D": "https://storage.haruk.in/s185iyor.png", + "8093D": "https://storage.haruk.in/s185iyor.png", + "8092D": "https://storage.haruk.in/s185iyoy.png", + "8094D": "https://storage.haruk.in/s185iyoy.png", + + // ── 高徳線・徳島線・牟岐線・鳴門線 キハ40・47 ──── + "4303D": "https://storage.haruk.in/s40.png", + "371D": "https://storage.haruk.in/s40.png", + "316D": "https://storage.haruk.in/s40.png", + "362D": "https://storage.haruk.in/s40.png", + "4376D": "https://storage.haruk.in/s40.png", + "951D": "https://storage.haruk.in/s40.png", + "953D": "https://storage.haruk.in/s40.png", + "955D": "https://storage.haruk.in/s40.png", + "973D": "https://storage.haruk.in/s40.png", + "975D": "https://storage.haruk.in/s40.png", + "977D": "https://storage.haruk.in/s40.png", + "979D": "https://storage.haruk.in/s40.png", + "981D": "https://storage.haruk.in/s40.png", + "950D": "https://storage.haruk.in/s40.png", + "968D": "https://storage.haruk.in/s40.png", + "970D": "https://storage.haruk.in/s40.png", + "972D": "https://storage.haruk.in/s40.png", + "974D": "https://storage.haruk.in/s40.png", + "976D": "https://storage.haruk.in/s40.png", + "980D": "https://storage.haruk.in/s40.png", + "982D": "https://storage.haruk.in/s40.png", + + // ── 1000形 ───────────────────────────────────────── + "4311D": "https://storage.haruk.in/s1000.png", + "363D": "https://storage.haruk.in/s1000.png", + "356D": "https://storage.haruk.in/s1000.png", + "4374D": "https://storage.haruk.in/s1000.png", + "433D": "https://storage.haruk.in/s1000.png", + "4447D": "https://storage.haruk.in/s1000.png", + "451D": "https://storage.haruk.in/s1000.png", + "450D": "https://storage.haruk.in/s1000.png", + "4458D": "https://storage.haruk.in/s1000.png", + "474D": "https://storage.haruk.in/s1000.png", + + // ── 1200形 ───────────────────────────────────────── + "4301D": "https://storage.haruk.in/s1200n.png", + "4327D": "https://storage.haruk.in/s1200n.png", + "4329D": "https://storage.haruk.in/s1200n.png", + "4343D": "https://storage.haruk.in/s1200n.png", + "353D": "https://storage.haruk.in/s1200n.png", + "355D": "https://storage.haruk.in/s1200n.png", + "367D": "https://storage.haruk.in/s1200n.png", + "310D": "https://storage.haruk.in/s1200n.png", + "4326D": "https://storage.haruk.in/s1200n.png", + "4334D": "https://storage.haruk.in/s1200n.png", + "4342D": "https://storage.haruk.in/s1200n.png", + "358D": "https://storage.haruk.in/s1200n.png", + "364D": "https://storage.haruk.in/s1200n.png", + "4453D": "https://storage.haruk.in/s1200n.png", + "4455D": "https://storage.haruk.in/s1200n.png", + "4457D": "https://storage.haruk.in/s1200n.png", + "463D": "https://storage.haruk.in/s1200n.png", + "475D": "https://storage.haruk.in/s1200n.png", + "477D": "https://storage.haruk.in/s1200n.png", + "485D": "https://storage.haruk.in/s1200n.png", + "4430D": "https://storage.haruk.in/s1200n.png", + "434D": "https://storage.haruk.in/s1200n.png", + "438D": "https://storage.haruk.in/s1200n.png", + "4460D": "https://storage.haruk.in/s1200n.png", + "4464D": "https://storage.haruk.in/s1200n.png", + "4466D": "https://storage.haruk.in/s1200n.png", + "478D": "https://storage.haruk.in/s1200n.png", + "484D": "https://storage.haruk.in/s1200n.png", + "957D": "https://storage.haruk.in/s1200n.png", + "4959D": "https://storage.haruk.in/s1200n.png", + "4963D": "https://storage.haruk.in/s1200n.png", + "4967D": "https://storage.haruk.in/s1200n.png", + "4971D": "https://storage.haruk.in/s1200n.png", + "952D": "https://storage.haruk.in/s1200n.png", + "4954D": "https://storage.haruk.in/s1200n.png", + "4958D": "https://storage.haruk.in/s1200n.png", + "4962D": "https://storage.haruk.in/s1200n.png", + "4966D": "https://storage.haruk.in/s1200n.png", + + // ── 半定期臨時 ───────────────────────────────────── + "9174M": "https://storage.haruk.in/s5001.png", + "9395D": "https://storage.haruk.in/s1500.png", +}; + +/** 正規表現パターンマッチング (完全一致で未ヒットの場合に評価) */ +export const TRAIN_ICON_REGEX: Array<{ pattern: string; url: string }> = [ + // 高徳線 普通 + { pattern: "^(4|5)3\\d\\dD$", url: "https://storage.haruk.in/s1500.png" }, + { pattern: "^3\\d\\dD$", url: "https://storage.haruk.in/s1500.png" }, + // 徳島線 普通 + { pattern: "^(4|5)4\\d\\dD$", url: "https://storage.haruk.in/s1500.png" }, + { pattern: "^4\\d\\dD$", url: "https://storage.haruk.in/s1500.png" }, + // 鳴門線 普通 + { + pattern: "^(4|5)9(5|6|7|8)\\dD$", + url: "https://storage.haruk.in/s1500.png", + }, + { pattern: "^9(5|6|7|8)\\dD$", url: "https://storage.haruk.in/s1500.png" }, +]; diff --git a/lib/webview/trainTypeConfig.ts b/lib/webview/trainTypeConfig.ts new file mode 100644 index 0000000..70b0172 --- /dev/null +++ b/lib/webview/trainTypeConfig.ts @@ -0,0 +1,35 @@ +/** + * 列車種別ごとの表示設定 + * + * - typeColor : nameReplace で使う種別ラベルの文字色 + * - borderColor: setNewTrainItem で使う枠線色 + * - bgColor : setNewTrainItem で使う背景色 + * - label : 種別ラベル文字列 + * - isWanman : ワンマン列車かどうか + */ +export interface TrainTypeConfig { + label: string; + typeColor: string; + borderColor: string; + bgColor: string; + isWanman: boolean; +} + +export const TRAIN_TYPE_CONFIG: Record = { + Normal: { label: "普通", typeColor: "black", borderColor: "black", bgColor: "#ffffffcc", isWanman: false }, + OneMan: { label: "普通", typeColor: "black", borderColor: "black", bgColor: "#ffffffcc", isWanman: true }, + Rapid: { label: "快速", typeColor: "rgba(0, 140, 255, 1)", borderColor: "rgba(0, 140, 255, 1)", bgColor: "#ffffffcc", isWanman: false }, + OneManRapid: { label: "快速", typeColor: "rgba(0, 140, 255, 1)", borderColor: "rgba(0, 140, 255, 1)", bgColor: "#ffffffcc", isWanman: true }, + LTDEXP: { label: "特急", typeColor: "red", borderColor: "red", bgColor: "#ffffffcc", isWanman: false }, + NightLTDEXP: { label: "寝台特急", typeColor: "#d300b0ff", borderColor: "#d300b0ff", bgColor: "#ffffffcc", isWanman: false }, + SPCL: { label: "臨時", typeColor: "#008d07ff", borderColor: "#008d07ff", bgColor: "#ffffffcc", isWanman: false }, + SPCL_Normal: { label: "臨時", typeColor: "#008d07ff", borderColor: "#008d07ff", bgColor: "#ffffffcc", isWanman: false }, + SPCL_Rapid: { label: "臨時快速", typeColor: "rgba(0, 81, 255, 1)", borderColor: "#0051ffff", bgColor: "#ffffffcc", isWanman: false }, + SPCL_EXP: { label: "臨時特急", typeColor: "#a52e2eff", borderColor: "#a52e2eff", bgColor: "#ffffffcc", isWanman: false }, + Party: { label: "団体臨時", typeColor: "#ff7300ff", borderColor: "#ff7300ff", bgColor: "#ffd0a9ff", isWanman: false }, + Freight: { label: "貨物", typeColor: "#00869ecc", borderColor: "#00869ecc", bgColor: "#c7c7c7cc", isWanman: false }, + Forwarding: { label: "回送", typeColor: "#727272cc", borderColor: "#727272cc", bgColor: "#c7c7c7cc", isWanman: false }, + Trial: { label: "試運転", typeColor: "#727272cc", borderColor: "#727272cc", bgColor: "#c7c7c7cc", isWanman: false }, + Construction: { label: "工事", typeColor: "#727272cc", borderColor: "#727272cc", bgColor: "#c7c7c7cc", isWanman: false }, + FreightForwarding: { label: "単機回送", typeColor: "#727272cc", borderColor: "#727272cc", bgColor: "#c7c7c7cc", isWanman: false }, +};