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 |
| 6 var graphPainter = (function () { |
| 7 "use strict"; |
| 8 var graphPainter = {}; |
| 9 |
| 10 function updateBufferGraph(playerInfo, bufferGraph) { |
| 11 bufferGraph.setWidth(400); |
| 12 |
| 13 var p = playerInfo.properties; |
| 14 |
| 15 bufferGraph.plot(p.buffer_start, p.buffer_end); |
| 16 bufferGraph.plot(p.buffer_start, p.buffer_current); |
| 17 bufferGraph.draw(); |
| 18 } |
| 19 |
| 20 graphPainter.paintNew = function (playerInfo, div, options) { |
| 21 removeChildren(div); |
| 22 |
| 23 var p = playerInfo.properties; |
| 24 |
| 25 // If we can, make a new graph for the buffer status |
| 26 if (p.buffer_start !== undefined && p.buffer_current !== undefined && |
| 27 p.buffer_end !== undefined && p.total_bytes !== undefined) { |
| 28 |
| 29 var bufferGraph = new RangeGraph(p.total_bytes); |
| 30 updateBufferGraph(playerInfo, bufferGraph); |
| 31 bufferGraph.element.setAttribute('id', "buffer-graph"); |
| 32 bufferGraph.element.setAttribute('style', "vertical-align:middle;"); |
| 33 |
| 34 |
| 35 div.appendChild(document.createTextNode("Buffer\u00a0")); |
| 36 div.appendChild(bufferGraph.element); |
| 37 } |
| 38 |
| 39 }; |
| 40 graphPainter.paintExist = function (playerInfo, div, options) { |
| 41 var bufferGraphElem = div.querySelector("#buffer-graph"); |
| 42 |
| 43 if (bufferGraphElem) { |
| 44 // Use the 'existing' constructor for RangeGraph to |
| 45 // build it off of the existing bufferGraphElem |
| 46 var bufferGraph = new RangeGraph(playerInfo.properties.total_bytes, |
| 47 bufferGraphElem); |
| 48 updateBufferGraph(playerInfo, bufferGraph); |
| 49 } |
| 50 }; |
| 51 graphPainter.invalidate = function () { |
| 52 }; |
| 53 |
| 54 return graphPainter; |
| 55 }()); |
OLD | NEW |