-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocument.js
95 lines (90 loc) · 2.16 KB
/
document.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
95
/*
* Copyright 2012, Saravana Kumar
* Dual licensed under the MIT or GPL Version 2 licenses.
*
*/
var doc=({
CreateDiv:function(clsName){
var element = document.createElement('div');
element.className = clsName;
return element;
},
CreateDisplayField:function(clsName,value){
var newText = document.createTextNode(value);
var divElement = doc.CreateDiv();
divElement.className = clsName;
divElement.appendChild(newText);
return divElement;
},
CreateList:function(clsName,value){
var li = document.createElement('li');
li.className = clsName;
if(document.all){
li.innerText = value;
}
else{
li.textContent = value;
}
return li;
},
CreateLink:function(clsName,href,value){
var link = document.createElement('a');
link.className = clsName;
link.href = href;
link.value = value;
link.appendChild(doc.CreateSpan("",value));
return link;
},
CreateImage:function(clsName,img){
var image = document.createElement('img');
image.className = clsName
image.src = img;
return image;
},
CreateListImage:function(clsName,img,value){
var li = doc.CreateList(clsName,"");
var link = doc.CreateLink("","#",value);
var image = doc.CreateImage("",img);
link.appendChild(image);
li.appendChild(link);
return li;
},
CreateLabel:function(clsName,value){
var label = document.createElement('label');
label.className = clsName;
if(document.all){
label.innerText = value;
}
else{
label.textContent = value;
}
return label;
},
CreateSpan:function(clsName,value){
var span = document.createElement('span');
span.className = clsName;
if(document.all){
span.innerText = value;
}
else{
span.textContent = value;
}
return span;
},
CreateUnOrderList:function(clsName){
var ul = document.createElement('ul');
ul.className= clsName;
return ul;
},
AppendElement: function(id,element){
var parent = document.getElementById(id);
parent.appendChild(element);
},
Clear:function(id){
var parent = document.getElementById(id);
var element = parent.cloneNode(false);
var top = parent.parentNode;
top.removeChild(parent);
top = top.appendChild(element);
}
});