OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @param {!HTMLSelectElement} selectElement | 7 * @param {!HTMLSelectElement} selectElement |
8 */ | 8 */ |
9 WebInspector.NetworkConditionsSelector = function(selectElement) | 9 WebInspector.NetworkConditionsSelector = function(selectElement) |
10 { | 10 { |
(...skipping 27 matching lines...) Expand all Loading... | |
38 var preset = presets[i]; | 38 var preset = presets[i]; |
39 var throughputInKbps = preset.value.throughput / (1024 / 8); | 39 var throughputInKbps = preset.value.throughput / (1024 / 8); |
40 var isThrottling = (throughputInKbps > 0) || preset.value.latency; | 40 var isThrottling = (throughputInKbps > 0) || preset.value.latency; |
41 var option; | 41 var option; |
42 if (!isThrottling) { | 42 if (!isThrottling) { |
43 option = new Option(preset.title, preset.title); | 43 option = new Option(preset.title, preset.title); |
44 } else { | 44 } else { |
45 var throughputText = (throughputInKbps < 1024) ? WebInspector.UI String("%d Kbps", throughputInKbps) : WebInspector.UIString("%d Mbps", (throughp utInKbps / 1024) | 0); | 45 var throughputText = (throughputInKbps < 1024) ? WebInspector.UI String("%d Kbps", throughputInKbps) : WebInspector.UIString("%d Mbps", (throughp utInKbps / 1024) | 0); |
46 var title = WebInspector.UIString("%s (%s %dms RTT)", preset.tit le, throughputText, preset.value.latency); | 46 var title = WebInspector.UIString("%s (%s %dms RTT)", preset.tit le, throughputText, preset.value.latency); |
47 option = new Option(title, preset.title); | 47 option = new Option(title, preset.title); |
48 option.title = WebInspector.UIString("Maximum download throughpu t: %s.\r\nMinimum round-trip time: %dms.", throughputText, preset.value.latency) ; | |
paulirish
2015/08/03 16:26:20
http://i.imgur.com/zCPwEXx.png
"RTT" is somethin
samli
2015/08/05 07:53:30
This must be platform specific, I can't see that o
| |
49 } | 48 } |
50 option.settingValue = preset.value; | 49 option.settingValue = preset.value; |
51 this._selectElement.appendChild(option); | 50 this._selectElement.appendChild(option); |
52 } | 51 } |
53 }, | 52 }, |
54 | 53 |
55 _optionSelected: function() | 54 _optionSelected: function() |
56 { | 55 { |
57 this._setting.removeChangeListener(this._settingChanged, this); | 56 this._setting.removeChangeListener(this._settingChanged, this); |
58 this._setting.set(this._selectElement.options[this._selectElement.select edIndex].settingValue); | 57 this._setting.set(this._selectElement.options[this._selectElement.select edIndex].settingValue); |
59 this._setting.addChangeListener(this._settingChanged, this); | 58 this._setting.addChangeListener(this._settingChanged, this); |
60 }, | 59 }, |
61 | 60 |
62 _settingChanged: function() | 61 _settingChanged: function() |
63 { | 62 { |
64 var value = this._setting.get(); | 63 var value = this._setting.get(); |
65 var options = this._selectElement.options; | 64 var options = this._selectElement.options; |
66 for (var index = 0; index < options.length; ++index) { | 65 for (var index = 0; index < options.length; ++index) { |
67 var option = options[index]; | 66 var option = options[index]; |
68 if (option.settingValue.throughput === value.throughput && option.se ttingValue.latency === value.latency) | 67 if (option.settingValue.throughput === value.throughput && option.se ttingValue.latency === value.latency) |
69 this._selectElement.selectedIndex = index; | 68 this._selectElement.selectedIndex = index; |
70 } | 69 } |
71 } | 70 } |
72 } | 71 } |
OLD | NEW |