-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathscript.js
executable file
·145 lines (140 loc) · 6.78 KB
/
script.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
function button_add_click(){
var table=document.getElementById(table_name);
var combobox=document.getElementById(combobox_name);
var delete_text;
var delete_index;
var counter=0;
// combobox exists ?
if(combobox!=null){
// remove selected child
for(counter=0;counter<combobox.childNodes.length;counter++){
if(combobox.childNodes[counter].selected){
delete_text=combobox.childNodes[counter].value;
delete_index=get_element_index(field_values,delete_text);
//out("text:"+delete_text+" index:"+delete_index);
combobox.removeChild(combobox.childNodes[counter]);
combobox=document.getElementById(combobox_name);
//out(combobox.childNodes.length);
// combobox is empty ?
if(combobox.childNodes.length==1){
//combobox.setAttribute("Visible","false");
// remove combobox from
remove_element_from_parent(document.getElementById(combobox_parent_name),combobox);
}
//out(delete_text);
break;
}
}
//create row into table
if(table==null){
// create table with header
var table=document.createElement(table_name);
table.id=table_name;
var table_row=document.createElement("tr");
var table_header_1=document.createElement("th");
var table_header_2=document.createElement("th");
table_header_1.innerHTML="<center>description</center>";
table_row.appendChild(table_header_1);
table_header_2.innerHTML="<center>manager</center>";
table_row.appendChild(table_header_2);
table.appendChild(table_row);
}
// create header
var table=document.getElementById(table_name);
var table_row=document.createElement("tr");
table_row.id="row_"+delete_index;
var table_header_1=document.createElement("td");
var table_header_2=document.createElement("td");
table_header_1.innerHTML="<center>"+delete_text+"</center><br/><input type='text' size=10 id='"+form_element_prefix+delete_index+"' name='"+form_element_prefix+delete_index+"'/>";
table_row.appendChild(table_header_1);
table_header_2.innerHTML="<input type='button' value='delete' onclick='delete_table_row(\"row_"+delete_index+"\")'/>";
table_row.appendChild(table_header_2);
table.appendChild(table_row);
}else{
// check for scan resource or check for test
}
}
function delete_table_row(row_name){
// get index from array
var element_index=row_name.substring("row_".length,row_name.length);
//out("element_name:"+row_name+" element_index:"+element_index);
// find element and delete row into table
var counter=0;
var table=document.getElementById(table_name);
var find_element=document.getElementById(row_name);
for(counter=0;counter<table.childNodes.length;counter++){
if(table.childNodes[counter]==find_element){
table.removeChild(find_element);
break;
}
}
// adding element into combobox
var combobox=document.getElementById(combobox_name);
// create combobox ?
if(combobox==null){
var parent_element=document.getElementById(combobox_parent_name);
var combobox=document.createElement("select");
combobox.id=combobox_name;
parent_element.appendChild(combobox);
}
// add element
combobox=document.getElementById(combobox_name);
var option_new=document.createElement("option");
//out("element_index:"+element_index+" Value:"+field_values[element_index]);
var option_text=document.createTextNode(field_values[element_index]);
option_new.appendChild(option_text);
combobox.appendChild(option_new);
}
// get index of element from array
function get_element_index(array,element){
var return_value=-1;
var counter=0;
if(array!=null){
for(counter=0;counter<array.length;counter++){
if(array[counter]==element){
return_value=counter;
break;
}
}
}
return return_value;
}
// delete element_for_delete from parent
function remove_element_from_parent(parent,element_for_delete){
var counter=0;
for(counter=0;counter<parent.childNodes.length;counter++){
if(parent.childNodes[counter]==element_for_delete){
parent.removeChild(element_for_delete);
break;
}
}
}
function load_combobox_criteria(){
var combobox=document.getElementById(combobox_name);
var counter=0;
var option_new;
var option_text
for (counter=0;counter<field_values.length;counter++){
option_new=document.createElement("option");
option_text=document.createTextNode(field_values[counter]);
option_new.appendChild(option_text);
combobox.appendChild(option_new);
}
}
var console_name="console";
function out(value){
var element=document.getElementById(console_name);
if(element!=null){
// console is found
if((value==null)||(value=="")||(value==" ")||(value=="\n")){
var element_child=document.createElement("br");
element.appendChild(element_child);
}else{
var element_child=document.createElement("div");
element.appendChild(element_child);
element_child.appendChild(document.createTextNode(value));
}
}else{
// console not found
}
}