miklcct / kmb-lwb-combined-headway-eta Goto Github PK
View Code? Open in Web Editor NEWKMB & LWB combined headway ETA
Home Page: https://miklcct.com/kmb_eta/
License: GNU Affero General Public License v3.0
KMB & LWB combined headway ETA
Home Page: https://miklcct.com/kmb_eta/
License: GNU Affero General Public License v3.0
When running the script in HTTPS server, all queries to search.kmb.hk will be redirected to proxy server. Since the proxy server redirect all traffic to etav3.kmb.hk, queries to proxy server for search.kmb.hk will be failed.
It looks like the issue is due to determination to call proxy server or not is by checking the protocol of the URL:
Common.js
$.get((location.protocol === 'https:' ? Common.PROXY_URL : '') + Common.API_ENDPOINT, query, callback);
Hi, I decided to use your fetcher code for my MMM-HK-KMB project.
In the StopRoute.js there are some forEach
. Use map
would improve the performance of the code.
I didn't check the side-effect but it seems to me that it works. I also didn't check other code because StopRoute
is more critical.
Using demo site with below URL, stops information shows correctly but no ETA is shown.
http://kmb_eta.csproject.org/?stop=KW16-E-0900-0&selections=74X-1
I copied the snippet from Eta.js
const time = new Date();
time.setHours(Number(obj.time.split(':')[0]), Number(obj.time.split(':')[1]), 0);
if (time.getTime() - Date.now() < -60 * 60 * 1000 * 2) {
// the time is less than 2 hours past - assume midnight rollover
time.setDate(time.getDate() + 1);
}
if (time.getTime() - Date.now() > 60 * 60 * 1000 * 6) {
// the time is more than 6 hours in the future - assume midnight rollover
time.setDate(time.getDate() - 1);
}
The time
and Date.now()
object uses the timezone of the system (I am just using UTC as the system default). However the setHours
uses the Hong Kong time (obtained from the API). For my case midnight rollover would always happen.
I don't use date but just notice my date is always off by a day when I check the eta.time
string.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.