aboutsummaryrefslogtreecommitdiff
path: root/js/io/system/coreioapi.js
diff options
context:
space:
mode:
authorKruti Shah2012-07-17 12:40:00 -0700
committerKruti Shah2012-07-17 12:40:00 -0700
commitbf2d7bdb22c28089dc1067bc9094ebc590daac87 (patch)
tree2156d9920ea1b7db49ed6460545fea7cda121bae /js/io/system/coreioapi.js
parent7e2c2dbd040ed79a3f0678f91bd4b6db9cf69231 (diff)
parentb4b3e45d6684e77d361b4f8ca5be4889428320c5 (diff)
downloadninja-bf2d7bdb22c28089dc1067bc9094ebc590daac87.tar.gz
Merge branch 'refs/heads/TimelineUberJD' into Timeline-local-kruti
Diffstat (limited to 'js/io/system/coreioapi.js')
-rwxr-xr-xjs/io/system/coreioapi.js593
1 files changed, 297 insertions, 296 deletions
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js
index d3977106..6f9766c6 100755
--- a/js/io/system/coreioapi.js
+++ b/js/io/system/coreioapi.js
@@ -1,24 +1,25 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility LLC.
3All Rights Reserved. 3All Rights Reserved.
4BSD License.
5 4
6Redistribution and use in source and binary forms, with or without 5Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met: 6modification, are permitted provided that the following conditions are met:
8 7
9 - Redistributions of source code must retain the above copyright notice, 8* Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer. 9 this list of conditions and the following disclaimer.
11 - Redistributions in binary form must reproduce the above copyright 10
12 notice, this list of conditions and the following disclaimer in the 11* Redistributions in binary form must reproduce the above copyright notice,
13 documentation and/or other materials provided with the distribution. 12 this list of conditions and the following disclaimer in the documentation
14 - Neither the name of Motorola Mobility nor the names of its contributors 13 and/or other materials provided with the distribution.
15 may be used to endorse or promote products derived from this software 14
16 without specific prior written permission. 15* Neither the name of Motorola Mobility LLC nor the names of its
16 contributors may be used to endorse or promote products derived from this
17 software without specific prior written permission.
17 18
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -32,87 +33,87 @@ POSSIBILITY OF SUCH DAMAGE.
32//////////////////////////////////////////////////////////////////////// 33////////////////////////////////////////////////////////////////////////
33NOTES: 34NOTES:
34 35
35 Core API reference in NINJA: this.application.ninja.coreIoApi 36 Core API reference in NINJA: this.application.ninja.coreIoApi
36 37
37//////////////////////////////////////////////////////////////////////// 38////////////////////////////////////////////////////////////////////////
38///////////////////////////////////////////////////////////////////// */ 39///////////////////////////////////////////////////////////////////// */
39var Montage = require("montage/core/core").Montage, 40var Montage = require("montage/core/core").Montage,
40 Component = require("montage/ui/component").Component, 41 Component = require("montage/ui/component").Component,
41 Popup = require("js/components/popup.reel").Popup, 42 Popup = require("js/components/popup.reel").Popup,
42 CloudPopup = require("js/io/ui/cloudpopup.reel").CloudPopup, 43 CloudPopup = require("js/io/ui/cloudpopup.reel").CloudPopup,
43 ChromeApi = require("js/io/system/chromeapi").ChromeApi, 44 ChromeApi = require("js/io/system/chromeapi").ChromeApi,
44 NinjaLibrary = require("js/io/system/ninjalibrary").NinjaLibrary; 45 NinjaLibrary = require("js/io/system/ninjalibrary").NinjaLibrary;
45//////////////////////////////////////////////////////////////////////// 46////////////////////////////////////////////////////////////////////////
46//Exporting as Project I/O 47//Exporting as Project I/O
47exports.CoreIoApi = Montage.create(Component, { 48exports.CoreIoApi = Montage.create(Component, {
48 //////////////////////////////////////////////////////////////////// 49 ////////////////////////////////////////////////////////////////////
49 // 50 //
50 deserializedFromTemplate: { 51 deserializedFromTemplate: {
51 enumerable: false, 52 enumerable: false,
52 value: function () { 53 value: function () {
53 //////////////////////////////////////////////////////////// 54 ////////////////////////////////////////////////////////////
54 //Checking for local storage of URL for IO 55 //Checking for local storage of URL for IO
55 if (this.application.localStorage.getItem("ioRootUrl")) { 56 if (this.application.localStorage.getItem("ioRootUrl")) {
56 //Getting URL from local storage 57 //Getting URL from local storage
57 this.rootUrl = this.application.localStorage.getItem("ioRootUrl"); 58 this.rootUrl = this.application.localStorage.getItem("ioRootUrl");
58 //Checks for IO API to be active 59 //Checks for IO API to be active
59 this.ioServiceDetected = this.cloudAvailable(); 60 this.ioServiceDetected = this.cloudAvailable();
60 } else { 61 } else {
61 //IO API to be inactive 62 //IO API to be inactive
62 this.ioServiceDetected = false; 63 this.ioServiceDetected = false;
63 } 64 }
64 //////////////////////////////////////////////////////////// 65 ////////////////////////////////////////////////////////////
65 //Instance of ninja library 66 //Instance of ninja library
66 this.ninjaLibrary = NinjaLibrary; 67 this.ninjaLibrary = NinjaLibrary;
67 this.ninjaLibrary.coreApi = this; 68 this.ninjaLibrary.coreApi = this;
68 //Getting reference of chrome file system API 69 //Getting reference of chrome file system API
69 this.chromeFileSystem = ChromeApi; 70 this.chromeFileSystem = ChromeApi;
70 //Sending size in MBs for file system storage 71 //Sending size in MBs for file system storage
71 var chromeFs = this.chromeFileSystem.init(20); 72 var chromeFs = this.chromeFileSystem.init(20);
72 //Checking for availability of API 73 //Checking for availability of API
73 if (chromeFs) { 74 if (chromeFs) {
74 this.chromeFileSystem.addEventListener('ready', this, false); 75 this.chromeFileSystem.addEventListener('ready', this, false);
75 } else { 76 } else {
76 //Error, Chrome File System API not detected 77 //Error, Chrome File System API not detected
77 } 78 }
78 //////////////////////////////////////////////////////////// 79 ////////////////////////////////////////////////////////////
79 } 80 }
80 }, 81 },
81 //////////////////////////////////////////////////////////////////// 82 ////////////////////////////////////////////////////////////////////
82 // 83 //
83 handleReady: { 84 handleReady: {
84 enumerable: false, 85 enumerable: false,
85 value: function (e) { 86 value: function (e) {
86 //Removing events 87 //Removing events
87 this.chromeFileSystem.removeEventListener('ready', this, false); 88 this.chromeFileSystem.removeEventListener('ready', this, false);
88 //Listening for library to be copied event (builds list) 89 //Listening for library to be copied event (builds list)
89 this.chromeFileSystem.addEventListener('library', this, false); 90 this.chromeFileSystem.addEventListener('library', this, false);
90 //TODO: Add sync loading screen logic (Add screen here) 91 //TODO: Add sync loading screen logic (Add screen here)
91 } 92 }
92 }, 93 },
93 //////////////////////////////////////////////////////////////////// 94 ////////////////////////////////////////////////////////////////////
94 // 95 //
95 handleLibrary: { 96 handleLibrary: {
96 enumerable: false, 97 enumerable: false,
97 value: function (e) { 98 value: function (e) {
98 //Removing events 99 //Removing events
99 this.chromeFileSystem.removeEventListener('library', this, false); 100 this.chromeFileSystem.removeEventListener('library', this, false);
100 //Listening for synced library event 101 //Listening for synced library event
101 this.ninjaLibrary.addEventListener('sync', this, false); 102 this.ninjaLibrary.addEventListener('sync', this, false);
102 //Sending library to be synced to chrome 103 //Sending library to be synced to chrome
103 this.ninjaLibrary.synchronize(e._event.ninjaChromeLibrary, this.chromeFileSystem); 104 this.ninjaLibrary.synchronize(e._event.ninjaChromeLibrary, this.chromeFileSystem);
104 105
105 } 106 }
106 }, 107 },
107 //////////////////////////////////////////////////////////////////// 108 ////////////////////////////////////////////////////////////////////
108 // 109 //
109 handleSync: { 110 handleSync: {
110 enumerable: false, 111 enumerable: false,
111 value: function (e) { 112 value: function (e) {
112 console.log('Ninja Local Library: Ready'); 113 console.log('Ninja Local Library: Ready');
113 //Removing events 114 //Removing events
114 this.ninjaLibrary.removeEventListener('sync', this, false); 115 this.ninjaLibrary.removeEventListener('sync', this, false);
115 //TODO: Add sync loading screen logic (Remove screen here) 116 //TODO: Add sync loading screen logic (Remove screen here)
116 } 117 }
117 }, 118 },
118 //////////////////////////////////////////////////////////////////// 119 ////////////////////////////////////////////////////////////////////
@@ -124,12 +125,12 @@ exports.CoreIoApi = Montage.create(Component, {
124 //////////////////////////////////////////////////////////////////// 125 ////////////////////////////////////////////////////////////////////
125 // 126 //
126 chromeNinjaLibrary: { 127 chromeNinjaLibrary: {
127 enumerable: false, 128 enumerable: false,
128 get: function() { 129 get: function() {
129 return this._chromeNinjaLibrary; 130 return this._chromeNinjaLibrary;
130 }, 131 },
131 set: function(value) { 132 set: function(value) {
132 this._chromeNinjaLibrary = value; 133 this._chromeNinjaLibrary = value;
133 } 134 }
134 }, 135 },
135 //////////////////////////////////////////////////////////////////// 136 ////////////////////////////////////////////////////////////////////
@@ -141,15 +142,15 @@ exports.CoreIoApi = Montage.create(Component, {
141 //////////////////////////////////////////////////////////////////// 142 ////////////////////////////////////////////////////////////////////
142 // 143 //
143 chromeFileSystem: { 144 chromeFileSystem: {
144 enumerable: false, 145 enumerable: false,
145 get: function() { 146 get: function() {
146 return this._chromeFileSystem; 147 return this._chromeFileSystem;
147 }, 148 },
148 set: function(value) { 149 set: function(value) {
149 this._chromeFileSystem = value; 150 this._chromeFileSystem = value;
150 } 151 }
151 }, 152 },
152 //////////////////////////////////////////////////////////////////// 153 ////////////////////////////////////////////////////////////////////
153 // 154 //
154 _ioServiceDetected: { 155 _ioServiceDetected: {
155 enumerable: false, 156 enumerable: false,
@@ -158,15 +159,15 @@ exports.CoreIoApi = Montage.create(Component, {
158 //////////////////////////////////////////////////////////////////// 159 //////////////////////////////////////////////////////