Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
</head>
<body>
<div id="root"></div>
<script src="dist/index.js"></script>
<!--
Only one of the following js files is needed. For development
use example.js. For production use dist/index.js.
-->
<!-- <script src="dist/index.js"></script> -->
<script src="/example.js"></script>
</body>
</html>
37 changes: 24 additions & 13 deletions lib/components/viewers/stop-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { setMainPanelContent, toggleAutoRefresh } from '../../actions/ui'
import { findStop, findStopTimesForStop } from '../../actions/api'
import { forgetStop, rememberStop, setLocation } from '../../actions/map'
import { routeComparator } from '../../util/itinerary'
import { getShowUserSettings } from '../../util/state'
import { formatDuration, formatStopTime, getTimeFormat } from '../../util/time'

class StopViewer extends Component {
Expand Down Expand Up @@ -110,9 +111,10 @@ class StopViewer extends Component {

render () {
const {
stopData,
hideBackButton,
homeTimezone,
showUserSettings,
stopData,
stopViewerArriving,
timeFormat
} = this.props
Expand Down Expand Up @@ -166,17 +168,20 @@ class StopViewer extends Component {
? <span>{stopData.name}</span>
: <span>Loading Stop...</span>
}
<Button
onClick={this._toggleFavorite}
bsSize='large'
style={{
color: this._isFavorite() ? 'yellow' : 'black',
padding: 0,
marginLeft: '5px'
}}
bsStyle='link'>
<Icon type={this._isFavorite() ? 'star' : 'star-o'} />
</Button>
{showUserSettings
? <Button
onClick={this._toggleFavorite}
bsSize='large'
style={{
color: this._isFavorite() ? 'yellow' : 'black',
padding: 0,
marginLeft: '5px'
}}
bsStyle='link'>
<Icon type={this._isFavorite() ? 'star' : 'star-o'} />
</Button>
: null
}
</div>
<div style={{ clear: 'both' }} />
</div>
Expand Down Expand Up @@ -376,7 +381,11 @@ class PatternRow extends Component {

const ONE_HOUR_IN_SECONDS = 3600

function getHomeTime (homeTimezone) {
/**
* @param {string} [homeTimezone='America/New_York'] Timezone string
* @return {number} Current time in home timezone in seconds since midnight
*/
function getHomeTime (homeTimezone = 'America/New_York') {
const now = moment()
return now.tz(homeTimezone).diff(now.clone().startOf('day'), 'seconds')
}
Expand Down Expand Up @@ -475,11 +484,13 @@ function getStatusLabel (delay) {
// connect to redux store

const mapStateToProps = (state, ownProps) => {
const showUserSettings = getShowUserSettings(state.otp)
return {
autoRefreshStopTimes: state.otp.user.autoRefreshStopTimes,
favoriteStops: state.otp.user.favoriteStops,
homeTimezone: state.otp.config.homeTimezone,
viewedStop: state.otp.ui.viewedStop,
showUserSettings,
stopData: state.otp.transitIndex.stops[state.otp.ui.viewedStop.stopId],
stopViewerArriving: state.otp.config.language.stopViewerArriving,
timeFormat: getTimeFormat(state.otp.config)
Expand Down