]> gitweb @ CieloNegro.org - Rakka.git/commitdiff
Eliminated <input type
authorpho <pho@cielonegro.org>
Tue, 11 Nov 2008 07:32:27 +0000 (16:32 +0900)
committerpho <pho@cielonegro.org>
Tue, 11 Nov 2008 07:32:27 +0000 (16:32 +0900)
darcs-hash:20081111073227-62b54-db9a5689272dab9211cd58ab6b58fcf9224d50cb.gz

Rakka/Environment.hs
js/editPage.js
js/localFile.js

index 367b67365b896d03a2053bcf4ec20ce6f7ce9ca4..1af20d1cc58b68206d9f9523ad0a9be23369f546 100644 (file)
@@ -19,7 +19,7 @@ import           Rakka.Wiki.Interpreter
 import qualified Rakka.Wiki.Interpreter.Base      as Base
 import qualified Rakka.Wiki.Interpreter.Image     as Image
 import qualified Rakka.Wiki.Interpreter.PageList  as PageList
-import qualified Rakka.Wiki.Interpreter.Trackback as Trackback
+--import qualified Rakka.Wiki.Interpreter.Trackback as Trackback
 import qualified Rakka.Wiki.Interpreter.Outline   as Outline
 import           Subversion.Repository
 import           System.Directory
@@ -92,7 +92,7 @@ mkInterpTable = listToTable $
                 foldl (++) [] [ Base.interpreters
                               , Image.interpreters
                               , PageList.interpreters
-                              , Trackback.interpreters
+                              --, Trackback.interpreters
                               , Outline.interpreters
                               ]
     where
index a9813d2d3fa8bdc21bfaa6359b7a634ac93a0a49..e4483a1e3520104e5372401ae8f6f12a13dfd489 100644 (file)
         $(fldJSSource).change(makeDirty);
 
         var fldUploadFile
-            = $.INPUT({type: "file"});
-
-        $(fldUploadFile).change(makeDirty);
+            = $.INPUT({type: "text", disabled: true});
+        var btnSelectFile
+            = $.INPUT({type: "button", value: "Select File"});
+
+        $(btnSelectFile).click(function () {
+                                   var path = Rakka.selectFile("Select a binary file to upload", "open");
+                                   if (path != null) {
+                                       fldUploadFile.value = path;
+                                       makeDirty();
+                                   }
+                               });
 
         var fldRedirect
             = $.INPUT({type: "text", value: (defaultType == "redirect" ? source : "")});
                 $(trOtherLangs).show();
                 $(trSummary).show();
                 $(trContent).find("th").text("File");
-                $(trContent).find("td").empty().append(fldUploadFile);
+                $(trContent).find("td").empty().append(fldUploadFile).append(btnSelectFile);
                 $(btnPreview).show();
             }
             else if (btnTypeRedirect.checked) {
index 1a6fbfec73a012872318dbefc2ab58daa52a14b9..40d4ac8376c8c43e9d219887703176f21b09473f 100644 (file)
 (function () {
 
-    Rakka.canAccessLocalFile = function () {
-        return $.browser.mozilla;
-    };
-
-    var loadBin_mozilla = function (path) {
-        try {
-            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-        }
-        catch (e) {
-            alert("Permission to read local file was denied. " +
-                  "Open about:config and check that " +
-                  "signed.applets.codebase_principal_support is set to true.");
-        }
-
-        var localFile
-            = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
-        localFile.initWithPath(path);
-
-        var stream
-            = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);
-        stream.init(localFile, 0x01, 00004, null);
-
-        var bstream
-            = Components.classes["@mozilla.org/network/buffered-input-stream;1"].getService();
-        bstream.QueryInterface(Components.interfaces.nsIBufferedInputStream);
-        bstream.init(stream, 1000);
-        bstream.QueryInterface(Components.interfaces.nsIInputStream);
-
-        var binary
-            = Components.classes["@mozilla.org/binaryinputstream;1"].createInstance(Components.interfaces.nsIBinaryInputStream);
-        binary.setInputStream(stream);
-
-        return binary.readBytes(binary.available());
-    };
-
-    Rakka.loadLocalBinaryFile = function (path) {
-        if ($.browser.mozilla) {
-            return loadBin_mozilla(path);
-        }
-    };
-    
+     Rakka.canAccessLocalFile = function () {
+         return $.browser.mozilla;
+     };
+
+     var loadBin_mozilla = function (path) {
+         try {
+             netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+         }
+         catch (e) {
+             alert("Permission to read local file was denied. " +
+                   "Open about:config and check that " +
+                   "signed.applets.codebase_principal_support is set to true.");
+         }
+
+         var localFile
+             = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
+         localFile.initWithPath(path);
+
+         var stream
+             = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);
+         stream.init(localFile, 0x01, 00004, null);
+
+         var bstream
+             = Components.classes["@mozilla.org/network/buffered-input-stream;1"].getService();
+         bstream.QueryInterface(Components.interfaces.nsIBufferedInputStream);
+         bstream.init(stream, 1000);
+         bstream.QueryInterface(Components.interfaces.nsIInputStream);
+
+         var binary
+             = Components.classes["@mozilla.org/binaryinputstream;1"].createInstance(Components.interfaces.nsIBinaryInputStream);
+         binary.setInputStream(stream);
+
+         return binary.readBytes(binary.available());
+     };
+
+     var selectFile_mozilla = function (title, mode) {
+         try {
+             netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+         }
+         catch (e) {
+             alert("Permission to select local file was denied. " +
+                   "Open about:config and check that " +
+                   "signed.applets.codebase_principal_support is set to true.");
+         }
+
+         var nsIFilePicker = Components.interfaces.nsIFilePicker;
+
+         var modeID;
+         if (mode == "open") {
+             modeID = nsIFilePicker.modeOpen;
+         }
+         else if (mode == "save") {
+             modeID = nsIFilePicker.modeSave;
+         }
+         else if (mode == "getFolder") {
+             modeID = nsIFilePicker.modeGetFolder;
+         }
+         else if (mode == "modeOpenMultiple") {
+             modeID = nsIFilePicker.modeOpenMultiple;
+         }
+         else {
+             throw new Error("Unknown file picker mode: " + mode);
+         }
+
+         var picker = Components
+                          .classes["@mozilla.org/filepicker;1"]
+                             .createInstance(nsIFilePicker);
+         picker.init(window, title, modeID);
+         picker.appendFilters(nsIFilePicker.filterAll);
+
+         var ret = picker.show();
+         if (ret == nsIFilePicker.returnOK || ret == nsIFilePicker.returnReplace) {
+             return picker.file.path;
+         }
+         else {
+             return null;
+         }
+     };
+
+     Rakka.selectFile = function (title, mode) {
+         if ($.browser.mozilla) {
+             return selectFile_mozilla(title, mode);
+         }
+         else {
+             throw new Error("It's not possible to select local files using JavaScript with your browser. Consider using Firefox.");
+         }
+     };
+
+     Rakka.loadLocalBinaryFile = function (path) {
+         if ($.browser.mozilla) {
+             return loadBin_mozilla(path);
+         }
+         else {
+             throw new Error("It's not possible to load local files using JavaScript with your browser. Consider using Firefox.");
+         }
+     };
+
 })();
\ No newline at end of file