3 * This script should get called by every onChange event...
6 <script type="text/javascript">
8 var highest_active_rule = (-1);
10 function UpdateRules() {
12 * Show only the active rows...
14 highest_active_rule = (-1);
15 for (i=0; i< <?SIEVE:MAX_RULES>; ++i) {
16 if ($('active'+i).checked) {
17 $('rule' + i).style.display = 'block';
18 highest_active_rule = i;
21 $('rule' + i).style.display = 'none';
25 * Show only the fields relevant to the rules...
27 for (i=0; i<=highest_active_rule; ++i) {
28 d = ($('movedown'+i));
29 if (i < highest_active_rule) {
30 d.style.display = 'block';
33 d.style.display = 'none';
35 d = ($('hfield'+i).options[$('hfield'+i).selectedIndex].value);
37 $('div_size'+i).style.display = 'none';
38 $('div_compare'+i).style.display = 'none';
39 $('div_nocompare'+i).style.display = 'block';
41 else if (d == 'size') {
42 $('div_size'+i).style.display = 'block';
43 $('div_compare'+i).style.display = 'none';
44 $('div_nocompare'+i).style.display = 'none';
47 $('div_size'+i).style.display = 'none';
48 $('div_compare'+i).style.display = 'block';
49 $('div_nocompare'+i).style.display = 'none';
51 d = ($('action'+i).options[$('action'+i).selectedIndex].value);
52 if (d == 'fileinto') {
53 $('div_fileinto'+i).style.display = 'block';
54 $('div_redirect'+i).style.display = 'none';
55 $('div_automsg'+i).style.display = 'none';
56 } else if (d == 'redirect') {
57 $('div_fileinto'+i).style.display = 'none';
58 $('div_redirect'+i).style.display = 'block';
59 $('div_automsg'+i).style.display = 'none';
60 } else if ((d == 'reject') || (d == 'vacation')) {
61 $('div_fileinto'+i).style.display = 'none';
62 $('div_redirect'+i).style.display = 'none';
63 $('div_automsg'+i).style.display = 'block';
65 $('div_fileinto'+i).style.display = 'none';
66 $('div_redirect'+i).style.display = 'none';
67 $('div_automsg'+i).style.display = 'none';
69 if (highest_active_rule < <?SIEVE:MAX_RULES> - 1) {
70 $('div_addrule').style.display = 'block';
72 $('div_addrule').style.display = 'none';
77 * Add a rule (really, just un-hide it)
80 highest_active_rule = highest_active_rule + 1;
81 $('active'+highest_active_rule).checked = true;
87 function SwapRules(ra, rb) {
89 var things = new Array();
91 things[1] = 'compare';
94 things[4] = 'fileinto';
95 things[5] = 'redirect';
97 things[7] = 'sizecomp';
98 things[8] = 'sizeval';
99 things[9] = 'automsg';
101 for (i=0; i<=9; ++i) {
102 tempval=$(things[i]+ra).value;
103 $(things[i]+ra).value = $(things[i]+rb).value;
104 $(things[i]+rb).value = tempval;
108 * Delete a rule (percolate the deleted rule out to the end, then deactivate it)
110 function DeleteRule(rd) {
111 for (j=rd; j<=highest_active_rule; ++j) {
114 $('active'+highest_active_rule).checked = false;
121 <div id="div_addrule"><a href="javascript:AddRule();"><?_("Add rule")></a><br></div>
122 <script type="text/javascript">UpdateRules();</script>