aboutsummaryrefslogtreecommitdiff
path: root/js/io/ui/cloudpopup.reel/cloudpopup.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/io/ui/cloudpopup.reel/cloudpopup.js')
-rwxr-xr-xjs/io/ui/cloudpopup.reel/cloudpopup.js193
1 files changed, 97 insertions, 96 deletions
diff --git a/js/io/ui/cloudpopup.reel/cloudpopup.js b/js/io/ui/cloudpopup.reel/cloudpopup.js
index c64d8974..200eb703 100755
--- a/js/io/ui/cloudpopup.reel/cloudpopup.js
+++ b/js/io/ui/cloudpopup.reel/cloudpopup.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
@@ -30,136 +31,136 @@ POSSIBILITY OF SUCH DAMAGE.
30 31
31//////////////////////////////////////////////////////////////////////// 32////////////////////////////////////////////////////////////////////////
32// 33//
33var Montage = require("montage/core/core").Montage, 34var Montage = require("montage/core/core").Montage,
34 Component = require("montage/ui/component").Component; 35 Component = require("montage/ui/component").Component;
35//////////////////////////////////////////////////////////////////////// 36////////////////////////////////////////////////////////////////////////
36// 37//
37exports.CloudPopup = Montage.create(Component, { 38exports.CloudPopup = Montage.create(Component, {
38 //////////////////////////////////////////////////////////////////// 39 ////////////////////////////////////////////////////////////////////
39 // 40 //
40 hasTemplate: { 41 hasTemplate: {
41 value: true 42 value: true
42 }, 43 },
43 //////////////////////////////////////////////////////////////////// 44 ////////////////////////////////////////////////////////////////////
44 // 45 //
45 _os: { 46 _os: {
46 value: null 47 value: null
47 }, 48 },
48 //////////////////////////////////////////////////////////////////// 49 ////////////////////////////////////////////////////////////////////
49 // 50 //
50 components: { 51 components: {
51 enumerable: false, 52 enumerable: false,
52 value: {test_btn: null, ok_btn: null, cancel_btn: null, download_btn: null, status: null, url: null} 53 value: {test_btn: null, ok_btn: null, cancel_btn: null, download_btn: null, status: null, url: null}
53 }, 54 },
54 //////////////////////////////////////////////////////////////////// 55 ////////////////////////////////////////////////////////////////////
55 // 56 //
56 prepareForDraw: { 57 prepareForDraw: {
57 enumerable: false, 58 enumerable: false,
58 value: function () { 59 value: function () {
59 // 60 //
60 this.components.test_btn = this.element.getElementsByClassName('btn_test nj-skinned')[0]; 61 this.components.test_btn = this.element.getElementsByClassName('btn_test nj-skinned')[0];
61 this.components.ok_btn = this.element.getElementsByClassName('btn_ok nj-skinned')[0]; 62 this.components.ok_btn = this.element.getElementsByClassName('btn_ok nj-skinned')[0];
62 this.components.cancel_btn = this.element.getElementsByClassName('btn_cancel nj-skinned')[0]; 63 this.components.cancel_btn = this.element.getElementsByClassName('btn_cancel nj-skinned')[0];
63 this.components.status = this.element.getElementsByClassName('status')[0]; 64 this.components.status = this.element.getElementsByClassName('status')[0];
64 this.components.url = this.element.getElementsByClassName('cloud_url')[0]; 65 this.components.url = this.element.getElementsByClassName('cloud_url')[0];
65 this.components.download_btn = this.element.getElementsByClassName('btn_download nj-skinned')[0]; 66 this.components.download_btn = this.element.getElementsByClassName('btn_download nj-skinned')[0];
66 } 67 }
67 }, 68 },
68 //////////////////////////////////////////////////////////////////// 69 ////////////////////////////////////////////////////////////////////
69 // 70 //
70 willDraw: { 71 willDraw: {
71 enumerable: false, 72 enumerable: false,
72 value: function() { 73 value: function() {
73 // 74 //
74 if (navigator.appVersion.indexOf("Win")!=-1) { 75 if (navigator.appVersion.indexOf("Win")!=-1) {
75 this._os = 'windows'; 76 this._os = 'windows';
76 } else if (navigator.appVersion.indexOf("Mac")!=-1) { 77 } else if (navigator.appVersion.indexOf("Mac")!=-1) {
77 this._os = 'mac'; 78 this._os = 'mac';
78 } else { 79 } else {
79 //Alternate message for no OS detected (probably Linux) 80 //Alternate message for no OS detected (probably Linux)
80 this.element.getElementsByTagName('section')[0].style.display = 'none'; 81 this.element.getElementsByTagName('section')[0].style.display = 'none';
81 } 82 }
82 } 83 }
83 }, 84 },
84 //////////////////////////////////////////////////////////////////// 85 ////////////////////////////////////////////////////////////////////
85 // 86 //
86 draw: { 87 draw: {
87 enumerable: false, 88 enumerable: false,
88 value: function() { 89 value: function() {
89 // 90 //
90 if (this.application.localStorage.getItem("ioRootUrl")) { 91 if (this.application.localStorage.getItem("ioRootUrl")) {
91 this.components.url.value = this.application.localStorage.getItem("ioRootUrl"); 92 this.components.url.value = this.application.localStorage.getItem("ioRootUrl");
92 } 93 }
93 // 94 //
94 this.testConnection(); 95 this.testConnection();
95 if (this.application.ninja.coreIoApi.cloudAvailable()) { 96 if (this.application.ninja.coreIoApi.cloudAvailable()) {
96 this.closeDialog(); 97 this.closeDialog();
97 } 98 }
98 } 99 }
99 }, 100 },
100 //////////////////////////////////////////////////////////////////// 101 ////////////////////////////////////////////////////////////////////
101 // 102 //
102 didDraw: { 103 didDraw: {
103 enumerable: false, 104 enumerable: false,
104 value: function() { 105 value: function() {
105 // 106 //
106 this.components.download_btn.addEventListener('click', this.downloadCloudApp.bind(this), false); 107 this.components.download_btn.addEventListener('click', this.downloadCloudApp.bind(this), false);
107 // 108 //
108 this.components.test_btn.addEventListener('click', this.testConnection.bind(this), false); 109 this.components.test_btn.addEventListener('click', this.testConnection.bind(this), false);
109 // 110 //
110 this.components.ok_btn.addEventListener('click', this.closeDialog.bind(this), false); 111 this.components.ok_btn.addEventListener('click', this.closeDialog.bind(this), false);
111 this.components.cancel_btn.addEventListener('click', this.cancelDialog.bind(this), false); 112 this.components.cancel_btn.addEventListener('click', this.cancelDialog.bind(this), false);
112 } 113 }
113 }, 114 },
114 //////////////////////////////////////////////////////////////////// 115 ////////////////////////////////////////////////////////////////////
115 // 116 //
116 downloadCloudApp: { 117 downloadCloudApp: {
117 enumerable: false, 118 enumerable: false,
118 value: function() { 119 value: function() {
119 if(this._os === 'mac') { 120 if(this._os === 'mac') {
120 location.href = '/ninja_localcloud_for_mac.zip'; 121 location.href = '/ninja_localcloud_for_mac.zip';
121 } else if (this._os === 'windows') { 122 } else if (this._os === 'windows') {
122 location.href = '/ninja_localcloud_for_windows.zip'; 123 location.href = '/ninja_localcloud_for_windows.zip';
123 } else { 124 } else {
124 alert('Your operating system is not supported by the Ninja Local Cloud App.'); 125 alert('Your operating system is not supported by the Ninja Local Cloud App.');
125 } 126 }
126 } 127 }
127 }, 128 },
128 //////////////////////////////////////////////////////////////////// 129 ////////////////////////////////////////////////////////////////////
129 // 130 //
130 testConnection: { 131 testConnection: {
131 enumerable: false, 132 enumerable: false,
132 value: function() { 133 value: function() {
133 // 134 //
134 this.application.ninja.coreIoApi.rootUrl = this.components.url.value; 135 this.application.ninja.coreIoApi.rootUrl = this.components.url.value;
135 // 136 //
136 if (this.application.ninja.coreIoApi.cloudAvailable()) { 137 if (this.application.ninja.coreIoApi.cloudAvailable()) {
137 this.components.status.style.color = '#77FF00'; 138 this.components.status.style.color = '#77FF00';
138 this.components.status.innerHTML = 'Connected to '+this.application.ninja.coreIoApi.cloudData.name; 139 this.components.status.innerHTML = 'Connected to '+this.application.ninja.coreIoApi.cloudData.name;
139 } else { 140 } else {
140 this.components.status.style.color = '#FF3A3A'; 141 this.components.status.style.color = '#FF3A3A';
141 this.components.status.innerHTML = 'Disconnected'; 142 this.components.status.innerHTML = 'Disconnected';
142 }