Chromium Code Reviews| 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 (selectedThumbnailId) |
| 91 imagePath = $(selectedThumbnailId + '-image').src; | 90 imagePath = $(selectedThumbnailId + '-image').src; |
| 92 | 91 |
| 93 // Note, categories are based from 1 in our protocol buffers, so no | 92 // Note, categories are based from 1 in our protocol buffers, so no |
| 94 // adjustment is needed on selectedIndex. | 93 // adjustment is needed on selectedIndex. |
| 94 var pageUrl = $('page-url-text').value; | |
| 95 if (!$('page-url-checkbox').checked) | |
| 96 pageUrl = ""; | |
| 95 var reportArray = [String($('issue-with-combo').selectedIndex), | 97 var reportArray = [String($('issue-with-combo').selectedIndex), |
| 96 $('page-url-text').value, | 98 pageUrl, |
| 97 $('description-text').value, | 99 $('description-text').value, |
| 98 imagePath]; | 100 imagePath]; |
| 99 | 101 |
| 100 // Add chromeos data if it exists. | 102 // Add chromeos data if it exists. |
| 101 if ($('user-email-text') && $('sys-info-checkbox')) { | 103 if ($('user-email-text') && $('sys-info-checkbox')) { |
| 102 reportArray = reportArray.concat([$('user-email-text').value, | 104 var userEmail= $('user-email-text').value; |
| 105 if (!$('user-email-checkbox').checked) | |
| 106 userEmail = ""; | |
|
oshima
2010/11/29 19:09:22
single quote
rkc
2010/11/29 22:41:08
Done.
| |
| 107 reportArray = reportArray.concat([userEmail, | |
| 103 String($('sys-info-checkbox').checked)]); | 108 String($('sys-info-checkbox').checked)]); |
| 104 } | 109 } |
| 105 | 110 |
| 106 // 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. |
| 107 window.open(FEEDBACK_LANDING_PAGE, '_blank'); | 112 window.open(FEEDBACK_LANDING_PAGE, '_blank'); |
| 108 chrome.send('sendReport', reportArray); | 113 chrome.send('sendReport', reportArray); |
| 109 return true; | 114 return true; |
| 110 } | 115 } |
| 111 | 116 |
| 112 function cancel() { | 117 function cancel() { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 129 | 134 |
| 130 return true; | 135 return true; |
| 131 } | 136 } |
| 132 | 137 |
| 133 /** | 138 /** |
| 134 * Select the saved screenshots div, restoring the image that was | 139 * Select the saved screenshots div, restoring the image that was |
| 135 * selected when we had this div open previously. | 140 * selected when we had this div open previously. |
| 136 */ | 141 */ |
| 137 function savedSelected() { | 142 function savedSelected() { |
| 138 $('current-screenshots').style.display = 'none'; | 143 $('current-screenshots').style.display = 'none'; |
| 139 $('saved-screenshots').style.display = 'block'; | |
| 140 | 144 |
| 141 if (selectedThumbnailDivId != 'saved-screenshots') | 145 if ($('saved-screenshots').childElementCount == 0) { |
| 142 selectImage('saved-screenshots', savedThumbnailIds['saved-screenshots']); | 146 // setupSavedScreenshots will take care of changing visibility |
| 147 chrome.send('refreshSavedScreenshots', []); | |
| 148 } else { | |
| 149 $('saved-screenshots').style.display = 'block'; | |
| 150 if (selectedThumbnailDivId != 'saved-screenshots') | |
| 151 selectImage('saved-screenshots', savedThumbnailIds['saved-screenshots']); | |
| 152 } | |
| 143 | 153 |
| 144 return true; | 154 return true; |
| 145 } | 155 } |
| 146 | 156 |
| 147 /** | 157 /** |
| 148 * Unselect all screenshots divs. | 158 * Unselect all screenshots divs. |
| 149 */ | 159 */ |
| 150 function noneSelected() { | 160 function noneSelected() { |
| 151 $('current-screenshots').style.display = 'none'; | 161 $('current-screenshots').style.display = 'none'; |
| 152 if ($('saved-screenshots')) | 162 if ($('saved-screenshots')) |
| 153 $('saved-screenshots').style.display = 'none'; | 163 $('saved-screenshots').style.display = 'none'; |
| 154 | 164 |
| 155 selectedThumbnailDivId = ''; | 165 selectedThumbnailDivId = ''; |
| 156 selectedThumbnailId = ''; | 166 selectedThumbnailId = ''; |
| 157 return true; | 167 return true; |
| 158 } | 168 } |
| 169 | |
| 170 /** | |
| 171 * Toggle the type of screenshot we're showing to the user between | |
| 172 * the current screenshot, and a list of saved screenshots | |
| 173 */ | |
| 174 function toggleScreenshotType() { | |
| 175 // If we are showing the current screenshot, show the saved screenshots; | |
| 176 // otherwise, show the current screenshot. Update the text appropriately, | |
| 177 // the text is our marker to know what we are currently showing. | |
| 178 if ($('screenshot-label').innerHTML.indexOf( | |
| 179 localStrings.getString('current-screenshot')) > -1) { | |
| 180 // Switch to saved screenshots. | |
| 181 $('screenshot-label').innerHTML = $('screenshot-label').innerHTML.replace( | |
| 182 localStrings.getString('current-screenshot'), | |
| 183 localStrings.getString('saved-screenshot')); | |
| 184 | |
| 185 $('screenshot-link').innerHTML = $('screenshot-link').innerHTML.replace( | |
| 186 localStrings.getString('choose-different-screenshot'), | |
| 187 localStrings.getString('choose-original-screenshot')); | |
|
oshima
2010/11/29 19:09:22
This looks a bit hacky. can't this be done via css
rkc
2010/11/29 22:41:08
Done.
| |
| 188 | |
| 189 savedSelected(); | |
| 190 } else { | |
| 191 // Go back to current screenshot. | |
| 192 $('screenshot-label').innerHTML = $('screenshot-label').innerHTML.replace( | |
| 193 localStrings.getString('saved-screenshot'), | |
| 194 localStrings.getString('current-screenshot')); | |
| 195 | |
| 196 $('screenshot-link').innerHTML = $('screenshot-link').innerHTML.replace( | |
| 197 localStrings.getString('choose-original-screenshot'), | |
| 198 localStrings.getString('choose-different-screenshot')); | |
| 199 | |
| 200 currentSelected(); | |
| 201 } | |
| 202 } | |
| OLD | NEW |