Completed 'Add New Note'. The new sticky notes view
authorArt Cancro <ajc@citadel.org>
Tue, 6 May 2008 21:04:59 +0000 (21:04 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 6 May 2008 21:04:59 +0000 (21:04 +0000)
is now fully operational, although there are still a few
tweaks I still want to make (such as the ability to change a
note's color -- it will display any color it's told to but
there's not yet a button to change it.

webcit/notes.c
webcit/roomops.c
webcit/webcit.c
webcit/webcit.h

index b4a08b469d14cda35049f6dfc3e570224cb09205..e77982d2e96e1e39ee8416143d2d6e5f6decbef9 100644 (file)
@@ -162,6 +162,26 @@ struct vnote *vnote_new_from_msg(long msgnum) {
 }
 
 
+/*
+ * Serialize a vnote and write it to the server
+ */
+void write_vnote_to_server(struct vnote *v) 
+{
+       char buf[1024];
+
+       serv_puts("ENT0 1|||4");
+       serv_getln(buf, sizeof buf);
+       if (buf[0] == '4') {
+               serv_puts("Content-type: text/vnote");
+               serv_puts("");
+               serv_puts(vnote_serialize(v));
+               serv_puts("000");
+       }
+}
+
+
+
+
 /*
  * Background ajax call to receive updates from the browser when a note is moved, resized, or updated.
  */
@@ -229,14 +249,7 @@ void ajax_update_note(void) {
        }
 
        /* Serialize it and save it to the message base.  Server will delete the old one. */
-       serv_puts("ENT0 1|||4");
-       serv_getln(buf, sizeof buf);
-       if (buf[0] == '4') {
-               serv_puts("Content-type: text/vnote");
-               serv_puts("");
-               serv_puts(vnote_serialize(v));
-               serv_puts("000");
-       }
+       write_vnote_to_server(v);
 
        begin_ajax_response();
        if (v->body) {
@@ -275,3 +288,22 @@ void display_note(long msgnum, int unread) {
        }
 }
 
+
+
+/*
+ * Create a new note
+ */
+void add_new_note(void) {
+       struct vnote *v;
+
+       v = vnote_new();
+       if (v) {
+               v->uid = malloc(128);
+               generate_uuid(v->uid);
+               v->body = strdup(_("Click on any note to edit it."));
+               write_vnote_to_server(v);
+               vnote_free(v);
+       }
+       
+       readloop("readfwd");
+}
index e9a25ddc915b0c66c7038d1bc53b6d7ba8a9bcdb..d8a3d7c5f0eaaacc1a78e7497618478989f8fe7d 100644 (file)
@@ -667,7 +667,7 @@ void embed_room_banner(char *got, int navbar_style) {
                                case VIEW_NOTES:
                                        wprintf(
                                                "<li class=\"enternewnote\">"
-                                               "<a href=\"javascript:add_new_note();\">"
+                                               "<a href=\"add_new_note\">"
                                                "<img  src=\"static/enternewnote_24x.gif\" "
                                                "alt=\"\"><span class=\"navbar_link\">"
                                                "%s"
index 7aefacf22476b7c7c74e07d90f4d9a58286c6d12..d16258f748fe7690d2c8d265bca25e274ae3ac60 100644 (file)
@@ -2063,6 +2063,8 @@ void session_loop(struct httprequest *req)
                dump_vars();
                wprintf("</PRE><hr />\n");
                wDumpContent(1);
+       } else if (!strcasecmp(action, "add_new_note")) {
+               add_new_note();
        } else if (!strcasecmp(action, "ajax_update_note")) {
                ajax_update_note();
        } else if (!strcasecmp(action, "display_room_directory")) {
index bec5aa6c1dd23c40b4a59bdababcac4133382532..74e161428cf9975a6e93da9e40f50b4757bae0a0 100644 (file)
@@ -694,6 +694,7 @@ void cal_process_attachment(char *part_source, long msgnum, char *cal_partnum);
 void display_calendar(long msgnum, int unread);
 void display_task(long msgnum, int unread);
 void display_note(long msgnum, int unread);
+void add_new_note(void);
 void updatenote(void);
 void ajax_update_note(void);
 void do_calendar_view(void);