Do some js parsing
This commit is contained in:
parent
c538f145b1
commit
f10946b96d
@ -3,6 +3,16 @@ import { BrowserRouter, Route, Link } from "react-router-dom";
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { HeaderBar } from "./lib/header-bar.js"
|
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) {
|
function isSundaySchedule(curTime) {
|
||||||
// Deliberately switch over the effective day in the middle of the
|
// Deliberately switch over the effective day in the middle of the
|
||||||
// night.
|
// night.
|
||||||
@ -195,7 +205,7 @@ class RouteSearch extends Component {
|
|||||||
value={this.state.hour}
|
value={this.state.hour}
|
||||||
onChange={(evt) => this.setState({hour: parseInt(evt.target.value)}) } disabled={departNow}
|
onChange={(evt) => this.setState({hour: parseInt(evt.target.value)}) } disabled={departNow}
|
||||||
>
|
>
|
||||||
{ _.map(_.range(1, 13), (hour) => { return <option key={`h-${hour}`} value={hour}>{hour}</option>;}) }
|
{ _.map(_.range(1, 13), (hour) => { return <option key={`h-${hour}`} value={hour}>{padNumber(hour)}</option>;}) }
|
||||||
</select>
|
</select>
|
||||||
<span>:</span>
|
<span>:</span>
|
||||||
<select
|
<select
|
||||||
@ -203,7 +213,7 @@ class RouteSearch extends Component {
|
|||||||
value={this.state.min}
|
value={this.state.min}
|
||||||
onChange={(evt) => this.setState({min: parseInt(evt.target.value)}) } disabled={departNow}
|
onChange={(evt) => this.setState({min: parseInt(evt.target.value)}) } disabled={departNow}
|
||||||
>
|
>
|
||||||
{ _.map(_.range(0, 60), (min) => { return <option key={`m-${min}`} value={min}>{min}</option>;}) }
|
{ _.map(_.range(0, 60), (min) => { return <option key={`m-${min}`} value={min}>{padNumber(min)}</option>;}) }
|
||||||
</select>
|
</select>
|
||||||
<select
|
<select
|
||||||
name="isPM"
|
name="isPM"
|
||||||
@ -234,7 +244,9 @@ class RouteSearch extends Component {
|
|||||||
Depart at:
|
Depart at:
|
||||||
{ this.renderTimePicker() }
|
{ this.renderTimePicker() }
|
||||||
</div>
|
</div>
|
||||||
|
<div style={{padding: '5px'}}>
|
||||||
<input type="submit" value="Search"/>
|
<input type="submit" value="Search"/>
|
||||||
|
</div>
|
||||||
</form>);
|
</form>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,6 @@
|
|||||||
[%give %fact ~[/elevators] %json !>(update)]~
|
[%give %fact ~[/elevators] %json !>(update)]~
|
||||||
::
|
::
|
||||||
[%routeplan *]
|
[%routeplan *]
|
||||||
~& client-response.sign-arvo
|
|
||||||
=/ value=json (parse-routeplan-response:cc client-response.sign-arvo)
|
=/ value=json (parse-routeplan-response:cc client-response.sign-arvo)
|
||||||
?> ?=(%o -.value)
|
?> ?=(%o -.value)
|
||||||
=/ update=json (pairs:enjs:format [update+o+p.value ~])
|
=/ update=json (pairs:enjs:format [update+o+p.value ~])
|
||||||
@ -214,7 +213,13 @@
|
|||||||
++ parse-routeplan-response
|
++ parse-routeplan-response
|
||||||
|= response=client-response:iris
|
|= response=client-response:iris
|
||||||
^- json
|
^- 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
|
++ poke-handle-json
|
||||||
|= jon=json
|
|= jon=json
|
||||||
^- (list card)
|
^- (list card)
|
||||||
|
Loading…
Reference in New Issue
Block a user