SkyNX/SkyNX-Streamer/js/settings.js

89 lines
2.6 KiB
JavaScript
Raw Normal View History

2020-04-16 00:15:44 +00:00
var debug = true;
var clientSettings = {
2020-04-16 03:58:28 +00:00
"debug": false,
2020-04-16 00:15:44 +00:00
"accentColor": {
"r": 50,
"g": 50,
"b": 50,
"a": 0.9
},
2020-04-16 03:58:28 +00:00
"rainbowEnabled": true,
"devToolsOnStartup": false,
"ip": "172.16.0.10",
"quality": 5
2020-04-16 00:15:44 +00:00
};
var clientSettingsPath = "./settings.json";
if (fs.existsSync(clientSettingsPath)) {
loadClientSettings();
} else {
DB.save(clientSettingsPath, clientSettings)
}
var saveSettingsTO
function saveClientSettingsTimeout() {
clearTimeout(saveSettingsTO);
saveSettingsTO = setTimeout(saveClientSettings, 500);
}
function saveClientSettings() {
verifySettings();
DB.save(clientSettingsPath, clientSettings);
}
function verifySettings() {
}
function loadClientSettings() {
clientSettings = DB.load(clientSettingsPath)
$("#debugEnabled").prop("checked", clientSettings.debug);
$("#rainbowEnabled").prop("checked", clientSettings.rainbowEnabled);
$("#devToolsOnStartup").prop("checked", clientSettings.devToolsOnStartup);
2020-04-16 03:58:28 +00:00
$("#qualitySlider").val(clientSettings.quality);
$('#qualityLabel').html("Quality: " + clientSettings.quality + "M");
$("#ipInput").val(clientSettings.ip);
2020-04-16 00:15:44 +00:00
applyClientSettings();
if (clientSettings.devToolsOnStartup) {
openDevTools();
}
}
function applyClientSettings() {
if (clientSettings.debug) {
$("#dev-btn").fadeIn(400);
$("#rld-btn").fadeIn(400);
} else {
$("#dev-btn").fadeOut(400);
$("#rld-btn").fadeOut(400);
}
if (clientSettings.rainbowEnabled) {
rainbowAccent();
} else {
setAccentColor(clientSettings.accentColor.r, clientSettings.accentColor.g, clientSettings.accentColor.b, clientSettings.accentColor.a);
}
}
$("#rainbowEnabled").on('change', function () {
clientSettings.rainbowEnabled = $("#rainbowEnabled").prop("checked");
saveClientSettings();
applyClientSettings();
});
// $("#debugEnabled").on('change', function () {
// clientSettings.debug = $("#debugEnabled").prop("checked");
// saveClientSettings();
// applyClientSettings();
// });
// $("#devToolsOnStartup").on('change', function () {
// clientSettings.devToolsOnStartup = $("#devToolsOnStartup").prop("checked");
// saveClientSettings();
// applyClientSettings();
// });
$('#installScpVBusBtn').click(function () {
ipcRenderer.send('installScpVBus');
2020-04-16 00:15:44 +00:00
});
$('#unInstallScpVBusBtn').click(function () {
ipcRenderer.send('unInstallScpVBus');
});
$('#installAudioDriverBtn').click(function () {
ipcRenderer.send('installAudioDriver');
2020-04-16 00:15:44 +00:00
});
$('#unInstallAudioDriverBtn').click(function () {
ipcRenderer.send('unInstallAudioDriver');
});