-Rakka.$previewHeader = null;
-Rakka.$previewArea = null;
+(function () {
-Rakka.isDirty = null;
+ var $previewHeader = null;
+ var $previewArea = null;
-Rakka.editPage = function (pageName) {
- var $area = Rakka.switchScreen();
+ var isDirty = null;
- Rakka.displayWaitingMessage("Loading... please wait.");
+ Rakka.editPage = function (pageName) {
+ var $area = Rakka.switchScreen();
+
+ Rakka.displayWaitingMessage("Loading... please wait.");
- // XML 版のページを取得する。
- $.ajax({
- url : Rakka.baseURI + pageName + ".xml",
- success: function (pageXml) {
- Rakka.hideWaitingMessage();
+ // XML 版のページを取得する。
+ $.ajax({
+ url : Rakka.baseURI + pageName + ".xml",
+ success: function (pageXml) {
+ Rakka.hideWaitingMessage();
- var $page = $(pageXml).find("page");
- var oldRevision = $page.attr("revision");
- var defaultType
- = $page.attr("isBinary") == "yes" ? "binary"
- : $page.attr("type") == "text/x-rakka" ? "rakka"
- : $page.attr("type") == "text/css" ? "css"
- : $page.attr("redirect") != null ? "redirect"
- : "unknown"
- ;
- var source
- = $page.attr("redirect") != null ? $page.attr("redirect")
- : $page.find("textData").text()
- ;
- var summary = $page.find("summary").text();
+ var $page = $(pageXml).find("page");
+ var oldRevision = $page.attr("revision");
+ var defaultType
+ = $page.attr("isBinary") == "yes" ? "binary"
+ : $page.attr("type") == "text/x-rakka" ? "rakka"
+ : $page.attr("type") == "text/css" ? "css"
+ : $page.attr("redirect") != null ? "redirect"
+ : "unknown"
+ ;
+ var source
+ = $page.attr("redirect") != null ? $page.attr("redirect")
+ : $page.find("textData").text()
+ ;
+ var summary = $page.find("summary").text();
- Rakka.displayPageEditor(pageName, oldRevision, defaultType, source, summary);
- },
- error : function (req) {
- Rakka.hideWaitingMessage();
-
- if (req.status == 404) {
- Rakka.displayPageEditor(pageName, null, "rakka", null, "");
- }
- else {
- $area.text("Error: " + req.status + " " + req.statusText);
+ displayPageEditor(pageName, oldRevision, defaultType, source, summary);
+ },
+ error : function (req) {
+ Rakka.hideWaitingMessage();
+
+ if (req.status == 404) {
+ displayPageEditor(pageName, null, "rakka", null, "");
+ }
+ else {
+ $area.text("Error: " + req.status + " " + req.statusText);
+ }
}
- }
- });
-};
+ });
+ };
-Rakka.newPage = function () {
- Rakka.displayPageEditor("", null, "rakka", null, "");
-};
+ Rakka.newPage = function () {
+ displayPageEditor("", null, "rakka", null, "");
+ };
-Rakka.displayPageEditor = function (pageName, oldRevision, defaultType, source, summary) {
- var $area = Rakka.switchScreen();
- $area.empty();
+ var displayPageEditor = function (pageName, oldRevision, defaultType, source, summary) {
+ var $area = Rakka.switchScreen();
- Rakka.$previewHeader = $( $.H1({}, "Preview") );
- $area.append(Rakka.$previewHeader);
- Rakka.$previewHeader.hide();
+ $previewHeader = $( $.H1({}, "Preview") );
+ $area.append($previewHeader);
+ $previewHeader.hide();
- Rakka.$previewArea = $( $.DIV({className: "preview"}) );
- $area.append(Rakka.$previewArea);
- Rakka.$previewArea.hide();
+ $previewArea = $( $.DIV({className: "preview"}) );
+ $area.append($previewArea);
+ $previewArea.hide();
- $area.append($.H1({}, pageName == "" ? "Create page" : "Edit page"));
+ $area.append($.H1({}, pageName == "" ? "Create page" : "Edit page"));
- var makeDirty = function () {
- Rakka.isDirty = true;
- };
+ var makeDirty = function () {
+ isDirty = true;
+ };
- var fldPageName
- = $.INPUT({type : "text", value: pageName});
+ var fldPageName
+ = $.INPUT({type : "text", value: pageName});
- $(fldPageName).change(makeDirty);
+ $(fldPageName).change(makeDirty);
- var btnTypeRakka
- = $.INPUT({type : "radio",
- name : "type",
- checked: (defaultType == "rakka" ? "checked" : "")});
+ var btnTypeRakka
+ = $.INPUT({type : "radio",
+ name : "type",
+ checked: (defaultType == "rakka" ? "checked" : "")});
- $(btnTypeRakka).change(makeDirty);
+ $(btnTypeRakka).change(makeDirty);
- var btnTypeCSS
- = $.INPUT({type : "radio",
- name : "type",
- checked: (defaultType == "css" ? "checked" : "")});
+ var btnTypeCSS
+ = $.INPUT({type : "radio",
+ name : "type",
+ checked: (defaultType == "css" ? "checked" : "")});
- $(btnTypeCSS).change(makeDirty);
+ $(btnTypeCSS).change(makeDirty);
- var btnTypeBinary
- = $.INPUT({type : "radio",
- name : "type",
- checked: (defaultType == "binary" ? "checked" : "")});
+ var btnTypeBinary
+ = $.INPUT({type : "radio",
+ name : "type",
+ checked: (defaultType == "binary" ? "checked" : "")});
- $(btnTypeBinary).change(makeDirty);
+ $(btnTypeBinary).change(makeDirty);
- var btnTypeRedirect
- = $.INPUT({type : "radio",
- name : "type",
- checked: (defaultType == "redirect" ? "checked" : "")});
+ var btnTypeRedirect
+ = $.INPUT({type : "radio",
+ name : "type",
+ checked: (defaultType == "redirect" ? "checked" : "")});
- $(btnTypeRedirect).change(makeDirty);
+ $(btnTypeRedirect).change(makeDirty);
- var fldSummary
- = $.TEXTAREA({className: "summary"}, summary);
+ var fldSummary
+ = $.TEXTAREA({className: "summary"}, summary);
- $(fldSummary).change(makeDirty);
+ $(fldSummary).change(makeDirty);
- var trSummary
- = $.TR({},
- $.TH({}, "Summary"),
- $.TD({}, fldSummary));
+ var trSummary
+ = $.TR({},
+ $.TH({}, "Summary"),
+ $.TD({}, fldSummary));
- var fldRakkaSource
- = $.TEXTAREA({className: "source"},
- (defaultType == "rakka" && source != null ? source : ""));
+ var fldRakkaSource
+ = $.TEXTAREA({className: "source"},
+ (defaultType == "rakka" && source != null ? source : ""));
- $(fldRakkaSource).change(makeDirty);
+ $(fldRakkaSource).change(makeDirty);
- var fldCSSSource
- = $.TEXTAREA({className: "source"},
- (defaultType == "css" && source != null ? source : ""));
+ var fldCSSSource
+ = $.TEXTAREA({className: "source"},
+ (defaultType == "css" && source != null ? source : ""));
- $(fldCSSSource).change(makeDirty);
+ $(fldCSSSource).change(makeDirty);
- var fldUploadFile
- = $.INPUT({type: "file"});
+ var fldUploadFile
+ = $.INPUT({type: "file"});
- $(fldUploadFile).change(makeDirty);
+ $(fldUploadFile).change(makeDirty);
- var fldRedirect
- = $.INPUT({type: "text", value: (defaultType == "redirect" ? source : "")});
+ var fldRedirect
+ = $.INPUT({type: "text", value: (defaultType == "redirect" ? source : "")});
- $(fldRedirect).change(makeDirty);
+ $(fldRedirect).change(makeDirty);
- var trContent
- = $.TR({},
- $.TH({}),
- $.TD({})
- );
+ var trContent
+ = $.TR({},
+ $.TH({}),
+ $.TD({})
+ );
- var btnPreview
- = $.INPUT({type: "button", value: "Preview page"});
-
- $(btnPreview).click(function () {
- if (btnTypeRakka.checked) {
- Rakka.previewRakkaPage(
- fldPageName.value, fldRakkaSource.value);
- }
- else if (btnTypeBinary.checked) {
- Rakka.previewBinaryPage(
- fldPageName.value, fldUploadFile.value);
- }
- });
+ var btnPreview
+ = $.INPUT({type: "button", value: "Preview page"});
+
+ $(btnPreview).click(function () {
+ if (btnTypeRakka.checked) {
+ previewRakkaPage(
+ fldPageName.value, fldRakkaSource.value);
+ }
+ else if (btnTypeBinary.checked) {
+ previewBinaryPage(
+ fldPageName.value, fldUploadFile.value);
+ }
+ });
+
+ var btnSubmit
+ = $.INPUT({type: "button", value: "Submit page"});
+
+ $(btnSubmit).click(function () {
+ if (btnTypeRakka.checked) {
+ submitTextPage(
+ pageName,
+ oldRevision,
+ fldPageName.value,
+ "text/x-rakka",
+ fldSummary.value,
+ fldRakkaSource.value);
+ }
+ else if (btnTypeCSS.checked) {
+ submitTextPage(
+ pageName,
+ oldRevision,
+ fldPageName.value,
+ "text/css",
+ fldSummary.value,
+ fldCSSSource.value);
+ }
+ else if (btnTypeBinary.checked) {
+ submitBinaryPage(
+ pageName,
+ oldRevision,
+ fldPageName.value,
+ fldSummary.value,
+ fldUploadFile.value);
+ }
+ else if (btnTypeRedirect.checked) {
+ submitRedirection(
+ pageName,
+ oldRevision,
+ fldPageName.value,
+ fldRedirect.value);
+ }
+ });
+
+ var btnDelete
+ = $.INPUT({type: "button", value: "Delete this page"});
+
+ $(btnDelete).click(function () {
+ if (window.confirm("Do you really want to delete this page?")) {
+ deletePage(pageName);
+ }
+ });
- var btnSubmit
- = $.INPUT({type: "button", value: "Submit page"});
-
- $(btnSubmit).click(function () {
- if (btnTypeRakka.checked) {
- Rakka.submitTextPage(
- pageName,
- oldRevision,
- fldPageName.value,
- "text/x-rakka",
- fldSummary.value,
- fldRakkaSource.value);
- }
- else if (btnTypeCSS.checked) {
- Rakka.submitTextPage(
- pageName,
- oldRevision,
- fldPageName.value,
- "text/css",
- fldSummary.value,
- fldCSSSource.value);
- }
- else if (btnTypeBinary.checked) {
- Rakka.submitBinaryPage(
- pageName,
- oldRevision,
- fldPageName.value,
- fldSummary.value,
- fldUploadFile.value);
- }
- else if (btnTypeRedirect.checked) {
- Rakka.submitRedirection(
- pageName,
- oldRevision,
- fldPageName.value,
- fldRedirect.value);
- }
- });
+ var btnCancel
+ = $.INPUT({type: "button", value: "Cancel editing"});
- var btnDelete
- = $.INPUT({type: "button", value: "Delete this page"});
-
- $(btnDelete).click(function () {
- if (window.confirm("Do you really want to delete this page?")) {
- Rakka.deletePage(pageName);
+ $(btnCancel).click(function () {
+ if (isDirty) {
+ if (window.confirm("Do you really want to discard changes?")) {
+ Rakka.restoreScreen();
+ }
+ }
+ else {
+ Rakka.restoreScreen();
+ }
+ });
+
+ var updateTRContent = function () {
+ if (btnTypeRakka.checked) {
+ $(trSummary).show();
+ $(trContent).find("th").text("Wiki source");
+ $(trContent).find("td").empty().append(fldRakkaSource);
+ $(btnPreview).show();
+ }
+ else if (btnTypeCSS.checked) {
+ $(trSummary).show();
+ $(trContent).find("th").text("CSS source");
+ $(trContent).find("td").empty().append(fldCSSSource);
+ $(btnPreview).hide();
+ }
+ else if (btnTypeBinary.checked) {
+ $(trSummary).show();
+ $(trContent).find("th").text("File");
+ $(trContent).find("td").empty().append(fldUploadFile);
+ $(btnPreview).show();
+ }
+ else if (btnTypeRedirect.checked) {
+ $(trSummary).hide();
+ $(trContent).find("th").text("Destination Page");
+ $(trContent).find("td").empty().append(fldRedirect);
+ $(btnPreview).hide();
+ }
+ };
+ $(btnTypeRakka ).change(updateTRContent);
+ $(btnTypeCSS ).change(updateTRContent);
+ $(btnTypeBinary ).change(updateTRContent);
+ $(btnTypeRedirect).change(updateTRContent);
+ updateTRContent();
+
+ var pageEditor
+ = $.TABLE({className: "pageEditor"},
+ $.TBODY({},
+ $.TR({},
+ $.TH({}, "Page name"),
+ $.TD({}, fldPageName)
+ ),
+ $.TR({},
+ $.TH({}, "Page type"),
+ $.TD({},
+ $.UL({},
+ $.LI({},
+ $.LABEL({},
+ btnTypeRakka,
+ "Wiki page"
+ )
+ ),
+ $.LI({},
+ $.LABEL({},
+ btnTypeCSS,
+ "Style sheet"
+ )
+ ),
+ $.LI({},
+ $.LABEL({},
+ btnTypeBinary,
+ "Binary file"
+ )
+ ),
+ $.LI({},
+ $.LABEL({},
+ btnTypeRedirect,
+ "Redirection"
+ )
+ )
+ )
+ )
+ ),
+ trSummary,
+ trContent,
+ $.TR({},
+ $.TH({}),
+ $.TD({}, btnPreview, btnSubmit, btnDelete, btnCancel)
+ )
+ )
+ );
+
+ if (oldRevision == null || oldRevision == 0) {
+ // 削除不可
+ $(btnDelete).hide();
}
- });
- var btnCancel
- = $.INPUT({type: "button", value: "Cancel editing"});
+ $area.append(pageEditor);
- $(btnCancel).click(function () {
- if (Rakka.isDirty) {
- if (window.confirm("Do you really want to discard changes?")) {
- Rakka.restoreScreen();
+ isDirty = false;
+ };
+
+ var previewRakkaPage = function (pageName, source) {
+ Rakka.displayWaitingMessage("Loading... please wait.");
+
+ var url = Rakka.baseURI + "render/" + encodeURI(pageName);
+ $.ajax({
+ type : "POST",
+ url : url,
+ contentType: "text/x-rakka",
+ data : source,
+ processData: false,
+ success : function (resultDoc) {
+ Rakka.hideWaitingMessage();
+ showPreview(resultDoc);
+ },
+ error : function (req) {
+ Rakka.hideWaitingMessage();
+ alert("Error: " + req.status + " " + req.statusText);
}
- }
- else {
- Rakka.restoreScreen();
- }
- });
-
- var updateTRContent = function () {
- if (btnTypeRakka.checked) {
- $(trSummary).show();
- $(trContent).find("th").text("Wiki source");
- $(trContent).find("td").empty().append(fldRakkaSource);
- $(btnPreview).show();
- }
- else if (btnTypeCSS.checked) {
- $(trSummary).show();
- $(trContent).find("th").text("CSS source");
- $(trContent).find("td").empty().append(fldCSSSource);
- $(btnPreview).hide();
- }
- else if (btnTypeBinary.checked) {
- $(trSummary).show();
- $(trContent).find("th").text("File");
- $(trContent).find("td").empty().append(fldUploadFile);
- $(btnPreview).show();
- }
- else if (btnTypeRedirect.checked) {
- $(trSummary).hide();
- $(trContent).find("th").text("Destination Page");
- $(trContent).find("td").empty().append(fldRedirect);
- $(btnPreview).hide();
- }
+ });
};
- $(btnTypeRakka ).change(updateTRContent);
- $(btnTypeCSS ).change(updateTRContent);
- $(btnTypeBinary ).change(updateTRContent);
- $(btnTypeRedirect).change(updateTRContent);
- updateTRContent();
-
- var pageEditor
- = $.TABLE({className: "pageEditor"},
- $.TBODY({},
- $.TR({},
- $.TH({}, "Page name"),
- $.TD({}, fldPageName)
- ),
- $.TR({},
- $.TH({}, "Page type"),
- $.TD({},
- $.UL({},
- $.LI({},
- $.LABEL({},
- btnTypeRakka,
- "Wiki page"
- )
- ),
- $.LI({},
- $.LABEL({},
- btnTypeCSS,
- "Style sheet"
- )
- ),
- $.LI({},
- $.LABEL({},
- btnTypeBinary,
- "Binary file"
- )
- ),
- $.LI({},
- $.LABEL({},
- btnTypeRedirect,
- "Redirection"
- )
- )
- )
- )
- ),
- trSummary,
- trContent,
- $.TR({},
- $.TH({}),
- $.TD({}, btnPreview, btnSubmit, btnDelete, btnCancel)
- )
- )
- );
-
- if (oldRevision == null || oldRevision == 0) {
- // 削除不可
- $(btnDelete).hide();
- }
-
- $area.append(pageEditor);
-
- Rakka.isDirty = false;
-};
-
-Rakka.previewRakkaPage = function (pageName, source) {
- Rakka.displayWaitingMessage("Loading... please wait.");
-
- var url = Rakka.baseURI + "render/" + encodeURI(pageName);
- $.ajax({
- type : "POST",
- url : url,
- contentType: "text/x-rakka",
- data : source,
- processData: false,
- success : function (resultDoc) {
- Rakka.hideWaitingMessage();
- Rakka.showPreview(resultDoc);
- },
- error : function (req) {
- Rakka.hideWaitingMessage();
- alert("Error: " + req.status + " " + req.statusText);
- }
- });
-};
-
-Rakka.previewBinaryPage = function (pageName, path) {
- Rakka.displayWaitingMessage("Loading... please wait.");
-
- /* Firefox でバイナリを送らうとすると 0x00 の位置で切れてしまふ。*/
- var bin = Rakka.loadLocalBinaryFile(path);
- var url = Rakka.baseURI + "render/" + encodeURI(pageName);
- $.ajax({
- type : "POST",
- url : url,
- contentType: "application/x-rakka-base64-stream",
- data : Rakka.encodeBase64(bin),
- processData: false,
- success : function (resultDoc) {
- Rakka.hideWaitingMessage();
- Rakka.showPreview(resultDoc);
- },
- error : function (req) {
- Rakka.hideWaitingMessage();
- alert("Error: " + req.status + " " + req.statusText);
- }
- });
-};
-Rakka.showPreview = function (doc) {
- Rakka.$previewArea.empty();
-
- Rakka.$previewHeader.show();
- Rakka.$previewArea.show();
-
- var root = doc.documentElement;
- var child = root.firstChild;
- do {
- if (child.nodeType == 1) {
- // 要素だったので複製
- Rakka.$previewArea.append(child.cloneNode(true));
- }
- } while (child = child.nextSibling);
+ var previewBinaryPage = function (pageName, path) {
+ Rakka.displayWaitingMessage("Loading... please wait.");
+
+ /* Firefox でバイナリを送らうとすると 0x00 の位置で切れてしまふ。*/
+ var bin = Rakka.loadLocalBinaryFile(path);
+ var url = Rakka.baseURI + "render/" + encodeURI(pageName);
+ $.ajax({
+ type : "POST",
+ url : url,
+ contentType: "application/x-rakka-base64-stream",
+ data : Rakka.encodeBase64(bin),
+ processData: false,
+ success : function (resultDoc) {
+ Rakka.hideWaitingMessage();
+ showPreview(resultDoc);
+ },
+ error : function (req) {
+ Rakka.hideWaitingMessage();
+ alert("Error: " + req.status + " " + req.statusText);
+ }
+ });
+ };
+
+ var showPreview = function (doc) {
+ $previewArea.empty();
+
+ $previewHeader.show();
+ $previewArea.show();
+
+ var root = doc.documentElement;
+ var child = root.firstChild;
+ do {
+ if (child.nodeType == 1) {
+ // 要素だったので複製
+ $previewArea.append(child.cloneNode(true));
+ }
+ } while (child = child.nextSibling);
+
+ Rakka.scrollToTopLeft();
+ };
- Rakka.scrollToTopLeft();
-};
+ var submitTextPage = function (pageName, oldRevision, givenPageName, mimeType, summary, text) {
+ var doc = document.implementation.createDocument(
+ "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null);
-Rakka.submitTextPage = function (pageName, oldRevision, givenPageName, mimeType, summary, text) {
- var doc = document.implementation.createDocument(
- "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null);
+ var page = doc.documentElement;
- var page = doc.documentElement;
+ if (oldRevision != null) {
+ // ページ書換時
+ var updateInfo = doc.createElement("updateInfo");
+ updateInfo.setAttribute("oldRevision", oldRevision);
- if (oldRevision != null) {
- // ページ書換時
- var updateInfo = doc.createElement("updateInfo");
- updateInfo.setAttribute("oldRevision", oldRevision);
+ if (pageName != givenPageName) {
+ var move = doc.createElement("move");
+ move.setAttribute("from", pageName);
+ updateInfo.appendChild(move);
+ }
- if (pageName != givenPageName) {
- var move = doc.createElement("move");
- move.setAttribute("from", pageName);
- updateInfo.appendChild(move);
+ page.appendChild(updateInfo);
}
- page.appendChild(updateInfo);
- }
-
- page.setAttribute("type", mimeType);
-
- if (summary != null) {
- var s = doc.createElement("summary");
- s.appendChild(
- doc.createTextNode(summary));
- page.appendChild(s);
- }
-
- var textData = doc.createElement("textData");
- textData.appendChild(
- doc.createTextNode(text));
-
- page.appendChild(textData);
-
- Rakka.displayWaitingMessage("Submitting... please wait.");
-
- var url = Rakka.baseURI + encodeURI(givenPageName);
- $.ajax({
- type : "PUT",
- url : url,
- contentType: "text/xml",
- data : doc,
- processData: false,
- success : function () {
- window.location.replace(url);
- },
- error : function (req) {
- Rakka.hideWaitingMessage();
-
- var $area = Rakka.switchScreen();
- $area.text("Error: " + req.status + " " + req.statusText);
+ page.setAttribute("type", mimeType);
+
+ if (summary != null) {
+ var s = doc.createElement("summary");
+ s.appendChild(
+ doc.createTextNode(summary));
+ page.appendChild(s);
}
- });
-};
-Rakka.submitBinaryPage = function (pageName, oldRevision, givenPageName, summary, path) {
- var doc = document.implementation.createDocument(
- "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null);
+ var textData = doc.createElement("textData");
+ textData.appendChild(
+ doc.createTextNode(text));
+
+ page.appendChild(textData);
+
+ Rakka.displayWaitingMessage("Submitting... please wait.");
+
+ var url = Rakka.baseURI + encodeURI(givenPageName);
+ $.ajax({
+ type : "PUT",
+ url : url,
+ contentType: "text/xml",
+ data : doc,
+ processData: false,
+ success : function () {
+ window.location.replace(url);
+ },
+ error : function (req) {
+ Rakka.hideWaitingMessage();
+
+ var $area = Rakka.switchScreen();
+ $area.text("Error: " + req.status + " " + req.statusText);
+ }
+ });
+ };
+
+ var submitBinaryPage = function (pageName, oldRevision, givenPageName, summary, path) {
+ var doc = document.implementation.createDocument(
+ "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null);
- var page = doc.documentElement;
+ var page = doc.documentElement;
- if (oldRevision != null) {
- // ページ書換時
- var updateInfo = doc.createElement("updateInfo");
- updateInfo.setAttribute("oldRevision", oldRevision);
+ if (oldRevision != null) {
+ // ページ書換時
+ var updateInfo = doc.createElement("updateInfo");
+ updateInfo.setAttribute("oldRevision", oldRevision);
- if (pageName != givenPageName) {
- var move = doc.createElement("move");
- move.setAttribute("from", pageName);
- updateInfo.appendChild(move);
+ if (pageName != givenPageName) {
+ var move = doc.createElement("move");
+ move.setAttribute("from", pageName);
+ updateInfo.appendChild(move);
+ }
+
+ page.appendChild(updateInfo);
}
- page.appendChild(updateInfo);
- }
-
- page.setAttribute("type", "");
-
- if (summary != null) {
- var s = doc.createElement("summary");
- s.appendChild(
- doc.createTextNode(summary));
- page.appendChild(s);
- }
-
- var bin = Rakka.loadLocalBinaryFile(path);
- var b64 = Rakka.encodeBase64(bin);
-
- var binaryData = doc.createElement("binaryData");
- binaryData.appendChild(
- doc.createTextNode(b64));
-
- page.appendChild(binaryData);
-
- Rakka.displayWaitingMessage("Submitting... please wait.");
-
- var url = Rakka.baseURI + encodeURI(givenPageName);
- $.ajax({
- type : "PUT",
- url : url,
- contentType: "text/xml",
- data : doc,
- processData: false,
- success : function () {
- window.location.replace(url);
- },
- error : function (req) {
- Rakka.hideWaitingMessage();
-
- var $area = Rakka.switchScreen();
- $area.text("Error: " + req.status + " " + req.statusText);
+ page.setAttribute("type", "");
+
+ if (summary != null) {
+ var s = doc.createElement("summary");
+ s.appendChild(
+ doc.createTextNode(summary));
+ page.appendChild(s);
}
- });
-};
-Rakka.submitRedirection = function (pageName, oldRevision, givenPageName, destination) {
- var doc = document.implementation.createDocument(
- "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null);
+ var bin = Rakka.loadLocalBinaryFile(path);
+ var b64 = Rakka.encodeBase64(bin);
+
+ var binaryData = doc.createElement("binaryData");
+ binaryData.appendChild(
+ doc.createTextNode(b64));
+
+ page.appendChild(binaryData);
+
+ Rakka.displayWaitingMessage("Submitting... please wait.");
+
+ var url = Rakka.baseURI + encodeURI(givenPageName);
+ $.ajax({
+ type : "PUT",
+ url : url,
+ contentType: "text/xml",
+ data : doc,
+ processData: false,
+ success : function () {
+ window.location.replace(url);
+ },
+ error : function (req) {
+ Rakka.hideWaitingMessage();
+
+ var $area = Rakka.switchScreen();
+ $area.text("Error: " + req.status + " " + req.statusText);
+ }
+ });
+ };
- var page = doc.documentElement;
+ var submitRedirection = function (pageName, oldRevision, givenPageName, destination) {
+ var doc = document.implementation.createDocument(
+ "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null);
- if (oldRevision != null) {
- // ページ書換時
- var updateInfo = doc.createElement("updateInfo");
- updateInfo.setAttribute("oldRevision", oldRevision);
+ var page = doc.documentElement;
- if (pageName != givenPageName) {
- var move = doc.createElement("move");
- move.setAttribute("from", pageName);
- updateInfo.appendChild(move);
- }
+ if (oldRevision != null) {
+ // ページ書換時
+ var updateInfo = doc.createElement("updateInfo");
+ updateInfo.setAttribute("oldRevision", oldRevision);
- page.appendChild(updateInfo);
- }
-
- page.setAttribute("redirect", destination);
-
- Rakka.displayWaitingMessage("Submitting... please wait.");
-
- var url = Rakka.baseURI + encodeURI(givenPageName);
- $.ajax({
- type : "PUT",
- url : url,
- contentType: "text/xml",
- data : doc,
- processData: false,
- success : function () {
- window.location.replace(url);
- },
- error : function (req) {
- Rakka.hideWaitingMessage();
-
- var $area = Rakka.switchScreen();
- $area.text("Error: " + req.status + " " + req.statusText);
- }
- });
-};
-
-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);
+ if (pageName != givenPageName) {
+ var move = doc.createElement("move");
+ move.setAttribute("from", pageName);
+ updateInfo.appendChild(move);
+ }
+
+ page.appendChild(updateInfo);
}
- });
-};
+
+ page.setAttribute("redirect", destination);
+
+ Rakka.displayWaitingMessage("Submitting... please wait.");
+
+ var url = Rakka.baseURI + encodeURI(givenPageName);
+ $.ajax({
+ type : "PUT",
+ url : url,
+ contentType: "text/xml",
+ data : doc,
+ processData: false,
+ success : function () {
+ window.location.replace(url);
+ },
+ error : function (req) {
+ Rakka.hideWaitingMessage();
+
+ var $area = Rakka.switchScreen();
+ $area.text("Error: " + req.status + " " + req.statusText);
+ }
+ });
+ };
+
+ var 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);
+ }
+ });
+ };
+
+})();
\ No newline at end of file