Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 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 // Constants. | 5 // Constants. |
| 6 var FEEDBACK_LANDING_PAGE = | 6 var FEEDBACK_LANDING_PAGE = |
|
Dan Beam
2012/04/05 22:24:13
/** @const */
Tyler Breisacher (Chromium)
2012/04/05 22:49:55
Here, yes. The other constants are not actually co
Dan Beam
2012/04/06 02:58:29
Only meant this one.
| |
| 7 'http://www.google.com/support/chrome/go/feedback_confirmation' | 7 'http://www.google.com/support/chrome/go/feedback_confirmation'; |
| 8 | 8 |
| 9 var selectedThumbnailDivId = ''; | 9 var selectedThumbnailDivId = ''; |
| 10 var selectedThumbnailId = ''; | 10 var selectedThumbnailId = ''; |
| 11 var selectedImageUrl; | 11 var selectedImageUrl; |
| 12 | 12 |
| 13 var savedThumbnailIds = []; | 13 var savedThumbnailIds = []; |
| 14 savedThumbnailIds['current-screenshots'] = ''; | 14 savedThumbnailIds['current-screenshots'] = ''; |
| 15 savedThumbnailIds['saved-screenshots'] = ''; | 15 savedThumbnailIds['saved-screenshots'] = ''; |
| 16 | 16 |
| 17 var categoryTag = ""; | 17 var categoryTag = ''; |
| 18 | 18 |
| 19 var localStrings = new LocalStrings(); | 19 var localStrings = new LocalStrings(); |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * Selects an image thumbnail in the specified div. | 22 * Selects an image thumbnail in the specified div. |
| 23 */ | 23 */ |
| 24 function selectImage(divId, thumbnailId) { | 24 function selectImage(divId, thumbnailId) { |
| 25 var thumbnailDivs = $(divId).children; | 25 var thumbnailDivs = $(divId).children; |
| 26 selectedThumbnailDivId = divId; | 26 selectedThumbnailDivId = divId; |
| 27 if (thumbnailDivs.length == 0) { | 27 if (thumbnailDivs.length == 0) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 } | 74 } |
| 75 | 75 |
| 76 /** | 76 /** |
| 77 * Disables screenshots completely. | 77 * Disables screenshots completely. |
| 78 */ | 78 */ |
| 79 function disableScreenshots() { | 79 function disableScreenshots() { |
| 80 $('screenshot-row').hidden = true; | 80 $('screenshot-row').hidden = true; |
| 81 $('screenshot-checkbox').checked = false; | 81 $('screenshot-checkbox').checked = false; |
| 82 | 82 |
| 83 $('current-screenshots').hidden = true; | 83 $('current-screenshots').hidden = true; |
| 84 if ($('saved-screenshots')) | 84 if ($('saved-screenshots')) |
|
Dan Beam
2012/04/05 22:24:13
I'll let this double $('id') lookup slide.
| |
| 85 $('saved-screenshots').hidden = true; | 85 $('saved-screenshots').hidden = true; |
| 86 } | 86 } |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * Send's the report; after the report is sent, we need to be redirected to | 89 * Send's the report; after the report is sent, we need to be redirected to |
| 90 * the landing page, but we shouldn't be able to navigate back, hence | 90 * the landing page, but we shouldn't be able to navigate back, hence |
| 91 * we open the landing page in a new tab and sendReport closes this tab. | 91 * we open the landing page in a new tab and sendReport closes this tab. |
| 92 */ | 92 */ |
| 93 function sendReport() { | 93 function sendReport() { |
| 94 if ($('description-text').value.length == 0) { | 94 if ($('description-text').value.length == 0) { |
| 95 alert(localStrings.getString('no-description')); | 95 alert(localStrings.getString('no-description')); |
| 96 return false; | 96 return false; |
| 97 } | 97 } |
| 98 | 98 |
| 99 var imagePath = ''; | 99 var imagePath = ''; |
| 100 if ($('screenshot-checkbox').checked && selectedThumbnailId) | 100 if ($('screenshot-checkbox').checked && selectedThumbnailId) |
| 101 imagePath = $(selectedThumbnailId + '-image').src; | 101 imagePath = $(selectedThumbnailId + '-image').src; |
| 102 var pageUrl = $('page-url-text').value; | 102 var pageUrl = $('page-url-text').value; |
| 103 if (!$('page-url-checkbox').checked) | 103 if (!$('page-url-checkbox').checked) |
| 104 pageUrl = ''; | 104 pageUrl = ''; |
| 105 | 105 |
| 106 var reportArray = [pageUrl, | 106 var reportArray = [pageUrl, |
| 107 categoryTag, | 107 categoryTag, |
| 108 $('description-text').value, | 108 $('description-text').value, |
| 109 imagePath]; | 109 imagePath]; |
| 110 | 110 |
| 111 // Add chromeos data if it exists. | 111 // Add chromeos data if it exists. |
| 112 if ($('user-email-text') && $('sys-info-checkbox')) { | 112 if ($('user-email-text') && $('sys-info-checkbox')) { |
| 113 var userEmail= $('user-email-text').textContent; | 113 var userEmail = $('user-email-text').textContent; |
|
Dan Beam
2012/04/05 22:24:13
and this one, >:|
| |
| 114 if (!$('user-email-checkbox').checked) | 114 if (!$('user-email-checkbox').checked) |
| 115 userEmail = ''; | 115 userEmail = ''; |
| 116 reportArray = reportArray.concat([userEmail, | 116 reportArray = reportArray.concat([userEmail, |
| 117 String($('sys-info-checkbox').checked)]); | 117 String($('sys-info-checkbox').checked)]); |
| 118 } | 118 } |
| 119 | 119 |
| 120 // open the landing page in a new tab, sendReport will close this one. | 120 // open the landing page in a new tab, sendReport will close this one. |
| 121 window.open(FEEDBACK_LANDING_PAGE, '_blank'); | 121 window.open(FEEDBACK_LANDING_PAGE, '_blank'); |
| 122 chrome.send('sendReport', reportArray); | 122 chrome.send('sendReport', reportArray); |
| 123 return true; | 123 return true; |
| 124 } | 124 } |
| 125 | 125 |
| 126 function cancel() { | 126 function cancel() { |
| 127 chrome.send('cancel', []); | 127 chrome.send('cancel'); |
| 128 return true; | 128 return true; |
| 129 } | 129 } |
| 130 | 130 |
| 131 /** | 131 /** |
| 132 * Select the current screenshots div, restoring the image that was | 132 * Select the current screenshots div, restoring the image that was |
| 133 * selected when we had this div open previously. | 133 * selected when we had this div open previously. |
| 134 */ | 134 */ |
| 135 function currentSelected() { | 135 function currentSelected() { |
| 136 // TODO(rkc): Change this to use a class instead. | 136 // TODO(rkc): Change this to use a class instead. |
| 137 $('current-screenshots').hidden = false; | 137 $('current-screenshots').hidden = false; |
| 138 if ($('saved-screenshots')) | 138 if ($('saved-screenshots')) |
| 139 $('saved-screenshots').hidden = true; | 139 $('saved-screenshots').hidden = true; |
|
Dan Beam
2012/04/05 22:24:13
and this one, >:|
| |
| 140 | 140 |
| 141 if (selectedThumbnailDivId != 'current-screenshots') | 141 if (selectedThumbnailDivId != 'current-screenshots') |
| 142 selectImage('current-screenshots', | 142 selectImage('current-screenshots', |
|
Dan Beam
2012/04/05 22:24:13
and this one, >:|
| |
| 143 savedThumbnailIds['current-screenshots']); | 143 savedThumbnailIds['current-screenshots']); |
| 144 | 144 |
| 145 return true; | 145 return true; |
| 146 } | 146 } |
| 147 | 147 |
| 148 /** | 148 /** |
| 149 * Select the saved screenshots div, restoring the image that was | 149 * Select the saved screenshots div, restoring the image that was |
| 150 * selected when we had this div open previously. | 150 * selected when we had this div open previously. |
| 151 */ | 151 */ |
| 152 function savedSelected() { | 152 function savedSelected() { |
| 153 $('current-screenshots').hidden = true; | 153 $('current-screenshots').hidden = true; |
| 154 | 154 |
| 155 if ($('saved-screenshots').childElementCount == 0) { | 155 if ($('saved-screenshots').childElementCount == 0) { |
| 156 // setupSavedScreenshots will take care of changing visibility | 156 // setupSavedScreenshots will take care of changing visibility |
| 157 chrome.send('refreshSavedScreenshots', []); | 157 chrome.send('refreshSavedScreenshots'); |
| 158 } else { | 158 } else { |
| 159 $('saved-screenshots').hidden = false; | 159 $('saved-screenshots').hidden = false; |
|
Dan Beam
2012/04/05 22:24:13
and this one, >:|
| |
| 160 if (selectedThumbnailDivId != 'saved-screenshots') | 160 if (selectedThumbnailDivId != 'saved-screenshots') |
| 161 selectImage('saved-screenshots', savedThumbnailIds['saved-screenshots']); | 161 selectImage('saved-screenshots', savedThumbnailIds['saved-screenshots']); |
| 162 } | 162 } |
| 163 | 163 |
| 164 return true; | 164 return true; |
| 165 } | 165 } |
| 166 | 166 |
| 167 | 167 |
| 168 /** | 168 /** |
| 169 * Change the type of screenshot we're showing to the user from | 169 * Change the type of screenshot we're showing to the user from |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 194 | 194 |
| 195 currentSelected(); | 195 currentSelected(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 /////////////////////////////////////////////////////////////////////////////// | 198 /////////////////////////////////////////////////////////////////////////////// |
| 199 // Document Functions: | 199 // Document Functions: |
| 200 /** | 200 /** |
| 201 * Window onload handler, sets up the page. | 201 * Window onload handler, sets up the page. |
| 202 */ | 202 */ |
| 203 function load() { | 203 function load() { |
| 204 if ($('sysinfo-url')) { | 204 if ($('sysinfo-url')) { |
|
Dan Beam
2012/04/05 22:24:13
and this, :|
| |
| 205 $('sysinfo-url').onclick = function(event) { | 205 $('sysinfo-url').onclick = function(event) { |
| 206 chrome.send('openSystemTab'); | 206 chrome.send('openSystemTab'); |
| 207 }; | 207 }; |
| 208 } | 208 } |
| 209 | 209 |
| 210 <if expr="pp_ifdef('chromeos')"> | 210 <if expr="pp_ifdef('chromeos')"> |
| 211 $('screenshot-link-tosaved').onclick = changeToSaved; | 211 $('screenshot-link-tosaved').onclick = changeToSaved; |
| 212 $('screenshot-link-tocurrent').onclick = changeToCurrent; | 212 $('screenshot-link-tocurrent').onclick = changeToCurrent; |
| 213 </if> | 213 </if> |
| 214 $('send-report-button').onclick = sendReport; | 214 $('send-report-button').onclick = sendReport; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 244 // If a page url is spcified in the parameters, override the default page url. | 244 // If a page url is spcified in the parameters, override the default page url. |
| 245 if (parameters['customPageUrl'] != '') { | 245 if (parameters['customPageUrl'] != '') { |
| 246 $('page-url-text').value = parameters['customPageUrl']; | 246 $('page-url-text').value = parameters['customPageUrl']; |
| 247 // and disable the page image, since it doesn't make sense on a custum url. | 247 // and disable the page image, since it doesn't make sense on a custum url. |
| 248 disableScreenshots(); | 248 disableScreenshots(); |
| 249 } | 249 } |
| 250 | 250 |
| 251 // Pick up the category tag (for most cases this will be an empty string) | 251 // Pick up the category tag (for most cases this will be an empty string) |
| 252 categoryTag = parameters['categoryTag']; | 252 categoryTag = parameters['categoryTag']; |
| 253 | 253 |
| 254 chrome.send('getDialogDefaults', []); | 254 chrome.send('getDialogDefaults'); |
| 255 chrome.send('refreshCurrentScreenshot', []); | 255 chrome.send('refreshCurrentScreenshot'); |
| 256 }; | 256 } |
| 257 | 257 |
| 258 function setupCurrentScreenshot(screenshot) { | 258 function setupCurrentScreenshot(screenshot) { |
| 259 addScreenshot('current-screenshots', screenshot); | 259 addScreenshot('current-screenshots', screenshot); |
| 260 } | 260 } |
| 261 | 261 |
| 262 function setupSavedScreenshots(screenshots) { | 262 function setupSavedScreenshots(screenshots) { |
| 263 if (screenshots.length == 0) { | 263 if (screenshots.length == 0) { |
| 264 $('saved-screenshots').textContent = | 264 $('saved-screenshots').textContent = |
| 265 localStrings.getString('no-saved-screenshots'); | 265 localStrings.getString('no-saved-screenshots'); |
| 266 | 266 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 277 | 277 |
| 278 // Now that we have our screenshots, try selecting the saved screenshots | 278 // Now that we have our screenshots, try selecting the saved screenshots |
| 279 // again. | 279 // again. |
| 280 savedSelected(); | 280 savedSelected(); |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 | 283 |
| 284 function setupDialogDefaults(defaults) { | 284 function setupDialogDefaults(defaults) { |
| 285 if (defaults.length > 0) { | 285 if (defaults.length > 0) { |
| 286 if ($('page-url-text').value == '') | 286 if ($('page-url-text').value == '') |
| 287 $('page-url-text').value = defaults[0]; | 287 $('page-url-text').value = defaults[0]; |
|
Dan Beam
2012/04/05 22:24:13
and this one, >:|
| |
| 288 if (defaults[0] == '') | 288 if (defaults[0] == '') |
| 289 $('page-url-checkbox').checked = false; | 289 $('page-url-checkbox').checked = false; |
| 290 | 290 |
| 291 if (defaults.length > 2) { | 291 if (defaults.length > 2) { |
| 292 // We're in Chromium OS. | 292 // We're in Chromium OS. |
| 293 $('user-email-text').textContent = defaults[2]; | 293 $('user-email-text').textContent = defaults[2]; |
| 294 if (defaults[2] == '') { | 294 if (defaults[2] == '') { |
| 295 // if we didn't get an e-mail address from cros, | 295 // if we didn't get an e-mail address from cros, |
| 296 // disable the user email display totally. | 296 // disable the user email display totally. |
| 297 $('user-email-table').hidden = true; | 297 $('user-email-table').hidden = true; |
| 298 | 298 |
| 299 // this also means we are in privacy mode, so no saved screenshots. | 299 // this also means we are in privacy mode, so no saved screenshots. |
| 300 $('screenshot-link-tosaved').hidden = true; | 300 $('screenshot-link-tosaved').hidden = true; |
| 301 } | 301 } |
| 302 } | 302 } |
| 303 } | 303 } |
| 304 } | 304 } |
| 305 | 305 |
| 306 window.addEventListener('DOMContentLoaded', load); | 306 window.addEventListener('DOMContentLoaded', load); |
| OLD | NEW |