Skip to content

Commit

Permalink
first run preset. PA -> SF. (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed May 5, 2017
1 parent 9822663 commit bed685a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = {
"extends": "google",
"env": {
"browser": true
"browser": true,
"es6": true
},
"rules": {
"camelcase": 0,
Expand All @@ -27,6 +28,7 @@ module.exports = {
"varsIgnorePattern": "(^_$)"
}],
"quotes": [1, "single"],
"no-var": 0,
"require-jsdoc": 0,
"valid-jsdoc": 0
}
Expand Down
7 changes: 5 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ <h1 class="title header-group">
<label class="input-label" for="toselect">To:</label>
<div id="to" class="location"></div>
<button id="reverse" type="submit"></button>
<p class="onetap">One-tap:
<a href="#" id="firstruntrigger">Palo Alto &rarr; San Francisco</a>.
</p>
</div>
<div class="when header-group">
<button class="when-button selected" value="now">
Expand All @@ -73,9 +76,9 @@ <h1 class="title header-group">
<p>Bombardier trains are denoted with a sparkle✨.</p>
</div>
<div class="copyright">
Schedule represents the <b>April 10, 2017</b> effective Caltrain schedule.
<b>April 10, 2017</b> effective Caltrain schedule.
</div>

<div class="copyright">
Built by @samccone & @paul_irish
<br>
Expand Down
12 changes: 11 additions & 1 deletion javascripts/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ NodeList.prototype.on = NodeList.prototype.addEventListener = (function(name, fn
return prev + ('<div class="trip">' +
'<span class="departure"' +
(trip.bombardier ? 'data-bombardier="✨"' : '') +
'>' + second2str(trip.departure_time) +
'>' + second2str(trip.departure_time) +
'</span>' +
'<span class="duration">' +
time_relative(trip.departure_time, trip.arrival_time) + ' min' +
Expand Down Expand Up @@ -381,6 +381,8 @@ NodeList.prototype.on = NodeList.prototype.addEventListener = (function(name, fn
schedule();
});

$('#firstruntrigger').on('click', firstRun)

$('#reverse').on('click', function() {
var from = $('#from select').value;
var to = $('#to select').value;
Expand All @@ -392,6 +394,14 @@ NodeList.prototype.on = NodeList.prototype.addEventListener = (function(name, fn
});
}

function firstRun(locationSelects) {
const fromselect = $('#fromselect');
const toselect = $('#toselect');
fromselect.querySelector('[value="Palo Alto"]').selected = true;
toselect.querySelector('[value="San Francisco"]').selected = true;
toselect.dispatchEvent(new Event('change'));
}

function constructSelect(name, opts) {
return '<select id="' + name + 'select">' + opts.reduce(function(prev, curr) {
return prev + '<option value="' + curr + '">' + curr + '</option>';
Expand Down
11 changes: 11 additions & 0 deletions stylesheets/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,17 @@ p {
margin: 7px 0 4px;
}

p.onetap {
margin: 18px 15px 0;
font-size: 17px;
text-align: center;
display: none;
}

.firstrun .onetap {
display: block;
}

.firstrun .when,
.firstrun #instructions,
.firstrun #reverse {
Expand Down

0 comments on commit bed685a

Please sign in to comment.