From 2451802940ba07f8bade32bda88c172b520abc9b Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 11 Nov 2006 06:15:53 +0000 Subject: [PATCH] javascript code to move rules up and down --- webcit/sieve.c | 77 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 18 deletions(-) diff --git a/webcit/sieve.c b/webcit/sieve.c index 20c032d9d..32c92408a 100644 --- a/webcit/sieve.c +++ b/webcit/sieve.c @@ -407,18 +407,25 @@ void display_rules_editor_inner_div(void) { " \n" "function UpdateRules() { \n" " for (i=0; i<%d; ++i) { \n", MAX_RULES); - wprintf(" 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" - " } else if (d == 'redirect') { \n" - " $('div_fileinto'+i).style.display = 'none'; \n" + 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 = ($('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" + " } else if (d == 'redirect') { \n" + " $('div_fileinto'+i).style.display = 'none'; \n" " $('div_redirect'+i).style.display = 'block'; \n" - " } else { \n" - " $('div_fileinto'+i).style.display = 'none'; \n" - " $('div_redirect'+i).style.display = 'none'; \n" + " } else { \n" + " $('div_fileinto'+i).style.display = 'none'; \n" + " $('div_redirect'+i).style.display = 'none'; \n" + " } \n" " } \n" - " } \n" ); /* * Show only the active rows... @@ -442,6 +449,27 @@ void display_rules_editor_inner_div(void) { " $('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" + " \n" + " for (i=0; i<7; ++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" + "} \n" " \n" ); @@ -462,22 +490,32 @@ void display_rules_editor_inner_div(void) { wprintf("", i); wprintf(""); - wprintf("%d. %s", i+1, _("If") ); + if (i>0) wprintf("" + "", i-1, i); + + wprintf("" + "", + i, i+1, i); + + wprintf(" %d. %s", i+1, _("If") ); wprintf(""); - wprintf("", + i, i); wprintf("", _("Sender")); wprintf("", _("Recipient")); wprintf(""); wprintf(""); wprintf(""); - wprintf("", + i, i); wprintf("", _("matches")); wprintf("", _("does not match")); wprintf(""); - wprintf("", i); + wprintf("", i, i); wprintf(""); wprintf(""); @@ -489,7 +527,7 @@ void display_rules_editor_inner_div(void) { wprintf(""); wprintf("
", i); - wprintf("", i, i); for (j=0; j"); wprintf("
", i); - wprintf("", i); + wprintf("", i, i); wprintf("
"); wprintf(""); @@ -514,7 +552,8 @@ void display_rules_editor_inner_div(void) { wprintf("%s", _("and then") ); wprintf(""); - wprintf("", + i, i); wprintf("", _("stop")); wprintf("", _("continue processing")); wprintf(""); @@ -525,8 +564,10 @@ void display_rules_editor_inner_div(void) { } wprintf(""); - wprintf("Add rule\n"); + wprintf("Add rule
\n"); + wprintf("" + "Swap first two rules (test)
\n"); wprintf("