Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
function getInfo() { let input = document.getElementById("stopId"); let stopNameDiv = document.getElementById("stopName"); let bussesUl = document.getElementById("buses"); let stopCode = input.value; var requestOptions = { method: 'GET', redirect: 'follow' }; fetch(`http://localhost:3030/jsonstore/bus/businfo/${stopCode}`, requestOptions) .then(response => response.json()) .then(o => populate(o)) .catch(error => wrongId()); function populate(obj) { bussesUl.innerHTML=""; stopNameDiv.textContent = obj.name; let bussesArr = Array.from(Object.entries(obj.buses)); bussesArr.forEach(b => { let busLi = document.createElement("li"); busLi.textContent = `Bus ${b[0]} arrives in ${b[1]} minutes`; bussesUl.appendChild(busLi); }); input.value = ""; } function wrongId() { stopNameDiv.textContent = "Error"; bussesUl.innerHTML = ""; } }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)