Change string concats to template literals

This commit is contained in:
Sam Schloegel
2022-01-03 14:31:13 -05:00
parent c5691b56c9
commit aec191e178
11 changed files with 47 additions and 80 deletions
+4 -4
View File
@@ -32,7 +32,7 @@ exports.data = function (device, osc) {
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++) {
device.send('/eos/get/cuelist/index/' + i);
device.send(`/eos/get/cuelist/index/${i}`);
}
} else if (
p[1] == 'out' &&
@@ -41,7 +41,7 @@ exports.data = function (device, osc) {
p[5] == 'list'
) {
device.data.cuelists[p[4]] = {};
device.send('/eos/get/cue/' + p[4] + '/count');
device.send(`/eos/get/cue/${p[4]}/count`);
} else if (
p[1] == 'out' &&
p[2] == 'get' &&
@@ -49,7 +49,7 @@ exports.data = function (device, osc) {
p[5] == 'count'
) {
for (var i = 0; i < osc.args[0]; i++) {
device.send('/eos/get/cue/' + p[4] + '/index/' + i);
device.send(`'/eos/get/cue/${p[4]}/index/${i}`);
}
} else if (
p[1] == 'out' &&
@@ -124,7 +124,7 @@ exports.data = function (device, osc) {
var listCount = p[7];
var cueNumber = osc.args[1];
device.send('/eos/get/cue/' + cueList + '/' + cueNumber);
device.send(`/eos/get/cue/${cueList}/${cueNumber}`);
//console.log("SENT /eos/get/cue/"+cueList+"/"+cueNumber);
} else if (
p[2] == 'cmd' ||
+3 -5
View File
@@ -25,10 +25,9 @@ exports.data = function (device, message) {
const md5 = require('md5');
if (msg.substring(0, 8) == 'PJLINK 1') {
password = md5(msg.substring(9, 17) + 'JBMIAProjectorLink');
password = md5(`${msg.substring(9, 17)}JBMIAProjectorLink`);
device.send(
password +
'%1POWR ?\r%1INPT ?\r%1AVMT ?\r%1ERST ?\r%1LAMP ?\r%1NAME ?\r%1INF1 ?\r%1INF2 ?\r%2SNUM ?\r%2SVER ?\r'
`${password}%1POWR ?\r%1INPT ?\r%1AVMT ?\r%1ERST ?\r%1LAMP ?\r%1NAME ?\r%1INF1 ?\r%1INF2 ?\r%2SNUM ?\r%2SVER ?\r`
);
}
if (msg.substring(0, 7) == '%1POWR=') {
@@ -115,8 +114,7 @@ function processPJLink(device, str, that) {
exports.heartbeat = function (device) {
if (password) {
device.send(
password +
'%1POWR ?\r%1INPT ?\r%1AVMT ?\r%1ERST ?\r%1LAMP ?\r%1NAME ?\r%1INF1 ?\r%1INF2 ?\r%2SNUM ?\r%2SVER ?\r'
`${password}%1POWR ?\r%1INPT ?\r%1AVMT ?\r%1ERST ?\r%1LAMP ?\r%1NAME ?\r%1INF1 ?\r%1INF2 ?\r%2SNUM ?\r%2SVER ?\r`
);
}
};
+6 -12
View File
@@ -25,12 +25,12 @@ exports.data = function (device, osc) {
selectionIsPlayhead: true,
};
device.data.version = d[i].version;
device.send('/workspace/' + d[i].uniqueID + '/cueLists');
device.send('/workspace/' + d[i].uniqueID + '/updates', [
device.send(`/workspace/${d[i].uniqueID}/cueLists`);
device.send(`/workspace/${d[i].uniqueID}/updates`, [
{ type: 'i', value: 1 },
]);
device.send('/cue/playbackPosition/uniqueID');
device.send('/workspace/' + d[i].uniqueID + '/selectionIsPlayhead');
device.send(`/workspace/${d[i].uniqueID}/selectionIsPlayhead`);
}
} else if (p[1] == 'workspace' && p[3] == 'cueLists') {
var workspace = p[2];
@@ -59,11 +59,7 @@ exports.data = function (device, osc) {
cue.groups = groups;
device.send(
'/workspace/' +
workspace +
'/cue_id/' +
cue.uniqueID +
'/valuesForKeys',
`/workspace/${workspace}/cue_id/${cue.uniqueID}/valuesForKeys`,
[
{
type: 's',
@@ -89,7 +85,7 @@ exports.data = function (device, osc) {
device.draw();
} else if (p[0] == 'update' && p[1] == 'workspace' && p[3] == 'cue_id') {
device.send('/workspace/' + p[2] + '/cueLists');
device.send(`/workspace/${p[2]}/cueLists`);
} else if (
p[0] == 'update' &&
p[1] == 'workspace' &&
@@ -143,8 +139,6 @@ exports.data = function (device, osc) {
exports.heartbeat = function (device) {
try {
device.send(
'/workspace/' + Object.keys(device.data.workspaces)[0] + '/thump'
);
device.send(`/workspace/${Object.keys(device.data.workspaces)[0]}/thump`);
} catch (err) {}
};
+1 -1
View File
@@ -27,7 +27,7 @@ exports.data = function (device, message) {
var i = 0;
while (arr[i][arr[i].length - 1] != '"') {
i++;
device.data.showName += arr[i] + ' ';
device.data.showName += `${arr[i]} `;
}
device.data.showName = device.data.showName.substring(
1,
+6 -8
View File
@@ -48,9 +48,9 @@ exports.data = function (device, buf) {
for (var i = 0; i <= 32; i++) {
device.send(
Buffer.from(
'/ch/' +
i.toString().padStart(2, '0') +
'/config/name\u0000\u0000\u0000\u0000'
`/ch/${i
.toString()
.padStart(2, '0')}/config/name\u0000\u0000\u0000\u0000`
)
);
}
@@ -85,7 +85,7 @@ exports.data = function (device, buf) {
}
device.draw();
device.send(
Buffer.from('/ch/' + addr[1] + '/mix/fader\u0000\u0000\u0000\u0000')
Buffer.from(`/ch/${addr[1]}/mix/fader\u0000\u0000\u0000\u0000`)
);
} else if (msg[0].indexOf('/config/name') > 0) {
var addr = parseAddress(msg[0]);
@@ -93,16 +93,14 @@ exports.data = function (device, buf) {
device.data.channelNames[channel - 1] = msg[2];
device.draw();
device.send(
Buffer.from('/ch/' + addr[1] + '/config/color\u0000\u0000\u0000\u0000')
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]);
device.data.channelColors[channel - 1] = buf.readInt8(27);
device.draw();
device.send(
Buffer.from('/ch/' + addr[1] + '/mix/on\u0000\u0000\u0000\u0000')
);
device.send(Buffer.from(`/ch/${addr[1]}/mix/on\u0000\u0000\u0000\u0000`));
} else {
//console.log(msg)
}
+6 -8
View File
@@ -53,9 +53,9 @@ exports.data = function (device, buf) {
for (var i = 0; i <= 32; i++) {
device.send(
Buffer.from(
'/ch/' +
i.toString().padStart(2, '0') +
'/config/name\u0000\u0000\u0000\u0000'
`/ch/${i
.toString()
.padStart(2, '0')}/config/name\u0000\u0000\u0000\u0000`
)
);
}
@@ -90,7 +90,7 @@ exports.data = function (device, buf) {
}
device.draw();
device.send(
Buffer.from('/ch/' + addr[1] + '/mix/fader\u0000\u0000\u0000\u0000')
Buffer.from(`/ch/${addr[1]}/mix/fader\u0000\u0000\u0000\u0000`)
);
} else if (msg[0].indexOf('/config/name') > 0) {
var addr = parseAddress(msg[0]);
@@ -98,16 +98,14 @@ exports.data = function (device, buf) {
device.data.channelNames[channel - 1] = msg[4];
device.draw();
device.send(
Buffer.from('/ch/' + addr[1] + '/config/color\u0000\u0000\u0000\u0000')
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]);
device.data.channelColors[channel - 1] = buf.readInt8(27);
device.draw();
device.send(
Buffer.from('/ch/' + addr[1] + '/mix/on\u0000\u0000\u0000\u0000')
);
device.send(Buffer.from(`/ch/${addr[1]}/mix/on\u0000\u0000\u0000\u0000`));
} else {
//console.log(msg)
}
+4 -6
View File
@@ -15,7 +15,7 @@ registerDevice = function (newDevice) {
console.log(PLUGINS.all);
if (PLUGINS.all[newDevice.type] == undefined) {
console.error('Plugin for device ' + newDevice.type + ' does not exist.');
console.error(`Plugin for device ${newDevice.type} does not exist.`);
return true;
}
@@ -166,11 +166,9 @@ module.exports.initDeviceConnection = initDeviceConnection;
module.exports.deleteActive = function () {
var device = VIEW.getActiveDevice();
var choice = confirm(
'Are you sure you want to delete ' +
device.type +
' device "' +
(device.displayName || device.defaultName) +
'"?'
`Are you sure you want to delete ${device.type} device "${
device.displayName || device.defaultName
}"?`
);
if (choice) {
+7 -10
View File
@@ -6,20 +6,17 @@ var allPlugins = {};
module.exports.all = allPlugins;
module.exports.init = function (callback) {
console.log('Loading plugin files... ' + __dirname + '/../plugins');
console.log(`Loading plugin files... ${__dirname}/../plugins`);
fs.readdir(__dirname + '/../plugins', function (err, files) {
fs.readdir(`${__dirname}/../plugins`, function (err, files) {
for (var i in files) {
var plugin = files[i];
if (plugin[0] != '.') {
console.log(i + ' ' + plugin);
allPlugins[plugin] = require(__dirname +
'/../plugins/' +
plugin +
'/' +
plugin +
'.js');
console.log(`${i} ${plugin}`);
allPlugins[
plugin
] = require(`${__dirname}/../plugins/${plugin}/${plugin}.js`);
allPlugins[plugin].deviceInfoUpdate = function (device, param, value) {
DEVICE.infoUpdate(device, param, value);
@@ -30,7 +27,7 @@ module.exports.init = function (callback) {
allPlugins[plugin].template = ejs.compile(
fs.readFileSync(
__dirname + '/../plugins/' + plugin + '/' + plugin + '.html',
`${__dirname}/../plugins/${plugin}/${plugin}.html`,
'utf8'
)
);
+2 -6
View File
@@ -46,7 +46,7 @@ loadSlot = function (slotIndex) {
module.exports.loadSlot = loadSlot;
module.exports.loadDevices = function () {
console.log('Loading ' + savedDevices.length + ' saved devices...');
console.log(`Loading ${savedDevices.length} saved devices...`);
console.log(savedDevices);
for (var i = 0; i < savedDevices.length; i++) {
@@ -75,11 +75,7 @@ module.exports.saveAll = function () {
}
localStorage.setItem('savedSlots', JSON.stringify(savedSlots));
console.log(
'Saved ' +
currentPins.length +
' pinned devices to slot ' +
activeSlot +
'!'
`Saved ${currentPins.length} pinned devices to slot ${activeSlot}!`
);
savedDevices = [];
+2 -2
View File
@@ -58,7 +58,7 @@ searchAll = function () {
break;
}
} catch (err) {
console.error('Unable to search for plugin ' + p);
console.error(`Unable to search for plugin ${p}`);
}
}
@@ -218,7 +218,7 @@ findOnlineDevices = function () {
cur[2] = j;
for (var k = Number(f[3]); k < Number(l[3]); k++) {
cur[3] = k;
allIPs.push(cur[0] + '.' + cur[1] + '.' + cur[2] + '.' + cur[3]);
allIPs.push(`${cur[0]}.${cur[1]}.${cur[2]}.${cur[3]}`);
}
}
}
+6 -18
View File
@@ -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');
var $deviceDrawArea = document.getElementById(`device-${id}-draw-area`);
var $devicePinned = document.getElementById(`device-${id}-pinned`);
if ($deviceDrawArea == null) {
return true;
@@ -68,7 +68,7 @@ drawDeviceInterface = function (id) {
str += '</body></html>';
$deviceDrawArea.setAttribute('class', d.type + ' draw-area');
$deviceDrawArea.setAttribute('class', `${d.type} draw-area`);
$deviceDrawArea.contentWindow.document.open();
$deviceDrawArea.contentWindow.document.write(str);
@@ -155,29 +155,17 @@ switchDevice = function (id) {
var $deviceWrapper = document.getElementById('device-' + i);
if (!$deviceWrapper) {
var html =
'<div class="col device-wrapper" id="device-' +
i +
'">' +
'<img id="device-' +
i +
'-pinned" class="device-pin" src="src/img/outline_push_pin_white_18dp.png">' +
'<iframe id="device-' +
i +
'-draw-area" class="draw-area"></iframe>' +
'<div id="device-' +
i +
'-settings"></div></div>';
var html = `<div class="col device-wrapper" id="device-${i}"><img id="device-${i}-pinned" class="device-pin" src="src/img/outline_push_pin_white_18dp.png"><iframe id="device-${i}-draw-area" class="draw-area"></iframe><div id="device-${i}-settings"></div></div>`;
document
.getElementById('all-devices')
.insertAdjacentHTML('afterbegin', html);
$deviceWrapper = document.getElementById('device-' + i);
$deviceWrapper = document.getElementById(`device-${i}`);
}
switchClass(document.getElementById(id), 'active-device');
drawDeviceInterface(id);
switchClass(document.getElementById('device-' + id), 'active-device-outline');
switchClass(document.getElementById(`device-${id}`), 'active-device-outline');
document.getElementById('device-settings-table').style.display = 'block';
document.getElementById('device-settings-plugin-dropdown').value =