34 Components.utils.import(
"resource://app/jsmodules/DOMUtils.jsm");
35 Components.utils.import(
"resource://app/jsmodules/SBJobUtils.jsm");
36 Components.utils.import(
"resource://app/jsmodules/StringUtils.jsm");
38 if (typeof(
Cc) ==
"undefined")
39 var
Cc = Components.classes;
40 if (typeof(
Ci) ==
"undefined")
41 var
Ci = Components.interfaces;
42 if (typeof(
Cr) ==
"undefined")
43 var
Cr = Components.results;
44 if (typeof(
Cu) ==
"undefined")
45 var
Cu = Components.utils;
47 var playbackPrefsUI = {
48 _outputBufferMin: 100,
49 _outputBufferMax: 10000,
50 _outputBufferMaxDigits: 5,
52 _streamingBufferMin: 32,
53 _streamingBufferMax: 10240,
54 _streamingBufferMaxDigits: 5,
56 _outputBufferTextbox:
null,
57 _streamingBufferTextbox:
null,
59 initialize:
function playbackPrefsUI_initialize() {
60 this._outputBufferTextbox = document.getElementById(
"playback_output_buffer_textbox");
61 this._streamingBufferTextbox = document.getElementById(
"playback_streaming_buffer_textbox");
66 doOnOutputBufferChange:
function playbackPrefsUI_doOnOutputBufferChange() {
67 var bufferVal = this._getPrefElemValue(this._getPrefElem(
"output_buffer_pref"));
68 this._verifyIntValueBounds(this._outputBufferTextbox,
70 this._outputBufferMin,
71 this._outputBufferMax);
74 doOnOutputBufferKeypress:
function playbackPrefsUI_doOnOutputBufferKeypress(aEvent) {
75 this._verifyIntInputValue(aEvent,
76 this._outputBufferTextbox,
77 this._outputBufferMin,
78 this._outputBufferMax,
79 this._outputBufferMaxDigits);
82 doOnStreamingBufferChange:
function playbackPrefsUI_doOnStreamingBufferChange() {
83 var streamingVal = this._getPrefElemValue(this._getPrefElem(
"streaming_buffer_pref"));
84 this._verifyIntValueBounds(this._streamingBufferTextbox,
86 this._streamingBufferMin,
87 this._streamingBufferMax);
90 doOnStreamingBufferKeypress:
function playbackPrefsUI_doOnStreamingBufferKeypress(aEvent) {
91 this._verifyIntInputValue(aEvent,
92 this._streamingBufferTextbox,
93 this._streamingBufferMin,
94 this._streamingBufferMax,
95 this._streamingBufferMaxDigits);
98 doOnNormalizationEnabledChange:
99 function playbackPrefsUI_doOnNormalizationEnabledChange() {
101 !this._getPrefElemValue(this._getPrefElem(
"normalization_enabled_pref"));
103 var normalizeList = document.getElementById(
"playback_normalization_preferred_gain_list");
104 var normalizeLabel = document.getElementById(
"playback_normalization_preferred_gain_label");
106 normalizeList.setAttribute(
"disabled", normalize);
107 normalizeLabel.setAttribute(
"disabled", normalize);
110 _update:
function playbackPrefsUI__update() {
111 this.doOnOutputBufferChange();
112 this.doOnNormalizationEnabledChange();
124 _getPrefElem:
function playback__getPrefElem(aPrefID) {
126 var prefElemList = DOMUtils.getElementsByAttribute(document,
129 if (!prefElemList || (prefElemList.length == 0))
132 return prefElemList[0];
144 _getPrefElemValue:
function playbackPrefsUI__getPrefElemValue(aElement) {
146 if (aElement.localName ==
"checkbox")
147 return aElement.checked;
149 return aElement.value;
152 _verifyIntValueBounds:
function playbackPrefsUI__verifyIntValueBounds(aElement,
158 aElement.setAttribute(
"invalid",
true);
160 else if(aElement.hasAttribute(
"invalid")){
161 aElement.removeAttribute(
"invalid");
165 _verifyIntInputValue:
function playbackPrefsUI__verifyIntInputValue(aEvent,
168 if (!aEvent.ctrlKey && !aEvent.metaKey && !aEvent.altKey && aEvent.charCode) {
169 if (aEvent.charCode < 48 || aEvent.charCode > 57) {
170 aEvent.preventDefault();
172 }
else if (aElement.value.length + 1 > aMaxDigits &&
173 aElement.selectionStart == aElement.selectionEnd) {
174 aEvent.preventDefault();
191 var playbackPrefsPane = {
192 doPaneLoad:
function playbackPrefsPane_doPaneLoad() {
193 playbackPrefsUI.initialize();