OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 localStrings = new LocalStrings(); | |
6 | |
7 /** | |
8 * Requests the list of crashes from the backend. | |
9 */ | |
10 function requestCrashes() { | |
11 chrome.send('requestCrashList', []) | |
12 } | |
13 | |
14 /** | |
15 * Callback from backend with the list of crashes. Builds the UI. | |
16 * @param {boolean} enabled Whether or not crash reporting is enabled. | |
17 * @param {array} crashes The list of crashes. | |
18 */ | |
19 function updateCrashList(enabled, crashes) { | |
20 $('countBanner').textContent = localStrings.getStringF('crashCountFormat', | |
21 crashes.length); | |
22 | |
23 var crashSection = $('crashList'); | |
24 | |
25 if (enabled) { | |
arv (Not doing code reviews)
2011/02/20 23:44:00
If you used HTML5 hidden property:
$('enabledMode
| |
26 $('enabledMode').classList.remove('hidden'); | |
27 $('disabledMode').classList.add('hidden'); | |
28 } else { | |
29 $('enabledMode').classList.add('hidden'); | |
30 $('disabledMode').classList.remove('hidden'); | |
31 return; | |
32 } | |
33 | |
34 // Clear any previous list. | |
35 crashSection.innerHTML = ''; | |
arv (Not doing code reviews)
2011/02/20 23:44:00
I prefer textContent = '' but no big deal.
| |
36 | |
37 for (var i = 0; i < crashes.length; i++) { | |
38 var crash = crashes[i]; | |
39 | |
40 var crashBlock = document.createElement('div'); | |
arv (Not doing code reviews)
2011/02/20 23:44:00
An alternative might have been to put this as mark
| |
41 var title = document.createElement('h3'); | |
42 title.textContent = localStrings.getStringF('crashHeaderFormat', | |
43 crash['id']); | |
44 crashBlock.appendChild(title); | |
45 var date = document.createElement('p'); | |
46 date.textContent = localStrings.getStringF('crashTimeFormat', | |
47 crash['time']); | |
48 crashBlock.appendChild(date); | |
49 var linkBlock = document.createElement('p'); | |
50 var link = document.createElement('a'); | |
51 link.href = 'http://code.google.com/p/chromium/issues/entry?' + | |
52 'comment=URL%20(if%20applicable)%20where%20crash%20occurred:%20%0A%0A' + | |
53 'What%20steps%20will%20reproduce%20this%20crash?%0A1.%0A2.%0A3.%0A%0A' + | |
54 '****DO%20NOT%20CHANGE%20BELOW%20THIS%20LINE****%0Areport_id:' + | |
55 crash['id']; | |
56 link.target = '_blank'; | |
57 link.textContent = localStrings.getString('bugLinkText'); | |
58 linkBlock.appendChild(link); | |
59 crashBlock.appendChild(linkBlock); | |
60 crashSection.appendChild(crashBlock); | |
61 } | |
62 | |
63 if (crashes.length == 0) | |
64 $('noCrashes').classList.remove('hidden'); | |
65 else | |
66 $('noCrashes').classList.add('hidden'); | |
67 } | |
68 | |
69 document.addEventListener('DOMContentLoaded', requestCrashes); | |
OLD | NEW |