diff --git a/main.js b/main.js index 618e0f6..4af27fd 100644 --- a/main.js +++ b/main.js @@ -12,7 +12,7 @@ if (require('electron-squirrel-startup')) { app.quit(); } -var menu; +let menu; let mainWindow; const createWindow = () => { diff --git a/plugins/eos/eos.js b/plugins/eos/eos.js index 6772e3b..ab54d18 100644 --- a/plugins/eos/eos.js +++ b/plugins/eos/eos.js @@ -22,8 +22,8 @@ exports.ready = function (device) { }; exports.data = function (device, osc) { - var address = osc.address; - var p = osc.address.split('/'); + const address = osc.address; + const p = osc.address.split('/'); p.shift(); if (p[1] == 'out' && p[2] == 'show' && p[3] == 'name') { @@ -31,7 +31,7 @@ exports.data = function (device, osc) { device.data.cuelists = {}; this.deviceInfoUpdate(device, 'defaultName', osc.args[0]); } else if (osc.address == '/eos/out/get/cuelist/count') { - for (var i = 0; i < osc.args[0]; i++) { + for (let i = 0; i < osc.args[0]; i++) { device.send(`/eos/get/cuelist/index/${i}`); } } else if ( @@ -48,7 +48,7 @@ exports.data = function (device, osc) { p[3] == 'cue' && p[5] == 'count' ) { - for (var i = 0; i < osc.args[0]; i++) { + for (let i = 0; i < osc.args[0]; i++) { device.send(`'/eos/get/cue/${p[4]}/index/${i}`); } } else if ( @@ -119,10 +119,10 @@ exports.data = function (device, osc) { device.data.activeCue = p[5]; device.draw(); } else if (p[1] == 'out' && p[2] == 'notify' && p[3] == 'cue') { - var cueList = p[4]; - var listIndex = p[6]; - var listCount = p[7]; - var cueNumber = osc.args[1]; + const cueList = p[4]; + const listIndex = p[6]; + const listCount = p[7]; + const cueNumber = osc.args[1]; device.send(`/eos/get/cue/${cueList}/${cueNumber}`); // console.log("SENT /eos/get/cue/"+cueList+"/"+cueNumber); diff --git a/plugins/pjlink/pjlink.js b/plugins/pjlink/pjlink.js index 2f85e28..3d0ce09 100644 --- a/plugins/pjlink/pjlink.js +++ b/plugins/pjlink/pjlink.js @@ -1,3 +1,5 @@ +const md5 = require('md5'); + exports.defaultName = 'PJLink Projector'; exports.connectionType = 'TCPsocket'; exports.heartbeatInterval = 5000; @@ -16,13 +18,11 @@ exports.ready = function (device) { // Power status query // device.send("%1POWR ?\r"); }; -var password = false; +let password = false; exports.data = function (device, message) { this.deviceInfoUpdate(device, 'status', 'ok'); - var msg = message.toString(); - - const md5 = require('md5'); + const msg = message.toString(); if (msg.substring(0, 8) == 'PJLINK 1') { password = md5(`${msg.substring(9, 17)}JBMIAProjectorLink`); @@ -63,7 +63,7 @@ exports.data = function (device, message) { }; function processPJLink(device, str, that) { - var arr = str.split('%'); + const arr = str.split('%'); for (var key in arr) { var split = arr[key].split('='); var key = split[0]; diff --git a/plugins/qlab/qlab.js b/plugins/qlab/qlab.js index 45890cd..d7e7267 100644 --- a/plugins/qlab/qlab.js +++ b/plugins/qlab/qlab.js @@ -10,8 +10,8 @@ exports.ready = function (device) { }; exports.data = function (device, osc) { - var address = osc.address; - var p = osc.address.split('/'); + const address = osc.address; + const p = osc.address.split('/'); p.shift(); // console.log(address) @@ -19,7 +19,7 @@ exports.data = function (device, osc) { if (osc.address == '/reply/workspaces') { const d = JSON.parse(osc.args[0]).data; device.data.workspaces = {}; - for (var i = 0; i < d.length; i++) { + for (let i = 0; i < d.length; i++) { device.data.workspaces[d[i].uniqueID] = { displayName: d[i].displayName, selectionIsPlayhead: true, @@ -33,14 +33,14 @@ exports.data = function (device, osc) { device.send(`/workspace/${d[i].uniqueID}/selectionIsPlayhead`); } } else if (p[1] == 'workspace' && p[3] == 'cueLists') { - var workspace = p[2]; - var d = JSON.parse(osc.args[0]).data; + const workspace = p[2]; + const d = JSON.parse(osc.args[0]).data; device.data.workspaces[workspace].cueLists = {}; device.data.workspaces[workspace].allCues = {}; device.data.workspaces[workspace].allCuesOrdered = []; device.data.lastCueInGroup = {}; - for (var i in d) { + for (let i in d) { device.data.workspaces[workspace].cueLists[d[i].uniqueID] = d[i]; device.data.workspaces[workspace].cueLists[d[i].uniqueID].cues = d[i].cues; @@ -48,11 +48,11 @@ exports.data = function (device, osc) { getMoreCueInfo(d[i], []); function getMoreCueInfo(group, groups_arg) { - var groups = JSON.parse(JSON.stringify(groups_arg)); + const groups = JSON.parse(JSON.stringify(groups_arg)); groups.push(group.uniqueID); - for (var cueIndex in group.cues) { - var cue = group.cues[cueIndex]; + for (let cueIndex in group.cues) { + const cue = group.cues[cueIndex]; // console.log(cue) device.data.lastCueInGroup[group.uniqueID] = cue; @@ -99,19 +99,19 @@ exports.data = function (device, osc) { // response to /cue/playbackPosition/uniqueID device.data.playbackPosition = JSON.parse(osc.args[0]).data; } else if (p[3] == 'mode') { - var cueID = p[2]; - var mode = JSON.parse(osc.args[0]).data; - var workspaceID = JSON.parse(osc.args[0]).workspace_id; + const cueID = p[2]; + const mode = JSON.parse(osc.args[0]).data; + const workspaceID = JSON.parse(osc.args[0]).workspace_id; device.data.workspaces[workspaceID].allCues[cueID].mode = mode; } else if (p[3] == 'valuesForKeys') { this.deviceInfoUpdate(device, 'status', 'ok'); - var d = JSON.parse(osc.args[0]); + const d = JSON.parse(osc.args[0]); - var cueID = p[2]; - var workspace = d.workspace_id; - var cueList = d.data.parent; + const cueID = p[2]; + const workspace = d.workspace_id; + const cueList = d.data.parent; device.data.workspaces[workspace].allCues[cueID].mode = d.data.mode; device.data.workspaces[workspace].allCues[cueID].preWait = d.data.preWait; diff --git a/plugins/watchout/watchout.js b/plugins/watchout/watchout.js index 038b389..1c43cca 100644 --- a/plugins/watchout/watchout.js +++ b/plugins/watchout/watchout.js @@ -16,15 +16,15 @@ exports.ready = function (device) { }; exports.data = function (device, message) { - var msg = message.toString(); + const msg = message.toString(); if (msg.substring(0, 5) == 'Ready') { device.send('getStatus\n'); } if (msg.substring(0, 5) == 'Reply') { - var arr = msg.split(' '); + const arr = msg.split(' '); device.data.showName = ''; - var i = 0; + let i = 0; while (arr[i][arr[i].length - 1] != '"') { i++; device.data.showName += `${arr[i]} `; diff --git a/plugins/x32/x32.js b/plugins/x32/x32.js index 050f49d..99cfe38 100644 --- a/plugins/x32/x32.js +++ b/plugins/x32/x32.js @@ -33,7 +33,7 @@ exports.ready = function (device) { exports.data = function (device, buf) { this.deviceInfoUpdate(device, 'status', 'ok'); - var msg = buf.toString().split('\u0000\u0000'); + const msg = buf.toString().split('\u0000\u0000'); if (msg[0] == '/xinfo') { this.deviceInfoUpdate(device, 'defaultName', msg[4]); @@ -45,7 +45,7 @@ exports.data = function (device, buf) { device.send(Buffer.from('/lr/mix/fader\u0000\u0000\u0000\u0000')); device.send(Buffer.from('/lr/mix/on\u0000\u0000\u0000\u0000')); - for (var i = 0; i <= 32; i++) { + for (let i = 0; i <= 32; i++) { device.send( Buffer.from( `/ch/${i @@ -58,8 +58,8 @@ exports.data = function (device, buf) { } else if (msg[0] == '/meters/0') { // console.log(msg) } else if (msg[0].indexOf('/mix/fader') >= 0) { - var addr = parseAddress(msg[0]); - var channel = Number(addr[1]); + const addr = parseAddress(msg[0]); + const channel = Number(addr[1]); if (addr[0] == 'ch') { device.data.channelFaders[channel - 1] = buf.readFloatBE(24); @@ -75,8 +75,8 @@ exports.data = function (device, buf) { device.draw(); } else if (msg[0].indexOf('/mix/on') >= 0) { - var addr = parseAddress(msg[0]); - var channel = Number(addr[1]); + const addr = parseAddress(msg[0]); + const channel = Number(addr[1]); if (addr[0] == 'ch') { device.data.channelMutes[channel - 1] = buf[23]; @@ -88,16 +88,16 @@ exports.data = function (device, buf) { Buffer.from(`/ch/${addr[1]}/mix/fader\u0000\u0000\u0000\u0000`) ); } else if (msg[0].indexOf('/config/name') > 0) { - var addr = parseAddress(msg[0]); - var channel = Number(addr[1]); + const addr = parseAddress(msg[0]); + const channel = Number(addr[1]); device.data.channelNames[channel - 1] = msg[2]; device.draw(); device.send( Buffer.from(`/ch/${addr[1]}/config/color\u0000\u0000\u0000\u0000`) ); } else if (msg[0].indexOf('/config/color') > 0) { - var addr = parseAddress(msg[0]); - var channel = Number(addr[1]); + const addr = parseAddress(msg[0]); + const channel = Number(addr[1]); device.data.channelColors[channel - 1] = buf.readInt8(27); device.draw(); device.send(Buffer.from(`/ch/${addr[1]}/mix/on\u0000\u0000\u0000\u0000`)); @@ -112,7 +112,7 @@ exports.heartbeat = function (device) { }; function parseAddress(msg) { - var addr = msg.split('/'); + const addr = msg.split('/'); addr.shift(); return addr; } diff --git a/plugins/xair/xair.js b/plugins/xair/xair.js index e83faae..db5cee1 100644 --- a/plugins/xair/xair.js +++ b/plugins/xair/xair.js @@ -33,7 +33,7 @@ exports.ready = function (device) { exports.data = function (device, buf) { this.deviceInfoUpdate(device, 'status', 'ok'); - var msg = buf.toString().split('\u0000'); + const msg = buf.toString().split('\u0000'); if (msg[0] == '/xinfo') { if (msg[7].length > 0) { @@ -50,7 +50,7 @@ exports.data = function (device, buf) { device.send(Buffer.from('/lr/mix/fader\u0000\u0000\u0000\u0000')); device.send(Buffer.from('/lr/mix/on\u0000\u0000\u0000\u0000')); - for (var i = 0; i <= 32; i++) { + for (let i = 0; i <= 32; i++) { device.send( Buffer.from( `/ch/${i @@ -63,8 +63,8 @@ exports.data = function (device, buf) { } else if (msg[0] == '/meters/0') { // console.log(msg) } else if (msg[0].indexOf('/mix/fader') >= 0) { - var addr = parseAddress(msg[0]); - var channel = Number(addr[1]); + const addr = parseAddress(msg[0]); + const channel = Number(addr[1]); if (addr[0] == 'ch') { device.data.channelFaders[channel - 1] = buf.readFloatBE(24); @@ -80,8 +80,8 @@ exports.data = function (device, buf) { device.draw(); } else if (msg[0].indexOf('/mix/on') >= 0) { - var addr = parseAddress(msg[0]); - var channel = Number(addr[1]); + const addr = parseAddress(msg[0]); + const channel = Number(addr[1]); if (addr[0] == 'ch') { device.data.channelMutes[channel - 1] = buf[23]; @@ -93,16 +93,16 @@ exports.data = function (device, buf) { Buffer.from(`/ch/${addr[1]}/mix/fader\u0000\u0000\u0000\u0000`) ); } else if (msg[0].indexOf('/config/name') > 0) { - var addr = parseAddress(msg[0]); - var channel = Number(addr[1]); + const addr = parseAddress(msg[0]); + const channel = Number(addr[1]); device.data.channelNames[channel - 1] = msg[4]; device.draw(); device.send( Buffer.from(`/ch/${addr[1]}/config/color\u0000\u0000\u0000\u0000`) ); } else if (msg[0].indexOf('/config/color') > 0) { - var addr = parseAddress(msg[0]); - var channel = Number(addr[1]); + const addr = parseAddress(msg[0]); + const channel = Number(addr[1]); device.data.channelColors[channel - 1] = buf.readInt8(27); device.draw(); device.send(Buffer.from(`/ch/${addr[1]}/mix/on\u0000\u0000\u0000\u0000`)); @@ -117,7 +117,7 @@ exports.heartbeat = function (device) { }; function parseAddress(msg) { - var addr = msg.split('/'); + const addr = msg.split('/'); addr.shift(); return addr; } diff --git a/preload.js b/preload.js index 5b68bfe..d415e87 100644 --- a/preload.js +++ b/preload.js @@ -75,7 +75,7 @@ window.init = function () { document.getElementById('device-list').onclick = function (e) { e.stopPropagation(); - var deviceID = e.srcElement.id; + const deviceID = e.srcElement.id; if (e.srcElement.id != 'device-list') { VIEW.switchDevice(deviceID); } diff --git a/src/device.js b/src/device.js index e5bf305..795645b 100644 --- a/src/device.js +++ b/src/device.js @@ -8,7 +8,7 @@ const PLUGINS = require('./plugins.js'); const VIEW = require('./view.js'); const SAVESLOTS = require('./saveSlots.js'); -var devices = {}; +const devices = {}; module.exports.all = devices; registerDevice = function (newDevice) { @@ -19,14 +19,14 @@ registerDevice = function (newDevice) { return true; } - var initElements = document.getElementsByClassName('init'); - for (var i = 0; i < initElements.length; i++) { + const initElements = document.getElementsByClassName('init'); + for (let i = 0; i < initElements.length; i++) { initElements[i].style.display = 'none'; } // only register device if it hasn't already been added if (newDevice.addresses.length > 0) { - for (var i in devices) { + for (let i in devices) { if ( devices[i].type == newDevice.type && JSON.stringify(devices[i].addresses) == @@ -41,9 +41,9 @@ registerDevice = function (newDevice) { // console.log("Registered new "+newDevice.type) - var id = newDevice.id || uuid(); + const id = newDevice.id || uuid(); devices[id] = { - id: id, + id, status: 'new', type: newDevice.type, displayName: newDevice.displayName, @@ -70,7 +70,7 @@ registerDevice = function (newDevice) { module.exports.registerDevice = registerDevice; initDeviceConnection = function (id) { - var device = devices[id]; + const device = devices[id]; infoUpdate(device, 'status', 'new'); @@ -82,8 +82,8 @@ initDeviceConnection = function (id) { device.connection.close(); } catch (err) {} - const type = devices[id].type; - var plugins = PLUGINS.all; + const { type } = devices[id]; + const plugins = PLUGINS.all; if (plugins[type].connectionType == 'osc') { device.connection = new osc.TCPSocketPort({ @@ -159,8 +159,8 @@ initDeviceConnection = function (id) { module.exports.initDeviceConnection = initDeviceConnection; module.exports.deleteActive = function () { - var device = VIEW.getActiveDevice(); - var choice = confirm( + const device = VIEW.getActiveDevice(); + const choice = confirm( `Are you sure you want to delete ${device.type} device "${ device.displayName || device.defaultName }"?` @@ -176,7 +176,7 @@ module.exports.deleteActive = function () { }; module.exports.changeActiveType = function (newType) { - var device = VIEW.getActiveDevice(); + const device = VIEW.getActiveDevice(); device.type = newType; initDeviceConnection(device.id); @@ -185,7 +185,7 @@ module.exports.changeActiveType = function (newType) { }; module.exports.changeActiveIP = function (newIP) { - var device = VIEW.getActiveDevice(); + const device = VIEW.getActiveDevice(); device.addresses[0] = newIP; initDeviceConnection(device.id); VIEW.draw(device); @@ -193,7 +193,7 @@ module.exports.changeActiveIP = function (newIP) { }; module.exports.changeActivePort = function (newPort) { - var device = VIEW.getActiveDevice(); + const device = VIEW.getActiveDevice(); device.port = newPort; initDeviceConnection(device.id); @@ -202,14 +202,14 @@ module.exports.changeActivePort = function (newPort) { }; module.exports.changeActiveName = function (newName) { - var device = VIEW.getActiveDevice(); + const device = VIEW.getActiveDevice(); device.displayName = newName; infoUpdate(device, 'displayName', newName); VIEW.draw(device); SAVESLOTS.saveAll(); }; module.exports.changeActivePinIndex = function (newPin) { - var device = VIEW.getActiveDevice(); + const device = VIEW.getActiveDevice(); device.pinIndex = newPin; VIEW.draw(device); SAVESLOTS.saveAll(); @@ -219,7 +219,7 @@ module.exports.changePinIndex = function (device, newPin) { // SAVESLOTS.saveAll(); }; module.exports.refreshActive = function () { - var device = VIEW.getActiveDevice(); + const device = VIEW.getActiveDevice(); if (device == undefined) { return true; } @@ -239,8 +239,8 @@ module.exports.infoUpdate = infoUpdate; setInterval(heartbeat, 100); function heartbeat() { - for (var i in devices) { - var device = devices[i]; + for (let i in devices) { + const device = devices[i]; if (Date.now() >= device.lastHeartbeat + device.heartbeatInterval) { if (device.status == 'broken') { initDeviceConnection(i); diff --git a/src/plugins.js b/src/plugins.js index 8d73da8..4b62ede 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -2,15 +2,15 @@ const fs = require('fs'); const DEVICE = require('./device.js'); const VIEW = require('./view.js'); -var allPlugins = {}; +const allPlugins = {}; module.exports.all = allPlugins; module.exports.init = function (callback) { console.log(`Loading plugin files... ${__dirname}/../plugins`); fs.readdir(`${__dirname}/../plugins`, (err, files) => { - for (var i in files) { - var plugin = files[i]; + for (let i in files) { + const plugin = files[i]; if (plugin[0] != '.') { console.log(`${i} ${plugin}`); diff --git a/src/saveSlots.js b/src/saveSlots.js index 10dd219..2037652 100644 --- a/src/saveSlots.js +++ b/src/saveSlots.js @@ -1,16 +1,16 @@ const VIEW = require('./view.js'); const DEVICE = require('./device.js'); -var activeSlot = false; -var savedSlots = [[], [], [], []]; -var savedDevices = []; +let activeSlot = false; +let savedSlots = [[], [], [], []]; +let savedDevices = []; -var storedSlots = localStorage.getItem('savedSlots'); +const storedSlots = localStorage.getItem('savedSlots'); if (storedSlots) { savedSlots = JSON.parse(storedSlots); } -var storedDevices = localStorage.getItem('savedDevices'); +const storedDevices = localStorage.getItem('savedDevices'); if (storedDevices) { savedDevices = JSON.parse(storedDevices); } @@ -25,9 +25,9 @@ loadSlot = function (slotIndex) { VIEW.resetPinned(); for (var d in savedSlots[slotIndex]) { - var savedDevice = savedSlots[slotIndex][d]; + const savedDevice = savedSlots[slotIndex][d]; for (var d in DEVICE.all) { - var device = DEVICE.all[d]; + const device = DEVICE.all[d]; // if(device.addresses[0] == savedDevice.addresses[0] && device.type == savedDevice.type){ if (device.id == savedDevice.id) { VIEW.pinDevice(device); @@ -49,7 +49,7 @@ module.exports.loadDevices = function () { console.log(`Loading ${savedDevices.length} saved devices...`); console.log(savedDevices); - for (var i = 0; i < savedDevices.length; i++) { + for (let i = 0; i < savedDevices.length; i++) { DEVICE.registerDevice({ type: savedDevices[i].type, displayName: savedDevices[i].displayName, @@ -63,10 +63,10 @@ module.exports.loadDevices = function () { module.exports.saveAll = function () { console.log('Saving...'); - var currentPins = VIEW.getPinnedDevices(); + const currentPins = VIEW.getPinnedDevices(); savedSlots[activeSlot] = []; - for (var i = 0; i < currentPins.length; i++) { + for (let i = 0; i < currentPins.length; i++) { savedSlots[activeSlot][i] = { addresses: currentPins[i].addresses, type: currentPins[i].type, @@ -96,9 +96,9 @@ module.exports.saveAll = function () { }; module.exports.deleteFromSlots = function (device) { - for (var i = 1; i <= 3; i++) { + for (let i = 1; i <= 3; i++) { console.log(savedSlots); - for (var j = 0; j < savedSlots[i].length; j++) { + for (let j = 0; j < savedSlots[i].length; j++) { if (savedSlots[i][j].id == device.id) { delete savedSlots[i][j]; } diff --git a/src/search.js b/src/search.js index 66e79fc..3ec1010 100644 --- a/src/search.js +++ b/src/search.js @@ -10,8 +10,8 @@ const DEVICE = require('./device.js'); // const SEARCH = require('./search.js'); const PLUGINS = require('./plugins.js'); -var searching = false; -var allServers = false; +let searching = false; +let allServers = false; searchAll = function () { if (searching) { @@ -22,7 +22,7 @@ searchAll = function () { document.getElementById('search-button').style.opacity = 0.2; // console.clear(); - for (var i in DEVICE.all) { + for (let i in DEVICE.all) { DEVICE.infoUpdate(DEVICE.all[i], 'status', 'refresh'); } @@ -30,7 +30,7 @@ searchAll = function () { // findOnlineDevices(); allServers = getServers(); - var TCPFlag = true; + let TCPFlag = true; if (allServers.length > 2046) { alert( 'Unable to search for TCP devices - subnet too large!\n\nCue View requires subnet 255.255.248.0 (/21) or smaller.' @@ -40,8 +40,8 @@ searchAll = function () { console.log(PLUGINS); - for (var p in PLUGINS.all) { - var plugin = PLUGINS.all[p]; + for (let p in PLUGINS.all) { + const plugin = PLUGINS.all[p]; console.log(p); try { switch (plugin.searchOptions.type) { @@ -70,7 +70,7 @@ searchAll = function () { searching = false; document.getElementById('search-button').style.opacity = ''; - for (var i = 0; i < searchSockets.length; i++) { + for (let i = 0; i < searchSockets.length; i++) { try { searchSockets[i].close(); } catch (err) {} @@ -94,8 +94,8 @@ newSearchBonjour = function (pluginType, plugin) { bonjour.find({ type: plugin.searchOptions.bonjourName }, (e) => { console.log(pluginType); - var validAddresses = []; - for (var i in e.addresses) { + const validAddresses = []; + for (let i in e.addresses) { if (e.addresses[i].indexOf(':') == -1) { validAddresses.push(e.addresses[i]); } @@ -135,13 +135,13 @@ newSearchBonjour = function (pluginType, plugin) { // |_| \_____|_| newSearchTCP = function (pluginType, plugin) { - for (var i = 0; i < allServers.length; i++) { + for (let i = 0; i < allServers.length; i++) { TCPtest(allServers[i], pluginType, plugin); } }; TCPtest = function (ip, pluginType, plugin) { - var client = net.createConnection(plugin.searchOptions.testPort, ip, () => { + const client = net.createConnection(plugin.searchOptions.testPort, ip, () => { client.write(plugin.searchOptions.searchBuffer); // DEVICE.registerDevice({ // type: pluginType, @@ -168,17 +168,17 @@ TCPtest = function (ip, pluginType, plugin) { // from local-devices library function getServers() { - var interfaces = os.networkInterfaces(); - var result = []; + const interfaces = os.networkInterfaces(); + const result = []; - for (var key in interfaces) { - var addresses = interfaces[key]; - for (var i = addresses.length; i--; ) { - var address = addresses[i]; + for (const key in interfaces) { + const addresses = interfaces[key]; + for (let i = addresses.length; i--; ) { + const address = addresses[i]; if (address.family === 'IPv4' && !address.internal) { - var subnet = ip.subnet(address.address, address.netmask); - var current = ip.toLong(subnet.firstAddress); - var last = ip.toLong(subnet.lastAddress) - 1; + const subnet = ip.subnet(address.address, address.netmask); + let current = ip.toLong(subnet.firstAddress); + const last = ip.toLong(subnet.lastAddress) - 1; while (current++ < last) result.push(ip.fromLong(current)); } } @@ -188,11 +188,11 @@ function getServers() { } findOnlineDevices = function () { - var allInterfaces = os.networkInterfaces(); - var validInterfaces = []; - for (var i in allInterfaces) { - for (var j = 0; j < allInterfaces[i].length; j++) { - var iface = allInterfaces[i][j]; + const allInterfaces = os.networkInterfaces(); + const validInterfaces = []; + for (let i in allInterfaces) { + for (let j = 0; j < allInterfaces[i].length; j++) { + const iface = allInterfaces[i][j]; if ( iface.family == 'IPv4' && @@ -204,15 +204,15 @@ findOnlineDevices = function () { } } - for (var i = 0; i < validInterfaces.length; i++) { - var block = new Netmask(validInterfaces[i].cidr); - var f = block.first.split('.'); - var l = block.last.split('.'); - var cur = [f[0], f[1], f[2], f[3]]; + for (let i = 0; i < validInterfaces.length; i++) { + const block = new Netmask(validInterfaces[i].cidr); + const f = block.first.split('.'); + const l = block.last.split('.'); + const cur = [f[0], f[1], f[2], f[3]]; - for (var j = Number(f[2]); j <= Number(l[2]); j++) { + for (let j = Number(f[2]); j <= Number(l[2]); j++) { cur[2] = j; - for (var k = Number(f[3]); k < Number(l[3]); k++) { + for (let k = Number(f[3]); k < Number(l[3]); k++) { cur[3] = k; allIPs.push(`${cur[0]}.${cur[1]}.${cur[2]}.${cur[3]}`); } @@ -284,13 +284,13 @@ findOnlineDevices = function () { const pjLinkMessage = Buffer.from([0x25, 0x32, 0x53, 0x52, 0x43, 0x48, 0x0d]); const xAirMessage = Buffer.from([0x2f, 0x78, 0x69, 0x6e, 0x66, 0x6f]); -var serverUDP = dgram.createSocket('udp4'); -var serverUDP2 = dgram.createSocket('udp4'); +const serverUDP = dgram.createSocket('udp4'); +const serverUDP2 = dgram.createSocket('udp4'); -var searchSockets = []; +const searchSockets = []; newSearchUDP = function (pluginType, plugin) { - var i = searchSockets.push(dgram.createSocket('udp4')) - 1; + const i = searchSockets.push(dgram.createSocket('udp4')) - 1; searchSockets[i].bind(plugin.searchOptions.listenPort, () => { searchSockets[i].send( plugin.searchOptions.searchBuffer, diff --git a/src/view.js b/src/view.js index ba2c646..77b8662 100644 --- a/src/view.js +++ b/src/view.js @@ -3,7 +3,7 @@ const DEVICE = require('./device.js'); const PLUGINS = require('./plugins.js'); // const _ = require('lodash/function'); -var pinnedDevices = []; +const pinnedDevices = []; module.exports.pinnedDevices = pinnedDevices; let activeDevice = false; @@ -14,8 +14,8 @@ module.exports.init = function () { drawDeviceInterface = function (id) { // console.log("DRAW") - var $deviceDrawArea = document.getElementById(`device-${id}-draw-area`); - var $devicePinned = document.getElementById(`device-${id}-pinned`); + const $deviceDrawArea = document.getElementById(`device-${id}-draw-area`); + const $devicePinned = document.getElementById(`device-${id}-pinned`); if ($deviceDrawArea == null) { return true; @@ -23,7 +23,7 @@ drawDeviceInterface = function (id) { d = DEVICE.all[id]; - var str = ''; + let str = ''; if (d.status == 'ok') { str += "