]> gitweb @ CieloNegro.org - Rakka.git/commitdiff
localFile.js works again!
authorPHO <pho@cielonegro.org>
Mon, 15 Feb 2010 13:30:29 +0000 (22:30 +0900)
committerPHO <pho@cielonegro.org>
Mon, 15 Feb 2010 13:30:29 +0000 (22:30 +0900)
Rakka.cabal
js/editPage.js
js/localFile.js

index 6889592f3c2c48a54fdaed49261b80ddef0c1289..bf0cc2972c27b461000ff18833b74e5e5525939e 100644 (file)
@@ -27,11 +27,6 @@ Data-Files:
     defaultPages/StyleSheet/CieloNegro.xml
     defaultPages/StyleSheet/Default.xml
     schemas/rakka-page-1.0.rng
-
-Source-Repository head
-    Type: git
-    Location: git://git.cielonegro.org/Rakka
-
 Extra-Source-Files:
     Rakka.buildinfo.in
     configure
@@ -52,6 +47,10 @@ Extra-Source-Files:
     tests/RakkaUnitTest.hs
     tests/WikiParserTest.hs
 
+Source-Repository head
+    Type: git
+    Location: git://git.cielonegro.org/Rakka.git
+
 Flag build-test-suite
     Description: Build the test suite.
     Default:     False
index 26b68ce7a7e4542c3411e2cbb5242255b4512580..1843be911ae682ce4b3347c1d10a9509c878c9c4 100644 (file)
             = $.INPUT({type: "button", value: "Select file..."});
 
         $(btnSelectFile).click(function () {
-                                   var path = Rakka.selectFile("Select a binary file to upload", "open");
-                                   if (path != null) {
-                                       uploadFileBin = Rakka.loadLocalBinaryFile(path);
-                                       fldUploadFile.value = Rakka.hexDump(uploadFileBin, 128);
-                                       makeDirty();
-                                   }
-                               });
+            var file = Rakka.selectFile("Select a binary file to upload", "open");
+            if (file != null) {
+                uploadFileBin = Rakka.loadLocalBinaryFile(file);
+                fldUploadFile.value = Rakka.hexDump(uploadFileBin, 128);
+                makeDirty();
+            }
+        });
 
         var fldRedirect
             = $.INPUT({type: "text", value: (defaultType == "redirect" ? source : "")});
index 40d4ac8376c8c43e9d219887703176f21b09473f..3709aeea47cae198764074b51c4d4c87e4014e1a 100644 (file)
@@ -4,7 +4,9 @@
          return $.browser.mozilla;
      };
 
-     var loadBin_mozilla = function (path) {
+     var loadBin_mozilla = function (localFile) {
+         /* localFile: nsILocalFile */
+
          try {
              netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
          }
                    "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);
+             = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(
+                 Components.interfaces.nsIFileInputStream);
          stream.init(localFile, 0x01, 00004, null);
 
          var bstream
@@ -29,7 +28,8 @@
          bstream.QueryInterface(Components.interfaces.nsIInputStream);
 
          var binary
-             = Components.classes["@mozilla.org/binaryinputstream;1"].createInstance(Components.interfaces.nsIBinaryInputStream);
+             = Components.classes["@mozilla.org/binaryinputstream;1"].createInstance(
+                 Components.interfaces.nsIBinaryInputStream);
          binary.setInputStream(stream);
 
          return binary.readBytes(binary.available());
@@ -72,7 +72,7 @@
 
          var ret = picker.show();
          if (ret == nsIFilePicker.returnOK || ret == nsIFilePicker.returnReplace) {
-             return picker.file.path;
+             return picker.file;
          }
          else {
              return null;
@@ -88,9 +88,9 @@
          }
      };
 
-     Rakka.loadLocalBinaryFile = function (path) {
+     Rakka.loadLocalBinaryFile = function (file) {
          if ($.browser.mozilla) {
-             return loadBin_mozilla(path);
+             return loadBin_mozilla(file);
          }
          else {
              throw new Error("It's not possible to load local files using JavaScript with your browser. Consider using Firefox.");