| 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 /** @const */ var FEEDBACK_LANDING_PAGE = | 6 /** @const */ var FEEDBACK_LANDING_PAGE = |
| 7 'https://www.google.com/support/chrome/go/feedback_confirmation'; | 7 'https://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 var forceDisableScreenshots = false; |
| 18 | 19 |
| 19 /** | 20 /** |
| 20 * Selects an image thumbnail in the specified div. | 21 * Selects an image thumbnail in the specified div. |
| 21 * @param {string} divId The id of the div to search in. | 22 * @param {string} divId The id of the div to search in. |
| 22 * @param {string} thumbnailId The id of the thumbnail to search for. | 23 * @param {string} thumbnailId The id of the thumbnail to search for. |
| 23 */ | 24 */ |
| 24 function selectImage(divId, thumbnailId) { | 25 function selectImage(divId, thumbnailId) { |
| 25 var thumbnailDivs = $(divId).children; | 26 var thumbnailDivs = $(divId).children; |
| 26 selectedThumbnailDivId = divId; | 27 selectedThumbnailDivId = divId; |
| 27 if (thumbnailDivs.length == 0) { | 28 if (thumbnailDivs.length == 0) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 thumbnailDiv.appendChild(innerDiv); | 70 thumbnailDiv.appendChild(innerDiv); |
| 70 $(divId).appendChild(thumbnailDiv); | 71 $(divId).appendChild(thumbnailDiv); |
| 71 | 72 |
| 72 if (!selectedThumbnailId) | 73 if (!selectedThumbnailId) |
| 73 selectImage(divId, thumbnailDiv.id); | 74 selectImage(divId, thumbnailDiv.id); |
| 74 } | 75 } |
| 75 | 76 |
| 76 /** | 77 /** |
| 77 * Disables screenshots completely. | 78 * Disables screenshots completely. |
| 78 */ | 79 */ |
| 79 function disableScreenshots() { | 80 function enableScreenshots() { |
| 80 $('screenshot-row').hidden = true; | 81 if (forceDisableScreenshots) |
| 81 $('screenshot-checkbox').checked = false; | 82 return; |
| 82 | 83 $('screenshot-row').hidden = false; |
| 83 $('current-screenshots').hidden = true; | |
| 84 if ($('saved-screenshots')) | |
| 85 $('saved-screenshots').hidden = true; | |
| 86 } | 84 } |
| 87 | 85 |
| 88 /** | 86 /** |
| 89 * Sends the report; after the report is sent, we need to be redirected to | 87 * Sends 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 | 88 * 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. | 89 * we open the landing page in a new tab and sendReport closes this tab. |
| 92 * @return {boolean} True if the report was sent. | 90 * @return {boolean} True if the report was sent. |
| 93 */ | 91 */ |
| 94 function sendReport() { | 92 function sendReport() { |
| 95 if ($('description-text').value.length == 0) { | 93 if ($('description-text').value.length == 0) { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // For a clean URL, trim the parameters from the hash. | 231 // For a clean URL, trim the parameters from the hash. |
| 234 window.location.hash = window.location.hash.substring(0, queryPos); | 232 window.location.hash = window.location.hash.substring(0, queryPos); |
| 235 } | 233 } |
| 236 | 234 |
| 237 // Set the initial description text. | 235 // Set the initial description text. |
| 238 $('description-text').textContent = parameters['description']; | 236 $('description-text').textContent = parameters['description']; |
| 239 // If a page url is spcified in the parameters, override the default page url. | 237 // If a page url is spcified in the parameters, override the default page url. |
| 240 if (parameters['customPageUrl'] != '') { | 238 if (parameters['customPageUrl'] != '') { |
| 241 $('page-url-text').value = parameters['customPageUrl']; | 239 $('page-url-text').value = parameters['customPageUrl']; |
| 242 // and disable the page image, since it doesn't make sense on a custum url. | 240 // and disable the page image, since it doesn't make sense on a custum url. |
| 243 disableScreenshots(); | 241 $('screenshot-checkbox').checked = false; |
| 242 forceDisableScreenshots = true; |
| 244 } | 243 } |
| 245 | 244 |
| 246 // Pick up the category tag (for most cases this will be an empty string) | 245 // Pick up the category tag (for most cases this will be an empty string) |
| 247 categoryTag = parameters['categoryTag']; | 246 categoryTag = parameters['categoryTag']; |
| 248 | 247 |
| 249 chrome.send('getDialogDefaults'); | 248 chrome.send('getDialogDefaults'); |
| 250 chrome.send('refreshCurrentScreenshot'); | 249 chrome.send('refreshCurrentScreenshot'); |
| 251 } | 250 } |
| 252 | 251 |
| 253 function setupCurrentScreenshot(screenshot) { | 252 function setupCurrentScreenshot(screenshot) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 271 for (i = 0; i < screenshots.length; ++i) | 270 for (i = 0; i < screenshots.length; ++i) |
| 272 addScreenshot('saved-screenshots', screenshots[i]); | 271 addScreenshot('saved-screenshots', screenshots[i]); |
| 273 | 272 |
| 274 // Now that we have our screenshots, try selecting the saved screenshots | 273 // Now that we have our screenshots, try selecting the saved screenshots |
| 275 // again. | 274 // again. |
| 276 savedSelected(); | 275 savedSelected(); |
| 277 } | 276 } |
| 278 } | 277 } |
| 279 | 278 |
| 280 function setupDialogDefaults(defaults) { | 279 function setupDialogDefaults(defaults) { |
| 281 if (defaults.length > 0) { | 280 // Current url. |
| 282 if ($('page-url-text').value == '') | 281 if ($('page-url-text').value == '') |
| 283 $('page-url-text').value = defaults[0]; | 282 $('page-url-text').value = defaults.currentUrl; |
| 284 if (defaults[0] == '') | 283 if (defaults.currentUrl == '') |
| 285 $('page-url-checkbox').checked = false; | 284 $('page-url-checkbox').checked = false; |
| 286 | 285 |
| 287 if (defaults.length > 2) { | 286 // Are screenshots disabled? |
| 288 // We're in Chromium OS. | 287 if (!defaults.disableScreenshots) |
| 289 $('user-email-text').textContent = defaults[2]; | 288 enableScreenshots(); |
| 290 if (defaults[2] == '') { | |
| 291 // if we didn't get an e-mail address from cros, | |
| 292 // disable the user email display totally. | |
| 293 $('user-email-table').hidden = true; | |
| 294 | 289 |
| 295 // this also means we are in privacy mode, so no saved screenshots. | 290 // User e-mail. |
| 296 $('screenshot-link-tosaved').hidden = true; | 291 if ($('user-email-text')) { |
| 297 } | 292 // We're in Chromium OS. |
| 293 $('user-email-text').textContent = defaults.userEmail; |
| 294 if (defaults.userEmail == '') { |
| 295 // if we didn't get an e-mail address from cros, |
| 296 // disable the user email display totally. |
| 297 $('user-email-table').hidden = true; |
| 298 |
| 299 // this also means we are in privacy mode, so no saved screenshots. |
| 300 $('screenshot-link-tosaved').hidden = true; |
| 298 } | 301 } |
| 299 } | 302 } |
| 300 } | 303 } |
| 301 | 304 |
| 302 window.addEventListener('DOMContentLoaded', load); | 305 window.addEventListener('DOMContentLoaded', load); |
| OLD | NEW |