Skip to content

Commit

Permalink
[microphone] Fixup template to get rid of ng-if on icon
Browse files Browse the repository at this point in the history
  • Loading branch information
knolleary committed May 4, 2020
1 parent b2cefb5 commit 4033261
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion node-red-node-ui-microphone/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-node-ui-microphone",
"version": "0.1.3",
"version": "0.1.4",
"description": "A Node-RED ui node to record audio on a dashboard.",
"author": "Nick O'Leary",
"license": "Apache-2.0",
Expand Down
10 changes: 8 additions & 2 deletions node-red-node-ui-microphone/ui_microphone.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ module.exports = function(RED) {
function HTML(config) {
var configAsJson = JSON.stringify(config);
var html = String.raw`
<md-button aria-label="capture audio" id="microphone_control_{{$id}}" class="nr-ui-microphone-button" ng-disabled="!enabled" ng-click="toggleMicrophone()"><i ng-if="enabled" class="fa fa-2x fa-microphone" /><i ng-if="!enabled" class="fa fa-2x fa-microphone-slash" /></md-button>
<input type='hidden' ng-init='init(` + configAsJson + `)'>
<input type='hidden' ng-init='init(` + configAsJson + `)'>
<md-button aria-label="capture audio" id="microphone_control_{{$id}}" class="nr-ui-microphone-button" ng-disabled="!enabled" ng-click="toggleMicrophone()"><i class="fa fa-2x fa-microphone"></i></md-button>
`;
return html;
}
Expand Down Expand Up @@ -88,6 +88,12 @@ module.exports = function(RED) {

$scope.enabled = !!navigator.mediaDevices;

if (!$scope.enabled) {
setTimeout(function() {
$("#microphone_control_"+$scope.$id+" i").removeClass("fa-microphone").addClass("fa-microphone-slash");
},50);
}

var worker;
var mediaRecorder;
var audioContext;
Expand Down

0 comments on commit 4033261

Please sign in to comment.