OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 function sendCommand(cmd) { | 5 function sendCommand(cmd) { |
6 window.domAutomationController.setAutomationId(1); | 6 window.domAutomationController.setAutomationId(1); |
7 window.domAutomationController.send(cmd); | 7 window.domAutomationController.send(cmd); |
8 } | 8 } |
9 | 9 |
10 function makeImageSet(url1x, url2x) { | 10 function makeImageSet(url1x, url2x) { |
11 return '-webkit-image-set(url(' + url1x + ') 1x, url(' + url2x + ') 2x)'; | 11 return '-webkit-image-set(url(' + url1x + ') 1x, url(' + url2x + ') 2x)'; |
12 } | 12 } |
13 | 13 |
14 function initialize() { | 14 function initialize() { |
15 if (loadTimeData.getBoolean('allowAccessRequests')) { | 15 if (loadTimeData.getBoolean('allowAccessRequests')) { |
16 $('request-access-button').onclick = function(event) { | 16 $('request-access-button').onclick = function(event) { |
17 updateAfterRequestSent(); | 17 $('request-access-button').hidden = true; |
18 sendCommand('request'); | 18 sendCommand('request'); |
19 }; | 19 }; |
20 } else { | 20 } else { |
21 $('request-access-button').hidden = true; | 21 $('request-access-button').hidden = true; |
22 } | 22 } |
23 var avatarURL1x = loadTimeData.getString('avatarURL1x'); | 23 var avatarURL1x = loadTimeData.getString('avatarURL1x'); |
24 var avatarURL2x = loadTimeData.getString('avatarURL2x'); | 24 var avatarURL2x = loadTimeData.getString('avatarURL2x'); |
25 if (avatarURL1x) { | 25 if (avatarURL1x) { |
26 $('avatar-img').style.content = makeImageSet(avatarURL1x, avatarURL2x); | 26 $('avatar-img').style.content = makeImageSet(avatarURL1x, avatarURL2x); |
27 $('avatar-img').hidden = false; | 27 $('avatar-img').hidden = false; |
28 $('error-img').hidden = true; | 28 $('error-img').hidden = true; |
29 var secondAvatarURL1x = loadTimeData.getString('secondAvatarURL1x'); | 29 var secondAvatarURL1x = loadTimeData.getString('secondAvatarURL1x'); |
30 var secondAvatarURL2x = loadTimeData.getString('secondAvatarURL2x'); | 30 var secondAvatarURL2x = loadTimeData.getString('secondAvatarURL2x'); |
31 if (secondAvatarURL1x) { | 31 if (secondAvatarURL1x) { |
32 $('second-avatar-img').style.content = | 32 $('second-avatar-img').style.content = |
33 makeImageSet(secondAvatarURL1x, secondAvatarURL2x); | 33 makeImageSet(secondAvatarURL1x, secondAvatarURL2x); |
34 $('second-avatar-img').hidden = false; | 34 $('second-avatar-img').hidden = false; |
35 // The avatar images should overlap a bit. | 35 // The avatar images should overlap a bit. |
36 $('avatar-img').style.left = '6px'; | 36 $('avatar-img').style.left = '6px'; |
37 $('avatar-img').style.zIndex = '1'; | 37 $('avatar-img').style.zIndex = '1'; |
38 $('second-avatar-img').style.left = '-6px'; | 38 $('second-avatar-img').style.left = '-6px'; |
39 } | 39 } |
40 } | 40 } |
41 $('back-button').onclick = function(event) { | 41 $('back-button').onclick = function(event) { |
42 sendCommand('back'); | 42 sendCommand('back'); |
43 }; | 43 }; |
44 } | 44 } |
45 | 45 |
46 /** | 46 /** |
47 * Updates the interstitial to show that the request was sent. | 47 * Updates the interstitial to show that the request failed or was sent. |
48 * @param {boolean} isSuccessful | |
Bernhard Bauer
2014/12/17 17:05:17
Document the parameter please.
khannan
2014/12/17 17:39:09
I tried emulating a bad js file so did not know ho
| |
48 */ | 49 */ |
49 function updateAfterRequestSent() { | 50 function requestStatus(isSuccessful) { |
Bernhard Bauer
2014/12/17 17:05:17
Name this method so it's in imperative?
khannan
2014/12/17 17:39:09
Done.
| |
50 $('error-img').hidden = true; | 51 $('error-img').hidden = true; |
51 $('request-access-button').hidden = true; | |
52 $('block-page-message').hidden = true; | 52 $('block-page-message').hidden = true; |
53 $('request-sent-message').hidden = false; | 53 if (isSuccessful) { |
54 if ($('avatar-img').hidden) { | 54 $('request-failed-message').hidden = true; |
55 $('request-sent-message').style.marginTop = '40px'; | 55 $('request-sent-message').hidden = false; |
56 if ($('avatar-img').hidden) { | |
57 $('request-sent-message').style.marginTop = '40px'; | |
58 } | |
59 } else { | |
60 $('request-failed-message').hidden = false; | |
61 $('request-access-button').hidden = false; | |
56 } | 62 } |
57 } | 63 } |
58 | 64 |
59 document.addEventListener('DOMContentLoaded', initialize); | 65 document.addEventListener('DOMContentLoaded', initialize); |
OLD | NEW |