From: PHO Date: Mon, 15 Feb 2010 13:30:29 +0000 (+0900) Subject: localFile.js works again! X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Rakka.git;a=commitdiff_plain;h=c21f22c897782e6d49ce1e8cd06e2cb27d02d2f6 localFile.js works again! --- diff --git a/Rakka.cabal b/Rakka.cabal index 6889592..bf0cc29 100644 --- a/Rakka.cabal +++ b/Rakka.cabal @@ -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 diff --git a/js/editPage.js b/js/editPage.js index 26b68ce..1843be9 100644 --- a/js/editPage.js +++ b/js/editPage.js @@ -237,13 +237,13 @@ = $.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 : "")}); diff --git a/js/localFile.js b/js/localFile.js index 40d4ac8..3709aee 100644 --- a/js/localFile.js +++ b/js/localFile.js @@ -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"); } @@ -14,12 +16,9 @@ "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.");