mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-14 15:24:52 +09:00
Split up codebase into the packages @clsterio/lib, @clusterio/master, @clusterio/slave, and @clusterio/ctl using lerna to manage them. This will allow deployment to use only the parts needed reducing install size, and better separate the code into shared library, master, slave and control.
35 lines
1.3 KiB
JavaScript
35 lines
1.3 KiB
JavaScript
|
|
if(localStorage.settings) {
|
|
let settings = JSON.parse(localStorage.settings);
|
|
|
|
let HTML = "";
|
|
|
|
for(let key in settings) {
|
|
HTML += drawSetting(key, settings[key]);
|
|
}
|
|
document.querySelector("#body").innerHTML = document.querySelector("#body").innerHTML + HTML;
|
|
}
|
|
|
|
window.onload = function(){
|
|
// loop through all settings and add onclick events for them
|
|
let sliders = document.querySelectorAll(".settings-box .switch .slider");
|
|
for(let i = 0; i < sliders.length; i++) {
|
|
sliders[i].onclick = function() {
|
|
let settings = JSON.parse(localStorage.settings);
|
|
let selectedSliderParent = $(this.parentElement.parentElement);
|
|
// walk through DOM structure created by drawSetting and update localstorage from that
|
|
console.log(selectedSliderParent.find('.settings-text').html() + " = " + (selectedSliderParent.find("label input").val() === 'on'));
|
|
settings[selectedSliderParent.find('.settings-text').html()] = (selectedSliderParent.find("label input").val() === 'on');
|
|
|
|
localStorage.settings = JSON.stringify(settings);
|
|
}
|
|
}
|
|
};
|
|
|
|
function drawSetting(settingText, checked) {
|
|
|
|
let HTML = '<div class="settings-box">' +
|
|
'<label class="switch"><input type="checkbox" checked="' + checked + '"' +
|
|
'><div class="slider round"></div></label><span class="settings-text ml-3 align-middle">' + settingText + '</span></div>';
|
|
return HTML;
|
|
} |