-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathscript.js
More file actions
63 lines (53 loc) · 1.87 KB
/
script.js
File metadata and controls
63 lines (53 loc) · 1.87 KB
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
const app = new Vue({
el: '#app',
data() {
return {
authUserName: '',
patternPanel: false,
patternArray: [],
cordinates: [
{}, // an empty object to avoid confusion
{x: 50, y: 50},
{x: 150, y: 50},
{x: 250, y: 50},
{x: 50, y: 150},
{x: 150, y: 150},
{x: 250, y: 150},
{x: 50, y: 250},
{x: 150, y: 250},
{x: 250, y: 250},
],
email: ''
}
},
methods: {
hoverOnNode(event){
if(event.buttons == 1 || event.buttons == 3){
console.log(`previews value ${this.patternArray[this.patternArray.length - 1]} new value ${event.target.id}`)
if(this.patternArray[this.patternArray.length - 1] != event.target.id && // don't add if user hover on last node
this.patternArray[this.patternArray.length - 2] != event.target.id) // don't add if user hover on second last node
{
this.patternArray.push(event.target.id);
}
}
},
authenticate(){
if(this.patternArray.length > 1)
{
axios.post('authenticate.php', {
email: this.email,
pattern: this.patternArray.join('')
})
.then(function (response) {
app.authUserName = response.data;
console.log(app.authUserName);
app.patternArray = [];
})
.catch(function (error) {
console.log(error);
});
}
}
}
});
window.addEventListener('onmouseup', app.authenticate())