OLD | NEW |
1 // Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 1 // Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
2 // | 2 // |
3 // Use of this source code is governed by a BSD-style license | 3 // Use of this source code is governed by a BSD-style license |
4 // that can be found in the LICENSE file in the root of the source | 4 // that can be found in the LICENSE file in the root of the source |
5 // tree. An additional intellectual property rights grant can be found | 5 // tree. An additional intellectual property rights grant can be found |
6 // in the file PATENTS. All contributing project authors may | 6 // in the file PATENTS. All contributing project authors may |
7 // be found in the AUTHORS file in the root of the source tree. | 7 // be found in the AUTHORS file in the root of the source tree. |
8 | 8 |
9 /** | 9 /** |
10 * Inspector UI class. | 10 * Inspector UI class. |
11 * @constructor | 11 * @constructor |
12 */ | 12 */ |
13 function Inspector() { | 13 function Inspector() { |
14 this.audioPlayer_ = new Audio(); | 14 this.audioPlayer_ = new Audio(); |
15 this.inspectorNode_ = document.createElement('div'); | 15 this.inspectorNode_ = document.createElement('div'); |
16 this.divNoiseGenerator_ = document.createElement('div'); | 16 this.divTestDataGeneratorName_ = document.createElement('div'); |
17 this.divNoiseParameters_ = document.createElement('div'); | 17 this.divTestDataGenParameters_ = document.createElement('div'); |
18 this.buttonPlayAudioIn_ = document.createElement('button'); | 18 this.buttonPlayAudioIn_ = document.createElement('button'); |
19 this.buttonPlayAudioOut_ = document.createElement('button'); | 19 this.buttonPlayAudioOut_ = document.createElement('button'); |
20 this.buttonPlayAudioRef_ = document.createElement('button'); | 20 this.buttonPlayAudioRef_ = document.createElement('button'); |
21 this.buttonStopAudio_ = document.createElement('button'); | 21 this.buttonStopAudio_ = document.createElement('button'); |
22 | 22 |
23 this.selectedItem_ = null; | 23 this.selectedItem_ = null; |
24 this.audioInUrl_ = null; | 24 this.audioInUrl_ = null; |
25 this.audioOutUrl_ = null; | 25 this.audioOutUrl_ = null; |
26 this.audioRefUrl_ = null; | 26 this.audioRefUrl_ = null; |
27 } | 27 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 * Open the inspector. | 72 * Open the inspector. |
73 * @param {DOMElement} target: score element that has been clicked. | 73 * @param {DOMElement} target: score element that has been clicked. |
74 */ | 74 */ |
75 Inspector.prototype.openInspector = function(target) { | 75 Inspector.prototype.openInspector = function(target) { |
76 if (this.selectedItem_ != null) { | 76 if (this.selectedItem_ != null) { |
77 this.selectedItem_.classList.remove('selected'); | 77 this.selectedItem_.classList.remove('selected'); |
78 } | 78 } |
79 this.selectedItem_ = target; | 79 this.selectedItem_ = target; |
80 this.selectedItem_.classList.add('selected'); | 80 this.selectedItem_.classList.add('selected'); |
81 | 81 |
82 var target = this.selectedItem_.querySelector('.noise-desc'); | 82 var target = this.selectedItem_.querySelector('.test-data-gen-desc'); |
83 var noiseName = target.querySelector('input[name=noise_name]').value; | 83 var testDataGenName = target.querySelector('input[name=gen_name]').value; |
84 var noiseParams = target.querySelector('input[name=noise_params]').value; | 84 var testDataGenParams = target.querySelector('input[name=gen_params]').value; |
85 var audioIn = target.querySelector('input[name=audio_in]').value; | 85 var audioIn = target.querySelector('input[name=audio_in]').value; |
86 var audioOut = target.querySelector('input[name=audio_out]').value; | 86 var audioOut = target.querySelector('input[name=audio_out]').value; |
87 var audioRef = target.querySelector('input[name=audio_ref]').value; | 87 var audioRef = target.querySelector('input[name=audio_ref]').value; |
88 | 88 |
89 this.divNoiseGenerator_.innerHTML = noiseName; | 89 this.divTestDataGeneratorName_.innerHTML = testDataGenName; |
90 this.divNoiseParameters_.innerHTML = noiseParams; | 90 this.divTestDataGenParameters_.innerHTML = testDataGenParams; |
91 | 91 |
92 this.audioInUrl_ = audioIn; | 92 this.audioInUrl_ = audioIn; |
93 this.audioOutUrl_ = audioOut; | 93 this.audioOutUrl_ = audioOut; |
94 this.audioRefUrl_ = audioRef; | 94 this.audioRefUrl_ = audioRef; |
95 }; | 95 }; |
96 | 96 |
97 /** | 97 /** |
98 * Play APM audio input signal. | 98 * Play APM audio input signal. |
99 */ | 99 */ |
100 Inspector.prototype.playAudioIn = function() { | 100 Inspector.prototype.playAudioIn = function() { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 this.audioPlayer_.play(); | 136 this.audioPlayer_.play(); |
137 }; | 137 }; |
138 | 138 |
139 /** | 139 /** |
140 * Build inspector. | 140 * Build inspector. |
141 */ | 141 */ |
142 Inspector.prototype.buildInspector_ = function() { | 142 Inspector.prototype.buildInspector_ = function() { |
143 var self = this; | 143 var self = this; |
144 | 144 |
145 this.inspectorNode_.setAttribute('class', 'inspector'); | 145 this.inspectorNode_.setAttribute('class', 'inspector'); |
146 this.inspectorNode_.innerHTML = '<div class="property noise-generator">' + | 146 this.inspectorNode_.innerHTML = |
147 '<div class="name">noise generator</div>' + | 147 '<div class="property test-data-gen-name">' + |
148 '</div>' + | 148 '<div class="name">test data generator</div>' + |
149 '<div class="property noise-parmas">' + | 149 '</div>' + |
150 '<div class="name">parameters</div>' + | 150 '<div class="property test-data-gen-parmas">' + |
151 '</div>' + | 151 '<div class="name">parameters</div>' + |
152 '<div class="buttons"></div>'; | 152 '</div>' + |
| 153 '<div class="buttons"></div>'; |
153 | 154 |
154 // Add value nodes. | 155 // Add value nodes. |
155 function addValueNode(node, parent_selector) { | 156 function addValueNode(node, parent_selector) { |
156 node.setAttribute('class', 'value'); | 157 node.setAttribute('class', 'value'); |
157 node.innerHTML = '-'; | 158 node.innerHTML = '-'; |
158 var parentNode = self.inspectorNode_.querySelector(parent_selector); | 159 var parentNode = self.inspectorNode_.querySelector(parent_selector); |
159 parentNode.appendChild(node); | 160 parentNode.appendChild(node); |
160 } | 161 } |
161 addValueNode(this.divNoiseGenerator_, 'div.noise-generator'); | 162 addValueNode(this.divTestDataGeneratorName_, 'div.test-data-gen-name'); |
162 addValueNode(this.divNoiseParameters_, 'div.noise-parmas'); | 163 addValueNode(this.divTestDataGenParameters_, 'div.test-data-gen-parmas'); |
163 | 164 |
164 // Add buttons. | 165 // Add buttons. |
165 var buttonsNode = this.inspectorNode_.querySelector('div.buttons'); | 166 var buttonsNode = this.inspectorNode_.querySelector('div.buttons'); |
166 function addButton(node, caption, callback) { | 167 function addButton(node, caption, callback) { |
167 node.innerHTML = caption; | 168 node.innerHTML = caption; |
168 buttonsNode.appendChild(node); | 169 buttonsNode.appendChild(node); |
169 node.onclick = callback.bind(self); | 170 node.onclick = callback.bind(self); |
170 } | 171 } |
171 addButton(this.buttonPlayAudioIn_, 'A_in (<strong>1</strong>)', | 172 addButton(this.buttonPlayAudioIn_, 'A_in (<strong>1</strong>)', |
172 this.playAudioIn); | 173 this.playAudioIn); |
173 addButton(this.buttonPlayAudioOut_, 'A_out (<strong>2</strong>)', | 174 addButton(this.buttonPlayAudioOut_, 'A_out (<strong>2</strong>)', |
174 this.playAudioOut); | 175 this.playAudioOut); |
175 addButton(this.buttonPlayAudioRef_, 'A_ref (<strong>3</strong>)', | 176 addButton(this.buttonPlayAudioRef_, 'A_ref (<strong>3</strong>)', |
176 this.playAudioRef); | 177 this.playAudioRef); |
177 addButton(this.buttonStopAudio_, '<strong>S</strong>top', this.stopAudio); | 178 addButton(this.buttonStopAudio_, '<strong>S</strong>top', this.stopAudio); |
178 }; | 179 }; |
179 | 180 |
180 /** | 181 /** |
181 * Instance and initialize the inspector. | 182 * Instance and initialize the inspector. |
182 */ | 183 */ |
183 function initialize() { | 184 function initialize() { |
184 var inspector = new Inspector(); | 185 var inspector = new Inspector(); |
185 inspector.init(); | 186 inspector.init(); |
186 } | 187 } |
OLD | NEW |