mirror of
https://github.com/stagehacks/Cue-View.git
synced 2026-08-06 06:13:40 +00:00
Define variables before use
This commit is contained in:
@@ -12,78 +12,10 @@ if (require('electron-squirrel-startup')) {
|
||||
app.quit();
|
||||
}
|
||||
|
||||
const isMac = process.platform === 'darwin';
|
||||
let menu;
|
||||
let mainWindow;
|
||||
|
||||
const createWindow = () => {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 1500,
|
||||
height: 900,
|
||||
titleBarStyle: 'hiddenInset',
|
||||
transparent: true,
|
||||
frame: false,
|
||||
show: false,
|
||||
// backgroundColor: "#333333",
|
||||
vibrancy: 'window',
|
||||
visualEffectState: 'followWindow',
|
||||
webPreferences: {
|
||||
// enableRemoteModule: true,
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true,
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
},
|
||||
});
|
||||
|
||||
mainWindow.loadFile('index.html');
|
||||
|
||||
mainWindow.on('ready-to-show', () => {
|
||||
mainWindow.show();
|
||||
});
|
||||
|
||||
if (process.defaultApp) {
|
||||
mainWindow.webContents.openDevTools();
|
||||
}
|
||||
|
||||
menu = Menu.buildFromTemplate(menuTemplate);
|
||||
Menu.setApplicationMenu(menu);
|
||||
};
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow();
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
||||
});
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('enableDeviceDropdown', (event, arg) => {
|
||||
menu.getMenuItemById('devicePin').enabled = true;
|
||||
menu.getMenuItemById('deviceDelete').enabled = true;
|
||||
});
|
||||
ipcMain.on('disableDeviceDropdown', (event, arg) => {
|
||||
menu.getMenuItemById('devicePin').enabled = false;
|
||||
menu.getMenuItemById('deviceDelete').enabled = false;
|
||||
});
|
||||
|
||||
ipcMain.on('enableSearchAll', (event, arg) => {
|
||||
menu.getMenuItemById('deviceSearch').enabled = true;
|
||||
});
|
||||
ipcMain.on('disableSearchAll', (event, arg) => {
|
||||
menu.getMenuItemById('deviceSearch').enabled = false;
|
||||
});
|
||||
|
||||
ipcMain.on('setDevicePin', (event, arg) => {
|
||||
menu.getMenuItemById('devicePin').checked = arg;
|
||||
});
|
||||
|
||||
const isMac = process.platform === 'darwin';
|
||||
|
||||
const menuTemplate = [
|
||||
{ role: 'appMenu' },
|
||||
{
|
||||
@@ -184,3 +116,70 @@ const menuTemplate = [
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const createWindow = () => {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 1500,
|
||||
height: 900,
|
||||
titleBarStyle: 'hiddenInset',
|
||||
transparent: true,
|
||||
frame: false,
|
||||
show: false,
|
||||
// backgroundColor: "#333333",
|
||||
vibrancy: 'window',
|
||||
visualEffectState: 'followWindow',
|
||||
webPreferences: {
|
||||
// enableRemoteModule: true,
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true,
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
},
|
||||
});
|
||||
|
||||
mainWindow.loadFile('index.html');
|
||||
|
||||
mainWindow.on('ready-to-show', () => {
|
||||
mainWindow.show();
|
||||
});
|
||||
|
||||
if (process.defaultApp) {
|
||||
mainWindow.webContents.openDevTools();
|
||||
}
|
||||
|
||||
menu = Menu.buildFromTemplate(menuTemplate);
|
||||
Menu.setApplicationMenu(menu);
|
||||
};
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow();
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
||||
});
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('enableDeviceDropdown', (event, arg) => {
|
||||
menu.getMenuItemById('devicePin').enabled = true;
|
||||
menu.getMenuItemById('deviceDelete').enabled = true;
|
||||
});
|
||||
ipcMain.on('disableDeviceDropdown', (event, arg) => {
|
||||
menu.getMenuItemById('devicePin').enabled = false;
|
||||
menu.getMenuItemById('deviceDelete').enabled = false;
|
||||
});
|
||||
|
||||
ipcMain.on('enableSearchAll', (event, arg) => {
|
||||
menu.getMenuItemById('deviceSearch').enabled = true;
|
||||
});
|
||||
ipcMain.on('disableSearchAll', (event, arg) => {
|
||||
menu.getMenuItemById('deviceSearch').enabled = false;
|
||||
});
|
||||
|
||||
ipcMain.on('setDevicePin', (event, arg) => {
|
||||
menu.getMenuItemById('devicePin').checked = arg;
|
||||
});
|
||||
|
||||
+42
-42
@@ -20,48 +20,6 @@ exports.ready = function (device) {
|
||||
};
|
||||
let password = false;
|
||||
|
||||
exports.data = function (device, message) {
|
||||
this.deviceInfoUpdate(device, 'status', 'ok');
|
||||
const msg = message.toString();
|
||||
|
||||
if (msg.substring(0, 8) == 'PJLINK 1') {
|
||||
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`
|
||||
);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%1POWR=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%1INPT=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%1AVMT=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%1ERST=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%1LAMP=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%1NAME=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%1INF1=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%1INF2=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%2SNUM=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%2SVER=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
};
|
||||
|
||||
function processPJLink(device, str, that) {
|
||||
const arr = str.split('%');
|
||||
for (var key in arr) {
|
||||
@@ -111,6 +69,48 @@ function processPJLink(device, str, that) {
|
||||
device.draw();
|
||||
}
|
||||
|
||||
exports.data = function (device, message) {
|
||||
this.deviceInfoUpdate(device, 'status', 'ok');
|
||||
const msg = message.toString();
|
||||
|
||||
if (msg.substring(0, 8) == 'PJLINK 1') {
|
||||
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`
|
||||
);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%1POWR=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%1INPT=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%1AVMT=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%1ERST=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%1LAMP=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%1NAME=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%1INF1=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%1INF2=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%2SNUM=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
if (msg.substring(0, 7) == '%2SVER=') {
|
||||
processPJLink(device, msg, this);
|
||||
}
|
||||
};
|
||||
|
||||
exports.heartbeat = function (device) {
|
||||
if (password) {
|
||||
device.send(
|
||||
|
||||
@@ -45,8 +45,6 @@ exports.data = function (device, osc) {
|
||||
device.data.workspaces[workspace].cueLists[d[i].uniqueID].cues =
|
||||
d[i].cues;
|
||||
|
||||
getMoreCueInfo(d[i], []);
|
||||
|
||||
function getMoreCueInfo(group, groups_arg) {
|
||||
const groups = JSON.parse(JSON.stringify(groups_arg));
|
||||
groups.push(group.uniqueID);
|
||||
@@ -79,6 +77,8 @@ exports.data = function (device, osc) {
|
||||
device.data.workspaces[workspace].allCues[cue.uniqueID] = cue;
|
||||
}
|
||||
}
|
||||
|
||||
getMoreCueInfo(d[i], []);
|
||||
}
|
||||
|
||||
// console.log(device.data.lastCueInGroup)
|
||||
|
||||
+18
-18
@@ -31,6 +31,24 @@ exports.ready = function (device) {
|
||||
// device.send(Buffer.from("/subscribe\x00,si\x00/-stat/solosw/01\x001"));
|
||||
};
|
||||
|
||||
function parseAddress(msg) {
|
||||
const addr = msg.split('/');
|
||||
addr.shift();
|
||||
return addr;
|
||||
}
|
||||
|
||||
function convertToDBTheBehringerWay(f) {
|
||||
if (f >= 0.5) {
|
||||
return f * 40 - 30;
|
||||
} else if (f >= 0.25) {
|
||||
return f * 80 - 50;
|
||||
} else if (f >= 0.0625) {
|
||||
return f * 160 - 70;
|
||||
} else {
|
||||
return f * 480 - 90;
|
||||
}
|
||||
}
|
||||
|
||||
exports.data = function (device, buf) {
|
||||
this.deviceInfoUpdate(device, 'status', 'ok');
|
||||
const msg = buf.toString().split('\u0000\u0000');
|
||||
@@ -110,21 +128,3 @@ exports.data = function (device, buf) {
|
||||
exports.heartbeat = function (device) {
|
||||
device.send(Buffer.from('/xremote'));
|
||||
};
|
||||
|
||||
function parseAddress(msg) {
|
||||
const addr = msg.split('/');
|
||||
addr.shift();
|
||||
return addr;
|
||||
}
|
||||
|
||||
function convertToDBTheBehringerWay(f) {
|
||||
if (f >= 0.5) {
|
||||
return f * 40 - 30;
|
||||
} else if (f >= 0.25) {
|
||||
return f * 80 - 50;
|
||||
} else if (f >= 0.0625) {
|
||||
return f * 160 - 70;
|
||||
} else {
|
||||
return f * 480 - 90;
|
||||
}
|
||||
}
|
||||
|
||||
+18
-18
@@ -31,6 +31,24 @@ exports.ready = function (device) {
|
||||
// device.send(Buffer.from("/subscribe\x00,si\x00/-stat/solosw/01\x001"));
|
||||
};
|
||||
|
||||
function parseAddress(msg) {
|
||||
const addr = msg.split('/');
|
||||
addr.shift();
|
||||
return addr;
|
||||
}
|
||||
|
||||
function convertToDBTheBehringerWay(f) {
|
||||
if (f >= 0.5) {
|
||||
return f * 40 - 30;
|
||||
} else if (f >= 0.25) {
|
||||
return f * 80 - 50;
|
||||
} else if (f >= 0.0625) {
|
||||
return f * 160 - 70;
|
||||
} else {
|
||||
return f * 480 - 90;
|
||||
}
|
||||
}
|
||||
|
||||
exports.data = function (device, buf) {
|
||||
this.deviceInfoUpdate(device, 'status', 'ok');
|
||||
const msg = buf.toString().split('\u0000');
|
||||
@@ -115,21 +133,3 @@ exports.data = function (device, buf) {
|
||||
exports.heartbeat = function (device) {
|
||||
device.send(Buffer.from('/xremote'));
|
||||
};
|
||||
|
||||
function parseAddress(msg) {
|
||||
const addr = msg.split('/');
|
||||
addr.shift();
|
||||
return addr;
|
||||
}
|
||||
|
||||
function convertToDBTheBehringerWay(f) {
|
||||
if (f >= 0.5) {
|
||||
return f * 40 - 30;
|
||||
} else if (f >= 0.25) {
|
||||
return f * 80 - 50;
|
||||
} else if (f >= 0.0625) {
|
||||
return f * 160 - 70;
|
||||
} else {
|
||||
return f * 480 - 90;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -237,7 +237,6 @@ infoUpdate = function (device, param, value) {
|
||||
};
|
||||
module.exports.infoUpdate = infoUpdate;
|
||||
|
||||
setInterval(heartbeat, 100);
|
||||
function heartbeat() {
|
||||
for (let i in devices) {
|
||||
const device = devices[i];
|
||||
@@ -257,3 +256,4 @@ function heartbeat() {
|
||||
}
|
||||
}
|
||||
}
|
||||
setInterval(heartbeat, 100);
|
||||
|
||||
+23
-23
@@ -13,6 +13,29 @@ const PLUGINS = require('./plugins.js');
|
||||
let searching = false;
|
||||
let allServers = false;
|
||||
|
||||
// from local-devices library
|
||||
function getServers() {
|
||||
const interfaces = os.networkInterfaces();
|
||||
const result = [];
|
||||
|
||||
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) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const searchSockets = [];
|
||||
|
||||
searchAll = function () {
|
||||
if (searching) {
|
||||
return true;
|
||||
@@ -166,27 +189,6 @@ TCPtest = function (ip, pluginType, plugin) {
|
||||
});
|
||||
};
|
||||
|
||||
// from local-devices library
|
||||
function getServers() {
|
||||
const interfaces = os.networkInterfaces();
|
||||
const result = [];
|
||||
|
||||
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) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
findOnlineDevices = function () {
|
||||
const allInterfaces = os.networkInterfaces();
|
||||
const validInterfaces = [];
|
||||
@@ -287,8 +289,6 @@ const xAirMessage = Buffer.from([0x2f, 0x78, 0x69, 0x6e, 0x66, 0x6f]);
|
||||
const serverUDP = dgram.createSocket('udp4');
|
||||
const serverUDP2 = dgram.createSocket('udp4');
|
||||
|
||||
const searchSockets = [];
|
||||
|
||||
newSearchUDP = function (pluginType, plugin) {
|
||||
const i = searchSockets.push(dgram.createSocket('udp4')) - 1;
|
||||
searchSockets[i].bind(plugin.searchOptions.listenPort, () => {
|
||||
|
||||
Reference in New Issue
Block a user