From f10946b96deba27f2f4eef4b32242320b977b3c7 Mon Sep 17 00:00:00 2001 From: ronreg-ribdev <56719257+ronreg-ribdev@users.noreply.github.com> Date: Fri, 5 Jun 2020 02:42:25 -0700 Subject: [PATCH] Do some js parsing --- src/js/components/root.js | 18 +++++++++++++++--- urbit/app/bartinfo.hoon | 9 +++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/js/components/root.js b/src/js/components/root.js index 80fb691..dcc5441 100644 --- a/src/js/components/root.js +++ b/src/js/components/root.js @@ -3,6 +3,16 @@ import { BrowserRouter, Route, Link } from "react-router-dom"; import _ from 'lodash'; import { HeaderBar } from "./lib/header-bar.js" +function padNumber(number) { + if (number == 0) { + return "00"; + } + if (number <= 9) { + return `0${number}` + } + return number.toString(); +} + function isSundaySchedule(curTime) { // Deliberately switch over the effective day in the middle of the // night. @@ -195,7 +205,7 @@ class RouteSearch extends Component { value={this.state.hour} onChange={(evt) => this.setState({hour: parseInt(evt.target.value)}) } disabled={departNow} > - { _.map(_.range(1, 13), (hour) => { return ;}) } + { _.map(_.range(1, 13), (hour) => { return ;}) } : +
+ +
); } } diff --git a/urbit/app/bartinfo.hoon b/urbit/app/bartinfo.hoon index e7eecb1..4692124 100644 --- a/urbit/app/bartinfo.hoon +++ b/urbit/app/bartinfo.hoon @@ -113,7 +113,6 @@ [%give %fact ~[/elevators] %json !>(update)]~ :: [%routeplan *] - ~& client-response.sign-arvo =/ value=json (parse-routeplan-response:cc client-response.sign-arvo) ?> ?=(%o -.value) =/ update=json (pairs:enjs:format [update+o+p.value ~]) @@ -214,7 +213,13 @@ ++ parse-routeplan-response |= response=client-response:iris ^- json - (with-json-handler response |=(x=json x)) + =, format + =/ handler + |= jon=json + ~& jon + =/ root=json ((ot:dejs [['root' same] ~]) jon) + root + (with-json-handler response handler) ++ poke-handle-json |= jon=json ^- (list card)