11 * display sticky notes
13 * msgnum = Message number on the local server of the note to be displayed
15 void display_note(long msgnum, int unread)
19 char display_notetext[SIZ];
24 serv_printf("MSG0 %ld", msgnum);
25 serv_getln(buf, sizeof buf);
27 wprintf("%s<br />\n", &buf[4]);
33 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
36 if ( (in_text) && (strlen(notetext) < SIZ-256) ) {
37 strcat(notetext, buf);
40 if ( (!in_text) && (!strncasecmp(buf, "exti=", 5)) ) {
41 safestrncpy(eid, &buf[5], sizeof eid);
44 if ( (!in_text) && (!strcasecmp(buf, "text")) ) {
49 /* Now sanitize the buffer */
50 len = strlen(notetext);
51 for (i=0; i<len; ++i) {
52 if (isspace(notetext[i])) notetext[i] = ' ';
55 /* Make it HTML-happy and print it. */
56 stresc(display_notetext, SIZ, notetext, 0, 0);
58 /* Lets try it as a draggable */
59 if (!IsEmptyStr(eid)) {
60 wprintf ("<IMG ALIGN=MIDDLE src=\"static/storenotes_48x.gif\" id=\"note_%s\" alt=\"Note\" ", eid);
61 wprintf ("class=\"notes\">\n");
62 wprintf ("<script type=\"text/javascript\">\n");
63 wprintf ("new Draggable (\"note_%s\", {revert:true})\n", eid);
64 wprintf ("</script>\n");
67 wprintf ("<IMG ALIGN=MIDDLE src=\"static/storenotes_48x.gif\" id=\"note_%ld\" ", msgnum);
68 wprintf ("class=\"notes\">\n");
69 wprintf ("<script type=\"text/javascript\">\n");
70 wprintf ("new Draggable (\"note_%ld\", {revert:true})\n", msgnum);
71 wprintf ("</script>\n");
74 if (!IsEmptyStr(eid)) {
75 wprintf("<span id=\"note%s\">%s</span><br />\n", eid, display_notetext);
78 wprintf("<span id=\"note%ld\">%s</span><br />\n", msgnum, display_notetext);
81 /* Offer in-place editing. */
82 if (!IsEmptyStr(eid)) {
83 wprintf("<script type=\"text/javascript\">"
84 "new Ajax.InPlaceEditor('note%s', 'updatenote?nonce=%ld?eid=%s', {rows:5,cols:72});"
95 * This gets called by the Ajax.InPlaceEditor when we save a note.
101 char display_notetext[SIZ];
106 serv_printf("ENT0 1||0|0||||||%s", bstr("eid"));
107 serv_getln(buf, sizeof buf);
109 text_to_server(bstr("value"));
113 begin_ajax_response();
114 msgnum = locate_message_by_uid(bstr("eid"));
116 serv_printf("MSG0 %ld", msgnum);
117 serv_getln(buf, sizeof buf);
119 strcpy(notetext, "");
120 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
122 /* Fill the buffer */
123 if ( (in_text) && (strlen(notetext) < SIZ-256) ) {
124 strcat(notetext, buf);
127 if ( (!in_text) && (!strcasecmp(buf, "text")) ) {
131 /* Now sanitize the buffer */
132 len = strlen(notetext);
133 for (i=0; i<len; ++i) {
134 if (isspace(notetext[i])) notetext[i] = ' ';
137 /* Make it HTML-happy and print it. */
138 stresc(display_notetext, SIZ, notetext, 0, 0);
139 wprintf("%s\n", display_notetext);
143 wprintf("%s", _("An error has occurred."));
157 * Display a <div> containing a rendered sticky note.
159 void display_vnote_div(struct vnote *v, long msgnum) {
161 wprintf("<div id=\"note%ld\" ", msgnum);
162 wprintf("style=\"position: relative; ");
163 wprintf("left: %dpx; ", v->pos_left);
164 wprintf("top: %dpx; ", v->pos_top);
165 wprintf("width: %dpx; ", v->pos_width);
166 wprintf("height: %dpx; ", v->pos_height);
167 wprintf("border: 1px solid black; ");
168 wprintf("background-color: #%02X%02X%02X ", v->color_red, v->color_green, v->color_blue);
180 * display sticky notes
182 * msgnum = Message number on the local server of the note to be displayed
184 void display_note_NEW(long msgnum, int unread) {
186 char mime_partnum[256];
187 char mime_filename[256];
188 char mime_content_type[256];
189 char mime_disposition[256];
191 char relevant_partnum[256];
192 char *relevant_source = NULL;
194 relevant_partnum[0] = '\0';
195 sprintf(buf, "MSG4 %ld", msgnum); /* we need the mime headers */
197 serv_getln(buf, sizeof buf);
198 if (buf[0] != '1') return;
200 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
201 if (!strncasecmp(buf, "part=", 5)) {
202 extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
203 extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
204 extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
205 extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
206 mime_length = extract_int(&buf[5], 5);
208 if (!strcasecmp(mime_content_type, "text/vnote")) {
209 strcpy(relevant_partnum, mime_partnum);
214 if (!IsEmptyStr(relevant_partnum)) {
215 relevant_source = load_mimepart(msgnum, relevant_partnum);
216 if (relevant_source != NULL) {
217 struct vnote *v = vnote_new_from_str(relevant_source);
218 free(relevant_source);
219 display_vnote_div(v, msgnum);
222 /* FIXME remove these debugging messages when finished */
223 wprintf("<script type=\"text/javascript\">");
224 wprintf("document.write('L: ' + $('note%ld').style.left + '<br>');", msgnum);
225 wprintf("document.write('T: ' + $('note%ld').style.top + '<br>');", msgnum);
226 wprintf("document.write('W: ' + $('note%ld').style.width + '<br>');", msgnum);
227 wprintf("document.write('H: ' + $('note%ld').style.height + '<br>');", msgnum);
228 wprintf("</script>");