Javascript multi-pane select for Sieve edit screen
authorArt Cancro <ajc@citadel.org>
Mon, 30 Oct 2006 16:34:16 +0000 (16:34 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 30 Oct 2006 16:34:16 +0000 (16:34 +0000)
based on the drop-down box

webcit/sieve.c

index 2f600811bed12d0e448919fb001b17dcd7c73731..4c900c090747f8aaee7bfebdf6e0a33748cf95b9 100644 (file)
@@ -16,6 +16,21 @@ void display_sieve(void)
 {
        output_headers(1, 1, 2, 0, 0, 0);
 
+       wprintf("<script type=\"text/javascript\">                                      \n"
+               "function ToggleSievePanels() {                                         \n"
+               " d = ($('sieveform').bigaction.options[$('sieveform').bigaction.selectedIndex].value); \n"
+               " for (i=0; i<3; ++i) {                                                 \n"
+               "  if (i == d) {                                                        \n"
+               "   $('sievediv' + i).style.display = 'block';                          \n"
+               "  }                                                                    \n"
+               "  else {                                                               \n"
+               "   $('sievediv' + i).style.display = 'none';                           \n"
+               "  }                                                                    \n"
+               " }                                                                     \n"
+               "}                                                                      \n"
+               "</script>                                                              \n"
+       );
+
        wprintf("<div id=\"banner\">\n");
        wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>");
        wprintf("<SPAN CLASS=\"titlebar\">");
@@ -29,12 +44,10 @@ void display_sieve(void)
                "<tr><td valign=top>\n");
 
 
-       wprintf("<form method=\"post\" action=\"save_sieve\">\n");
-
-       wprintf("</form>\n");
+       wprintf("<form id=\"sieveform\" method=\"post\" action=\"save_sieve\">\n");
 
        wprintf(_("When new mail arrives: "));
-        wprintf("<select name=\"bigaction\" size=1>\n");
+        wprintf("<select name=\"bigaction\" size=1 onChange=\"ToggleSievePanels();\">\n");
 
        wprintf("<option value=\"0\">");
        wprintf(_("Leave it in my inbox without filtering"));
@@ -50,6 +63,37 @@ void display_sieve(void)
 
        wprintf("</select>");
 
+
+
+       /* The "no filtering" div */
+
+       wprintf("<div id=\"sievediv0\" style=\"display:none\">\n");
+       wprintf("<div align=\"center\"><br /><br />");
+       wprintf(_("Your incoming mail will not be filtered through any scripts."));
+       wprintf("<br /><br /></div>\n");
+       wprintf("</div>\n");
+
+       /* The "webcit managed scripts" div */
+
+       wprintf("<div id=\"sievediv1\" style=\"display:none\">\n");
+       wprintf("<div align=\"center\"><br /><br />");
+       wprintf("FIXME div 1 isn't finished yet");
+       wprintf("<br /><br /></div>\n");
+       wprintf("</div>\n");
+
+
+       /* The "I'm smart and can write my own Sieve scripts" div */
+
+       wprintf("<div id=\"sievediv2\" style=\"display:none\">\n");
+       wprintf("<div align=\"center\"><br /><br />");
+       wprintf("FIXME div 2 isn't finished yet");
+       wprintf("<br /><br /></div>\n");
+       wprintf("</div>\n");
+
+
+
+       /* The rest of this is common for all panels... */
+
        wprintf("<div align=\"center\"><br>");
        wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Save changes"));
        wprintf("&nbsp;");
@@ -57,6 +101,12 @@ void display_sieve(void)
        wprintf("</div></form>\n");
 
        wprintf("</td></tr></table></div>\n");
+
+       wprintf("<script type=\"text/javascript\">      \n"
+               "ToggleSievePanels();                   \n"
+               "</script>                              \n"
+       );
+
        wDumpContent(1);
 
 }