From d74910a897f2db920f6f67d922532d245074c8f7 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Wed, 1 Feb 2012 11:51:24 -0800 Subject: Fixing coreIO API referencing --- js/components/ui/FilePicker/file-picker-controller.js | 9 ++++----- js/io/system/coreioapi.js | 3 ++- js/io/system/fileio.js | 11 ++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) (limited to 'js') diff --git a/js/components/ui/FilePicker/file-picker-controller.js b/js/components/ui/FilePicker/file-picker-controller.js index f14857ac..e71d1460 100755 --- a/js/components/ui/FilePicker/file-picker-controller.js +++ b/js/components/ui/FilePicker/file-picker-controller.js @@ -8,7 +8,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Montage = require("montage/core/core").Montage, pickerNavigatorReel = require("js/components/ui/FilePicker/pickerNavigator.reel").PickerNavigator, filePickerModelModule = require("js/components/ui/FilePicker/file-picker-model"), - fileSystem = require("js/io/system/filesystem").FileSystem, Popup = require("montage/ui/popup/popup.reel").Popup; //singleton with functions to create a new file picker instance and utilities to format or filter the model data @@ -101,7 +100,7 @@ var FilePickerController = exports.FilePickerController = Montage.create(require var aModel = filePickerModelModule.FilePickerModel.create(); var topLevelDirectories = null; - var driveData = fileSystem.shellApiHandler.getDirectoryContents({uri:"", recursive:false, returnType:"all"}); + var driveData = this.application.ninja.coreIoApi.getDirectoryContents({uri:"", recursive:false, returnType:"all"}); if(driveData.success){ topLevelDirectories = (JSON.parse(driveData.content)).children; }else{ @@ -244,7 +243,7 @@ var FilePickerController = exports.FilePickerController = Montage.create(require || !this._directoryContentCache[folderUri].children){ //get data using IO api try{ - var iodata = fileSystem.shellApiHandler.getDirectoryContents({uri:folderUri, recursive:false, returnType:"all"}); + var iodata = this.application.ninja.coreIoApi.getDirectoryContents({uri:folderUri, recursive:false, returnType:"all"}); //console.log("IO:getDirectoryContents:Response:\n"+"uri="+folderUri+"\n status="+iodata.status+"\n content= "+iodata.content); if(iodata.success && (iodata.status === 200) && (iodata.content !== null)){ folderContent = JSON.parse(iodata.content); @@ -456,7 +455,7 @@ var FilePickerController = exports.FilePickerController = Montage.create(require //check for directory staleness.... if stale query filesystem if((new Date()).getTime() > (this._directoryContentCache[folderUri].queriedTimeStamp + this.cacheStaleTime)){ try{ - var ifModifiedResponse = fileSystem.shellApiHandler.isDirectoryModified({uri:folderUri, recursive:false, returnType:"all"}, this._directoryContentCache[folderUri].queriedTimeStamp); + var ifModifiedResponse = this.application.ninja.coreIoApi.isDirectoryModified({uri:folderUri, recursive:false, returnType:"all"}, this._directoryContentCache[folderUri].queriedTimeStamp); //console.log("ifModifiedResponse"); //console.log(ifModifiedResponse); }catch(e){ @@ -468,7 +467,7 @@ var FilePickerController = exports.FilePickerController = Montage.create(require wasStale = true; //uri has changed. so update cache try{ - var iodata = fileSystem.shellApiHandler.getDirectoryContents({uri:folderUri, recursive:false, returnType:"all"}); + var iodata = this.application.ninja.coreIoApi.getDirectoryContents({uri:folderUri, recursive:false, returnType:"all"}); //console.log("IO:getDirectoryContents:Response:\n"+"uri="+folderUri+"\n status="+iodata.status+"\n content= "+iodata.content); if(iodata.success && (iodata.status === 200) && (iodata.content !== null)){ folderContent = JSON.parse(iodata.content); diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index 74b066ac..7e883b81 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js @@ -207,6 +207,7 @@ exports.CoreIoApi = Montage.create(Component, { directoryServiceURL: { enumerable: false, get: function() { + console.log(this); return String(this.rootUrl+this._directoryServiceURL); }, set: function(value) { @@ -1015,7 +1016,7 @@ exports.CoreIoApi = Montage.create(Component, { // if (xhr.readyState === 4) { retValue.status = xhr.status; - eval('retValue.response = '+xhr.response); + retValue.response = JSON.parse(xhr.response); retValue.success = true; } } diff --git a/js/io/system/fileio.js b/js/io/system/fileio.js index 38ab05e8..ac5812e9 100755 --- a/js/io/system/fileio.js +++ b/js/io/system/fileio.js @@ -11,11 +11,12 @@ NOTES: empty file will be created. 'contents' should be a string to be saved as the file. 'contentType' is the mime type of the file. + coreIoApi: this.application.ninja.coreIoApi + //////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// */ // -var Montage = require("montage/core/core").Montage, - CoreIoApi = require("js/io/system/coreioapi").CoreIoApi; +var Montage = require("montage/core/core").Montage; //////////////////////////////////////////////////////////////////////// //Exporting as File I/O exports.FileIo = Montage.create(Object.prototype, { @@ -28,12 +29,12 @@ exports.FileIo = Montage.create(Object.prototype, { enumerable: true, value: function(file) { //Checking for API to be available - if (!CoreIoApi.cloudAvailable()) { + if (!this.application.ninja.coreIoApi.cloudAvailable()) { //API not available, no IO action taken return null; } //Peforming check for file to exist - var check = CoreIoApi.fileExists(file.uri), status, create; + var check = this.application.ninja.coreIoApi.fileExists(file.uri), status, create; //Upon successful check, handling results if (check.success) { //Handling status of check @@ -44,7 +45,7 @@ exports.FileIo = Montage.create(Object.prototype, { break; case 404: //File does not exists, ready to be created - create = CoreIoApi.createFile(file); + create = this.application.ninja.coreIoApi.createFile(file); //Storing status to be returned (for UI handling) if (create.success) { status = check.status; -- cgit v1.2.3