-
Notifications
You must be signed in to change notification settings - Fork 1
/
ui.html
executable file
·139 lines (133 loc) · 4.19 KB
/
ui.html
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css"><!--
#updateCols {
visibility: collapse;
}
.updateCols {
visibility: collapse;
}
//--></style>
</head>
<body>
<script type="text/javascript" language="javascript"><!--
function addItem()
{
var allCols = document.csv_import.allCols;
//if (document.all)
//allCols = document.all.csv_import.allCols;
if(allCols.selectedIndex != -1)
{
var el = document.getElementsByName("sCols[]")[0];
var entry = document.createElement("option");
var item = allCols.options[allCols.selectedIndex];
entry.text = "col " + (el.length+1) + ": " + item.text;
entry.value = item.value;
if(item.value!="SPACER"){
allCols.remove(allCols.selectedIndex);
}
var option = null;
if (document.all)
option = entry.length;
el.add(entry, option);
}
}
function removeItem()
{
var allCols = document.getElementsByName("sCols[]")[0];
if(allCols.selectedIndex != -1)
{
var el = document.csv_import.allCols;
var entry = document.createElement("option");
var item = allCols.options[allCols.selectedIndex];
entry.text = item.value;
entry.value = item.value;
allCols.remove(allCols.selectedIndex);
var allOptions = allCols.getElementsByTagName("option");
for (var i = 0; i < allOptions.length; i++) {
allOptions[i].innerHTML = "col " + (i+1) + ": " + allOptions[i].value;
}
var option = null;
if (document.all)
option = entry.length;
if(item.value!="SPACER"){
el.add(entry, option);
}
}
}
function selectAll()
{
var allCols = document.getElementsByName("sCols[]")[0];
for(var i = 0; i < allCols.length; i++)
{
allCols.options[i].selected = true;
}
}
/**
* Select elements by their class name
*
* @author Dustin Diaz <dustin [at] dustindiaz [dot] com>
* @link http://www.dustindiaz.com/getelementsbyclass/
*/
function getElementsByClass(searchClass,node,tag) {
var classElements = new Array();
if ( node == null )
node = document;
if ( tag == null )
tag = '*';
var els = node.getElementsByTagName(tag);
var elsLen = els.length;
//var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
var pattern = new RegExp(""+searchClass+"");
for (i = 0, j = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
}
function toggleVisible(element, initial) {
var state = element.style.visibility;
if (state == "") {
state = initial;
}
if (state == "collapse") {
element.style.visibility = "visible";
} else {
element.style.visibility = "collapse";
}
}
function toggleVisibleElements(elements, initial) {
for (var i=0; i< elements.length; i++) {
//window.alert('in toggleVisibleElements element class = ' + element.className);
toggleVisible(elements[i], initial);
}
}
function toggleVisibleClass(tag, className, initial) {
classElements = getElementsByClass(className, null, tag);
toggleVisibleElements(classElements, 'collapse');
}
function toggleVisibleName(name, initial) {
nameElements = document.getElementsByName(name);
toggleVisibleElements(nameElements, 'collapse');
}
//--></script>
<form name="csv_import" enctype="multipart/form-data" action="/tim/csvtosql/ui_csvhandle.php" method="post" onsubmit="selectAll();">
<select size="20" name="sCols[]" style="width:300px;" onclick="removeItem();" multiple="multiple">
<option id='f' value='f'>col 1: f</option>
</select>
<select size="20" name="allCols" style="width:300px;" onclick="addItem();">
<option value="SPACER">[skip col]</option>
<option id='a' value='a'>a</option>
<option id='b' value='b'>b</option>
<option id='c' value='c'>c</option>
<option id='d' value='d'>d</option>
<option id='e' value='e'>e</option>
</select>
</form>
</body>
</html>