Chromium Code Reviews| 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) { | |
| 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 while (crashSection.firstChild) { | |
| 36 crashSection.removeChild(crashSection.firstChild); | |
| 37 } | |
|
Nico
2011/02/18 18:16:01
crashSection.innerHTML = "";
?
stuartmorgan
2011/02/18 19:41:21
Done.
| |
| 38 | |
| 39 for (var i = 0; i < crashes.length; i++) { | |
| 40 var crash = crashes[i]; | |
| 41 | |
| 42 var crashBlock = document.createElement('div'); | |
| 43 var title = document.createElement('h3'); | |
| 44 title.textContent = localStrings.getStringF('crashHeaderFormat', | |
| 45 crash['id']); | |
| 46 crashBlock.appendChild(title); | |
| 47 var date = document.createElement('p'); | |
| 48 date.textContent = localStrings.getStringF('crashTimeFormat', | |
| 49 crash['time']); | |
| 50 crashBlock.appendChild(date); | |
| 51 var linkBlock = document.createElement('p'); | |
| 52 var link = document.createElement('a'); | |
| 53 link.href = 'http://code.google.com/p/chromium/issues/entry?' + | |
| 54 'comment=URL%20(if%20applicable)%20where%20crash%20occurred:%20%0A%0A' + | |
| 55 'What%20steps%20will%20reproduce%20this%20crash?%0A1.%0A2.%0A3.%0A%0A' + | |
| 56 '****DO%20NOT%20CHANGE%20BELOW%20THIS%20LINE****%0Areport_id:' + | |
| 57 crash['id']; | |
| 58 link.target = '_blank'; | |
| 59 link.textContent = localStrings.getString('bugLinkText'); | |
| 60 linkBlock.appendChild(link); | |
| 61 crashBlock.appendChild(linkBlock); | |
| 62 crashSection.appendChild(crashBlock); | |
|
Nico
2011/02/18 18:16:01
Have you considered using our html templating engi
stuartmorgan
2011/02/18 19:41:21
I don't see a way to do it offhand. I can revisit
| |
| 63 } | |
| 64 | |
| 65 if (crashes.length == 0) | |
| 66 $('noCrashes').classList.remove('hidden'); | |
| 67 else | |
| 68 $('noCrashes').classList.add('hidden'); | |
| 69 } | |
| 70 | |
| 71 document.addEventListener('DOMContentLoaded', requestCrashes); | |
| OLD | NEW |