5 * \defgroup StickyNotes Functions which handle "sticky notes"
6 * \ingroup WebcitDisplayItems
11 #include "webserver.h"
14 * \brief display sticky notes
15 * \param msgnum the citadel mesage number
17 void display_note(long msgnum)
21 char display_notetext[SIZ];
26 // wprintf("<IMG ALIGN=MIDDLE src=\"static/storenotes_48x.gif\">\n");
27 serv_printf("MSG0 %ld", msgnum);
28 serv_getln(buf, sizeof buf);
30 wprintf("%s<br />\n", &buf[4]);
36 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
38 /** Fill the buffer */
39 if ( (in_text) && (strlen(notetext) < SIZ-256) ) {
40 strcat(notetext, buf);
43 if ( (!in_text) && (!strncasecmp(buf, "exti=", 5)) ) {
44 safestrncpy(eid, &buf[5], sizeof eid);
47 if ( (!in_text) && (!strcasecmp(buf, "text")) ) {
52 /** Now sanitize the buffer */
53 len = strlen(notetext);
54 for (i=0; i<len; ++i) {
55 if (isspace(notetext[i])) notetext[i] = ' ';
58 /** Make it HTML-happy and print it. */
59 stresc(display_notetext, SIZ, notetext, 0, 0);
60 /* Lets try it as a draggable */
61 if (!IsEmptyStr(eid)) {
62 wprintf ("<IMG ALIGN=MIDDLE src=\"static/storenotes_48x.gif\" id=\"note_%s\" alt=\"Note\" ", eid);
63 wprintf ("class=\"notes\">\n");
64 wprintf ("<script type=\"text/javascript\">\n");
65 // wprintf ("//<![CDATA[\n");
66 wprintf ("new Draggable (\"note_%s\", {revert:true})\n", eid);
67 // wprintf ("//]]>\n");
68 wprintf ("</script>\n");
71 wprintf ("<IMG ALIGN=MIDDLE src=\"static/storenotes_48x.gif\" id=\"note_%ld\" ", msgnum);
72 wprintf ("class=\"notes\">\n");
73 wprintf ("<script type=\"text/javascript\">\n");
74 // wprintf ("//<![CDATA[\n");
75 wprintf ("new Draggable (\"note_%ld\", {revert:true})\n", msgnum);
76 // wprintf ("//]]>\n");
77 wprintf ("</script>\n");
80 if (!IsEmptyStr(eid)) {
81 wprintf("<span id=\"note%s\">%s</span><br />\n", eid, display_notetext);
84 wprintf("<span id=\"note%ld\">%s</span><br />\n", msgnum, display_notetext);
87 /** Offer in-place editing. */
88 if (!IsEmptyStr(eid)) {
89 wprintf("<script type=\"text/javascript\">"
90 "new Ajax.InPlaceEditor('note%s', 'updatenote?nonce=%ld?eid=%s', {rows:5,cols:72});"
101 * \brief This gets called by the Ajax.InPlaceEditor when we save a note.
103 void updatenote(void)
107 char display_notetext[SIZ];
112 serv_printf("ENT0 1||0|0||||||%s", bstr("eid"));
113 serv_getln(buf, sizeof buf);
115 text_to_server(bstr("value"));
119 begin_ajax_response();
120 msgnum = locate_message_by_uid(bstr("eid"));
122 serv_printf("MSG0 %ld", msgnum);
123 serv_getln(buf, sizeof buf);
125 strcpy(notetext, "");
126 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
128 /** Fill the buffer */
129 if ( (in_text) && (strlen(notetext) < SIZ-256) ) {
130 strcat(notetext, buf);
133 if ( (!in_text) && (!strcasecmp(buf, "text")) ) {
137 /** Now sanitize the buffer */
138 len = strlen(notetext);
139 for (i=0; i<len; ++i) {
140 if (isspace(notetext[i])) notetext[i] = ' ';
143 /** Make it HTML-happy and print it. */
144 stresc(display_notetext, SIZ, notetext, 0, 0);
145 wprintf("%s\n", display_notetext);
149 wprintf("%s", _("An error has occurred."));