OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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 var playerListPainter = (function () { |
| 6 "use strict"; |
| 7 var playerListPainter = {}; |
| 8 |
| 9 playerListPainter.paintNew = function (playerInfo, div, opt_properties) { |
| 10 var ul = document.createElement('ul'); |
| 11 var playerManager = opt_properties.playerManager; |
| 12 |
| 13 goog.object.forEach(playerManager.players, function (player, id) { |
| 14 // If we have the opportunity to name it |
| 15 // something human readable, do so. |
| 16 |
| 17 var name; |
| 18 // If we have a url, use the file name (but not path) as the |
| 19 // name that is displayed |
| 20 if (player.properties.url) { |
| 21 var split = player.properties.url.split("/"); |
| 22 name = split[split.length - 1]; |
| 23 } |
| 24 |
| 25 name = name || player.properties.name || "player " + id; |
| 26 var li = document.createElement('li'); |
| 27 var btn = document.createElement('button'); |
| 28 |
| 29 btn.onclick = function () { |
| 30 playerManager.selectPlayer(id); |
| 31 }; |
| 32 |
| 33 btn.appendChild(document.createTextNode(name)); |
| 34 li.appendChild(btn); |
| 35 ul.appendChild(li); |
| 36 }); |
| 37 |
| 38 removeChildren(div); |
| 39 div.appendChild(ul); |
| 40 }; |
| 41 |
| 42 playerListPainter.paintExist = playerListPainter.paintNew; |
| 43 |
| 44 playerListPainter.invalidate = function () { |
| 45 }; |
| 46 |
| 47 return playerListPainter; |
| 48 }()); |
OLD | NEW |