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 // The <ul> holding the audio streams. | |
| 6 var audioStreams; | |
| 7 | |
| 8 // Returns the first item in itemList with id > item.id or null if none exist. | |
| 9 getFollowing = function(item, itemList) { | |
| 10 var length = itemList.length; | |
| 11 for (var i = 0; i < length; i++) { | |
| 12 if (itemList[i].id > item.id) | |
| 13 return itemList(i); | |
| 14 } | |
| 15 return null; | |
| 16 }; | |
| 17 | |
| 18 // Returns an English description of the status of |stream|. | |
|
scherkus (not reviewing)
2011/07/01 17:47:42
nit: s/an English/a text/ ?
Scott Franklin
2011/07/02 00:57:20
Done.
| |
| 19 audioStreamDetails = function(stream) { | |
| 20 return stream.id + ' is ' + (stream.playing ? 'playing' : 'paused') + | |
| 21 ' at ' + Math.round(stream.volume*100) + '% volume.'; | |
|
scherkus (not reviewing)
2011/07/01 17:47:42
nit: spacing on *
Scott Franklin
2011/07/02 00:57:20
Done.
| |
| 22 }; | |
| 23 | |
| 24 onAudioUpdate = function(args) { | |
| 25 var stream = document.getElementById(args.id); | |
| 26 if(!stream) { | |
|
scherkus (not reviewing)
2011/07/01 17:47:42
nit: spacing
Scott Franklin
2011/07/02 00:57:20
Line removed.
| |
| 27 stream=document.createElement('li'); | |
|
scherkus (not reviewing)
2011/07/01 17:47:42
nit: spacing on =
Scott Franklin
2011/07/02 00:57:20
Line removed.
| |
| 28 stream.setAttribute('id', args.id); | |
| 29 | |
| 30 // Insert the new stream into the sorted list. | |
| 31 audioStreams.insertBefore( | |
| 32 stream, getFollowing(stream, audioStreams.children)); | |
| 33 } | |
| 34 stream.innerHTML = audioStreamDetails(args); | |
| 35 stream.className = args.status; | |
| 36 }; | |
| 37 | |
| 38 onReceiveEverything = function(args) { | |
| 39 for (i in args.audio_streams) { | |
| 40 for (j in args.audio_streams[i]) { | |
| 41 for (k in args.audio_streams[i][j]) { | |
| 42 onAudioUpdate(args.audio_streams[i][j][k]); | |
| 43 } | |
| 44 } | |
| 45 } | |
| 46 }; | |
| 47 | |
| 48 onItemDeleted = function(args) { | |
| 49 var stream = document.getElementById(args); | |
| 50 if(stream) | |
|
scherkus (not reviewing)
2011/07/01 17:47:42
nit: spacing
Scott Franklin
2011/07/02 00:57:20
Line removed.
| |
| 51 audioStreams.removeChild(stream); | |
| 52 }; | |
| 53 | |
| 54 window.onload = function() { | |
| 55 audioStreams = document.getElementById('audio_streams'); | |
| 56 | |
| 57 // Get information about all currently active media. | |
| 58 chrome.send('getEverything'); | |
| 59 }; | |
| OLD | NEW |