##// END OF EJS Templates
code layout clean up select_list_move.js...
Toshi MARUYAMA -
r11513:af7540a23adb
parent child
Show More
@@ -1,14 +1,12
1 1 var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
2 2
3 function addOption(theSel, theText, theValue)
4 {
3 function addOption(theSel, theText, theValue) {
5 4 var newOpt = new Option(theText, theValue);
6 5 var selLength = theSel.length;
7 6 theSel.options[selLength] = newOpt;
8 7 }
9 8
10 function swapOptions(theSel, index1, index2)
11 {
9 function swapOptions(theSel, index1, index2) {
12 10 var text, value;
13 11 text = theSel.options[index1].text;
14 12 value = theSel.options[index1].value;
@@ -18,42 +16,31 function swapOptions(theSel, index1, index2)
18 16 theSel.options[index2].value = value;
19 17 }
20 18
21 function deleteOption(theSel, theIndex)
22 {
19 function deleteOption(theSel, theIndex) {
23 20 var selLength = theSel.length;
24 if(selLength>0)
25 {
21 if (selLength > 0) {
26 22 theSel.options[theIndex] = null;
27 23 }
28 24 }
29 25
30 function moveOptions(theSelFrom, theSelTo)
31 {
32
26 function moveOptions(theSelFrom, theSelTo) {
33 27 var selLength = theSelFrom.length;
34 28 var selectedText = new Array();
35 29 var selectedValues = new Array();
36 30 var selectedCount = 0;
37
38 31 var i;
39
40 for(i=selLength-1; i>=0; i--)
41 {
42 if(theSelFrom.options[i].selected)
43 {
32 for (i = selLength - 1; i >= 0; i--) {
33 if (theSelFrom.options[i].selected) {
44 34 selectedText[selectedCount] = theSelFrom.options[i].text;
45 35 selectedValues[selectedCount] = theSelFrom.options[i].value;
46 36 deleteOption(theSelFrom, i);
47 37 selectedCount++;
48 38 }
49 39 }
50
51 for(i=selectedCount-1; i>=0; i--)
52 {
40 for (i = selectedCount - 1; i >= 0; i--) {
53 41 addOption(theSelTo, selectedText[i], selectedValues[i]);
54 42 }
55
56 if(NS4) history.go(0);
43 if (NS4) history.go(0);
57 44 }
58 45
59 46 function moveOptionUp(theSel) {
@@ -73,8 +60,7 function moveOptionDown(theSel) {
73 60 }
74 61
75 62 // OK
76 function selectAllOptions(id)
77 {
63 function selectAllOptions(id) {
78 64 var select = $('#'+id);
79 65 select.children('option').attr('selected', true);
80 66 }
General Comments 0
You need to be logged in to leave comments. Login now