Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(531)

Side by Side Diff: chrome/browser/resources/feedback.js

Issue 9006003: Refactor and fix feedback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 2011 -> 2012 Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/feedback.html ('k') | chrome/browser/resources/feedback_invalid.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 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 =
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 = "";
18
17 var localStrings = new LocalStrings(); 19 var localStrings = new LocalStrings();
18 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';
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 if (!selectedThumbnailId) 72 if (!selectedThumbnailId)
71 selectImage(divId, thumbnailDiv.id); 73 selectImage(divId, thumbnailDiv.id);
72 } 74 }
73 75
74 /** 76 /**
75 * 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
76 * 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
77 * 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.
78 */ 80 */
79 function sendReport() { 81 function sendReport() {
80 if (!$('issue-with-combo').selectedIndex) { 82 if ($('description-text').value.length == 0) {
81 alert(localStrings.getString('no-issue-selected'));
82 return false;
83 } else if ($('description-text').value.length == 0) {
84 alert(localStrings.getString('no-description')); 83 alert(localStrings.getString('no-description'));
85 return false; 84 return false;
86 } 85 }
87 86
88 var imagePath = ''; 87 var imagePath = '';
89 if ($('screenshot-checkbox').checked && selectedThumbnailId) 88 if ($('screenshot-checkbox').checked && selectedThumbnailId)
90 imagePath = $(selectedThumbnailId + '-image').src; 89 imagePath = $(selectedThumbnailId + '-image').src;
91 var pageUrl = $('page-url-text').value; 90 var pageUrl = $('page-url-text').value;
92 if (!$('page-url-checkbox').checked) 91 if (!$('page-url-checkbox').checked)
93 pageUrl = ''; 92 pageUrl = '';
94 93
95 // Note, categories are based from 1 in our protocol buffers, so no 94 var reportArray = [pageUrl,
96 // adjustment is needed on selectedIndex. 95 categoryTag,
97 var reportArray = [String($('issue-with-combo').selectedIndex),
98 pageUrl,
99 $('description-text').value, 96 $('description-text').value,
100 imagePath]; 97 imagePath];
101 98
102 // Add chromeos data if it exists. 99 // Add chromeos data if it exists.
103 if ($('user-email-text') && $('sys-info-checkbox')) { 100 if ($('user-email-text') && $('sys-info-checkbox')) {
104 var userEmail= $('user-email-text').textContent; 101 var userEmail= $('user-email-text').textContent;
105 if (!$('user-email-checkbox').checked) 102 if (!$('user-email-checkbox').checked)
106 userEmail = ''; 103 userEmail = '';
107 reportArray = reportArray.concat([userEmail, 104 reportArray = reportArray.concat([userEmail,
108 String($('sys-info-checkbox').checked)]); 105 String($('sys-info-checkbox').checked)]);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 $('cancel-button').onclick = cancel; 203 $('cancel-button').onclick = cancel;
207 204
208 var menuOffPattern = /(^\?|&)menu=off($|&)/; 205 var menuOffPattern = /(^\?|&)menu=off($|&)/;
209 var menuDisabled = menuOffPattern.test(window.location.search); 206 var menuDisabled = menuOffPattern.test(window.location.search);
210 document.documentElement.setAttribute('hide-menu', menuDisabled); 207 document.documentElement.setAttribute('hide-menu', menuDisabled);
211 208
212 // Set default values for the possible parameters, and then parse the actual 209 // Set default values for the possible parameters, and then parse the actual
213 // values from the URL hash. 210 // values from the URL hash.
214 var parameters = { 211 var parameters = {
215 'description': '', 212 'description': '',
216 'issueType': 0, 213 'categoryTag': '',
217 }; 214 };
218 var queryPos = window.location.hash.indexOf('?'); 215 var queryPos = window.location.hash.indexOf('?');
219 if (queryPos !== -1) { 216 if (queryPos !== -1) {
220 // Get an array of parameters in 'name=value' form. 217 // Get an array of parameters in 'name=value' form.
221 var query = window.location.hash.substring(queryPos + 1).split('&'); 218 var query = window.location.hash.substring(queryPos + 1).split('&');
222 for (var i = 0; i < query.length; i++) { 219 for (var i = 0; i < query.length; i++) {
223 // Decode and store each parameter value. 220 // Decode and store each parameter value.
224 parameter = query[i].split('='); 221 parameter = query[i].split('=');
225 parameters[parameter[0]] = decodeURIComponent(parameter[1]); 222 parameters[parameter[0]] = decodeURIComponent(parameter[1]);
226 } 223 }
227 224
228 // For a clean URL, trim the parameters from the hash. 225 // For a clean URL, trim the parameters from the hash.
229 window.location.hash = window.location.hash.substring(0, queryPos); 226 window.location.hash = window.location.hash.substring(0, queryPos);
230 } 227 }
231 228
232 // Set the initial description text. 229 // Set the initial description text.
233 $('description-text').textContent = parameters['description']; 230 $('description-text').textContent = parameters['description'];
234 231
235 // Get a list of issues that we allow the user to select from. 232 // Pick up the category tag (for most cases this will be an empty string)
236 // Note, the order and the issues types themselves are different 233 categoryTag = parameters['categoryTag'];
237 // between Chromium and Chromium OS, so this code needs to be
238 // maintained individually between in these two sections.
239 var issueTypeText = [];
240 issueTypeText[0] = localStrings.getString('issue-choose');
241 <if expr="not pp_ifdef('chromeos')">
242 issueTypeText[1] = localStrings.getString('issue-page-formatting');
243 issueTypeText[2] = localStrings.getString('issue-page-load');
244 issueTypeText[3] = localStrings.getString('issue-plugins');
245 issueTypeText[4] = localStrings.getString('issue-tabs');
246 issueTypeText[5] = localStrings.getString('issue-sync');
247 issueTypeText[6] = localStrings.getString('issue-crashes');
248 issueTypeText[7] = localStrings.getString('issue-extensions');
249 issueTypeText[8] = localStrings.getString('issue-phishing');
250 issueTypeText[9] = localStrings.getString('issue-other');
251 var numDefaultIssues = issueTypeText.length;
252 issueTypeText[10] = localStrings.getString('issue-autofill');
253 </if>
254 <if expr="pp_ifdef('chromeos')">
255 issueTypeText[1] = localStrings.getString('issue-connectivity');
256 issueTypeText[2] = localStrings.getString('issue-sync');
257 issueTypeText[3] = localStrings.getString('issue-crashes');
258 issueTypeText[4] = localStrings.getString('issue-page-formatting');
259 issueTypeText[5] = localStrings.getString('issue-extensions');
260 issueTypeText[6] = localStrings.getString('issue-standby');
261 issueTypeText[7] = localStrings.getString('issue-phishing');
262 issueTypeText[8] = localStrings.getString('issue-other');
263 var numDefaultIssues = issueTypeText.length;
264 issueTypeText[9] = localStrings.getString('issue-autofill');
265 </if>
266 // Add all the issues to the selection box.
267 for (var i = 0; i < issueTypeText.length; i++) {
268 var option = document.createElement('option');
269 option.className = 'bug-report-text';
270 option.textContent = issueTypeText[i];
271 if (('' + i) === parameters['issueType'])
272 option.selected = true;
273
274 if (i < numDefaultIssues || option.selected)
275 $('issue-with-combo').add(option);
276 }
277 234
278 chrome.send('getDialogDefaults', []); 235 chrome.send('getDialogDefaults', []);
279 chrome.send('refreshCurrentScreenshot', []); 236 chrome.send('refreshCurrentScreenshot', []);
280 }; 237 };
281 238
282 function setupCurrentScreenshot(screenshot) { 239 function setupCurrentScreenshot(screenshot) {
283 addScreenshot('current-screenshots', screenshot); 240 addScreenshot('current-screenshots', screenshot);
284 } 241 }
285 242
286 function setupSavedScreenshots(screenshots) { 243 function setupSavedScreenshots(screenshots) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 $('user-email-table').style.display = 'none'; 277 $('user-email-table').style.display = 'none';
321 278
322 // this also means we are in privacy mode, so no saved screenshots. 279 // this also means we are in privacy mode, so no saved screenshots.
323 $('screenshot-link-tosaved').style.display = 'none'; 280 $('screenshot-link-tosaved').style.display = 'none';
324 } 281 }
325 } 282 }
326 } 283 }
327 } 284 }
328 285
329 window.addEventListener('DOMContentLoaded', load); 286 window.addEventListener('DOMContentLoaded', load);
OLDNEW
« no previous file with comments | « chrome/browser/resources/feedback.html ('k') | chrome/browser/resources/feedback_invalid.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698