Skip to content

Commit

Permalink
Add a screen for meta subjects
Browse files Browse the repository at this point in the history
  • Loading branch information
gregoirenovel committed Jun 21, 2017
1 parent e0f73e9 commit 6eeb0c4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
29 changes: 20 additions & 9 deletions app/controllers/index.js
Expand Up @@ -10,39 +10,50 @@ export default Ember.Controller.extend({

actions: {
start: function() {
this.setTimer();
this.setTimerForState('startups');
this.set('state', 'startups')
},

nextStartup: function() {
clearInterval(this.get('timer'));

if (this.get('startupIndex') < (this.get('startups.length') - 1)) {
this.setTimer();
this.setTimerForState('startups');
this.set('startupIndex', this.get('startupIndex') + 1);
} else {
this.set('startupIndex', 0);
this.set('state', 'home');
this.setTimerForState('meta');
this.set('state', 'meta');
}
},

goHome: function () {
clearInterval(this.get('timer'));
this.set('state', 'home');
}
},

setTimer: function() {
var endtime = this.endtime(65),
timer = setInterval(function() { this.tick(endtime); }.bind(this), 1000);
setTimerForState: function(state) {
var seconds = state === 'startups' ? 65 : 315,
endtime = this.endtime(seconds),
timer = setInterval(function() { this.tick(state, endtime); }.bind(this), 1000);

this.set('timer', timer);
this.tick(endtime);
this.tick(state, endtime);
},

tick: function(endtime) {
tick: function(state, endtime) {
var remainingTime = this.getRemainingTime(endtime);
this.set('secondsLeft', remainingTime.seconds);
this.set('minutesLeft', remainingTime.minutes);

if (remainingTime.total <= 0) {
this.get('hifi').play('assets/sounds/gong.mp3');
this.send('nextStartup');
if (state === 'startups') {
this.send('nextStartup');
} else {
this.send('goHome');
}
}
},

Expand Down
8 changes: 8 additions & 0 deletions app/templates/index.hbs
Expand Up @@ -6,6 +6,14 @@
<h2>{{currentStartup.name}}</h2>
<h3>{{currentStartup.pitch}}</h3>

<div class="time-left">
{{formattedMinutesLeft}}:{{formattedSecondsLeft}}
</div>
</div>
{{else if (eq state "meta")}}
<div {{action "goHome"}} class="container">
<h2>Sujets transverses</h2>

<div class="time-left">
{{formattedMinutesLeft}}:{{formattedSecondsLeft}}
</div>
Expand Down

0 comments on commit 6eeb0c4

Please sign in to comment.