Commits

Miki Tebeka committed b6f2b67

Delete UI (untested)

  • Participants
  • Parent commits f0e9b7f

Comments (0)

Files changed (2)

src/duderemember.clj

     [:a {:href (login-url "/")} "Login"]
     [:a {:href (logout-url "/")} "Logout"]))
 
+(def *jquery-url* 
+  "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js")
+
 (defn page [& content]
   (html
     [:head
      (include-css "/static/dude.css")
+     (include-js *jquery-url*)
+     (include-js "/static/dude.js")
      [:title *title*]]
     [:body 
      [:div {:class "header"} (header-link)]
     "No messages for you!"
     (for [message messages]
       [:div {:class "message" :id (key->string (:key message))}
-       "Time: " (format-time (:time message)) [:br]
+       "Time: " (format-time (:time message)) 
+       ; FIXME: I'll leave it to Sean to make it nice ;)
+       [:button {:class "delete"} "[X]"] [:br]
        (if (nil? (:url message))
          ["Text:" [:br] (:text message)]
          [:a {:href (:url message)} "Play"])])))

war/static/dude.js

+function delete_message (id) {
+    $.ajax({
+        success: function(data, status, request) {
+            $("#" + id).remove();
+        },
+        data: {id: id},
+        /* FIXME: error: function(request, status, error) { ... } */
+        type: "DELETE",
+        url: "/message/" + id
+    });
+}
+
+function on_ready() {
+    $("button.delete").click(function () { 
+            delete_message($(this).parent().attr("id"));
+    });
+}
+
+$(document).ready(on_ready);