2017-07-22 00:54:55 +02:00
|
|
|
/* Settings.js */
|
2017-08-30 19:44:29 +02:00
|
|
|
let Settings = {
|
2017-07-22 00:54:55 +02:00
|
|
|
CodeInstructionRunTime: 100,
|
|
|
|
MaxLogCapacity: 50,
|
|
|
|
MaxPortCapacity: 50,
|
2017-07-27 04:56:14 +02:00
|
|
|
SuppressMessages: false,
|
|
|
|
SuppressFactionInvites: false,
|
2017-07-25 16:39:56 +02:00
|
|
|
}
|
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
function loadSettings(saveString) {
|
|
|
|
Settings = JSON.parse(saveString);
|
|
|
|
}
|
|
|
|
|
2017-07-25 16:39:56 +02:00
|
|
|
function initSettings() {
|
|
|
|
Settings.CodeInstructionRunTime = 100;
|
|
|
|
Settings.MaxLogCapacity = 50;
|
|
|
|
Settings.MaxPortCapacity = 50;
|
2017-07-27 04:56:14 +02:00
|
|
|
Settings.SuppressMessages = false;
|
|
|
|
Settings.SuppressFactionInvites = false;
|
2017-07-25 16:39:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function setSettingsLabels() {
|
2017-08-30 19:44:29 +02:00
|
|
|
var nsExecTime = document.getElementById("settingsNSExecTimeRangeValLabel");
|
|
|
|
var nsLogLimit = document.getElementById("settingsNSLogRangeValLabel");
|
|
|
|
var nsPortLimit = document.getElementById("settingsNSPortRangeValLabel");
|
|
|
|
var suppressMsgs = document.getElementById("settingsSuppressMessages");
|
|
|
|
var suppressFactionInv = document.getElementById("settingsSuppressFactionInvites")
|
|
|
|
|
|
|
|
//Initialize values on labels
|
|
|
|
nsExecTime.innerHTML = Settings.CodeInstructionRunTime + "ms";
|
|
|
|
nsLogLimit.innerHTML = Settings.MaxLogCapacity;
|
|
|
|
nsPortLimit.innerHTML = Settings.MaxPortCapacity;
|
|
|
|
suppressMsgs.checked = Settings.SuppressMessages;
|
|
|
|
suppressFactionInv.checked = Settings.SuppressFactionInvites;
|
|
|
|
|
|
|
|
//Set handlers for when input changes
|
|
|
|
document.getElementById("settingsNSExecTimeRangeVal").oninput = function() {
|
|
|
|
nsExecTime.innerHTML = this.value + 'ms';
|
|
|
|
Settings.CodeInstructionRunTime = this.value;
|
|
|
|
};
|
|
|
|
|
|
|
|
document.getElementById("settingsNSLogRangeVal").oninput = function() {
|
|
|
|
nsLogLimit.innerHTML = this.value;
|
|
|
|
Settings.MaxLogCapacity = this.value;
|
|
|
|
};
|
|
|
|
|
|
|
|
document.getElementById("settingsNSPortRangeVal").oninput = function() {
|
|
|
|
nsPortLimit.innerHTML = this.value;
|
|
|
|
Settings.MaxPortCapacity = this.value;
|
|
|
|
};
|
|
|
|
|
|
|
|
document.getElementById("settingsSuppressMessages").onclick = function() {
|
|
|
|
Settings.SuppressMessages = this.checked;
|
|
|
|
};
|
|
|
|
|
|
|
|
document.getElementById("settingsSuppressFactionInvites").onclick = function() {
|
|
|
|
Settings.SuppressFactionInvites = this.checked;
|
|
|
|
};
|
2017-07-25 16:39:56 +02:00
|
|
|
}
|
2017-08-30 19:44:29 +02:00
|
|
|
|
|
|
|
export {Settings, initSettings, setSettingsLabels, loadSettings};
|