Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: chrome/browser/resources/chromeos/mobile_setup.js

Issue 10356042: Fix presubmit js style nits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 cr.define('mobile', function() { 6 cr.define('mobile', function() {
7 7
8 function MobileSetup() { 8 function MobileSetup() {
9 } 9 }
10 10
11 cr.addSingletonGetter(MobileSetup); 11 cr.addSingletonGetter(MobileSetup);
12 12
13 MobileSetup.PLAN_ACTIVATION_PAGE_LOADING = -1; 13 MobileSetup.PLAN_ACTIVATION_PAGE_LOADING = -1;
zel 2012/05/07 16:41:32 why removing spaces here? how's the making the cod
Tyler Breisacher (Chromium) 2012/05/07 17:12:25 This is required by the linter that runs as part o
Dan Beam 2012/05/07 17:43:53 http://google-styleguide.googlecode.com/svn/trunk/
14 MobileSetup.PLAN_ACTIVATION_START = 0; 14 MobileSetup.PLAN_ACTIVATION_START = 0;
15 MobileSetup.PLAN_ACTIVATION_TRYING_OTASP = 1; 15 MobileSetup.PLAN_ACTIVATION_TRYING_OTASP = 1;
16 MobileSetup.PLAN_ACTIVATION_RECONNECTING_OTASP_TRY = 2; 16 MobileSetup.PLAN_ACTIVATION_RECONNECTING_OTASP_TRY = 2;
17 MobileSetup.PLAN_ACTIVATION_INITIATING_ACTIVATION = 3; 17 MobileSetup.PLAN_ACTIVATION_INITIATING_ACTIVATION = 3;
18 MobileSetup.PLAN_ACTIVATION_RECONNECTING = 4; 18 MobileSetup.PLAN_ACTIVATION_RECONNECTING = 4;
19 MobileSetup.PLAN_ACTIVATION_PAYMENT_PORTAL_LOADING = 5; 19 MobileSetup.PLAN_ACTIVATION_PAYMENT_PORTAL_LOADING = 5;
20 MobileSetup.PLAN_ACTIVATION_SHOWING_PAYMENT = 6; 20 MobileSetup.PLAN_ACTIVATION_SHOWING_PAYMENT = 6;
21 MobileSetup.PLAN_ACTIVATION_RECONNECTING_PAYMENT = 7; 21 MobileSetup.PLAN_ACTIVATION_RECONNECTING_PAYMENT = 7;
22 MobileSetup.PLAN_ACTIVATION_DELAY_OTASP = 8; 22 MobileSetup.PLAN_ACTIVATION_DELAY_OTASP = 8;
23 MobileSetup.PLAN_ACTIVATION_START_OTASP = 9; 23 MobileSetup.PLAN_ACTIVATION_START_OTASP = 9;
24 MobileSetup.PLAN_ACTIVATION_OTASP = 10; 24 MobileSetup.PLAN_ACTIVATION_OTASP = 10;
25 MobileSetup.PLAN_ACTIVATION_RECONNECTING_OTASP = 11; 25 MobileSetup.PLAN_ACTIVATION_RECONNECTING_OTASP = 11;
26 MobileSetup.PLAN_ACTIVATION_DONE = 12; 26 MobileSetup.PLAN_ACTIVATION_DONE = 12;
27 MobileSetup.PLAN_ACTIVATION_ERROR = 0xFF; 27 MobileSetup.PLAN_ACTIVATION_ERROR = 0xFF;
28 28
29 MobileSetup.EXTENSION_PAGE_URL = 29 MobileSetup.EXTENSION_PAGE_URL =
30 'chrome-extension://iadeocfgjdjdmpenejdbfeaocpbikmab'; 30 'chrome-extension://iadeocfgjdjdmpenejdbfeaocpbikmab';
31 MobileSetup.ACTIVATION_PAGE_URL = MobileSetup.EXTENSION_PAGE_URL + 31 MobileSetup.ACTIVATION_PAGE_URL = MobileSetup.EXTENSION_PAGE_URL +
32 '/activation.html'; 32 '/activation.html';
33 MobileSetup.REDIRECT_POST_PAGE_URL = MobileSetup.EXTENSION_PAGE_URL + 33 MobileSetup.REDIRECT_POST_PAGE_URL = MobileSetup.EXTENSION_PAGE_URL +
34 '/redirect.html'; 34 '/redirect.html';
35 35
36 MobileSetup.localStrings_ = new LocalStrings(); 36 MobileSetup.localStrings_ = new LocalStrings();
37 37
38 MobileSetup.prototype = { 38 MobileSetup.prototype = {
39 // Mobile device information. 39 // Mobile device information.
40 deviceInfo_: null, 40 deviceInfo_: null,
41 frameName_ : '', 41 frameName_: '',
42 initialized_ : false, 42 initialized_: false,
43 faked_transaction_ : false, 43 faked_transaction_: false,
arv (Not doing code reviews) 2012/05/07 17:26:03 no underscores in JS names
kmadhusu 2012/05/08 20:20:19 Done.
44 payment_shown_ : false, 44 payment_shown_: false,
45 frame_load_error_ : 0, 45 frame_load_error_: 0,
46 frame_load_ignored_ : true, 46 frame_load_ignored_: true,
47 spinner_int_: -1, 47 spinner_int_: -1,
48 // UI states. 48 // UI states.
49 state_ : -1, 49 state_: -1,
50 STATE_UNKNOWN_: "unknown", 50 STATE_UNKNOWN_: 'unknown',
51 STATE_CONNECTING_: "connecting", 51 STATE_CONNECTING_: 'connecting',
52 STATE_ERROR_: "error", 52 STATE_ERROR_: 'error',
53 STATE_PAYMENT_: "payment", 53 STATE_PAYMENT_: 'payment',
54 STATE_ACTIVATING_: "activating", 54 STATE_ACTIVATING_: 'activating',
55 STATE_CONNECTED_: "connected", 55 STATE_CONNECTED_: 'connected',
56 56
57 initialize: function(frame_name, carrierPage) { 57 initialize: function(frame_name, carrierPage) {
58 if (this.initialized_) { 58 if (this.initialized_) {
59 console.log('calling initialize() again?'); 59 console.log('calling initialize() again?');
60 return; 60 return;
61 } 61 }
62 this.initialized_ = true; 62 this.initialized_ = true;
63 self = this; 63 self = this;
64 this.frameName_ = frame_name; 64 this.frameName_ = frame_name;
65 65
(...skipping 18 matching lines...) Expand all
84 return; 84 return;
85 } 85 }
86 self.confirm_.show( 86 self.confirm_.show(
87 MobileSetup.localStrings_.getString('cancel_question'), function() { 87 MobileSetup.localStrings_.getString('cancel_question'), function() {
88 window.close(); 88 window.close();
89 }); 89 });
90 }); 90 });
91 91
92 this.changeState_({state: MobileSetup.PLAN_ACTIVATION_PAGE_LOADING}); 92 this.changeState_({state: MobileSetup.PLAN_ACTIVATION_PAGE_LOADING});
93 // Kick off activation process. 93 // Kick off activation process.
94 chrome.send('startActivation', []); 94 chrome.send('startActivation');
95 }, 95 },
96 96
97 startSpinner_:function() { 97 startSpinner_: function() {
98 this.stopSpinner_(); 98 this.stopSpinner_();
99 this.spinner_int_ = setInterval(mobile.MobileSetup.drawProgress, 100); 99 this.spinner_int_ = setInterval(mobile.MobileSetup.drawProgress, 100);
100 }, 100 },
101 101
102 stopSpinner_:function() { 102 stopSpinner_: function() {
103 if (this.spinner_int_ != -1) { 103 if (this.spinner_int_ != -1) {
104 clearInterval(this.spinner_int_); 104 clearInterval(this.spinner_int_);
105 this.spinner_int_ = -1; 105 this.spinner_int_ = -1;
106 } 106 }
107 }, 107 },
108 108
109 onFrameLoaded_: function(success) { 109 onFrameLoaded_: function(success) {
110 chrome.send('paymentPortalLoad', [success ? 'ok' : 'failed']); 110 chrome.send('paymentPortalLoad', [success ? 'ok' : 'failed']);
111 }, 111 },
112 112
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 chrome.send('setTransactionStatus', [e.data.status]); 145 chrome.send('setTransactionStatus', [e.data.status]);
146 } 146 }
147 }, 147 },
148 148
149 changeState_: function(deviceInfo) { 149 changeState_: function(deviceInfo) {
150 var new_state = deviceInfo.state; 150 var new_state = deviceInfo.state;
151 if (this.state_ == new_state) 151 if (this.state_ == new_state)
152 return; 152 return;
153 var main = $('mainbody'); 153 var main = $('mainbody');
154 // Map handler state to UX. 154 // Map handler state to UX.
155 switch(new_state) { 155 switch (new_state) {
156 case MobileSetup.PLAN_ACTIVATION_PAGE_LOADING: 156 case MobileSetup.PLAN_ACTIVATION_PAGE_LOADING:
157 case MobileSetup.PLAN_ACTIVATION_START: 157 case MobileSetup.PLAN_ACTIVATION_START:
158 case MobileSetup.PLAN_ACTIVATION_DELAY_OTASP: 158 case MobileSetup.PLAN_ACTIVATION_DELAY_OTASP:
159 case MobileSetup.PLAN_ACTIVATION_START_OTASP: 159 case MobileSetup.PLAN_ACTIVATION_START_OTASP:
160 case MobileSetup.PLAN_ACTIVATION_RECONNECTING: 160 case MobileSetup.PLAN_ACTIVATION_RECONNECTING:
161 case MobileSetup.PLAN_ACTIVATION_RECONNECTING_PAYMENT: 161 case MobileSetup.PLAN_ACTIVATION_RECONNECTING_PAYMENT:
162 case MobileSetup.PLAN_ACTIVATION_RECONNECTING_OTASP_TRY: 162 case MobileSetup.PLAN_ACTIVATION_RECONNECTING_OTASP_TRY:
163 case MobileSetup.PLAN_ACTIVATION_RECONNECTING_OTASP: 163 case MobileSetup.PLAN_ACTIVATION_RECONNECTING_OTASP:
164 $('statusHeader').textContent = 164 $('statusHeader').textContent =
165 MobileSetup.localStrings_.getString('connecting_header'); 165 MobileSetup.localStrings_.getString('connecting_header');
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 this.state_ = new_state; 253 this.state_ = new_state;
254 }, 254 },
255 255
256 updateDeviceStatus_: function(deviceInfo) { 256 updateDeviceStatus_: function(deviceInfo) {
257 this.changeState_(deviceInfo); 257 this.changeState_(deviceInfo);
258 }, 258 },
259 259
260 portalFrameLoadError_: function(errorCode) { 260 portalFrameLoadError_: function(errorCode) {
261 if (this.frame_load_ignored_) 261 if (this.frame_load_ignored_)
262 return; 262 return;
263 console.log("Portal frame load error detected: " + errorCode); 263 console.log('Portal frame load error detected: ' + errorCode);
Tyler Breisacher (Chromium) 2012/05/07 17:12:25 It's often a good idea to change this kind of thin
kmadhusu 2012/05/08 20:20:19 Done.
264 this.frame_load_error_ = errorCode; 264 this.frame_load_error_ = errorCode;
265 }, 265 },
266 266
267 portalFrameLoadCompleted_: function() { 267 portalFrameLoadCompleted_: function() {
268 if (this.frame_load_ignored_) 268 if (this.frame_load_ignored_)
269 return; 269 return;
270 console.log("Portal frame load completed!"); 270 console.log('Portal frame load completed!');
271 this.onFrameLoaded_(this.frame_load_error_ == 0); 271 this.onFrameLoaded_(this.frame_load_error_ == 0);
272 }, 272 },
273 273
274 sendPostFrame_ : function(frameUrl) { 274 sendPostFrame_: function(frameUrl) {
275 var msg = { type: 'postFrame' }; 275 var msg = { type: 'postFrame' };
276 $(this.frameName_).contentWindow.postMessage(msg, frameUrl); 276 $(this.frameName_).contentWindow.postMessage(msg, frameUrl);
277 }, 277 },
278 278
279 sendDeviceInfo_ : function() { 279 sendDeviceInfo_: function() {
280 var msg = { 280 var msg = {
281 type: 'deviceInfoMsg', 281 type: 'deviceInfoMsg',
282 domain: document.location, 282 domain: document.location,
283 payload: { 283 payload: {
284 'carrier': this.deviceInfo_.carrier, 284 'carrier': this.deviceInfo_.carrier,
285 'MEID': this.deviceInfo_.MEID, 285 'MEID': this.deviceInfo_.MEID,
286 'IMEI': this.deviceInfo_.IMEI, 286 'IMEI': this.deviceInfo_.IMEI,
287 'MDN': this.deviceInfo_.MDN 287 'MDN': this.deviceInfo_.MDN
288 } 288 }
289 }; 289 };
290 $(this.frameName_).contentWindow.postMessage(msg, 290 $(this.frameName_).contentWindow.postMessage(msg,
291 this.deviceInfo_.payment_url); 291 this.deviceInfo_.payment_url);
292 } 292 }
293 293
294 }; 294 };
295 295
296 MobileSetup.drawProgress = function () { 296 MobileSetup.drawProgress = function() {
297 var ctx = canvas.getContext('2d'); 297 var ctx = canvas.getContext('2d');
298 ctx.clearRect(0, 0, canvas.width, canvas.height); 298 ctx.clearRect(0, 0, canvas.width, canvas.height);
299 299
300 var segmentCount = Math.min(12, canvas.width/1.6) // Number of segments 300 var segmentCount = Math.min(12, canvas.width / 1.6); // Number of segments
301 var rotation = 0.75; // Counterclockwise rotation 301 var rotation = 0.75; // Counterclockwise rotation
302 302
303 // Rotate canvas over time 303 // Rotate canvas over time
304 ctx.translate(canvas.width/2, canvas.height/2); 304 ctx.translate(canvas.width / 2, canvas.height / 2);
305 ctx.rotate(Math.PI * 2 / (segmentCount + rotation)); 305 ctx.rotate(Math.PI * 2 / (segmentCount + rotation));
306 ctx.translate(-canvas.width/2, -canvas.height/2); 306 ctx.translate(-canvas.width / 2, -canvas.height / 2);
307 307
308 var gap = canvas.width / 24; // Gap between segments 308 var gap = canvas.width / 24; // Gap between segments
309 var oRadius = canvas.width/2; // Outer radius 309 var oRadius = canvas.width / 2; // Outer radius
310 var iRadius = oRadius * 0.618; // Inner radius 310 var iRadius = oRadius * 0.618; // Inner radius
311 var oCircumference = Math.PI * 2 * oRadius; // Outer circumference 311 var oCircumference = Math.PI * 2 * oRadius; // Outer circumference
312 var iCircumference = Math.PI * 2 * iRadius; // Inner circumference 312 var iCircumference = Math.PI * 2 * iRadius; // Inner circumference
313 var oGap = gap / oCircumference; // Gap size as fraction of outer ring 313 var oGap = gap / oCircumference; // Gap size as fraction of outer ring
314 var iGap = gap / iCircumference; // Gap size as fraction of inner ring 314 var iGap = gap / iCircumference; // Gap size as fraction of inner ring
315 var oArc = Math.PI * 2 * ( 1 / segmentCount - oGap); // Angle of outer arcs 315 var oArc = Math.PI * 2 * (1 / segmentCount - oGap); // Angle of outer arcs
316 var iArc = Math.PI * 2 * ( 1 / segmentCount - iGap); // Angle of inner arcs 316 var iArc = Math.PI * 2 * (1 / segmentCount - iGap); // Angle of inner arcs
317 317
318 for (i = 0; i < segmentCount; i++){ // Draw each segment 318 for (i = 0; i < segmentCount; i++) { // Draw each segment
319 var opacity = Math.pow(1.0 - i / segmentCount, 3.0); 319 var opacity = Math.pow(1.0 - i / segmentCount, 3.0);
320 opacity = (0.15 + opacity * 0.8) // Vary from 0.15 to 0.95 320 opacity = (0.15 + opacity * 0.8); // Vary from 0.15 to 0.95
321 var angle = - Math.PI * 2 * i / segmentCount; 321 var angle = - Math.PI * 2 * i / segmentCount;
322 322
323 ctx.beginPath(); 323 ctx.beginPath();
324 ctx.arc(canvas.width/2, canvas.height/2, oRadius, 324 ctx.arc(canvas.width / 2, canvas.height / 2, oRadius,
325 angle - oArc/2, angle + oArc/2, false); 325 angle - oArc / 2, angle + oArc / 2, false);
326 ctx.arc(canvas.width/2, canvas.height/2, iRadius, 326 ctx.arc(canvas.width / 2, canvas.height / 2, iRadius,
327 angle + iArc/2, angle - iArc/2, true); 327 angle + iArc / 2, angle - iArc / 2, true);
328 ctx.closePath(); 328 ctx.closePath();
329 ctx.fillStyle = "rgba(240, 30, 29, " + opacity + ")"; 329 ctx.fillStyle = 'rgba(240, 30, 29, ' + opacity + ')';
330 ctx.fill(); 330 ctx.fill();
331 } 331 }
332 }; 332 };
333 333
334 MobileSetup.deviceStateChanged = function(deviceInfo) { 334 MobileSetup.deviceStateChanged = function(deviceInfo) {
335 MobileSetup.getInstance().updateDeviceStatus_(deviceInfo); 335 MobileSetup.getInstance().updateDeviceStatus_(deviceInfo);
336 }; 336 };
337 337
338 MobileSetup.portalFrameLoadError = function(errorCode) { 338 MobileSetup.portalFrameLoadError = function(errorCode) {
339 MobileSetup.getInstance().portalFrameLoadError_(errorCode); 339 MobileSetup.getInstance().portalFrameLoadError_(errorCode);
340 }; 340 };
341 341
342 MobileSetup.portalFrameLoadCompleted = function() { 342 MobileSetup.portalFrameLoadCompleted = function() {
343 MobileSetup.getInstance().portalFrameLoadCompleted_(); 343 MobileSetup.getInstance().portalFrameLoadCompleted_();
344 }; 344 };
345 345
346 MobileSetup.loadPage = function() { 346 MobileSetup.loadPage = function() {
347 mobile.MobileSetup.getInstance().initialize('paymentForm', 347 mobile.MobileSetup.getInstance().initialize('paymentForm',
348 mobile.MobileSetup.ACTIVATION_PAGE_URL); 348 mobile.MobileSetup.ACTIVATION_PAGE_URL);
349 }; 349 };
350 350
351 // Export 351 // Export
352 return { 352 return {
353 MobileSetup: MobileSetup 353 MobileSetup: MobileSetup
354 }; 354 };
355 355
356 }); 356 });
357 357
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698