Coder Social home page Coder Social logo

miklcct / kmb-lwb-combined-headway-eta Goto Github PK

View Code? Open in Web Editor NEW
14.0 3.0 3.0 767 KB

KMB & LWB combined headway ETA

Home Page: https://miklcct.com/kmb_eta/

License: GNU Affero General Public License v3.0

HTML 23.49% CSS 1.01% TypeScript 75.50%
eta

kmb-lwb-combined-headway-eta's Issues

All queries will be redirected to proxy server when running in HTTPS server

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);

Seems map would provide performance boost

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.

Date object would subject to the timezone of the server

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.