diff --git a/plugins/eos/main.js b/plugins/eos/main.js index d42dcde..4d060ce 100644 --- a/plugins/eos/main.js +++ b/plugins/eos/main.js @@ -10,13 +10,10 @@ exports.config = { mayChangePort: false, searchOptions: { type: 'TCPport', - searchBuffer: Buffer.from( - '\xc0/eos/ping\x00\x00\x2c\x00\x00\x00\xc0', - 'ascii' - ), + searchBuffer: Buffer.from('\xc0/eos/ping\x00\x00\x2c\x00\x00\x00\xc0', 'ascii'), testPort: 3032, validateResponse(msg, info) { - return msg.toString().indexOf('/eos/out'); + return msg.toString().includes('/eos/out'); }, }, }; @@ -43,38 +40,19 @@ exports.data = function data(_device, osc) { for (let i = 0; i < osc.args[0]; i++) { device.send(`/eos/get/cuelist/index/${i}`); } - } else if ( - match(addressParts, ['eos', 'out', 'get', 'cuelist', '*', 'list', '*', '*']) - ) { + } else if (match(addressParts, ['eos', 'out', 'get', 'cuelist', '*', 'list', '*', '*'])) { device.data.EOS.cueLists[addressParts[4]] = {}; device.send(`/eos/get/cue/${addressParts[4]}/count`); } else if (match(addressParts, ['eos', 'out', 'get', 'cue', '*', 'count'])) { for (let i = 0; i < osc.args[0]; i++) { device.send(`/eos/get/cue/${addressParts[4]}/index/${i}`); } - } else if ( - match(addressParts, [ - 'eos', - 'out', - 'get', - 'cue', - '*', - '*', - '*', - 'list', - '*', - '*', - ]) - ) { + } else if (match(addressParts, ['eos', 'out', 'get', 'cue', '*', '*', '*', 'list', '*', '*'])) { this.deviceInfoUpdate(device, 'status', 'ok'); - if ( - device.data.EOS.cueLists[addressParts[4]][addressParts[5]] === undefined - ) { + if (device.data.EOS.cueLists[addressParts[4]][addressParts[5]] === undefined) { device.data.EOS.cueLists[addressParts[4]][addressParts[5]] = {}; } - device.data.EOS.cueLists[addressParts[4]][addressParts[5]][ - addressParts[6] - ] = new Cue(osc.args); + device.data.EOS.cueLists[addressParts[4]][addressParts[5]][addressParts[6]] = new Cue(osc.args); device.update('cueData', { cue: device.data.EOS.cueLists[addressParts[4]][addressParts[5]], @@ -86,36 +64,17 @@ exports.data = function data(_device, osc) { // So: we should fetch all the parts of a cue somehow every time there's an update to a cue. delete device.data.EOS.cueLists[addressParts[4]][addressParts[5]]; device.draw(); - } else if ( - match(addressParts, [ - 'eos', - 'out', - 'get', - 'cue', - '*', - '*', - '*', - 'actions', - 'list', - '*', - '*', - ]) - ) { + } else if (match(addressParts, ['eos', 'out', 'get', 'cue', '*', '*', '*', 'actions', 'list', '*', '*'])) { if (osc.args.length === 3) { - device.data.EOS.cueLists[addressParts[4]][addressParts[5]][0].extLinks = - osc.args[2]; + device.data.EOS.cueLists[addressParts[4]][addressParts[5]][0].extLinks = osc.args[2]; } - } else if ( - match(addressParts, ['eos', 'out', 'event', 'cue', '*', '*', 'fire']) - ) { + } else if (match(addressParts, ['eos', 'out', 'event', 'cue', '*', '*', 'fire'])) { device.data.EOS.activeCue = addressParts[5]; device.draw(); device.update('activeCue', { uid: device.data.EOS.cueLists[addressParts[4]][addressParts[5]][0].uid, }); - } else if ( - match(addressParts, ['eos', 'out', 'notify', 'cue', '*', '*', '*', '*']) - ) { + } else if (match(addressParts, ['eos', 'out', 'notify', 'cue', '*', '*', '*', '*'])) { const cueList = addressParts[4]; const cueNumber = osc.args[1]; device.send(`/eos/get/cue/${cueList}/${cueNumber}`); @@ -126,9 +85,7 @@ exports.data = function data(_device, osc) { } }; -const cueTemplate = _.template( - fs.readFileSync(path.join(__dirname, `cue.ejs`)) -); +const cueTemplate = _.template(fs.readFileSync(path.join(__dirname, `cue.ejs`))); exports.update = function update(device, doc, updateType, data) { if (updateType === 'cueData') { diff --git a/plugins/pjlink/main.js b/plugins/pjlink/main.js index ca6a6c1..78d30b9 100644 --- a/plugins/pjlink/main.js +++ b/plugins/pjlink/main.js @@ -13,7 +13,7 @@ exports.config = { devicePort: 4352, listenPort: 4352, validateResponse(msg, info) { - return msg.toString().indexOf('%2ACKN=') >= 0; + return msg.toString().includes('%2ACKN='); }, }, fields: [ diff --git a/plugins/shure/main.js b/plugins/shure/main.js index 36a8515..d79c364 100644 --- a/plugins/shure/main.js +++ b/plugins/shure/main.js @@ -10,9 +10,9 @@ exports.config = { searchOptions: { type: 'TCPport', searchBuffer: Buffer.from('< GET DEVICE_ID >', 'ascii'), - testPort: 3032, + testPort: 2202, validateResponse(msg, info) { - return msg.toString().indexOf('DEVICE_ID'); + return msg.toString().includes('DEVICE_ID'); }, }, }; diff --git a/plugins/x32/main.js b/plugins/x32/main.js index a7d1953..d69d4cf 100644 --- a/plugins/x32/main.js +++ b/plugins/x32/main.js @@ -10,7 +10,7 @@ exports.config = { devicePort: 10023, listenPort: 0, validateResponse(msg, info) { - return msg.toString().indexOf('/xinfo') === 0; + return msg.toString().includes('/xinfo') === 0; }, }, }; @@ -69,9 +69,7 @@ exports.data = function data(device, oscData) { for (let i = 0; i < 70; i++) { if (i >= 0 && i < 32) { // These are channel meters - d.data.X32.inputs.channels[i].meter = Console.getBehringerDB( - buf.readFloatLE(offset) - ); + d.data.X32.inputs.channels[i].meter = Console.getBehringerDB(buf.readFloatLE(offset)); } offset += 4; @@ -84,14 +82,10 @@ exports.data = function data(device, oscData) { for (let i = 0; i < 49; i++) { if (i === 22) { // STEREO LEFT METER - d.data.X32.main.stereo.meter[0] = Console.getBehringerDB( - buf.readFloatLE(offset) - ); + d.data.X32.main.stereo.meter[0] = Console.getBehringerDB(buf.readFloatLE(offset)); } else if (i === 23) { // STEREO RIGHT METER - d.data.X32.main.stereo.meter[1] = Console.getBehringerDB( - buf.readFloatLE(offset) - ); + d.data.X32.main.stereo.meter[1] = Console.getBehringerDB(buf.readFloatLE(offset)); } offset += 4; } @@ -101,9 +95,7 @@ exports.data = function data(device, oscData) { if (addr[0] === 'ch') { const channel = Number(addr[1]); d.data.X32.inputs.channels[channel - 1].fader = oscData.args[0]; - d.data.X32.inputs.channels[channel - 1].faderDB = Console.getBehringerDB( - oscData.args[0] - ); + d.data.X32.inputs.channels[channel - 1].faderDB = Console.getBehringerDB(oscData.args[0]); } else if (addr[0] === 'main') { d.data.X32.main.stereo.fader = oscData.args[0]; d.data.X32.main.stereo.faderDB = Console.getBehringerDB(oscData.args[0]); diff --git a/plugins/xair/main.js b/plugins/xair/main.js index cac150b..ae8de1a 100644 --- a/plugins/xair/main.js +++ b/plugins/xair/main.js @@ -10,7 +10,7 @@ exports.config = { devicePort: 10024, listenPort: 0, validateResponse(msg, info) { - return msg.toString().indexOf('/xinfo') === 0; + return msg.toString().startWith('/xinfo'); }, }, }; @@ -74,31 +74,25 @@ exports.data = function data(device, buf) { d.send('/lr/mix/on\x00\x00\x00\x00'); for (let i = 0; i <= 32; i++) { - d.send( - Buffer.from( - `/ch/${i.toString().padStart(2, '0')}/config/name\x00\x00\x00\x00` - ) - ); + d.send(Buffer.from(`/ch/${i.toString().padStart(2, '0')}/config/name\x00\x00\x00\x00`)); } d.draw(); } else if (msg[0] === '/meters/0') { // console.log(msg) - } else if (msg[0].indexOf('/mix/fader') >= 0) { + } else if (msg[0].includes('/mix/fader')) { const addr = parseAddress(msg[0]); const channel = Number(addr[1]); if (addr[0] === 'ch') { d.data.channelFaders[channel - 1] = buf.readFloatBE(24); - d.data.channelFadersDB[channel - 1] = convertToDBTheBehringerWay( - buf.readFloatBE(24) - ); + d.data.channelFadersDB[channel - 1] = convertToDBTheBehringerWay(buf.readFloatBE(24)); } else if (addr[0] === 'lr') { d.data.stereoFader = buf.readFloatBE(20); d.data.stereoFaderDB = convertToDBTheBehringerWay(buf.readFloatBE(20)); } d.draw(); - } else if (msg[0].indexOf('/mix/on') >= 0) { + } else if (msg[0].includes('/mix/on')) { const addr = parseAddress(msg[0]); const channel = Number(addr[1]); @@ -109,13 +103,13 @@ exports.data = function data(device, buf) { } device.draw(); device.send(`/ch/${addr[1]}/mix/fader\x00\x00\x00\x00`); - } else if (msg[0].indexOf('/config/name') > 0) { + } else if (msg[0].includes('/config/name')) { const addr = parseAddress(msg[0]); const channel = Number(addr[1]); d.data.channelNames[channel - 1] = msg[4]; d.draw(); d.send(`/ch/${addr[1]}/config/color\x00\x00\x00\x00`); - } else if (msg[0].indexOf('/config/color') > 0) { + } else if (msg[0].includes('/config/color')) { const addr = parseAddress(msg[0]); const channel = Number(addr[1]); d.data.channelColors[channel - 1] = buf.readInt8(27); diff --git a/src/search.js b/src/search.js index 9367510..4dc14f9 100644 --- a/src/search.js +++ b/src/search.js @@ -118,7 +118,7 @@ function searchBonjour(pluginType, pluginConfig) { bonjour.find({ type: pluginConfig.searchOptions.bonjourName }, (e) => { const validAddresses = []; e.addresses.forEach((address) => { - if (address.indexOf(':') === -1) { + if (!address.includes(':')) { validAddresses.push(address); } }); diff --git a/src/view.js b/src/view.js index 65233dc..99ccf54 100644 --- a/src/view.js +++ b/src/view.js @@ -144,7 +144,7 @@ function switchDevice(id) { if (pinnedDevices.length > 0) { cols += pinnedDevices.length; } - if (pinnedDevices.indexOf(activeDevice) >= 0 || id === undefined) { + if (pinnedDevices.includes(activeDevice) || id === undefined) { cols--; } @@ -229,7 +229,7 @@ module.exports.pinActiveDevice = function pinActiveDevice() { if (activeDevice === undefined) { return; } - if (pinnedDevices.indexOf(DEVICE.all[activeDevice.id]) === -1) { + if (!pinnedDevices.includes(DEVICE.all[activeDevice.id])) { pinnedDevices.push(DEVICE.all[activeDevice.id]); } DEVICE.changeActivePinIndex(true);