Rakka.editPage = function (baseURI, pageName) { var $body = $("div.body"); $body.text("Loading... please wait."); // XML 版のページを取得する。 $.ajax({ url : baseURI + pageName + ".xml", success: function (pageXml) { var $page = $(pageXml).find("page"); var oldRevision = $page.attr("revision"); var defaultAction = $page.attr("isBinary") == "yes" ? "uploadFile" : $page.attr("type") == "text/x-rakka" ? "editAsWiki" : $page.attr("type") == "text/css" ? "editAsCSS" : "unknown" ; var source = $page.find("source").text(); Rakka.displayPageEditor($body, pageName, oldRevision, defaultAction, source); }, error : function (req) { if (req.status == 404) { Rakka.displayPageEditor($body, pageName, null, "editAsWiki"); } else { $body.text("Error: " + req.status + " " + req.statusText); } } }); }; Rakka.displayPageEditor = function ($place, pageName, oldRevision, defaultAction, source) { $place.empty(); var fldPageName = $.INPUT({type : "text", value: pageName}); var btnEditAsWiki = $.INPUT({type : "radio", name : "action", checked: (defaultAction == "editAsWiki" ? "checked" : "")}); var btnEditAsCSS = $.INPUT({type : "radio", name : "action", checked: (defaultAction == "editAsCSS" ? "checked" : "")}); var btnUploadFile = $.INPUT({type : "radio", name : "action", checked: (defaultAction == "uploadFile" ? "checked" : "")}); var btnDelete = $.INPUT({type : "radio", name : "action", checked: ""}); var pageEditor = $.TABLE({className: "pageEditor"}, $.TBODY({}, $.TR({}, $.TH({}, "Name of the page"), $.TD({}, fldPageName) ), $.TR({}, $.TH({}, "Action"), $.TD({}, $.UL({}, $.LI({}, $.LABEL({}, btnEditAsWiki, "Edit as a Wiki page" ) ), $.LI({}, $.LABEL({}, btnEditAsCSS, "Edit as a style sheet" ) ), $.LI({}, $.LABEL({}, btnUploadFile, "Upload a file" ) ), (oldRevision != "" && oldRevision != 0 ? $.LI({}, $.LABEL({}, btnDelete, "Delete this page" ) ) : []) ) ) ) ) ); $place.append(pageEditor); };