aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/io/system/coreioapi.js3
-rwxr-xr-xjs/io/system/fileio.js17
-rw-r--r--js/mediators/io-mediator.js41
-rwxr-xr-xjs/ninja.reel/ninja.js3
4 files changed, 37 insertions, 27 deletions
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js
index bdba5240..d9505cd6 100755
--- a/js/io/system/coreioapi.js
+++ b/js/io/system/coreioapi.js
@@ -92,6 +92,9 @@ exports.CoreIoApi = Montage.create(Component, {
92 //TODO: Remove test 92 //TODO: Remove test
93 //this.ninjaLibrary.copyLibToCloud('Users/kgq387/Desktop/Ninja Cloud/Disk', 'montage0.6.0'); 93 //this.ninjaLibrary.copyLibToCloud('Users/kgq387/Desktop/Ninja Cloud/Disk', 'montage0.6.0');
94 //this.ninjaLibrary.deleteLibraries(); 94 //this.ninjaLibrary.deleteLibraries();
95 window.hack = function (name, type) {
96 this.application.ninja.ioMediator.fileNew('Users/kgq387/Desktop/Ninja Cloud/Disk/'+name+'.'+type, '/js/io/templates/files/'+type+'.txt', function (status) {console.log(status)});
97 }.bind(this);
95 } 98 }
96 }, 99 },
97 //////////////////////////////////////////////////////////////////// 100 ////////////////////////////////////////////////////////////////////
diff --git a/js/io/system/fileio.js b/js/io/system/fileio.js
index 23186cf2..7bf4d41f 100755
--- a/js/io/system/fileio.js
+++ b/js/io/system/fileio.js
@@ -17,15 +17,13 @@ NOTES:
17//////////////////////////////////////////////////////////////////////// 17////////////////////////////////////////////////////////////////////////
18///////////////////////////////////////////////////////////////////// */ 18///////////////////////////////////////////////////////////////////// */
19// 19//
20var Montage = require("montage/core/core").Montage; 20var Montage = require("montage/core/core").Montage,
21 Component = require("montage/ui/component").Component;
21//////////////////////////////////////////////////////////////////////// 22////////////////////////////////////////////////////////////////////////
22//Exporting as File I/O 23//Exporting as File I/O
23exports.FileIo = Montage.create(require("montage/ui/component").Component, { 24exports.FileIo = Montage.create(Component, {
24 //////////////////////////////////////////////////////////////////// 25 ////////////////////////////////////////////////////////////////////
25 //newFile Object (*required): {uri*, contents, contentType} 26 //newFile Object (*required): {uri*, contents, contentType}
26 //Return codes
27 // 204: File exists | 400: File exists | 404: File does not exists
28 // 201: File succesfully created | 500: Unknown | undefined: Unknown
29 newFile: { 27 newFile: {
30 enumerable: true, 28 enumerable: true,
31 value: function(file) { 29 value: function(file) {
@@ -35,7 +33,7 @@ exports.FileIo = Montage.create(require("montage/ui/component").Component, {
35 return null; 33 return null;
36 } 34 }
37 //Peforming check for file to exist 35 //Peforming check for file to exist
38 var check = this.application.ninja.coreIoApi.fileExists(file.uri), status, create; 36 var check = this.application.ninja.coreIoApi.fileExists({uri: file.uri}), status, create;
39 //Upon successful check, handling results 37 //Upon successful check, handling results
40 if (check.success) { 38 if (check.success) {
41 //Handling status of check 39 //Handling status of check
@@ -47,10 +45,7 @@ exports.FileIo = Montage.create(require("montage/ui/component").Component, {
47 case 404: 45 case 404:
48 //File does not exists, ready to be created 46 //File does not exists, ready to be created
49 create = this.application.ninja.coreIoApi.createFile(file); 47 create = this.application.ninja.coreIoApi.createFile(file);
50 //Storing status to be returned (for UI handling) 48 status = create.status;
51 if (create.success) {
52 status = check.status;
53 }
54 break; 49 break;
55 default: 50 default:
56 //Unknown Error 51 //Unknown Error
@@ -61,6 +56,8 @@ exports.FileIo = Montage.create(require("montage/ui/component").Component, {
61 } 56 }
62 //Returning resulting code 57 //Returning resulting code
63 return status; 58 return status;
59 // 204: File exists | 400: File exists | 404: File does not exists
60 // 201: File succesfully created | 500: Unknown | undefined: Unknown
64 } 61 }
65 }, 62 },
66 //////////////////////////////////////////////////////////////////// 63 ////////////////////////////////////////////////////////////////////
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index 34e1eff2..66fea8b3 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -14,10 +14,17 @@ var Montage = require("montage/core/core").Montage,
14// 14//
15exports.IoMediator = Montage.create(Component, { 15exports.IoMediator = Montage.create(Component, {
16 //////////////////////////////////////////////////////////////////// 16 ////////////////////////////////////////////////////////////////////
17 //
18 hasTemplate: {
19 enumerable: false,
20 value: false
21 },
22 ////////////////////////////////////////////////////////////////////
17 // 23 //
18 deserializedFromTemplate: { 24 deserializedFromTemplate: {
19 enumerable: false, 25 enumerable: false,
20 value: function () { 26 value: function () {
27 //
21 } 28 }
22 }, 29 },
23 //////////////////////////////////////////////////////////////////// 30 ////////////////////////////////////////////////////////////////////
@@ -32,28 +39,30 @@ exports.IoMediator = Montage.create(Component, {
32 enumerable: false, 39 enumerable: false,
33 value: function (file, template, callback) { 40 value: function (file, template, callback) {
34 // 41 //
35 var xhr = new XMLHttpRequest(), returnObj=null; 42 var xhr = new XMLHttpRequest(), result;
36 xhr.open("GET", template, false); 43 xhr.open("GET", template, false);
37 xhr.send(); 44 xhr.send();
38 if (xhr.readyState === 4) { 45 if (xhr.readyState === 4) {
39 // 46 //
40 console.log(this.fio.newFile({uri: file, contents: xhr.response})); 47 switch (this.fio.newFile({uri: file, contents: xhr.response})) {
48 case 201:
49 result = {status: 201, success: true, uri: file};
50 break;
51 case 204:
52 result = {status: 204, success: false, uri: file};
53 break;
54 case 400:
55 result = {status: 400, success: false, uri: file};
56 break;
57 default:
58 result = {status: 500, success: false, uri: file};
59 break;
60 }
41 } else { 61 } else {
42 //Error 62 result = {status: 500, success: false, uri: file};
43 } 63 }
44 64 //
45 65 if (callback) callback(result);
46
47
48
49
50
51 //callback('win');
52
53
54 ///please keep until real data is ready so that I can test the flow
55 callback(returnObj);//returnObj will be like {"uri": "/gfdg/gdf/dfg.js", "success": true,...}
56 ////end - please keep until real data is ready
57 } 66 }
58 }, 67 },
59 //////////////////////////////////////////////////////////////////// 68 ////////////////////////////////////////////////////////////////////
diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js
index 3b9fc1c5..6c82cf30 100755
--- a/js/ninja.reel/ninja.js
+++ b/js/ninja.reel/ninja.js
@@ -14,7 +14,7 @@ exports.Ninja = Montage.create(Component, {
14 _preload: { value: false }, 14 _preload: { value: false },
15 15
16 ninjaVersion: { 16 ninjaVersion: {
17 value: window.ninjaVersion.ninja.version 17 value: null
18 }, 18 },
19 19
20 toolsData: { value: null }, 20 toolsData: { value: null },
@@ -34,6 +34,7 @@ exports.Ninja = Montage.create(Component, {
34 34
35 templateDidLoad: { 35 templateDidLoad: {
36 value: function() { 36 value: function() {
37 this.ninjaVersion = window.ninjaVersion.ninja.version;
37 this.eventManager.addEventListener( "preloadFinish", this, false); 38 this.eventManager.addEventListener( "preloadFinish", this, false);
38 } 39 }
39 }, 40 },