]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - js/editPage.js
started implementing systemConfig
[Rakka.git] / js / editPage.js
index 705f47adbb1f5351a929defeab96f6be25b74af6..5d782de880484ded293528371a31f042cb25d3a9 100644 (file)
@@ -11,7 +11,7 @@
         var $area = Rakka.switchScreen();
 
         Rakka.displayWaitingMessage("Loading... please wait.");
-    
+
         // XML 版のページを取得する。
         $.ajax({
             url    : Rakka.baseURI + pageName + ".xml",
@@ -42,7 +42,7 @@
                         : $page.find("textData").text()
                         ;
                     var summary     = $page.find("summary").text();
-                
+
                     displayPageEditor(pageName, oldRevision, defaultType, lang, isLocked, otherLangs, source, summary);
                 }
                 else {
@@ -51,7 +51,7 @@
             },
             error  : function (req) {
                 Rakka.hideWaitingMessage();
-                
+
                 if (req.status == 404) {
                     displayPageEditor(pageName, null, "rakka", null, false, {}, null, "");
                 }
@@ -82,7 +82,7 @@
         var makeDirty = function () {
             isDirty = true;
         };
-    
+
         var fldPageName
             = $.INPUT({type : "text", value: pageName});
 
                         $.LABEL({},
                                 chkIsLocked,
                                 "Disallow anonymous users to edit or delete this page")));
-        
+
         var btnTypeRakka
             = $.INPUT({type   : "radio",
                        name   : "type",
                        $.OPTION({value: ""}, "(unspecified)"),
                        (function () {
                            var options = [];
-                           
+
                            $.each(Rakka.getSystemConfig().languages, function (tag, name) {
                                options.push(
                                    $.OPTION({value: tag}, name));
 
                 var lang     = $(selLang).val();
                 var pageName = $(this).val();
-                
+
                 if (pageName == "") {
                     delete otherLangs[lang];
                 }
         $(fldRedirect).change(makeDirty);
 
         var trContent
-            = $.TR({}, 
+            = $.TR({},
                    $.TH({}),
                    $.TD({})
                   );
 
         var btnPreview
             = $.INPUT({type: "button", value: "Preview page"});
-        
+
         $(btnPreview).click(function () {
             if (btnTypeRakka.checked) {
                 previewRakkaPage(
 
         var btnSubmit
             = $.INPUT({type: "button", value: "Submit page"});
-        
+
         $(btnSubmit).click(function () {
             if (btnTypeRakka.checked) {
                 submitTextPage(
 
         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 previewRakkaPage = function (pageName, source) {
         Rakka.displayWaitingMessage("Loading... please wait.");
-        
+
         var url = Rakka.baseURI + "render/" + encodeURI(pageName);
         $.ajax({
             type       : "POST",
 
     var showPreview = function (doc) {
         $previewArea.empty();
-        
+
         $previewHeader.show();
         $previewArea.show();
-        
+
         var root  = doc.documentElement;
         var child = root.firstChild;
         do {
         Rakka.scrollToTopLeft();
     };
 
-    var submitTextPage = function (pageName, oldRevision, givenPageName, isLocked, mimeType, lang, otherLangs, summary, text) {
-        var doc = document.implementation.createDocument(
-            "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null);
-
-        var page = doc.documentElement;
+    var submitTextPage
+      = function (pageName, oldRevision, givenPageName, isLocked, mimeType, lang, otherLangs, summary, text) {
+         var NS   = "http://cielonegro.org/schema/Rakka/Page/1.0";
+         var doc  = document.implementation.createDocument(NS, "page", null);
+         var page = doc.documentElement;
 
         if (oldRevision != null) {
             // ページ書換時
-            var updateInfo = doc.createElement("updateInfo");
+            var updateInfo = doc.createElementNS(NS, "updateInfo");
             updateInfo.setAttribute("oldRevision", oldRevision);
 
             if (pageName != givenPageName) {
-                var move = doc.createElement("move");
+                var move = doc.createElementNS(NS, "move");
                 move.setAttribute("from", pageName);
                 updateInfo.appendChild(move);
             }
         }
 
         if (summary != null && summary != "") {
-            var s = doc.createElement("summary");
+            var s = doc.createElementNS(NS, "summary");
             s.appendChild(
                 doc.createTextNode(summary));
             page.appendChild(s);
         }
 
-        var oLang = doc.createElement("otherLang");
+        var oLang = doc.createElementNS(NS, "otherLang");
         for (var tag in otherLangs) {
-            var link = doc.createElement("link");
+            var link = doc.createElementNS(NS, "link");
             link.setAttribute("lang", tag);
             link.setAttribute("page", otherLangs[tag]);
             oLang.appendChild(link);
         }
         page.appendChild(oLang);
 
-        var textData = doc.createElement("textData");
+        var textData = doc.createElementNS(NS, "textData");
         textData.appendChild(
             doc.createTextNode(text));
 
             },
             error      : function (req) {
                 Rakka.hideWaitingMessage();
-                
+
                 var $area = Rakka.switchScreen();
                 $area.text("Error: " + req.status + " " + req.statusText);
             }
     };
 
     var submitBinaryPage = function (pageName, oldRevision, givenPageName, isLocked, lang, otherLangs, summary, path) {
-        var doc = document.implementation.createDocument(
-            "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null);
-
+        var NS   = "http://cielonegro.org/schema/Rakka/Page/1.0";
+        var doc  = document.implementation.createDocument(NS, "page", null);
         var page = doc.documentElement;
 
         if (oldRevision != null) {
             // ページ書換時
-            var updateInfo = doc.createElement("updateInfo");
+            var updateInfo = doc.createElementNS(NS, "updateInfo");
             updateInfo.setAttribute("oldRevision", oldRevision);
 
             if (pageName != givenPageName) {
-                var move = doc.createElement("move");
+                var move = doc.createElementNS(NS, "move");
                 move.setAttribute("from", pageName);
                 updateInfo.appendChild(move);
             }
         }
 
         if (summary != null) {
-            var s = doc.createElement("summary");
+            var s = doc.createElementNS(NS, "summary");
             s.appendChild(
                 doc.createTextNode(summary));
             page.appendChild(s);
         }
 
-        var oLang = doc.createElement("otherLang");
+        var oLang = doc.createElementNS(NS, "otherLang");
         for (var tag in otherLangs) {
-            var link = doc.createElement("link");
+            var link = doc.createElementNS(NS, "link");
             link.setAttribute("lang", tag);
             link.setAttribute("page", otherLangs[tag]);
             oLang.appendChild(link);
         var bin = Rakka.loadLocalBinaryFile(path);
         var b64 = Rakka.encodeBase64(bin);
 
-        var binaryData = doc.createElement("binaryData");
+        var binaryData = doc.createElementNS(NS, "binaryData");
         binaryData.appendChild(
             doc.createTextNode(b64));
 
             },
             error      : function (req) {
                 Rakka.hideWaitingMessage();
-                
+
                 var $area = Rakka.switchScreen();
                 $area.text("Error: " + req.status + " " + req.statusText);
             }
     };
 
     var submitRedirection = function (pageName, oldRevision, givenPageName, isLocked, destination) {
-        var doc = document.implementation.createDocument(
-            "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null);
-
+        var NS   = "http://cielonegro.org/schema/Rakka/Page/1.0";
+        var doc  = document.implementation.createDocument(NS, "page", null);
         var page = doc.documentElement;
 
         if (oldRevision != null) {
             // ページ書換時
-            var updateInfo = doc.createElement("updateInfo");
+            var updateInfo = doc.createElementNS(NS, "updateInfo");
             updateInfo.setAttribute("oldRevision", oldRevision);
 
             if (pageName != givenPageName) {
-                var move = doc.createElement("move");
+                var move = doc.createElementNS(NS, "move");
                 move.setAttribute("from", pageName);
                 updateInfo.appendChild(move);
             }
             },
             error      : function (req) {
                 Rakka.hideWaitingMessage();
-                
+
                 var $area = Rakka.switchScreen();
                 $area.text("Error: " + req.status + " " + req.statusText);
             }
             },
             error      : function (req) {
                 Rakka.hideWaitingMessage();
-                
+
                 var $area = Rakka.switchScreen();
                 $area.text("Error: " + req.status + " " + req.statusText);
             }