/belgiantrain-liveboard-wc

A web component simulating the liveboards in the NMBS/SNCB train stations

Primary LanguageJavaScriptMIT LicenseMIT

BelgianTrain Liveboard Web Component

A web component simulating the liveboards in the NMBS/SNCB train stations.

GitHub Release License

This webcomponent follows the open-wc recommendation.

Installation

Install with npm

npm install github:jonatcln/belgiantrain-liveboard-wc#semver:^0.1
<script type="module">
    import 'belgiantrain-liveboard-wc/belgiantrain-liveboard.js';
</script>

Use directly via cdn

<script
    type="module"
    src="https://cdn.jsdelivr.net/gh/jonatcln/belgiantrain-liveboard-wc@0.1/dist/belgiantrain-liveboard.min.js"
></script>

Usage

Basic usage example:

<belgiantrain-liveboard id="liveboard" lang="en"></belgiantrain-liveboard>

<script>
    fetch(
        'http://api.irail.be/liveboard/?station=Gent-Sint-Pieters&format=json&lang=en',
        {
            method: 'GET',
            headers: {
                Accept: 'application/json',
            },
        }
    )
        .then((response) => response.json())
        .then((data) => {
            document.getElementById('liveboard').data = data;
        });
</script>

Check out demo/index.html for a complete example.

License

Licensed under the MIT license.