Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 var gSelectedAvatarIconIndex = 0; | |
| 6 | |
| 7 /////////////////////////////////////////////////////////////////////////////// | |
| 8 // Helper functions | |
| 9 function $(o) {return document.getElementById(o);} | |
| 10 | |
| 11 function load() { | |
| 12 chrome.send('requestProfileInfo', []); | |
| 13 updateLogo(); | |
| 14 } | |
| 15 | |
| 16 function onCreate() { | |
| 17 chrome.send('create', [$('profile-name').value, | |
| 18 String(gSelectedAvatarIconIndex)]); | |
| 19 return false; | |
|
Miranda Callahan
2011/06/27 16:42:08
Not sure why we're returning "false" here, and in
sail
2011/06/27 17:37:24
Done.
Oops, left over code from when I was using t
| |
| 20 } | |
| 21 | |
| 22 function onCancel() { | |
| 23 chrome.send('cancel', []); | |
| 24 return false; | |
|
Miranda Callahan
2011/06/27 16:42:08
see comment above.
sail
2011/06/27 17:37:24
Done.
| |
| 25 } | |
| 26 | |
| 27 function onAvatarClicked(index) { | |
| 28 var menu = document.getElementById("avatar-menu"); | |
| 29 for (var i = 0; i < menu.childNodes.length; i++) { | |
| 30 var button = menu.childNodes[i]; | |
| 31 if (i == index) { | |
| 32 button.setAttribute("style", "background-color: blue"); | |
| 33 } else { | |
| 34 button.setAttribute("style", "background-color: transparent"); | |
| 35 } | |
| 36 } | |
| 37 gSelectedAvatarIconIndex = index; | |
| 38 } | |
| 39 | |
| 40 function updateLogo() { | |
| 41 var imageId = 'IDR_PRODUCT_LOGO'; | |
| 42 if (document.documentElement.getAttribute('customlogo') == 'true') | |
| 43 imageId = 'IDR_CUSTOM_PRODUCT_LOGO'; | |
| 44 | |
| 45 $('logo-img').src = 'chrome://theme/' + imageId + '?' + Date.now(); | |
| 46 } | |
| 47 | |
| 48 /////////////////////////////////////////////////////////////////////////////// | |
| 49 // Chrome callbacks: | |
| 50 | |
| 51 function setProfileInfo(profileName, profileIconIndex) { | |
| 52 $('profile-name').value = profileName; | |
| 53 onAvatarClicked(profileIconIndex); | |
| 54 } | |
| 55 | |
| 56 function setDefaultAvatarImages(imageUrlList) { | |
| 57 var menu = document.getElementById("avatar-menu"); | |
| 58 for (var i = 0; i < imageUrlList.length; i++) { | |
| 59 var button = document.createElement("input"); | |
| 60 button.setAttribute("type", "image"); | |
| 61 button.setAttribute("class", "avatar-button"); | |
| 62 button.setAttribute("src", imageUrlList[i]); | |
| 63 button.setAttribute("onclick", "onAvatarClicked(" + i + ")"); | |
| 64 menu.appendChild(button); | |
| 65 } | |
| 66 } | |
| 67 | |
| 68 function themeChanged() { | |
|
Miranda Callahan
2011/06/27 16:42:08
Is this for future use?
sail
2011/06/27 17:37:24
Yea, I removed this and add a TODO in the .cc code
| |
| 69 updateLogo(); | |
| 70 } | |
| 71 | |
| 72 // Add handlers to HTML elements. | |
| 73 document.body.onload = load; | |
| 74 $('create-button').onclick = function () { onCreate(''); }; | |
| 75 $('cancel-button').onclick = function () { onCancel(''); }; | |
| 76 $('profile-name-form').onsubmit = function () { | |
| 77 onCreate(''); | |
| 78 return false; | |
|
Miranda Callahan
2011/06/27 16:42:08
again, should this be returning false?
sail
2011/06/27 17:37:24
Yea, this has to return false so that the submit h
Miranda Callahan
2011/06/30 22:31:46
Can you add a comment to just clarify that for fut
sail
2011/06/30 22:38:15
Done.
| |
| 79 }; | |
| OLD | NEW |