-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
54 lines (45 loc) · 1018 Bytes
/
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
var COLORS = {
red : '#F00',
green : '#090'
}
var MESSAGE = {
good : 'access is allowed',
bad : 'access denied'
}
function identification(owner) {
var libs = ['islands-components', 'islands-user', 'islands-icons', 'islands-services', 'islands-page', 'islands-romochka'];
if (libs.indexOf(owner) != -1) {
var access = MESSAGE.good;
}
else {
var access = MESSAGE.bad;
}
return access;
}
var count = 1;
var MSG_LIMIT = 6;
function buttonclick() {
var input = document.getElementById('name'),
name = input.value,
access = identification(name),
newdiv = document.createElement('div'),
par = document.getElementById('output');
if (count > MSG_LIMIT) {
var olddiv = par.lastChild;
par.removeChild(olddiv);
}
if (par.firstChild) {
par.insertBefore(newdiv, par.firstChild);
}
else {
par.appendChild(newdiv);
}
newdiv.innerHTML = ('<br>' + access);
if (access == MESSAGE.bad) {
newdiv.style.color = COLORS.red;
}
else {
newdiv.style.color = COLORS.green;
}
count++;
}