Revert "serv_rssclient.c: style update"
[citadel.git] / webcit / static / t / sieve / display.html
1
2 <script type="text/javascript">
3
4 /*
5  * This script should get called by every onChange event...
6  *
7  */
8
9 var highest_active_rule = (-1);
10
11 function UpdateRules() {
12 /*
13  * Show only the active rows... /// TODO 255-> we need no limit anymore.
14  */
15   highest_active_rule = (-1);
16   for (i=0; i< 50; ++i) {
17    if ($('active'+i).checked) {
18      $('rule' + i).style.display = 'block';
19      highest_active_rule = i;
20    }
21    else {
22      $('rule' + i).style.display = 'none';
23    }
24   }
25
26 /*
27  * Show only the fields relevant to the rules...
28  */
29   for (i=0; i<=highest_active_rule; ++i) {
30     d = ($('movedown'+i));
31     if (i < highest_active_rule) {
32       d.style.display = 'block';
33     }
34     else {
35       d.style.display = 'none';
36     }
37     d = ($('hfield'+i).options[$('hfield'+i).selectedIndex].value);
38     if (d == 'all') {
39       $('div_size'+i).style.display = 'none';
40       $('div_compare'+i).style.display = 'none';
41       $('div_nocompare'+i).style.display = 'block';
42     }
43     else if (d == 'size') {
44       $('div_size'+i).style.display = 'block';
45       $('div_compare'+i).style.display = 'none';
46       $('div_nocompare'+i).style.display = 'none';
47     }
48     else {
49       $('div_size'+i).style.display = 'none';
50       $('div_compare'+i).style.display = 'block';
51       $('div_nocompare'+i).style.display = 'none';
52     }
53     d = ($('action'+i).options[$('action'+i).selectedIndex].value);
54     if (d == 'fileinto') {
55       $('div_fileinto'+i).style.display = 'block';
56       $('div_redirect'+i).style.display = 'none';
57       $('div_automsg'+i).style.display = 'none';
58     } else if (d == 'redirect') {
59       $('div_fileinto'+i).style.display = 'none';
60       $('div_redirect'+i).style.display = 'block';
61       $('div_automsg'+i).style.display = 'none';
62     } else if ((d == 'reject') || (d == 'vacation'))  {
63       $('div_fileinto'+i).style.display = 'none';
64       $('div_redirect'+i).style.display = 'none';
65       $('div_automsg'+i).style.display = 'block';
66     } else {
67       $('div_fileinto'+i).style.display = 'none';
68       $('div_redirect'+i).style.display = 'none';
69       $('div_automsg'+i).style.display = 'none';
70     }/* TODO: we don't have any limits anymore */
71     if (highest_active_rule < 49) {
72       $('div_addrule').style.display = 'block';
73     } else {
74       $('div_addrule').style.display = 'none';
75     }
76   }
77 }
78
79 /*
80  * Add a rule (really, just un-hide it)
81  */
82 function AddRule() {
83   highest_active_rule = highest_active_rule + 1;
84   $('active'+highest_active_rule).checked = true;
85   UpdateRules();
86 }
87
88 /*
89  * Swap two rules
90  */
91 function SwapRules(ra, rb) {
92
93   var things = new Array();
94   things[0] = 'hfield';
95   things[1] = 'compare';
96   things[2] = 'htext';
97   things[3] = 'action';
98   things[4] = 'fileinto';
99   things[5] = 'redirect';
100   things[6] = 'final';
101   things[7] = 'sizecomp';
102   things[8] = 'sizeval';
103   things[9] = 'automsg';
104
105   for (i=0; i<=9; ++i) {
106     tempval=$(things[i]+ra).value;
107     $(things[i]+ra).value = $(things[i]+rb).value;
108     $(things[i]+rb).value = tempval;
109   }
110 }
111
112 /*
113  * Delete a rule (percolate the deleted rule out to the end, then deactivate it)
114  */
115 function DeleteRule(rd) {
116   for (j=rd; j<=highest_active_rule; ++j) {
117     SwapRules(j, (j+1));
118   }
119   $('active'+highest_active_rule).checked = false;
120 }
121 </script>