Initial prettify

This commit is contained in:
Sam Schloegel
2022-01-03 10:51:25 -05:00
parent 551d29da60
commit c5691b56c9
26 changed files with 2602 additions and 2545 deletions
+102 -134
View File
@@ -1,215 +1,183 @@
const { remote } = require('electron');
const { ipcRenderer } = require('electron');
//let currWindow = remote.BrowserWindow.getFocusedWindow();
const { v4: uuid } = require('uuid');
let ejs = require('ejs');
let net = require("net");
let net = require('net');
let DEVICE = require("./src/device.js");
let PLUGINS = require("./src/plugins.js");
let SEARCH = require("./src/search.js");
let VIEW = require("./src/view.js");
let SAVESLOTS = require("./src/saveSlots.js");
let DEVICE = require('./src/device.js');
let PLUGINS = require('./src/plugins.js');
let SEARCH = require('./src/search.js');
let VIEW = require('./src/view.js');
let SAVESLOTS = require('./src/saveSlots.js');
window.addDevice = DEVICE.addDevice;
window.init = function () {
console.log('init!');
ipcRenderer.send('enableDeviceDropdown');
ipcRenderer.send('enableSearchAll');
window.init = function(){
console.log("init!")
ipcRenderer.send("enableDeviceDropdown");
ipcRenderer.send("enableSearchAll");
PLUGINS.init(function(){
PLUGINS.init(function () {
VIEW.init();
SAVESLOTS.loadDevices();
SAVESLOTS.loadSlot(1);
});
document.getElementById("device-settings-table").onclick = function(e){
document.getElementById('device-settings-table').onclick = function (e) {
e.stopPropagation();
}
document.getElementById("device-settings-name").onchange = function(e){
};
document.getElementById('device-settings-name').onchange = function (e) {
e.stopPropagation();
DEVICE.changeActiveName(e.target.value)
}
document.getElementById("device-settings-plugin-dropdown").onchange = function(e){
DEVICE.changeActiveName(e.target.value);
};
document.getElementById('device-settings-plugin-dropdown').onchange =
function (e) {
e.stopPropagation();
DEVICE.changeActiveType(e.target.value);
};
document.getElementById('device-settings-ip').onchange = function (e) {
e.stopPropagation();
DEVICE.changeActiveType(e.target.value)
}
document.getElementById("device-settings-ip").onchange = function(e){
DEVICE.changeActiveIP(e.target.value);
};
document.getElementById('device-settings-port').onchange = function (e) {
e.stopPropagation();
DEVICE.changeActiveIP(e.target.value)
}
document.getElementById("device-settings-port").onchange = function(e){
DEVICE.changeActivePort(e.target.value);
};
document.getElementById('device-settings-pin').onchange = function (e) {
e.stopPropagation();
DEVICE.changeActivePort(e.target.value)
}
document.getElementById("device-settings-pin").onchange = function(e){
e.stopPropagation();
if(e.target.checked){
if (e.target.checked) {
VIEW.pinActiveDevice();
}else{
} else {
VIEW.unpinActiveDevice();
}
}
};
document.getElementById("save-slot-1").onclick = function(e){
e.stopPropagation();
SAVESLOTS.loadSlot(1);
}
document.getElementById("save-slot-2").onclick = function(e){
e.stopPropagation();
SAVESLOTS.loadSlot(2);
}
document.getElementById("save-slot-3").onclick = function(e){
e.stopPropagation();
SAVESLOTS.loadSlot(3);
}
document.getElementById("refresh-device-button").onclick = function(e){
document.getElementById('save-slot-1').onclick = function (e) {
e.stopPropagation();
DEVICE.refreshActive()
}
SAVESLOTS.loadSlot(1);
};
document.getElementById('save-slot-2').onclick = function (e) {
e.stopPropagation();
SAVESLOTS.loadSlot(2);
};
document.getElementById('save-slot-3').onclick = function (e) {
e.stopPropagation();
SAVESLOTS.loadSlot(3);
};
document.getElementById("device-list").onclick = function(e){
e.stopPropagation();
var deviceID = e.srcElement.id;
if(e.srcElement.id != "device-list"){
VIEW.switchDevice(deviceID);
}
}
document.getElementById('refresh-device-button').onclick = function (e) {
e.stopPropagation();
DEVICE.refreshActive();
};
document.getElementById("add-device-button").onchange = function(e){
document.getElementById('device-list').onclick = function (e) {
e.stopPropagation();
var deviceID = e.srcElement.id;
if (e.srcElement.id != 'device-list') {
VIEW.switchDevice(deviceID);
}
};
DEVICE.registerDevice({
document.getElementById('add-device-button').onchange = function (e) {
DEVICE.registerDevice({
type: e.target.value,
defaultName: "New Device",
defaultName: 'New Device',
port: undefined,
addresses: []
addresses: [],
});
e.target.selectedIndex = 0;
SAVESLOTS.saveAll();
};
}
document.onkeyup = function(e){
switch(e.key){
case "ArrowUp":
document.onkeyup = function (e) {
switch (e.key) {
case 'ArrowUp':
VIEW.selectPreviousDevice();
break;
case "ArrowDown":
case 'ArrowDown':
VIEW.selectNextDevice();
break;
case "Tab":
if(document.activeElement.tagName!="INPUT" && document.activeElement.tagName!="SELECT"){
document.getElementById("device-settings-name").select();
case 'Tab':
if (
document.activeElement.tagName != 'INPUT' &&
document.activeElement.tagName != 'SELECT'
) {
document.getElementById('device-settings-name').select();
}
break;
}
}
};
// document.getElementById("device-settings-delete").onclick = function(e){
// e.stopPropagation();
// confirm("Are you sure you want to delete device \n\""+VIEW.getActiveDevice().name+"\"?")
// }
document.getElementById('device-list-col').onclick = function (e) {
try {
document
.querySelector('#device-list .active-device')
.classList.remove('active-device');
ipcRenderer.send('disableDeviceDropdown', '');
} catch (err) {
//console.log(err)
}
try {
document
.getElementsByClassName('active-device-outline')[0]
.classList.remove('active-device-outline');
} catch (err) {
//console.log(err)
}
document.getElementById("device-list-col").onclick = function(e){
try{
document.querySelector("#device-list .active-device").classList.remove("active-device");
ipcRenderer.send("disableDeviceDropdown", "");
}catch(err){
//console.log(err)
}
try{
document.getElementsByClassName("active-device-outline")[0].classList.remove("active-device-outline");
}catch(err){
//console.log(err)
}
VIEW.switchDevice();
}
};
};
}
ipcRenderer.on("setActiveDevicePinned", function(event, message){
if(!message){
ipcRenderer.on('setActiveDevicePinned', function (event, message) {
if (!message) {
VIEW.unpinActiveDevice();
}else{
} else {
VIEW.pinActiveDevice();
}
});
ipcRenderer.on("doSearch", function(event, message){
ipcRenderer.on('doSearch', function (event, message) {
window.searchAll();
});
ipcRenderer.on("doDelete", function(event, message){
ipcRenderer.on('doDelete', function (event, message) {
DEVICE.deleteActive();
});
ipcRenderer.on("resetViews", function(event, message){
ipcRenderer.on('resetViews', function (event, message) {
SAVESLOTS.resetSlots();
});
ipcRenderer.on("doSlots1", function(event, message){
ipcRenderer.on('doSlots1', function (event, message) {
SAVESLOTS.loadSlot(1);
});
ipcRenderer.on("doSlots2", function(event, message){
ipcRenderer.on('doSlots2', function (event, message) {
SAVESLOTS.loadSlot(2);
});
ipcRenderer.on("doSlots3", function(event, message){
ipcRenderer.on('doSlots3', function (event, message) {
SAVESLOTS.loadSlot(3);
});
function log(type, message) {}
function log(type, message){
}
function switchClass(element, className){
try{
function switchClass(element, className) {
try {
document.getElementsByClassName(className)[0].classList.remove(className);
}catch(err){
} catch (err) {
//console.log(err)
}
element.classList.add(className);
}
window.switchClass = function(element, className){
window.switchClass = function (element, className) {
switchClass(element, className);
}
};