-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcertification.js
94 lines (86 loc) · 2.93 KB
/
certification.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
88
89
90
91
92
93
94
var certopt=document.getElementById("certificate_options");
var inputs=certopt.getElementsByTagName('input');
if(inputs.length==0){
addinput();
}
function addinput()
{
document.getElementById('head').innerHTML="";
var inputs=certopt.getElementsByTagName('input');
var newfield=document.createElement('input');
newfield.setAttribute('type','text');
newfield.setAttribute('id','name');
newfield.setAttribute('name','name');
newfield.setAttribute('placeholder','Certificate Name');
newfield.setAttribute('class','certinput');
newfield.setAttribute('required','');
var neworg=document.createElement('input');
neworg.setAttribute('type','text');
neworg.setAttribute('id','org');
neworg.setAttribute('class','certinput');
neworg.setAttribute('name','org');
neworg.setAttribute('placeholder','Issuing Organisation');
neworg.setAttribute('required','');
var newdate=document.createElement('input');
newdate.setAttribute('type','text');
newdate.setAttribute('id','date');
newdate.setAttribute('class','certinput');
newdate.setAttribute('name','date');
newdate.setAttribute('placeholder','Issued Date(MM/YYYY)');
newdate.setAttribute('required','');
newdate.setAttribute('pattern','(0[1-9]|1[012])/[0-9]{4}');
var newurl=document.createElement('input');
newurl.setAttribute('type','URL');
newurl.setAttribute('id','url');
newurl.setAttribute('class','certinput');
newurl.setAttribute('name','url');
newurl.setAttribute('placeholder','Credential URL');
newurl.setAttribute('required','');
var text=document.createElement('p');
text.setAttribute('id','tx');
var node=document.createTextNode("Certification "+((inputs.length/4)+1));
text.appendChild(node);
certopt.appendChild(text);
const b=document.createElement("br");
certopt.appendChild(b);
certopt.appendChild(newfield);
certopt.appendChild(neworg);
certopt.appendChild(newdate);
certopt.appendChild(newurl);
const be=document.createElement("br");
certopt.appendChild(be);
const bre=document.createElement("br");
certopt.appendChild(bre);
}
function removeinput()
{
var t=certopt.getElementsByTagName('p');
var b=certopt.getElementsByTagName('br');
var inputs=certopt.getElementsByTagName('input');
if(inputs.length>4)
{
certopt.removeChild(inputs[(inputs.length)-1]);
certopt.removeChild(inputs[(inputs.length)-1]);
certopt.removeChild(inputs[(inputs.length)-1]);
certopt.removeChild(inputs[(inputs.length)-1]);
certopt.removeChild(t[(t.length)-1]);
certopt.removeChild(b[(b.length)-1]);
certopt.removeChild(b[(b.length)-1]);
certopt.removeChild(b[(b.length)-1]);
}
}
function save()
{
var inputs=certopt.getElementsByTagName('input');
if(inputs.length!=0)
{
var c=document.getElementsByClassName('certinput');
const d=[];
var i;
for(i=0;i<inputs.length;i++)
{
d[i]=c[i].value;
}
localStorage.setItem('ct',JSON.stringify(d));
}
}