1 Rakka.editPage = function (baseURI, pageName) {
2 var $body = $("div.body");
4 $body.text("Loading... please wait.");
8 url : baseURI + pageName + ".xml",
9 success: function (pageXml) {
10 var $page = $(pageXml).find("page");
11 var oldRevision = $page.attr("revision");
12 var defaultAction = $page.attr("isBinary") == "yes" ? "uploadFile"
13 : $page.attr("type") == "text/x-rakka" ? "editAsWiki"
14 : $page.attr("type") == "text/css" ? "editAsCSS"
17 var source = $page.find("source").text();
18 Rakka.displayPageEditor($body, pageName, oldRevision, defaultAction, source);
20 error : function (req) {
21 if (req.status == 404) {
22 Rakka.displayPageEditor($body, pageName, null, "editAsWiki");
25 $body.text("Error: " + req.status + " " + req.statusText);
31 Rakka.displayPageEditor = function ($place, pageName, oldRevision, defaultAction, source) {
35 = $.INPUT({type : "text", value: pageName});
38 = $.INPUT({type : "radio",
40 checked: (defaultAction == "editAsWiki" ? "checked" : "")});
43 = $.INPUT({type : "radio",
45 checked: (defaultAction == "editAsCSS" ? "checked" : "")});
48 = $.INPUT({type : "radio",
50 checked: (defaultAction == "uploadFile" ? "checked" : "")});
53 = $.INPUT({type : "radio",
58 = $.TABLE({className: "pageEditor"},
61 $.TH({}, "Name of the page"),
77 "Edit as a style sheet"
86 (oldRevision != "" && oldRevision != 0
100 $place.append(pageEditor);