summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/bug_report.js
diff options
context:
space:
mode:
authorrkc@google.com <rkc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-19 17:42:20 +0000
committerrkc@google.com <rkc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-19 17:42:20 +0000
commit74a9f9f48c5832f548368eb8b43933f6b2a10e60 (patch)
tree5067464449bbb6725d8daaec1dc9399eb0866ab2 /chrome/browser/resources/bug_report.js
parent4685af7696690319a792030aafb329169cb93fa2 (diff)
downloadchromium_src-74a9f9f48c5832f548368eb8b43933f6b2a10e60.zip
chromium_src-74a9f9f48c5832f548368eb8b43933f6b2a10e60.tar.gz
chromium_src-74a9f9f48c5832f548368eb8b43933f6b2a10e60.tar.bz2
Checkin for CL: http://codereview.chromium.org/3061044/show
TEST=Backend: Various reports submitted from Chrome OS and Windows builds sent to the feedback test server. For Chromium OS, sent reports with current screenshot and saved screenshots; verified all reports for data accuracy and completion. Frontend: Tested the UI features by excersizing various options; tested not selecting any issue, tested switching between screenshot types. Review URL: http://codereview.chromium.org/3181027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56708 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources/bug_report.js')
-rw-r--r--chrome/browser/resources/bug_report.js152
1 files changed, 152 insertions, 0 deletions
diff --git a/chrome/browser/resources/bug_report.js b/chrome/browser/resources/bug_report.js
new file mode 100644
index 0000000..508a954
--- /dev/null
+++ b/chrome/browser/resources/bug_report.js
@@ -0,0 +1,152 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Constants.
+var FEEDBACK_LANDING_PAGE =
+ 'http://www.google.com/support/chrome/go/feedback_confirmation'
+
+var selectedThumbnailDivId = '';
+var selectedThumbnailId = '';
+var selectedImageUrl;
+
+var savedThumbnailIds = [];
+savedThumbnailIds['current-screenshots'] = '';
+savedThumbnailIds['saved-screenshots'] = '';
+
+var localStrings = new LocalStrings();
+
+/**
+ * Selects an image thumbnail in the specified div.
+ */
+function selectImage(divId, thumbnailId) {
+ var thumbnailDivs = $(divId).children;
+ selectedThumbnailDivId = divId;
+ for (var i = 0; i < thumbnailDivs.length; i++) {
+ // If the the current div matches the thumbnail id provided,
+ // or there is no thumbnail id given, and we're at the first thumbnail.
+ if ((thumbnailDivs[i].id == thumbnailId) || (!thumbnailId && !i)) {
+ thumbnailDivs[i].className = 'image-thumbnail-container-selected';
+ selectedThumbnailId = thumbnailId;
+ savedThumbnailIds[divId] = thumbnailId;
+ } else {
+ thumbnailDivs[i].className = 'image-thumbnail-container';
+ }
+ }
+}
+
+/**
+ * Adds an image thumbnail to the specified div.
+ */
+function addScreenshot(divId, screenshot) {
+ var thumbnailDiv = document.createElement('div');
+ thumbnailDiv.className = 'image-thumbnail-container';
+
+ thumbnailDiv.id = divId + '-thumbnailDiv-' + $(divId).children.length;
+ thumbnailDiv.onclick = function() {
+ selectImage(divId, thumbnailDiv.id);
+ };
+
+ var innerDiv = document.createElement('div');
+ innerDiv.className = 'image-thumbnail';
+
+ var thumbnail = document.createElement('img');
+ thumbnail.id = thumbnailDiv.id + '-image';
+ thumbnail.src = screenshot;
+ innerDiv.appendChild(thumbnail);
+
+ var largeImage = document.createElement('img');
+ largeImage.src = screenshot;
+
+ var popupDiv = document.createElement('div');
+ popupDiv.appendChild(largeImage);
+ innerDiv.appendChild(popupDiv);
+
+ thumbnailDiv.appendChild(innerDiv);
+ $(divId).appendChild(thumbnailDiv);
+
+ if (!selectedThumbnailId)
+ selectImage(divId, thumbnailDiv.id);
+}
+
+/**
+ * Send's the report; after the report is sent, we need to be redirected to
+ * the landing page, but we shouldn't be able to navigate back, hence
+ * we open the landing page in a new tab and sendReport closes this tab.
+ */
+function sendReport() {
+ if (!$('issue-with-combo').selectedIndex) {
+ alert(localStrings.getString('no-issue-selected'));
+ return false;
+ }
+
+ var imagePath = '';
+ if (selectedThumbnailId)
+ imagePath = $(selectedThumbnailId + '-image').src;
+
+ // Note, categories are based from 1 in our protocol buffers, so no
+ // adjustment is needed on selectedIndex.
+ var reportArray = [String($('issue-with-combo').selectedIndex),
+ $('page-url-text').value,
+ $('description-text').value,
+ imagePath];
+
+ // Add chromeos data if it exists.
+ if ($('user-email-text') && $('sys-info-checkbox')) {
+ reportArray = reportArray.concat([$('user-email-text').value,
+ String($('sys-info-checkbox').checked)]);
+ }
+
+ // open the landing page in a new tab, sendReport will close this one.
+ window.open(FEEDBACK_LANDING_PAGE, '_blank');
+ chrome.send('sendReport', reportArray);
+ return true;
+}
+
+function cancel() {
+ chrome.send('cancel', []);
+ return true;
+}
+
+/**
+ * Select the current screenshots div, restoring the image that was
+ * selected when we had this div open previously.
+ */
+function currentSelected() {
+ $('current-screenshots').style.display = 'block';
+ if ($('saved-screenshots'))
+ $('saved-screenshots').style.display = 'none';
+
+ if (selectedThumbnailDivId != 'current-screenshots')
+ selectImage('current-screenshots',
+ savedThumbnailIds['current-screenshots']);
+
+ return true;
+}
+
+/**
+ * Select the saved screenshots div, restoring the image that was
+ * selected when we had this div open previously.
+ */
+function savedSelected() {
+ $('current-screenshots').style.display = 'none';
+ $('saved-screenshots').style.display = 'block';
+
+ if (selectedThumbnailDivId != 'saved-screenshots')
+ selectImage('saved-screenshots', savedThumbnailIds['saved-screenshots']);
+
+ return true;
+}
+
+/**
+ * Unselect all screenshots divs.
+ */
+function noneSelected() {
+ $('current-screenshots').style.display = 'none';
+ if ($('saved-screenshots'))
+ $('saved-screenshots').style.display = 'none';
+
+ selectedThumbnailDivId = '';
+ selectedThumbnailId = '';
+ return true;
+}