aboutsummaryrefslogtreecommitdiff
path: root/js/mediators
diff options
context:
space:
mode:
Diffstat (limited to 'js/mediators')
-rw-r--r--js/mediators/io-mediator.js40
1 files changed, 25 insertions, 15 deletions
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index b6d0e598..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,27 +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(); 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 /*
53var returnObj = null; //like {"uri": "/gfdg/gdf/dfg.js", "success": true,...}
54 callback(returnObj);
55*/
56 } 66 }
57 }, 67 },
58 //////////////////////////////////////////////////////////////////// 68 ////////////////////////////////////////////////////////////////////