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