-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.js
78 lines (64 loc) · 1.55 KB
/
index.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
import Vue from 'vue';
import VueIp from './src/VueIp.vue';
new Vue({
el: '#app',
components: {
VueIp
},
data() {
return {
ip: '',
port: false,
valid: null,
theme: 'material'
};
},
beforeMount() {
// Random IP Address on load
// this.changeIp()
},
methods: {
/**
* Generate random number
*/
random(min = 1, max = 270) {
return Math.floor(Math.random() * max) + min;
},
/**
* Triggers on change
*/
ipChange(ip, port, valid) {
this.ip = ip;
this.port = port;
this.valid = valid;
},
/**
* Trigger a random ip and port change
*/
changeIp(port) {
this.ip = this.random() + '.' + this.random() + '.' + this.random() + '.' + this.random();
if(port)
this.port = '' + this.random(1, 9) + this.random(1, 9) + this.random(1, 9) + this.random(1, 9);
else
this.port = false;
},
/**
* Switch on an off material design
*/
materialSwitch() {
if(!this.theme)
this.theme = 'material';
else
this.theme = false;
},
/**
* Reset everything
*/
reset() {
this.ip = '';
this.port = false;
this.valid = null;
this.theme = 'material'
}
}
});