OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 /** | 5 /** |
6 * WebUI to monitor the Sync File System Service. | 6 * WebUI to monitor the Sync File System Service. |
7 */ | 7 */ |
8 var SyncService = (function() { | 8 var SyncService = (function() { |
9 'use strict'; | 9 'use strict'; |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 * Handles callback from getUpdateLog. | 62 * Handles callback from getUpdateLog. |
63 * @param {Array} list List of dictionaries containing 'id', 'time', 'logEvent'. | 63 * @param {Array} list List of dictionaries containing 'id', 'time', 'logEvent'. |
64 */ | 64 */ |
65 SyncService.onGetLog = function(logEntries) { | 65 SyncService.onGetLog = function(logEntries) { |
66 var itemContainer = $('log-entries'); | 66 var itemContainer = $('log-entries'); |
67 for (var i = 0; i < logEntries.length; i++) { | 67 for (var i = 0; i < logEntries.length; i++) { |
68 var logEntry = logEntries[i]; | 68 var logEntry = logEntries[i]; |
69 var tr = document.createElement('tr'); | 69 var tr = document.createElement('tr'); |
70 var error = /ERROR/.test(logEntry.logEvent) ? ' error' : ''; | 70 var error = /ERROR/.test(logEntry.logEvent) ? ' error' : ''; |
71 tr.appendChild(createElementFromText('td', logEntry.time, | 71 tr.appendChild(createElementFromText('td', logEntry.time, |
72 {class: 'log-time'})); | 72 {'class': 'log-time'})); |
73 tr.appendChild(createElementFromText('td', logEntry.logEvent, | 73 tr.appendChild(createElementFromText('td', logEntry.logEvent, |
74 {class: 'log-event' + error})); | 74 {'class': 'log-event' + error})); |
75 itemContainer.appendChild(tr); | 75 itemContainer.appendChild(tr); |
76 | 76 |
77 lastLogEventId = logEntry.id; | 77 lastLogEventId = logEntry.id; |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 /** | 81 /** |
82 * Get initial sync service values and set listeners to get updated values. | 82 * Get initial sync service values and set listeners to get updated values. |
83 */ | 83 */ |
84 function main() { | 84 function main() { |
85 cr.ui.decorate('tabbox', cr.ui.TabBox); | 85 cr.ui.decorate('tabbox', cr.ui.TabBox); |
86 $('clear-log-button').addEventListener('click', clearLogs); | 86 $('clear-log-button').addEventListener('click', clearLogs); |
87 getServiceStatus(); | 87 getServiceStatus(); |
88 getNotificationSource(); | 88 getNotificationSource(); |
89 | 89 |
90 // TODO: Look for a way to push entries to the page when necessary. | 90 // TODO: Look for a way to push entries to the page when necessary. |
91 window.setInterval(getLog, 1000); | 91 window.setInterval(getLog, 1000); |
92 } | 92 } |
93 | 93 |
94 document.addEventListener('DOMContentLoaded', main); | 94 document.addEventListener('DOMContentLoaded', main); |
95 return SyncService; | 95 return SyncService; |
96 })(); | 96 })(); |
OLD | NEW |