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 cr.define('media', function() { | |
| 6 'use strict'; | |
| 7 | |
| 8 /** | |
| 9 * This class holds a list of MediaLogEvents. | |
| 10 * It inherits from <li> and contains a tabular list of said events, | |
| 11 * the time at which they occurred, and their parameters. | |
| 12 */ | |
| 13 var EventList = cr.ui.define('li'); | |
| 14 | |
| 15 EventList.prototype = { | |
| 16 __proto__: HTMLLIElement.prototype, | |
| 17 | |
| 18 /** | |
| 19 * Decorate this list item as an EventList. | |
| 20 */ | |
| 21 decorate: function() { | |
| 22 this.table_ = document.createElement('table'); | |
| 23 var details = document.createElement('details'); | |
| 24 var summary = media.makeElement('summary', 'Log:'); | |
| 25 details.appendChild(summary); | |
| 26 details.appendChild(this.table_); | |
| 27 this.appendChild(details); | |
| 28 | |
| 29 this.startTime_ = null; | |
|
arv (Not doing code reviews)
2011/09/22 19:26:04
This is better done on the prototype
startTime_:
scherkus (not reviewing)
2011/09/23 06:52:41
Done.
| |
| 30 | |
| 31 var hRow = document.createElement('tr'); | |
| 32 hRow.appendChild(media.makeElement('th', 'Time:')); | |
| 33 hRow.appendChild(media.makeElement('th', 'Event:')); | |
| 34 hRow.appendChild(media.makeElement('th', 'Parameters:')); | |
| 35 var header = document.createElement('thead'); | |
| 36 header.appendChild(hRow); | |
| 37 this.table_.appendChild(header); | |
| 38 }, | |
| 39 | |
| 40 /** | |
| 41 * Add an event to the list. It is stored as a new row in this.table_. | |
| 42 * @param {Object} event The MediaLogEvent that has occurred. | |
| 43 */ | |
| 44 addEvent: function(event) { | |
| 45 this.startTime_ = this.startTime_ || event.time; | |
| 46 event.time -= this.startTime_; | |
| 47 | |
| 48 var row = document.createElement('tr'); | |
| 49 row.appendChild(media.makeElement('td', media.round(event.time))); | |
| 50 row.appendChild(media.makeElement('td', event.type)); | |
| 51 var params = []; | |
| 52 for (var p in event.params) { | |
| 53 params.push(p + ': ' + event.params[p]); | |
| 54 } | |
| 55 | |
| 56 row.appendChild(media.makeElement('td', params.join(', '))); | |
| 57 this.table_.appendChild(row); | |
| 58 } | |
| 59 }; | |
| 60 | |
| 61 return { | |
| 62 EventList: EventList | |
| 63 }; | |
| 64 }); | |
| OLD | NEW |