@@ -1,88 +1,105 | |||
|
1 | 1 | var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5); |
|
2 | 2 | |
|
3 | 3 | function addOption(theSel, theText, theValue) { |
|
4 | 4 | var newOpt = new Option(theText, theValue); |
|
5 | 5 | var selLength = theSel.length; |
|
6 | 6 | theSel.options[selLength] = newOpt; |
|
7 | 7 | } |
|
8 | 8 | |
|
9 | 9 | function swapOptions(theSel, index1, index2) { |
|
10 | var text, value; | |
|
10 | var text, value, selected; | |
|
11 | 11 | text = theSel.options[index1].text; |
|
12 | 12 | value = theSel.options[index1].value; |
|
13 | selected = theSel.options[index1].selected; | |
|
13 | 14 | theSel.options[index1].text = theSel.options[index2].text; |
|
14 | 15 | theSel.options[index1].value = theSel.options[index2].value; |
|
16 | theSel.options[index1].selected = theSel.options[index2].selected; | |
|
15 | 17 | theSel.options[index2].text = text; |
|
16 | 18 | theSel.options[index2].value = value; |
|
19 | theSel.options[index2].selected = selected; | |
|
17 | 20 | } |
|
18 | 21 | |
|
19 | 22 | function deleteOption(theSel, theIndex) { |
|
20 | 23 | var selLength = theSel.length; |
|
21 | 24 | if (selLength > 0) { |
|
22 | 25 | theSel.options[theIndex] = null; |
|
23 | 26 | } |
|
24 | 27 | } |
|
25 | 28 | |
|
26 | 29 | function moveOptions(theSelFrom, theSelTo) { |
|
27 | 30 | var selLength = theSelFrom.length; |
|
28 | 31 | var selectedText = new Array(); |
|
29 | 32 | var selectedValues = new Array(); |
|
30 | 33 | var selectedCount = 0; |
|
31 | 34 | var i; |
|
32 | 35 | for (i = selLength - 1; i >= 0; i--) { |
|
33 | 36 | if (theSelFrom.options[i].selected) { |
|
34 | 37 | selectedText[selectedCount] = theSelFrom.options[i].text; |
|
35 | 38 | selectedValues[selectedCount] = theSelFrom.options[i].value; |
|
36 | 39 | deleteOption(theSelFrom, i); |
|
37 | 40 | selectedCount++; |
|
38 | 41 | } |
|
39 | 42 | } |
|
40 | 43 | for (i = selectedCount - 1; i >= 0; i--) { |
|
41 | 44 | addOption(theSelTo, selectedText[i], selectedValues[i]); |
|
42 | 45 | } |
|
43 | 46 | if (NS4) history.go(0); |
|
44 | 47 | } |
|
45 | 48 | |
|
46 | 49 | function moveOptionUp(theSel) { |
|
47 | var index = theSel.selectedIndex; | |
|
48 | if (index > 0) { | |
|
49 | swapOptions(theSel, index-1, index); | |
|
50 | theSel.selectedIndex = index-1; | |
|
50 | var indexTop = 0; | |
|
51 | for(var s=0; s<theSel.length; s++) { | |
|
52 | if (theSel.options[s].selected) { | |
|
53 | if (s > indexTop) { | |
|
54 | swapOptions(theSel, s-1, s); | |
|
55 | } | |
|
56 | indexTop++; | |
|
57 | } | |
|
51 | 58 | } |
|
52 | 59 | } |
|
53 | 60 | |
|
54 | 61 | function moveOptionTop(theSel) { |
|
55 | var index = theSel.selectedIndex; | |
|
56 | ||
|
57 | if (index > 0) { | |
|
58 | for (i=index; i>0; i--) { | |
|
59 | swapOptions(theSel, i-1, i); | |
|
62 | var indexTop = 0; | |
|
63 | for(var s=0; s<theSel.length; s++) { | |
|
64 | if (theSel.options[s].selected) { | |
|
65 | if (s > indexTop) { | |
|
66 | for (var i=s; i>indexTop; i--) { | |
|
67 | swapOptions(theSel, i-1, i); | |
|
68 | } | |
|
69 | } | |
|
70 | indexTop++; | |
|
60 | 71 | } |
|
61 | theSel.selectedIndex = 0; | |
|
62 | 72 | } |
|
63 | 73 | } |
|
64 | 74 | |
|
65 | 75 | function moveOptionDown(theSel) { |
|
66 |
var index = theSel. |
|
|
67 | if (index < theSel.length - 1) { | |
|
68 | swapOptions(theSel, index, index+1); | |
|
69 | theSel.selectedIndex = index+1; | |
|
76 | var indexBottom = theSel.length - 1; | |
|
77 | for(var s=indexBottom; s>=0; s--) { | |
|
78 | if (theSel.options[s].selected) { | |
|
79 | if (s < indexBottom) { | |
|
80 | swapOptions(theSel, s+1, s); | |
|
81 | } | |
|
82 | indexBottom--; | |
|
83 | } | |
|
70 | 84 | } |
|
71 | 85 | } |
|
72 | 86 | |
|
73 | 87 | function moveOptionBottom(theSel) { |
|
74 |
var index = theSel. |
|
|
75 | var indexTop = theSel.length - 1; | |
|
76 | if (index < theSel.length - 1) { | |
|
77 | for (i=index; i<indexTop; i++) { | |
|
78 | swapOptions(theSel, i+1, i); | |
|
88 | var indexBottom = theSel.length - 1; | |
|
89 | for(var s=indexBottom; s>=0; s--) { | |
|
90 | if (theSel.options[s].selected) { | |
|
91 | if (s < indexBottom) { | |
|
92 | for (i=s; i<indexBottom; i++) { | |
|
93 | swapOptions(theSel, i+1, i); | |
|
94 | } | |
|
95 | } | |
|
96 | indexBottom--; | |
|
79 | 97 | } |
|
80 | theSel.selectedIndex = indexTop; | |
|
81 | 98 | } |
|
82 | 99 | } |
|
83 | 100 | |
|
84 | 101 | // OK |
|
85 | 102 | function selectAllOptions(id) { |
|
86 | 103 | var select = $('#'+id); |
|
87 | 104 | select.children('option').attr('selected', true); |
|
88 | 105 | } |
General Comments 0
You need to be logged in to leave comments.
Login now