Chromium Code Reviews| Index: chrome/browser/resources/media_internals.js |
| diff --git a/chrome/browser/resources/media_internals.js b/chrome/browser/resources/media_internals.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2b19c7c2164b1f046384a0851adb748e382c52e6 |
| --- /dev/null |
| +++ b/chrome/browser/resources/media_internals.js |
| @@ -0,0 +1,59 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// The <ul> holding the audio streams. |
| +var audioStreams; |
| + |
| +// Returns the first item in itemList with id > item.id or null if none exist. |
| +getFollowing = function(item, itemList) { |
| + var length = itemList.length; |
| + for (var i = 0; i < length; i++) { |
| + if (itemList[i].id > item.id) |
| + return itemList(i); |
| + } |
| + return null; |
| +}; |
| + |
| +// 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.
|
| +audioStreamDetails = function(stream) { |
| + return stream.id + ' is ' + (stream.playing ? 'playing' : 'paused') + |
| + ' 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.
|
| +}; |
| + |
| +onAudioUpdate = function(args) { |
| + var stream = document.getElementById(args.id); |
| + if(!stream) { |
|
scherkus (not reviewing)
2011/07/01 17:47:42
nit: spacing
Scott Franklin
2011/07/02 00:57:20
Line removed.
|
| + 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.
|
| + stream.setAttribute('id', args.id); |
| + |
| + // Insert the new stream into the sorted list. |
| + audioStreams.insertBefore( |
| + stream, getFollowing(stream, audioStreams.children)); |
| + } |
| + stream.innerHTML = audioStreamDetails(args); |
| + stream.className = args.status; |
| +}; |
| + |
| +onReceiveEverything = function(args) { |
| + for (i in args.audio_streams) { |
| + for (j in args.audio_streams[i]) { |
| + for (k in args.audio_streams[i][j]) { |
| + onAudioUpdate(args.audio_streams[i][j][k]); |
| + } |
| + } |
| + } |
| +}; |
| + |
| +onItemDeleted = function(args) { |
| + var stream = document.getElementById(args); |
| + if(stream) |
|
scherkus (not reviewing)
2011/07/01 17:47:42
nit: spacing
Scott Franklin
2011/07/02 00:57:20
Line removed.
|
| + audioStreams.removeChild(stream); |
| +}; |
| + |
| +window.onload = function() { |
| + audioStreams = document.getElementById('audio_streams'); |
| + |
| + // Get information about all currently active media. |
| + chrome.send('getEverything'); |
| +}; |