-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
87 lines (87 loc) · 2.35 KB
/
app.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
new Vue({
el: '#app',
data: {
input: '',
showMenu: true,
error: false,
showGif: true,
timeout: null,
pathToImg: 'images/',
gifPath: 'images/loading.gif',
},
methods: {
validateInput: function (e) {
if (e.keyCode === 13) {
this.error = false;
this.fileName = '';
switch(this.input) {
case '12':
case '21':
this.fileName = '12.jpg';
break;
case '13':
case '31':
this.fileName = '13.jpg';
break;
case '14':
case '41':
this.fileName = '14.jpg';
break;
case '15':
case '51':
this.fileName = '15.jpg';
break;
case '23':
case '32':
this.fileName = '23.jpg';
break;
case '24':
case '42':
this.fileName = '24.jpg';
break;
case '25':
case '52':
this.fileName = '25.jpg';
break;
case '34':
case '43':
this.fileName = '34.jpg';
break;
case '35':
case '53':
this.fileName = '35.jpg';
break;
case '45':
case '54':
this.fileName = '45.jpg';
break;
default:
this.error = true;
this.input = '';
}
if (!this.error) {
this.pathToImg += this.fileName;
this.showMenu = false;
this.input = '';
this.refreshImage();
this.timeout = setTimeout(function() {
this.showGif = false;
}.bind(this), 4000);
}
}
},
reset: function (e) {
if (e.keyCode === 13) {
this.showMenu = true;
this.input = '';
this.pathToImg = 'images/';
this.error = false;
this.showGif = true;
clearTimeout(this.timeout);
}
},
refreshImage () {
this.gifPath += ('?t=' + new Date().getTime());
}
}
});