* added gcc printf format checking to wprintf
[citadel.git] / webcit / tabs.c
1 /*
2  * $Id$
3  *
4  */
5
6 #include "webcit.h"
7
8 /*
9  * print tabbed dialog
10  */
11 void tabbed_dialog(int num_tabs, char *tabnames[]) {
12         int i;
13
14         wprintf("<script type=\"text/javascript\">                                              "
15                 "var previously_selected_tab = '0';                                             "
16                 "function tabsel(which_tab) {                                                   "
17                 "       if (which_tab == previously_selected_tab) {                             "
18                 "               return;                                                         "
19                 "       }                                                                       "
20                 "       $('tabdiv'+previously_selected_tab).style.display = 'none';             "
21                 "       $('tabdiv'+which_tab).style.display = 'block';                          "
22                 "       $('tabtd'+previously_selected_tab).className = 'tab_cell_edit';         "
23                 "       $('tabtd'+which_tab).className = 'tab_cell_label';                      "
24                 "       previously_selected_tab = which_tab;                                    "
25                 "}                                                                              "
26                 "</script>                                                                      \n"
27         );
28
29         wprintf("<table id=\"TheTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
30                 "<tr align=\"center\" style=\"cursor:pointer\"><td>&nbsp;</td>"
31         );
32
33         for (i=0; i<num_tabs; ++i) {
34                 wprintf("<td id=\"tabtd%d\" class=\"%s\" "
35                         "onClick='tabsel(\"%d\");'"
36                         ">",
37                         i,
38                         ( (i==0) ? "tab_cell_label" : "tab_cell_edit" ),
39                         i
40                         );
41                 wprintf("%s", tabnames[i]);
42                 wprintf("</td>");
43
44                 wprintf("<td>&nbsp;</td>\n");
45         }
46
47         wprintf("</tr></table>\n");
48 }
49
50 /*
51  * print the tab-header
52  *
53  * tabnum:       number of the tab to print
54  * num_tabs:     total number oftabs to be printed
55  *
56  */
57 void begin_tab(int tabnum, int num_tabs) {
58         wprintf("<!-- begin tab %d of %d -->\n", tabnum, num_tabs);
59         wprintf("<div id=\"tabdiv%d\" style=\"display:%s\" class=\"tabcontent\" >",
60                 tabnum,
61                 ( (tabnum == 0) ? "block" : "none" )
62         );
63 }
64
65 /*
66  * print the tab-footer
67  * tabnum:       number of the tab to print
68  * num_tabs:     total number of tabs to be printed
69  *
70  */
71 void end_tab(int tabnum, int num_tabs) {
72         wprintf("</div>\n");
73         wprintf("<!-- end tab %d of %d -->\n", tabnum, num_tabs);
74
75         if (tabnum == num_tabs-1) {
76
77                 wprintf("<script type=\"text/javascript\">"
78                         " Nifty(\"table#TheTabs td\", \"small transparent top\");"
79                         "</script>"
80                 );
81
82         }
83 }
84
85