UNPKG

@apidaze/node-red-contrib-apidaze

Version:
84 lines (76 loc) 2.01 kB
<script type="text/javascript"> const operations = [ { name: 'Equal', value: 'equal', }, { name: 'Not Equal', value: 'notEqual', }, { name: 'Contains', value: 'contains', }, { name: 'Not Contains', value: 'notContains', }, { name: 'Regex', value: 'regex', }, ]; RED.nodes.registerType('dtmf-handler', { category: 'apidaze', color: '#E9967A', defaults: { operation: { value: operations[0].value, }, dialedDigits: { value: '', } }, inputs: 1, outputs: 3, outputLabels: ['DTMF match', 'DTMF fail', 'No DTMF'], icon: 'font-awesome/fa-tty', label: 'DTMF handler', oneditprepare: function() { const $select = $('select#node-input-operation'); $.each(operations, (index, item) => { const { name, value } = item; const $option = $('<option />', { value, text: name, selected: value === this.operation, }); $select.append($option); }); $select.on('change', function (event) { const newValue = $(this).val(); const $labelText = $('label[for="node-input-dialedDigits"] span'); if (newValue === 'regex') { $labelText.text('Regex') } else { $labelText.text('Dialed digits'); } }); } }); </script> <script type="text/html" data-template-name="dtmf-handler"> <div class="form-row"> <label for="node-input-operation"><i class="fa fa-tasks"></i> Operation</label> <select id="node-input-operation"></select> </div> <div class="form-row"> <label for="node-input-dialedDigits"><i class="fa fa-tty"></i> <span>Dialed digits</span></label> <input type="text" id="node-input-dialedDigits" /> </div> <input type="hidden" id="node-input-outputs" /> </script> <script type="text/html" data-help-name="dtmf-handler"> <p>Handles DTMFs in the flow.</p> </script>