OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 cr.define('errorCodes', function() { |
| 6 'use strict'; |
| 7 |
| 8 /** |
| 9 * Generate the page content. |
| 10 * @param {Array.<Object>} errorCodes Error codes array consisting of a |
| 11 * numerical error ID and error code string. |
| 12 */ |
| 13 function listErrorCodes(errorCodes) { |
| 14 var errorPageURL = 'chrome://network-error/'; |
| 15 var errorCodesList = document.createElement('ul'); |
| 16 for (var i = 0; i < errorCodes.length; i++) { |
| 17 var listEl = document.createElement('li'); |
| 18 var errorCodeLinkEl = document.createElement('a'); |
| 19 errorCodeLinkEl.href = errorPageURL + errorCodes[i].errorId; |
| 20 errorCodeLinkEl.textContent = errorCodes[i].errorCode + ' (' + |
| 21 errorCodes[i].errorId + ')'; |
| 22 listEl.appendChild(errorCodeLinkEl); |
| 23 errorCodesList.appendChild(listEl); |
| 24 } |
| 25 $('pages').appendChild(errorCodesList); |
| 26 } |
| 27 |
| 28 function initialize() { |
| 29 var xhr = new XMLHttpRequest(); |
| 30 xhr.open('GET', 'network-error-data.json', true); |
| 31 xhr.addEventListener('load', function(e) { |
| 32 if (xhr.status === 200) { |
| 33 var data = JSON.parse(xhr.responseText); |
| 34 listErrorCodes(data['errorCodes']); |
| 35 } |
| 36 }); |
| 37 xhr.send(null); |
| 38 } |
| 39 |
| 40 return { |
| 41 initialize: initialize |
| 42 }; |
| 43 }); |
| 44 |
| 45 document.addEventListener('DOMContentLoaded', errorCodes.initialize); |
OLD | NEW |