aboutsummaryrefslogtreecommitdiff
path: root/js/io/system/coreioapi.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/io/system/coreioapi.js')
-rwxr-xr-xjs/io/system/coreioapi.js167
1 files changed, 61 insertions, 106 deletions
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js
index 115fbf64..73d9fa76 100755
--- a/js/io/system/coreioapi.js
+++ b/js/io/system/coreioapi.js
@@ -15,89 +15,26 @@ NOTES:
15var Montage = require("montage/core/core").Montage, 15var Montage = require("montage/core/core").Montage,
16 Component = require("montage/ui/component").Component, 16 Component = require("montage/ui/component").Component,
17 Popup = require("js/components/popup.reel").Popup, 17 Popup = require("js/components/popup.reel").Popup,
18 CloudPopup = require("js/io/ui/cloudpopup.reel").CloudPopup; 18 CloudPopup = require("js/io/ui/cloudpopup.reel").CloudPopup,
19 ChromeApi = require("js/io/system/chromeapi").ChromeApi;
19//////////////////////////////////////////////////////////////////////// 20////////////////////////////////////////////////////////////////////////
20//Exporting as Project I/O 21//Exporting as Project I/O
21exports.CoreIoApi = Montage.create(Component, { 22exports.CoreIoApi = Montage.create(Component, {
22 //////////////////////////////////////////////////////////////////// 23 ////////////////////////////////////////////////////////////////////
23 // 24 //
24 deserializedFromTemplate: { 25 deserializedFromTemplate: {
25 enumerable: false, 26 enumerable: false,
26 value: function () { 27 value: function () {
27
28
29
30 ////////////////////////////////////////////////////////////
31 ////////////////////////////////////////////////////////////
32 //TODO: Remove, this is only for testing
33
34
35 window.webkitRequestFileSystem(window.PERSISTENT, 10*1024*1024 /*10MB*/, function (fs) {
36
37
38 console.log(fs);
39
40 var start = new Date().getTime();
41
42 for (var i=0; i<250; i++) {
43
44 fs.root.getFile('test'+i+'.txt', {create: true}, function(fileEntry) {
45
46 fileEntry.createWriter(function(fileWriter) {
47
48 var bb = new window.WebKitBlobBuilder;
49 bb.append('In condimentum facilisis porta. Sed nec diam eu diam mattis viverra. Nulla fringilla, orci ac euismod semper, magna diam porttitor mauris, quis sollicitudin sapien justo in libero. Vestibulum mollis mauris enim. Morbi euismod magna ac lorem rutrum elementum. Donec viverra auctor lobortis. Pellentesque eu est a nulla placerat dignissim. Morbi a enim in magna semper bibendum. Etiam scelerisque, nunc ac egestas consequat, odio nibh euismod nulla, eget auctor orci nibh vel nisi. Aliquam erat volutpat. Mauris vel neque sit amet nunc gravida congue sed sit amet purus. Quisque lacus quam, egestas ac tincidunt a, lacinia vel velit. Aenean facilisis nulla vitae urna tincidunt congue sed ut dui. Morbi malesuada nulla nec purus convallis consequat. Vivamus id mollis quam. Morbi ac commodo nulla. In condimentum orci id nisl volutpat bibendum. Quisque commodo hendrerit lorem quis egestas. Maecenas quis tortor arcu. Vivamus rutrum nunc non neque consectetur quis placerat neque lobortis. Nam vestibulum, arcu sodales feugiat consectetur, nisl orci bibendum elit, eu euismod magna sapien ut nibh. Donec semper quam scelerisque tortor dictum gravida. In hac habitasse platea dictumst. Nam pulvinar, odio sed rhoncus suscipit, sem diam ultrices mauris, eu consequat purus metus eu velit. Proin metus odio, aliquam eget molestie nec, gravida ut sapien. Phasellus quis est sed turpis sollicitudin venenatis sed eu odio. Praesent eget neque eu eros interdum malesuada non vel leo. Sed fringilla porta ligula egestas tincidunt. Nullam risus magna, ornare vitae varius eget, scelerisque a libero. Morbi eu porttitor ipsum. Nullam lorem nisi, posuere quis volutpat eget, luctus nec massa. Pellentesque aliquam lacinia tellus sit amet bibendum. Ut posuere justo in enim pretium scelerisque. Etiam ornare vehicula euismod. Vestibulum at risus augue. Sed non semper dolor. Sed fringilla consequat velit a porta. Pellentesque sed lectus pharetra ipsum ultricies commodo non sit amet velit. Suspendisse volutpat lobortis ipsum, in scelerisque nisi iaculis a. Duis pulvinar lacinia commodo. Integer in lorem id nibh luctus aliquam. Sed elementum, est ac sagittis porttitor, neque metus ultricies ante, in accumsan massa nisl non metus. Vivamus sagittis quam a lacus dictum tempor. Nullam in semper ipsum. Cras a est id massa malesuada tincidunt. Etiam a urna tellus. Ut rutrum vehicula dui, eu cursus magna tincidunt pretium. Donec malesuada accumsan quam, et commodo orci viverra et. Integer tincidunt sagittis lectus. Mauris ac ligula quis orci auctor tincidunt. Suspendisse odio justo, varius id posuere sit amet, iaculis sit amet orci. Suspendisse potenti. Suspendisse potenti. Aliquam erat volutpat. Sed posuere dignissim odio, nec cursus odio mollis et. Praesent cursus, orci ut dictum adipiscing, tellus ante porttitor leo, vel gravida lacus lorem vitae est. Duis ultricies feugiat ante nec aliquam. Maecenas varius, nulla vel fermentum semper, metus nibh bibendum nunc, vitae suscipit mauris velit ac nunc. Mauris nunc eros, egestas at vehicula tincidunt, commodo ac mauris. Nulla facilisi. Nunc eros sem, lobortis non pulvinar id, blandit in eros. In bibendum suscipit');
50 fileWriter.write(bb.getBlob('text/plain'));
51
52 });
53
54 });
55
56 }
57
58 var end = new Date().getTime();
59 var time = end - start;
60 console.log('Create execution time: ' + time);
61
62 start = new Date().getTime();
63
64 for (var j=0; j<250; j++) {
65
66 fs.root.getFile('test'+j+'.txt', {create: true}, function(fileEntry) {
67
68 fileEntry.file(function(file) {
69
70 var reader = new FileReader();
71 reader.onloadend = function(e) {
72 console.log(this.result);
73 };
74
75 reader.readAsText(file);
76
77 });
78
79 });
80
81 }
82
83
84 end = new Date().getTime();
85 time = end - start;
86 console.log('Read execution time: ' + time);
87
88
89
90
91
92
93 }.bind(this));
94
95
96 //////////////////////////////////////////////////////////// 28 ////////////////////////////////////////////////////////////
29 //Getting reference of chrome file system API
30 this.chromeFileSystem = ChromeApi;
31 //Sending size in MBs for file system storage
32 if (this.chromeFileSystem.init(20)) {
33 //Available
34 } else {
35 //Not available
36 }
97 //////////////////////////////////////////////////////////// 37 ////////////////////////////////////////////////////////////
98
99
100
101 //Checking for local storage of URL for IO 38 //Checking for local storage of URL for IO
102 if (window.localStorage['ioRootUrl']) { 39 if (window.localStorage['ioRootUrl']) {
103 //Getting URL from local storage 40 //Getting URL from local storage
@@ -108,46 +45,25 @@ exports.CoreIoApi = Montage.create(Component, {
108 //IO API to be inactive 45 //IO API to be inactive
109 this.ioServiceDetected = false; 46 this.ioServiceDetected = false;
110 } 47 }
48 ////////////////////////////////////////////////////////////
111 } 49 }
112 }, 50 },
113 ////////////////////////////////////////////////////////////////////
114 //Method to check status of I/O API, will return false if not active
115 cloudAvailable: {
116 enumerable: false,
117 value: function () {
118 var cloud = this.getCloudStatus();
119 //
120 if (this.rootUrl && cloud.status === 200) {
121 //Active
122 this.cloudData.name = cloud.response['name'];
123 this.cloudData.root = cloud.response['server-root'];
124 return true;
125 } else {
126 //Inactive
127 if (!this._cloudDialogOpen && this.application.ninja) {
128 this.showCloudDialog();
129 }
130 return false;
131 }
132 }
133 },
134 ////////////////////////////////////////////////////////////////////
135 //
136 _cloudDialogOpen: {
137 enumerable: false,
138 value: false
139 },
140 //////////////////////////////////////////////////////////////////// 51 ////////////////////////////////////////////////////////////////////
141 // 52 //
142 cloudData: { 53 _chromeFileSystem: {
143 enumerable: false, 54 enumerable: false,
144 value: {name: null, root: ''} 55 value: null
145 }, 56 },
146 //////////////////////////////////////////////////////////////////// 57 ////////////////////////////////////////////////////////////////////
147 // 58 //
148 _cloudDialogComponents: { 59 chromeFileSystem: {
149 enumerable: false, 60 enumerable: false,
150 value: {blackout: null, popup: null, dialog: null} 61 get: function() {
62 return this._chromeFileSystem;
63 },
64 set: function(value) {
65 this._chromeFileSystem = value;
66 }
151 }, 67 },
152 //////////////////////////////////////////////////////////////////// 68 ////////////////////////////////////////////////////////////////////
153 // 69 //
@@ -255,6 +171,45 @@ exports.CoreIoApi = Montage.create(Component, {
255 } 171 }
256 }, 172 },
257 //////////////////////////////////////////////////////////////////// 173 ////////////////////////////////////////////////////////////////////
174 //Method to check status of I/O API, will return false if not active
175 cloudAvailable: {
176 enumerable: false,
177 value: function () {
178 var cloud = this.getCloudStatus();
179 //
180 if (this.rootUrl && cloud.status === 200) {
181 //Active
182 this.cloudData.name = cloud.response['name'];
183 this.cloudData.root = cloud.response['server-root'];
184 return true;
185 } else {
186 //Inactive
187 if (!this._cloudDialogOpen && this.application.ninja) {
188 this.showCloudDialog();
189 }
190 return false;
191 }
192 }
193 },
194 ////////////////////////////////////////////////////////////////////
195 //
196 _cloudDialogOpen: {
197 enumerable: false,
198 value: false
199 },
200 ////////////////////////////////////////////////////////////////////
201 //
202 cloudData: {
203 enumerable: false,
204 value: {name: null, root: ''}
205 },
206 ////////////////////////////////////////////////////////////////////
207 //
208 _cloudDialogComponents: {
209 enumerable: false,
210 value: {blackout: null, popup: null, dialog: null}
211 },
212 ////////////////////////////////////////////////////////////////////
258 // 213 //
259 showCloudDialog: { 214 showCloudDialog: {
260 enumerable: false, 215 enumerable: false,