| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 = |
| 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 = ''; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 function addScreenshot(divId, screenshot) { | 45 function addScreenshot(divId, screenshot) { |
| 46 var thumbnailDiv = document.createElement('div'); | 46 var thumbnailDiv = document.createElement('div'); |
| 47 thumbnailDiv.className = 'image-thumbnail-container'; | 47 thumbnailDiv.className = 'image-thumbnail-container'; |
| 48 | 48 |
| 49 thumbnailDiv.id = divId + '-thumbnailDiv-' + $(divId).children.length; | 49 thumbnailDiv.id = divId + '-thumbnailDiv-' + $(divId).children.length; |
| 50 thumbnailDiv.onclick = function() { | 50 thumbnailDiv.onclick = function() { |
| 51 selectImage(divId, thumbnailDiv.id); | 51 selectImage(divId, thumbnailDiv.id); |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 var innerDiv = document.createElement('div'); | 54 var innerDiv = document.createElement('div'); |
| 55 innerDiv.className = 'image-thumbnail'; | 55 if (divId == 'current-screenshots') |
| 56 innerDiv.className = 'image-thumbnail-current'; |
| 57 else |
| 58 innerDiv.className = 'image-thumbnail'; |
| 56 | 59 |
| 57 var thumbnail = document.createElement('img'); | 60 var thumbnail = document.createElement('img'); |
| 58 thumbnail.id = thumbnailDiv.id + '-image'; | 61 thumbnail.id = thumbnailDiv.id + '-image'; |
| 59 // We add the ?+timestamp to make sure the image URLs are unique | 62 // We add the ?+timestamp to make sure the image URLs are unique |
| 60 // and Chrome does not load the image from cache. | 63 // and Chrome does not load the image from cache. |
| 61 thumbnail.src = screenshot + "?" + Date.now(); | 64 thumbnail.src = screenshot + '?' + Date.now(); |
| 62 innerDiv.appendChild(thumbnail); | 65 innerDiv.appendChild(thumbnail); |
| 63 | 66 |
| 64 var largeImage = document.createElement('img'); | |
| 65 largeImage.src = screenshot + "?" + Date.now(); | |
| 66 | |
| 67 var popupDiv = document.createElement('div'); | |
| 68 popupDiv.appendChild(largeImage); | |
| 69 innerDiv.appendChild(popupDiv); | |
| 70 | |
| 71 thumbnailDiv.appendChild(innerDiv); | 67 thumbnailDiv.appendChild(innerDiv); |
| 72 $(divId).appendChild(thumbnailDiv); | 68 $(divId).appendChild(thumbnailDiv); |
| 73 | 69 |
| 74 if (!selectedThumbnailId) | 70 if (!selectedThumbnailId) |
| 75 selectImage(divId, thumbnailDiv.id); | 71 selectImage(divId, thumbnailDiv.id); |
| 76 } | 72 } |
| 77 | 73 |
| 78 /** | 74 /** |
| 79 * Send's the report; after the report is sent, we need to be redirected to | 75 * Send's the report; after the report is sent, we need to be redirected to |
| 80 * the landing page, but we shouldn't be able to navigate back, hence | 76 * the landing page, but we shouldn't be able to navigate back, hence |
| 81 * we open the landing page in a new tab and sendReport closes this tab. | 77 * we open the landing page in a new tab and sendReport closes this tab. |
| 82 */ | 78 */ |
| 83 function sendReport() { | 79 function sendReport() { |
| 84 if (!$('issue-with-combo').selectedIndex) { | 80 if (!$('issue-with-combo').selectedIndex) { |
| 85 alert(localStrings.getString('no-issue-selected')); | 81 alert(localStrings.getString('no-issue-selected')); |
| 86 return false; | 82 return false; |
| 83 } else if ($('description-text').value.length == 0) { |
| 84 alert(localStrings.getString('no-description')); |
| 85 return false; |
| 87 } | 86 } |
| 88 | 87 |
| 89 var imagePath = ''; | 88 var imagePath = ''; |
| 90 if (selectedThumbnailId) | 89 if ($('screenshot-checkbox').checked && selectedThumbnailId) |
| 91 imagePath = $(selectedThumbnailId + '-image').src; | 90 imagePath = $(selectedThumbnailId + '-image').src; |
| 91 var pageUrl = $('page-url-text').value; |
| 92 if (!$('page-url-checkbox').checked) |
| 93 pageUrl = ''; |
| 92 | 94 |
| 95 // Note, categories are based from 1 in our protocol buffers, so no |
| 96 // adjustment is needed on selectedIndex. |
| 93 var reportArray = [String($('issue-with-combo').selectedIndex), | 97 var reportArray = [String($('issue-with-combo').selectedIndex), |
| 94 $('page-url-text').value, | 98 pageUrl, |
| 95 $('description-text').value, | 99 $('description-text').value, |
| 96 imagePath]; | 100 imagePath]; |
| 97 | 101 |
| 98 // Add chromeos data if it exists. | 102 // Add chromeos data if it exists. |
| 99 if ($('user-email-text') && $('sys-info-checkbox')) { | 103 if ($('user-email-text') && $('sys-info-checkbox')) { |
| 100 reportArray = reportArray.concat([$('user-email-text').value, | 104 var userEmail= $('user-email-text').textContent; |
| 105 if (!$('user-email-checkbox').checked) |
| 106 userEmail = ''; |
| 107 reportArray = reportArray.concat([userEmail, |
| 101 String($('sys-info-checkbox').checked)]); | 108 String($('sys-info-checkbox').checked)]); |
| 102 } | 109 } |
| 103 | 110 |
| 104 // open the landing page in a new tab, sendReport will close this one. | 111 // open the landing page in a new tab, sendReport will close this one. |
| 105 window.open(FEEDBACK_LANDING_PAGE, '_blank'); | 112 window.open(FEEDBACK_LANDING_PAGE, '_blank'); |
| 106 chrome.send('sendReport', reportArray); | 113 chrome.send('sendReport', reportArray); |
| 107 return true; | 114 return true; |
| 108 } | 115 } |
| 109 | 116 |
| 110 function cancel() { | 117 function cancel() { |
| 111 chrome.send('cancel', []); | 118 chrome.send('cancel', []); |
| 112 return true; | 119 return true; |
| 113 } | 120 } |
| 114 | 121 |
| 115 /** | 122 /** |
| 116 * Select the current screenshots div, restoring the image that was | 123 * Select the current screenshots div, restoring the image that was |
| 117 * selected when we had this div open previously. | 124 * selected when we had this div open previously. |
| 118 */ | 125 */ |
| 119 function currentSelected() { | 126 function currentSelected() { |
| 127 // TODO(rkc): Change this to use a class instead. |
| 120 $('current-screenshots').style.display = 'block'; | 128 $('current-screenshots').style.display = 'block'; |
| 121 if ($('saved-screenshots')) | 129 if ($('saved-screenshots')) |
| 122 $('saved-screenshots').style.display = 'none'; | 130 $('saved-screenshots').style.display = 'none'; |
| 123 | 131 |
| 124 if (selectedThumbnailDivId != 'current-screenshots') | 132 if (selectedThumbnailDivId != 'current-screenshots') |
| 125 selectImage('current-screenshots', | 133 selectImage('current-screenshots', |
| 126 savedThumbnailIds['current-screenshots']); | 134 savedThumbnailIds['current-screenshots']); |
| 127 | 135 |
| 128 return true; | 136 return true; |
| 129 } | 137 } |
| 130 | 138 |
| 131 /** | 139 /** |
| 132 * Select the saved screenshots div, restoring the image that was | 140 * Select the saved screenshots div, restoring the image that was |
| 133 * selected when we had this div open previously. | 141 * selected when we had this div open previously. |
| 134 */ | 142 */ |
| 135 function savedSelected() { | 143 function savedSelected() { |
| 136 $('current-screenshots').style.display = 'none'; | 144 $('current-screenshots').style.display = 'none'; |
| 137 $('saved-screenshots').style.display = 'block'; | |
| 138 | 145 |
| 139 if (selectedThumbnailDivId != 'saved-screenshots') | 146 if ($('saved-screenshots').childElementCount == 0) { |
| 140 selectImage('saved-screenshots', savedThumbnailIds['saved-screenshots']); | 147 // setupSavedScreenshots will take care of changing visibility |
| 148 chrome.send('refreshSavedScreenshots', []); |
| 149 } else { |
| 150 $('saved-screenshots').style.display = 'block'; |
| 151 if (selectedThumbnailDivId != 'saved-screenshots') |
| 152 selectImage('saved-screenshots', savedThumbnailIds['saved-screenshots']); |
| 153 } |
| 141 | 154 |
| 142 return true; | 155 return true; |
| 143 } | 156 } |
| 144 | 157 |
| 158 |
| 145 /** | 159 /** |
| 146 * Unselect all screenshots divs. | 160 * Change the type of screenshot we're showing to the user from |
| 161 * the current screenshot to saved screenshots |
| 147 */ | 162 */ |
| 148 function noneSelected() { | 163 function changeToSaved() { |
| 149 $('current-screenshots').style.display = 'none'; | 164 $('screenshot-label-current').style.display = 'none'; |
| 150 if ($('saved-screenshots')) | 165 $('screenshot-label-saved').style.display = 'inline'; |
| 151 $('saved-screenshots').style.display = 'none'; | |
| 152 | 166 |
| 153 selectedThumbnailDivId = ''; | 167 // Change the link to say "go to original" |
| 154 selectedThumbnailId = ''; | 168 $('screenshot-link-tosaved').style.display = 'none'; |
| 155 return true; | 169 $('screenshot-link-tocurrent').style.display = 'inline'; |
| 170 |
| 171 savedSelected(); |
| 156 } | 172 } |
| 173 |
| 174 /** |
| 175 * Change the type of screenshot we're showing to the user from |
| 176 * the saved screenshots to the current screenshots |
| 177 */ |
| 178 function changeToCurrent() { |
| 179 $('screenshot-label-current').style.display = 'inline'; |
| 180 $('screenshot-label-saved').style.display = 'none'; |
| 181 |
| 182 // Change the link to say "go to original" |
| 183 $('screenshot-link-tosaved').style.display = 'inline'; |
| 184 $('screenshot-link-tocurrent').style.display = 'none'; |
| 185 |
| 186 currentSelected(); |
| 187 } |
| OLD | NEW |