]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - js/editPage.js
implemented page deleting
[Rakka.git] / js / editPage.js
index a8869fb91b6b01552be1b2341873e92475c24654..959d0889c72d5310df4c3fd3b68404331d099f7c 100644 (file)
@@ -153,7 +153,9 @@ Rakka.displayPageEditor = function (pageName, oldRevision, defaultType, source)
         = $.INPUT({type: "button", value: "Delete this page"});
     
     $(btnDelete).click(function () {
-        throw new Error("FIXME: not implemented yet");
+        if (window.confirm("Do you really want to delete this page?")) {
+            Rakka.deletePage(pageName);
+        }
     });
 
     var updateTRContent = function () {
@@ -440,4 +442,21 @@ Rakka.submitRedirection = function (pageName, oldRevision, givenPageName, destin
             $area.text("Error: " + req.status + " " + req.statusText);
         }
     });
-};
\ No newline at end of file
+};
+
+Rakka.deletePage = function (pageName) {
+    var url = Rakka.baseURI + encodeURI(pageName);
+    $.ajax({
+        type       : "DELETE",
+        url        : url,
+        success    : function () {
+            window.location.replace(url);
+        },
+        error      : function (req) {
+            Rakka.hideWaitingMessage();
+            
+            var $area = Rakka.switchScreen();
+            $area.text("Error: " + req.status + " " + req.statusText);
+        }
+    });
+};