-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
61 lines (54 loc) · 1.67 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
new Vue({
el: '#app',
data: {
words: verbArray,
amount: verbArray.length,
actualWord: {},
finished_class: false,
isAnswered: false,
isRightAnswer: false,
isWrongAnswer: false,
right_counter: 0,
wrong_counter: 0
},
methods: {
responseIs(response) {
this.isAnswered = true;
if (this.actualWord.type === response) this.rightAnswer()
else this.wrongAnswer();
},
rightAnswer() {
this.isRightAnswer = true;
this.isWrongAnswer = false;
this.right_counter++
},
wrongAnswer() {
this.isRightAnswer = false;
this.isWrongAnswer = true;
this.wrong_counter++;
},
nextWord() {
this.words.shift();
if (this.words.length === 0) return this.finished_class = true
this.actualWord = this.words[0];
this.isRightAnswer = false;
this.isWrongAnswer = false;
this.isAnswered = false;
},
shareViaWebShare() {
const message = `I got ${this.right_counter} out of ${this.amount}.\n\n Você consegue bater o meu placar?\n`;
navigator.share({
title: 'Simple Past Game | Teacher Késsia Lima',
text: message,
url: window.location.href
})
}
},
mounted() {
this.words = this.words
.map(value => ({ value, sort: Math.random() }))
.sort((a, b) => a.sort - b.sort)
.map(({ value }) => value);
this.actualWord = this.words[0]
}
})