Skip to content

Commit

Permalink
add a button to go to the previous word; closes #10
Browse files Browse the repository at this point in the history
  • Loading branch information
bast committed Jan 16, 2019
1 parent 3ad32a7 commit f332557
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ <h1>{{ words[counter] }}</h1>
<div class="row">
<div class="col-md-12">
<div v-if="num_words > 1">
<button v-on:click="previous_word" type="button" class="btn-xs btn-success">Previous word</button>
&nbsp;
<button v-on:click="next_word" type="button" class="btn-xs btn-success">Next word</button>
&nbsp;
&nbsp;
Expand Down
7 changes: 7 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@
}
},
methods: {
previous_word: function() {
this.counter -= 1;
if (this.counter < 0) {
this.counter = this.num_words - 1;
}
this.word = this.words[this.counter];
},
next_word: function() {
this.counter += 1;
if (this.counter > (this.num_words - 1)) {
Expand Down

0 comments on commit f332557

Please sign in to comment.