From 36d50b6599ab98559c76e1fe57b1bb131c4433da Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 19 Apr 2012 15:53:18 -0700 Subject: Clean up --- js/io/system/fileio.js | 4 ++-- js/io/system/ninjalibrary.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'js/io') diff --git a/js/io/system/fileio.js b/js/io/system/fileio.js index f78ad173..1680ca7f 100755 --- a/js/io/system/fileio.js +++ b/js/io/system/fileio.js @@ -146,7 +146,7 @@ exports.FileIo = Montage.create(Component, { } }, //////////////////////////////////////////////////////////////////// - // + //TODO: Add functionality deleteFile: { enumerable: true, value: function() { @@ -159,7 +159,7 @@ exports.FileIo = Montage.create(Component, { } }, //////////////////////////////////////////////////////////////////// - // + //TODO: Add functionality copyFile: { enumerable: true, value: function() { diff --git a/js/io/system/ninjalibrary.js b/js/io/system/ninjalibrary.js index 201598fc..78bdbe53 100644 --- a/js/io/system/ninjalibrary.js +++ b/js/io/system/ninjalibrary.js @@ -213,7 +213,7 @@ exports.NinjaLibrary = Montage.create(Object.prototype, { xhr.responseType = "arraybuffer"; xhr.send(); //Checking for status - if (xhr.readyState === 4) { //TODO: add check for mime type + if (xhr.readyState === 4) { //Creating new file from loaded content this.chromeApi.fileNew('/'+tocopylibs[i].name+'/'+tocopylibs[i].file, xhr.response, function (status) {if(status) this.libraryCopied()}.bind(this)); } else { -- cgit v1.2.3 From 6356edefaea3fe78969c53fec2d371cb8f42d820 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 3 May 2012 15:28:38 -0700 Subject: Full CSS support on open Add full CSS for files on open (including loading cross-domain). This is only for files that are opened. --- js/io/system/coreioapi.js | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'js/io') diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index a06f45c6..1e6518fe 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js @@ -192,6 +192,23 @@ exports.CoreIoApi = Montage.create(Component, { set: function(value) { this._fileServiceURL = value; } + }, + //////////////////////////////////////////////////////////////////// + //File service API URL + _webServiceURL: { + enumerable: false, + value: '/web' + }, + //////////////////////////////////////////////////////////////////// + // + webServiceURL: { + enumerable: false, + get: function() { + return String(this.rootUrl+this._webServiceURL); + }, + set: function(value) { + this._webServiceURL = value; + } }, //////////////////////////////////////////////////////////////////// //Directory service API URL @@ -647,6 +664,53 @@ exports.CoreIoApi = Montage.create(Component, { } }, //////////////////////////////////////////////////////////////////// + // Reads an external file (cross-domain) + // Parameters: + // the file parameter must contain the following properties + // url: string value containing the full file path/URL i.e. "http://google.com/motorola.html" + // binary parameter is optional if the content is to be binary + // Return values: + // returns an object with two properties + // success: boolean indicating if the call succeeded or failed + // content: string containing the file contents + // status: int indicating the request HTTP status code + // 200 - the file was read and its contents were returned + // 404 - the file does not exist + // 500 - unknown server error occurred + readExternalFile: { + enumerable: false, + value: function(file) { + // + var retValue = {success:null, content:null, status:null}; + // + if(file && file.url && file.url.length) { + try { + var serviceURL = this._prepareServiceURL(this.webServiceURL, ''), + xhr = new XMLHttpRequest(); + // + xhr.open("GET", serviceURL+"?url="+file.url, false); + if (file.binary) xhr.setRequestHeader("return-type", "binary"); + xhr.setRequestHeader("Content-Type", "text/plain"); + xhr.send(); + // + if (xhr.readyState === 4) { + retValue.status = xhr.status; + if(xhr.status == 200) { + retValue.content = xhr.response; + } + retValue.success = true; + } + } + catch(error) { + xhr = null; + retValue.success = false; + } + } + // + return retValue; + } + }, + //////////////////////////////////////////////////////////////////// // Create a new directory/folder // Parameters: // the dir parameter must contain the following properties -- cgit v1.2.3