1
|
|
|
const utils = { |
2
|
|
|
passwordChecker: function(password) { |
3
|
|
|
let strength = 0; |
4
|
|
|
|
5
|
|
|
if (password.length >= 4 && password.length <= 6) { |
6
|
|
|
strength += 1; |
7
|
|
|
} else if (password.length >= 7 && password.length <= 9) { |
8
|
|
|
strength += 2; |
9
|
|
|
} else if (password.length >= 10) { |
10
|
|
|
strength += 4; |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
if (password.match(/[A-Z]/)) { |
14
|
|
|
strength += 3; |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
if (password.match(/[0-9]/)) { |
18
|
|
|
strength += 3; |
19
|
|
|
} |
20
|
|
|
return strength; |
21
|
|
|
}, |
22
|
|
|
getMonthSetup: function(year, month) { |
23
|
|
|
let first = new Date(year, month, 1), |
24
|
|
|
last = new Date(year, month + 1, 0); |
25
|
|
|
|
26
|
|
|
var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; |
27
|
|
|
|
28
|
|
|
let currentMonth = { |
29
|
|
|
start: days[first.getDay()], |
30
|
|
|
end: last.getDate() |
31
|
|
|
}; |
32
|
|
|
|
33
|
|
|
return currentMonth; |
34
|
|
|
}, |
35
|
|
|
getDayPos: function(day) { |
36
|
|
|
let startPos = { |
37
|
|
|
"Mon": 0, |
38
|
|
|
"Tue": 1, |
39
|
|
|
"Wed": 2, |
40
|
|
|
"Thu": 3, |
41
|
|
|
"Fri": 4, |
42
|
|
|
"Sat": 5, |
43
|
|
|
"Sun": 6 |
44
|
|
|
}; |
45
|
|
|
|
46
|
|
|
return startPos[day]; |
47
|
|
|
}, |
48
|
|
|
getDateAsString: function(date) { |
49
|
|
|
let y = date.getFullYear(), |
50
|
|
|
m = date.getMonth() + 1, |
51
|
|
|
d = date.getDate(), |
52
|
|
|
dateAsString = d + "/" + m + "/" + y; |
53
|
|
|
|
54
|
|
|
return dateAsString; |
55
|
|
|
}, |
56
|
|
|
getMonthNames: function() { |
57
|
|
|
const months = { |
58
|
|
|
"January": 0, |
59
|
|
|
"Feburary": 1, |
60
|
|
|
"March": 2, |
61
|
|
|
"April": 3, |
62
|
|
|
"May": 4, |
63
|
|
|
"June": 5, |
64
|
|
|
"July": 6, |
65
|
|
|
"August": 7, |
66
|
|
|
"September": 8, |
67
|
|
|
"October": 9, |
68
|
|
|
"November": 10, |
69
|
|
|
"December": 11 |
70
|
|
|
}; |
71
|
|
|
|
72
|
|
|
return months; |
73
|
|
|
}, |
74
|
|
|
isToday: function(someDate) { |
75
|
|
|
const today = new Date(); |
76
|
|
|
|
77
|
|
|
/*eslint-disable */ |
78
|
|
|
return someDate.getDate() == today.getDate() && |
79
|
|
|
someDate.getMonth() == today.getMonth() && |
80
|
|
|
someDate.getFullYear() == today.getFullYear() |
81
|
|
|
/*eslint-enable */ |
82
|
|
|
}, |
83
|
|
|
countryList: function() { |
84
|
|
|
let countries = [ |
85
|
|
|
"Albania", |
86
|
|
|
"Andorra", |
87
|
|
|
"Armenia", |
88
|
|
|
"Austria", |
89
|
|
|
"Azerbaijan", |
90
|
|
|
"Belarus", |
91
|
|
|
"Belgium", |
92
|
|
|
"Bosnia and Herzegovina", |
93
|
|
|
"Bulgaria", |
94
|
|
|
"Croatia", |
95
|
|
|
"Cyprus", |
96
|
|
|
"Czechia", |
97
|
|
|
"Denmark", |
98
|
|
|
"Estonia", |
99
|
|
|
"Finland", |
100
|
|
|
"France", |
101
|
|
|
"Georgia", |
102
|
|
|
"Germany", |
103
|
|
|
"Greece", |
104
|
|
|
"Hungary", |
105
|
|
|
"Iceland", |
106
|
|
|
"Ireland", |
107
|
|
|
"Italy", |
108
|
|
|
"Kazakhstan", |
109
|
|
|
"Kosovo", |
110
|
|
|
"Latvia", |
111
|
|
|
"Liechtenstein", |
112
|
|
|
"Lithuania", |
113
|
|
|
"Luxembourg", |
114
|
|
|
"Malta", |
115
|
|
|
"Moldova", |
116
|
|
|
"Monaco", |
117
|
|
|
"Montenegro", |
118
|
|
|
"Netherlands", |
119
|
|
|
"North Macedonia", |
120
|
|
|
"Norway", |
121
|
|
|
"Poland", |
122
|
|
|
"Portugal", |
123
|
|
|
"Romania", |
124
|
|
|
"Russia", |
125
|
|
|
"San Marino", |
126
|
|
|
"Serbia", |
127
|
|
|
"Slovakia", |
128
|
|
|
"Slovenia", |
129
|
|
|
"Spain", |
130
|
|
|
"Sweden", |
131
|
|
|
"Switzerland", |
132
|
|
|
"Turkey", |
133
|
|
|
"Ukraine", |
134
|
|
|
"United Kingdom", |
135
|
|
|
"Vatican City" |
136
|
|
|
]; |
137
|
|
|
|
138
|
|
|
return countries; |
139
|
|
|
} |
140
|
|
|
}; |
141
|
|
|
|
142
|
|
|
export default utils; |
143
|
|
|
|