From 0f6b0eb63d7a60872247e9dadaa1e06403f62287 Mon Sep 17 00:00:00 2001 From: Marco Chan Date: Mon, 18 Dec 2023 23:59:32 +0900 Subject: [PATCH 1/4] Fix/eslint-warning (#100) * use triple equal === * use template literal to fix warning * add lint script * eslint disable no-unused-var for const url --- package.json | 3 ++- public/search-worker.js | 6 +++--- scripts/pre-rendering.js | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 5dabff6b6849..ded13da3d884 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,8 @@ "alpha-deploy": "yarn build && gh-pages -d build --remote alpha -t -f", "docker": "cd docker && docker-compose up -d --build", "docker:build": "docker build . --pull --build-arg $(sed 's:#.*$::g' docker/.env | sed '/^\\s*$/d' | sed ':a;N;$!ba;s/\\n/ --build-arg /g')", - "docker:build-noenv": "docker build . --pull --build-arg $(sed 's:#.*$::g' .env | sed '/^\\s*$/d' | sed ':a;N;$!ba;s/\\n/ --build-arg /g')" + "docker:build-noenv": "docker build . --pull --build-arg $(sed 's:#.*$::g' .env | sed '/^\\s*$/d' | sed ':a;N;$!ba;s/\\n/ --build-arg /g')", + "lint": "eslint . --ext .js,.jsx,.ts,.tsx" }, "eslintConfig": { "extends": [ diff --git a/public/search-worker.js b/public/search-worker.js index 2bf1712331d9..764ad64f4db4 100644 --- a/public/search-worker.js +++ b/public/search-worker.js @@ -58,12 +58,12 @@ const buildStopRoute = (routeList) => { const dfs = (routeList, stopList, curLocation, targetLocation, curDepth, maxDepth, routeFrom = '', tmpRoute = '') => { if ( getDistance(curLocation, targetLocation) < 500 ) { - if ( curDepth == 0 ) { + if ( curDepth === 0 ) { dfsRoutes.push(tmpRoute) routeLv[routeFrom] = maxDepth - curDepth } return true - } else if ( curDepth == 0 ) { + } else if ( curDepth === 0 ) { return false } @@ -97,7 +97,7 @@ const dfs = (routeList, stopList, curLocation, targetLocation, curDepth, maxDept if ( stopIdx === -1 ) continue // skip if no take up stop is found // take off the bus for (var idx = stopIdx + 1; idx < stops.length; ++idx ) { - if ( dfs(routeList, stopList, stopList[stops[idx]].location, targetLocation, curDepth - 1, maxDepth, routeId, tmpRoute + '|' + `${routeId}/${stopIdx}-${idx}` ) ) { + if ( dfs(routeList, stopList, stopList[stops[idx]].location, targetLocation, curDepth - 1, maxDepth, routeId, `${tmpRoute}|${routeId}/${stopIdx}-${idx}` ) ) { routeLv[routeFrom] = maxDepth - curDepth found = true } diff --git a/scripts/pre-rendering.js b/scripts/pre-rendering.js index ac86213002fa..a264730e0322 100644 --- a/scripts/pre-rendering.js +++ b/scripts/pre-rendering.js @@ -93,6 +93,7 @@ function ensureDirExists(dir) { * @returns {string|number} */ async function getHTMLfromPuppeteerPage(page, pageUrl, idx) { + // eslint-disable-next-line no-unused-vars const url = new URL(pageUrl); try { if (!pageUrl.includes("/route/")) { From 935d4dc97990a06f6cf1a10cb9af1483e2843cd4 Mon Sep 17 00:00:00 2001 From: Marco Chan Date: Tue, 19 Dec 2023 00:00:13 +0900 Subject: [PATCH 2/4] define PLATFORM in utils (#102) --- src/components/home/SuccinctTimeReport.tsx | 3 +-- src/components/route-eta/TimeReport.tsx | 3 +-- src/utils.ts | 13 +++++++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/components/home/SuccinctTimeReport.tsx b/src/components/home/SuccinctTimeReport.tsx index 62cd1f0f4b74..3602043d0dce 100644 --- a/src/components/home/SuccinctTimeReport.tsx +++ b/src/components/home/SuccinctTimeReport.tsx @@ -10,7 +10,7 @@ import { Typography, } from "@mui/material"; import { Link, useNavigate } from "react-router-dom"; -import { vibrate } from "../../utils"; +import { PLATFORM, vibrate } from "../../utils"; import AppContext from "../../AppContext"; import { useTranslation } from "react-i18next"; import SuccinctEtas from "./SuccinctEtas"; @@ -105,7 +105,6 @@ const SuccinctTimeReport = ({ const platform = useMemo(() => { if (etas && etas.length > 0) { - const PLATFORM = ["", "①", "②", "③", "④", "⑤", "⑥", "⑦"]; const no = PLATFORM[ parseInt( diff --git a/src/components/route-eta/TimeReport.tsx b/src/components/route-eta/TimeReport.tsx index be1853a03122..c230dd0bebbe 100644 --- a/src/components/route-eta/TimeReport.tsx +++ b/src/components/route-eta/TimeReport.tsx @@ -5,6 +5,7 @@ import AppContext from "../../AppContext"; import { useEtas } from "../../hooks/useEtas"; import { LinearProgress } from "../Progress"; import { Eta, Terminal } from "hk-bus-eta"; +import { PLATFORM } from "../../utils"; interface TimeReportProps { routeId: string; @@ -145,8 +146,6 @@ const EtaLine = ({ ); }; -const PLATFORM = ["", "①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨"]; - const getRemark = (remark: string | null, language: string) => { if (remark === null) return ""; // retrieve single digit numerical string from remark as a circle text diff --git a/src/utils.ts b/src/utils.ts index 992807e67836..f404fc416193 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -385,3 +385,16 @@ export const coToType: Record = { lightRail: "lightRail", mtr: "mtr", }; + +export const PLATFORM = [ + "", + "①", + "②", + "③", + "④", + "⑤", + "⑥", + "⑦", + "⑧", + "⑨", +] as const; From 589fa71801bd108c3d6666a18fab84d9c05ede1c Mon Sep 17 00:00:00 2001 From: Brian Leung Date: Sun, 24 Dec 2023 07:33:17 +0800 Subject: [PATCH 3/4] add donation list (#114) --- src/Donations.ts | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/Donations.ts b/src/Donations.ts index 872d05179c4b..03b46a86947b 100644 --- a/src/Donations.ts +++ b/src/Donations.ts @@ -89,6 +89,46 @@ const Donations = [ en: "Channel C HK", }, }, + { + url: { + zh: "https://photonmedia.net/subscribe", + en: "https://photonmedia.net/subscribe", + }, + description: { + zh: "請訂閱《光傳媒》", + en: "Please subscribe the Photon Media", + }, + }, + { + url: { + zh: "https://wavezinehk.com/%e8%a8%82%e9%96%b1%e6%94%af%e6%8c%81", + en: "https://wavezinehk.com/%e8%a8%82%e9%96%b1%e6%94%af%e6%8c%81", + }, + description: { + zh: "請訂閱《Wave. 流行文化誌》", + en: "Please subscribe the Wave.", + }, + }, + { + url: { + zh: "https://thecollectivehk.com/subscribe", + en: "https://thecollectivehk.com/subscribe", + }, + description: { + zh: "請訂閱《集誌社》", + en: "Please subscribe The Collective", + }, + }, + { + url: { + zh: "https://linktr.ee/hkcourtnews", + en: "https://linktr.ee/hkcourtnews", + }, + description: { + zh: "請訂閱《庭刊》", + en: "Please subscribe The HK Court News", + }, + }, ]; export default Donations; From 64accc3c4ee22bea69e99693aa0eacd5c47ec791 Mon Sep 17 00:00:00 2001 From: Xavier Fung Date: Mon, 25 Dec 2023 00:02:57 +0800 Subject: [PATCH 4/4] Update readme on transport modes covered and data source (#110) * Update readme on transport modes covered and data source * Include FAQ link --- README.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 90d11aff5ee6..293f52368d71 100644 --- a/README.md +++ b/README.md @@ -4,15 +4,18 @@ [![Test](https://github.com/hkbus/hk-independent-bus-eta/actions/workflows/node.js.yml/badge.svg)](https://hkbus.app) -無廣告的巴士預報站整合了香港巴士(城巴新巴九巴嶼巴)、小巴及輕鐵港鐵的到站預報,介面清晣直接,力求讓用戶快速獲得所需資訊。 +無廣告的巴士預報站整合了香港巴士(九巴、龍運、城巴、嶼巴、港鐵巴士)、綠色小巴、輕鐵及港鐵的到站預報,介面清晣直接,力求讓用戶快速獲得所需資訊。 -An ad-free bus ETA site for Hong Kong, with arrival times from KMB, CTB, NWFB, LNB, minibus, lightrail, and MTR, with a clutter-free UI that lets you get what you need, fast. +An ad-free bus ETA site for Hong Kong, with arrival times from KMB, LWB, CTB, NLB, green minibus, light rail, and MTR, with a clutter-free UI that lets you get what you need, fast. + +## 常見問題 FAQ +[常見問題 FAQ](https://github.com/hkbus/hk-independent-bus-eta/wiki/%E5%B8%B8%E8%A6%8B%E5%95%8F%E9%A1%8C-FAQ) ## 資料來源 Data Sources -本網站一切到站預報資料均來自[資料一站通](https://data.gov.hk)及相關機構,路線及收費資料來自[HK Bus Crawling](https://github.com/hkbus/hk-bus-crawling/) +本網站一切到站預報資料均來自[資料一站通](https://data.gov.hk)、[空間數據共享平台](https://portal.csdi.gov.hk/csdi-webpage/)及相關機構,路線及收費資料來自[HK Bus Crawling](https://github.com/hkbus/hk-bus-crawling/) -ETA data is from [DATA.GOV.HK](https://data.gov.hk) and respective providers. Route and fare data from [HK Bus Crawling](https://github.com/hkbus/hk-bus-crawling/). +ETA data is from [DATA.GOV.HK](https://data.gov.hk), [Common Data Spatial Infrastructure](https://portal.csdi.gov.hk/csdi-webpage/) and respective providers. Route and fare data from [HK Bus Crawling](https://github.com/hkbus/hk-bus-crawling/). ## Note @@ -80,4 +83,4 @@ Project owner [chunlaw](https://github.com/chunlaw) is the initiator of the whol [thomassth](https://github.com/thomassth) -[maruk0chan](https://github.com/maruk0chan) \ No newline at end of file +[maruk0chan](https://github.com/maruk0chan)