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 defaultType = $page.attr("isBinary") == "yes" ? "binary"
13 : $page.attr("type") == "text/x-rakka" ? "rakka"
14 : $page.attr("type") == "text/css" ? "css"
17 var source = $page.find("textData").text();
18 Rakka.displayPageEditor($body, pageName, oldRevision, defaultType, source);
20 error : function (req) {
21 if (req.status == 404) {
22 Rakka.displayPageEditor($body, pageName, null, "rakka", null);
25 $body.text("Error: " + req.status + " " + req.statusText);
31 Rakka.displayPageEditor = function ($place, pageName, oldRevision, defaultType, source) {
34 $place.append($.H1({}, "Edit page"));
37 = $.INPUT({type : "text", value: pageName});
40 = $.INPUT({type : "radio",
42 checked: (defaultType == "rakka" ? "checked" : "")});
45 = $.INPUT({type : "radio",
47 checked: (defaultType == "css" ? "checked" : "")});
50 = $.INPUT({type : "radio",
52 checked: (defaultType == "binary" ? "checked" : "")});
56 = $.TEXTAREA({}, (defaultType == "rakka" && source != null ? source : ""));
59 = $.TEXTAREA({}, (defaultType == "css" && source != null ? source : ""));
62 = $.INPUT({type: "file"});
71 = $.INPUT({type: "button", value: "Preview page"});
74 = $.INPUT({type: "button", value: "Submit page"});
77 = $.INPUT({type: "button", value: "Delete this page"});
79 var updateTRContent = function () {
80 if (btnTypeRakka.checked) {
81 $(trContent).find("th").text("Wiki source");
82 $(trContent).find("td").empty().append(fldRakkaSource);
85 else if (btnTypeCSS.checked) {
86 $(trContent).find("th").text("CSS source");
87 $(trContent).find("td").empty().append(fldCSSSource);
90 else if (btnTypeBinary.checked) {
91 $(trContent).find("th").text("File");
92 $(trContent).find("td").empty().append(fldUploadFile);
99 $(btnTypeRakka ).change(updateTRContent);
100 $(btnTypeCSS ).change(updateTRContent);
101 $(btnTypeBinary).change(updateTRContent);
105 = $.TABLE({className: "pageEditor"},
108 $.TH({}, "Page name"),
109 $.TD({}, fldPageName)
112 $.TH({}, "Page type"),
139 $.TD({}, btnPreview, btnSubmit, btnDelete)
144 if (oldRevision == null || oldRevision == 0) {
149 $place.append(pageEditor);