-/*
- * This script should get called by every onChange event...
- *
- */
- wprintf("<script type=\"text/javascript\"> \n"
- " \n"
- "var highest_active_rule = (-1); \n"
- " \n"
- "function UpdateRules() { \n"
- " for (i=0; i<%d; ++i) { \n", MAX_RULES);
- wprintf(" d = ($('movedown'+i)); \n"
- " if (i < highest_active_rule) { \n"
- " d.style.display = 'block'; \n"
- " } \n"
- " else { \n"
- " d.style.display = 'none'; \n"
- " } \n"
- " d = ($('hfield'+i).options[$('hfield'+i).selectedIndex].value); \n"
- " if (d == 'all') { \n"
- " $('div_size'+i).style.display = 'none'; \n"
- " $('div_compare'+i).style.display = 'none'; \n"
- " $('div_nocompare'+i).style.display = 'block'; \n"
- " } \n"
- " else if (d == 'size') { \n"
- " $('div_size'+i).style.display = 'block'; \n"
- " $('div_compare'+i).style.display = 'none'; \n"
- " $('div_nocompare'+i).style.display = 'none'; \n"
- " } \n"
- " else { \n"
- " $('div_size'+i).style.display = 'none'; \n"
- " $('div_compare'+i).style.display = 'block'; \n"
- " $('div_nocompare'+i).style.display = 'none'; \n"
- " } \n"
- " d = ($('action'+i).options[$('action'+i).selectedIndex].value); \n"
- " if (d == 'fileinto') { \n"
- " $('div_fileinto'+i).style.display = 'block'; \n"
- " $('div_redirect'+i).style.display = 'none'; \n"
- " $('div_automsg'+i).style.display = 'none'; \n"
- " } else if (d == 'redirect') { \n"
- " $('div_fileinto'+i).style.display = 'none'; \n"
- " $('div_redirect'+i).style.display = 'block'; \n"
- " $('div_automsg'+i).style.display = 'none'; \n"
- " } else if ((d == 'reject') || (d == 'vacation')) { \n"
- " $('div_fileinto'+i).style.display = 'none'; \n"
- " $('div_redirect'+i).style.display = 'none'; \n"
- " $('div_automsg'+i).style.display = 'block'; \n"
- " } else { \n"
- " $('div_fileinto'+i).style.display = 'none'; \n"
- " $('div_redirect'+i).style.display = 'none'; \n"
- " $('div_automsg'+i).style.display = 'none'; \n"
- " } \n"
- " if (highest_active_rule < %d) { \n", MAX_RULES-1 );
- wprintf(" $('div_addrule').style.display = 'block'; \n"
- " } else { \n"
- " $('div_addrule').style.display = 'none'; \n"
- " } \n"
- " } \n"
- );
-/*
- * Show only the active rows...
- */
- wprintf(" highest_active_rule = (-1); \n");
- wprintf(" for (i=0; i<%d; ++i) { \n", MAX_RULES);
- wprintf(" if ($('active'+i).checked) { \n"
- " $('rule' + i).style.display = 'block'; \n"
- " highest_active_rule = i; \n"
- " } \n"
- " else { \n"
- " $('rule' + i).style.display = 'none'; \n"
- " } \n"
- " } \n"
- "} \n"
-/*
- * Add a rule (really, just un-hide it)
- */
- "function AddRule() { \n"
- " highest_active_rule = highest_active_rule + 1; \n"
- " $('active'+highest_active_rule).checked = true; \n"
- " UpdateRules(); \n"
- "} \n"
-/*
- * Swap two rules
- */
- "function SwapRules(ra, rb) { \n"
- " \n"
- " var things = new Array(); \n"
- " things[0] = 'hfield'; \n"
- " things[1] = 'compare'; \n"
- " things[2] = 'htext'; \n"
- " things[3] = 'action'; \n"
- " things[4] = 'fileinto'; \n"
- " things[5] = 'redirect'; \n"
- " things[6] = 'final'; \n"
- " things[7] = 'sizecomp'; \n"
- " things[8] = 'sizeval'; \n"
- " things[9] = 'automsg'; \n"
- " \n"
- " for (i=0; i<=9; ++i) { \n"
- " tempval=$(things[i]+ra).value; \n"
- " $(things[i]+ra).value = $(things[i]+rb).value; \n"
- " $(things[i]+rb).value = tempval; \n"
- " } \n"
- "} \n"
-/*
- * Delete a rule (percolate the deleted rule out to the end, then deactivate it)
- */
- "function DeleteRule(rd) { \n"
- " for (i=rd; i<highest_active_rule; ++i) { \n"
- " SwapRules(i, (i+1)); \n"
- " } \n"
- " $('active'+highest_active_rule).checked = false; \n"
- "} \n"
- "</script> \n"
- );
-
-
- wprintf("<br />");
-
- wprintf("<table cellpadding=2 width=100%%>");
-
- for (i=0; i<MAX_RULES; ++i) {
-
- /* Grab our existing values to populate */
- active = extract_int(rules[i], 0);
- extract_token(hfield, rules[i], 1, '|', sizeof hfield);
- extract_token(compare, rules[i], 2, '|', sizeof compare);
- extract_token(htext, rules[i], 3, '|', sizeof htext);
- extract_token(sizecomp, rules[i], 4, '|', sizeof sizecomp);
- sizeval = extract_int(rules[i], 5);
- extract_token(action, rules[i], 6, '|', sizeof action);
- extract_token(fileinto, rules[i], 7, '|', sizeof fileinto);
- extract_token(redirect, rules[i], 8, '|', sizeof redirect);
- extract_token(automsg, rules[i], 9, '|', sizeof automsg);
- extract_token(final, rules[i], 10, '|', sizeof final);
-
- /* now generate the table row */
-
- wprintf("<tr id=\"rule%d\" bgcolor=\"#%s\">",
- i,
- ((i%2) ? "DDDDDD" : "FFFFFF")
- );
-
- wprintf("<td width=5%% align=\"center\">");
-
- wprintf("<div style=\"display:none\">");
- wprintf("<input type=\"checkbox\" name=\"active%d\" id=\"active%d\" %s>",
- i, i,
- (active ? "checked" : "")
- );
- wprintf("</div>");
-
- if (i>0) wprintf("<a href=\"javascript:SwapRules(%d,%d);UpdateRules();\">"
- "<img border=\"0\" src=\"static/up_pointer.gif\" "
- "title=\"%s\"/></a>",
- i-1, i, _("Move rule up") );
-
- wprintf("<a href=\"javascript:SwapRules(%d,%d);UpdateRules();\">"
- "<img id=\"movedown%d\" border=\"0\" src=\"static/down_pointer.gif\" "
- "title=\"%s\"/></a>",
- i, i+1, i, _("Move rule down") );
-
- wprintf("<a href=\"javascript:DeleteRule(%d);UpdateRules();\">"
- "<img id=\"delete%d\" border=\"0\" src=\"static/delete.gif\" "
- "title=\"%s\"/></a>",
- i, i, _("Delete rule") );
-
- wprintf("</td>");
-
- wprintf("<td width=5%% align=\"center\">");
- wprintf("<font size=+2>%d</font>", i+1);
- wprintf("</td>");
-
- wprintf("<td width=20%%>%s ", _("If") );
-
- char *hfield_values[14][2] = {
- { "from", _("From") },
- { "tocc", _("To or Cc") },
- { "subject", _("Subject") },
- { "replyto", _("Reply-to") },
- { "sender", _("Sender") },
- { "resentfrom", _("Resent-From") },
- { "resentto", _("Resent-To") },
- { "envfrom", _("Envelope From") },
- { "envto", _("Envelope To") },
- { "xmailer", _("X-Mailer") },
- { "xspamflag", _("X-Spam-Flag") },
- { "xspamstatus", _("X-Spam-Status") },
- { "size", _("Message size") },
- { "all", _("All") }
- };
-
- wprintf("<select id=\"hfield%d\" name=\"hfield%d\" size=1 onChange=\"UpdateRules();\">",
- i, i);
- for (j=0; j<14; ++j) {
- wprintf("<option %s value=\"%s\">%s</option>",
- ( (!strcasecmp(hfield, hfield_values[j][0])) ? "selected" : ""),
- hfield_values[j][0],
- hfield_values[j][1]
- );
- }
-
- wprintf("</select>");
- wprintf("</td>");
-
- wprintf("<td width=20%%>");
-
- char *compare_values[4][2] = {
- { "contains", _("contains") },
- { "notcontains", _("does not contain") },
- { "is", _("is") },
- { "isnot", _("is not") }
- };
-
- wprintf("<div id=\"div_compare%d\">", i);
- wprintf("<select id=\"compare%d\" name=\"compare%d\" size=1 onChange=\"UpdateRules();\">",
- i, i);
- for (j=0; j<4; ++j) {
- wprintf("<option %s value=\"%s\">%s</option>",
- ( (!strcasecmp(compare, compare_values[j][0])) ? "selected" : ""),
- compare_values[j][0],
- compare_values[j][1]
- );
- }
- wprintf("</select>");
-
- wprintf("<input type=\"text\" id=\"htext%d\" name=\"htext%d\" value=\"", i, i);
- escputs(htext);
- wprintf("\"></div>");
-
- wprintf("<div id=\"div_nocompare%d\">", i);
- wprintf("%s", _("(All messages)"));
- wprintf("</div>");
-
- char *sizecomp_values[2][2] = {
- { "larger", _("is larger than") },
- { "smaller", _("is smaller than") }
- };
-
- wprintf("<div id=\"div_size%d\">", i);
- wprintf("<select id=\"sizecomp%d\" name=\"sizecomp%d\" size=1 onChange=\"UpdateRules();\">",
- i, i);
- for (j=0; j<2; ++j) {
- wprintf("<option %s value=\"%s\">%s</option>",
- ( (!strcasecmp(sizecomp, sizecomp_values[j][0])) ? "selected" : ""),
- sizecomp_values[j][0],
- sizecomp_values[j][1]
- );
- }
- wprintf("</select>");
-
- wprintf("<input type=\"text\" id=\"sizeval%d\" name=\"sizeval%d\" value=\"%d\">",
- i, i, sizeval);
- wprintf("bytes");
- wprintf("</div>");
-
- wprintf("</td>");
-
- wprintf("<td width=20%%>");
- wprintf("<select id=\"action%d\" name=\"action%d\" size=1 onChange=\"UpdateRules();\">",
- i, i);
- wprintf("<option value=\"keep\">%s</option>", _("Keep"));
- wprintf("<option value=\"discard\">%s</option>", _("Discard silently"));
- wprintf("<option value=\"reject\">%s</option>", _("Reject"));
- wprintf("<option value=\"fileinto\">%s</option>", _("Move message to"));
- wprintf("<option value=\"redirect\">%s</option>", _("Forward to"));
- wprintf("<option value=\"vacation\">%s</option>", _("Vacation"));
- wprintf("</select>");
-
- wprintf("<div id=\"div_fileinto%d\">", i);
- wprintf("<select name=\"fileinto%d\" id=\"fileinto%d\">", i, i);
- for (j=0; j<num_roomnames; ++j) {
- wprintf("<option ");
- if (!strcasecmp(rooms[j].name, "Mail")) {
- wprintf("selected ");
- }
- wprintf("value=\"");
- urlescputs(rooms[j].name);
- wprintf("\">");
- escputs(rooms[j].name);
- wprintf("</option>\n");
- }
- wprintf("</select>\n");
- wprintf("</div>");
-
- wprintf("<div id=\"div_redirect%d\">", i);
- wprintf("<input type=\"text\" id=\"redirect%d\" name=\"redirect%d\">", i, i);
- wprintf("</div>");