Skip to content

Commit

Permalink
Merge branch 'master' into feature/custom-range-map
Browse files Browse the repository at this point in the history
  • Loading branch information
maruk0chan authored Dec 26, 2023
2 parents 319a2f2 + 64accc3 commit 11ea225
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 13 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
[maruk0chan](https://github.com/maruk0chan)
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,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": [
Expand Down
6 changes: 3 additions & 3 deletions public/search-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions scripts/pre-rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/")) {
Expand Down
40 changes: 40 additions & 0 deletions src/Donations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
3 changes: 1 addition & 2 deletions src/components/home/SuccinctTimeReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Typography,
} from "@mui/material";
import { Link, useNavigate } from "react-router-dom";
import { getDistance, getDistanceWithUnit, vibrate } from "../../utils";
import { PLATFORM, getDistance, getDistanceWithUnit, vibrate } from "../../utils";
import AppContext from "../../AppContext";
import { useTranslation } from "react-i18next";
import SuccinctEtas from "./SuccinctEtas";
Expand Down Expand Up @@ -108,7 +108,6 @@ const SuccinctTimeReport = ({

const platform = useMemo(() => {
if (etas && etas.length > 0) {
const PLATFORM = ["", "①", "②", "③", "④", "⑤", "⑥", "⑦"];
const no =
PLATFORM[
parseInt(
Expand Down
3 changes: 1 addition & 2 deletions src/components/route-eta/TimeReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,16 @@ export const coToType: Record<Company, TransportType> = {
lightRail: "lightRail",
mtr: "mtr",
};

export const PLATFORM = [
"",
"①",
"②",
"③",
"④",
"⑤",
"⑥",
"⑦",
"⑧",
"⑨",
] as const;

0 comments on commit 11ea225

Please sign in to comment.