mirror of
https://github.com/thelounge/thelounge
synced 2024-11-23 04:23:13 +00:00
27393bb804
Write synced settings to localstorage. move settings and webpush init to init.js stub for server sending clientsettings get very basic setting sync working Also update client.config.clientSettings on settings:set Full setting sync with mandatory and excluded sync options Actually check client preferences. Further settings restructuring. Refactor options.js make storage act in a sane manner. Add new parameter to applySetting Do not sync if the setting is stored as a result of syncing General clean up, commenting and restructing. sync from server on checking "sync" offer initial sync Better deal with DOM being ready and instances of inital sync showing Don't try to disable autocompletion when not enabled. Restructure option.js to seperate functions from settings. More consistency in naming options vs settings Switch processSetting and applySetting names reflecting their functionality better. move options init back to configuration. simplify how settings are synced around. move options init after template building. Remove unneeded hasOwnProperty Use global for #theme and only apply theme in applySetting Return when no server side clientsettings excist. Autocompletion options to options.settings Make nocss param in url work again. Actually filter out empty highlight values. Clarify alwaysSync comment. Remove manual step for initial sync change attr to prop in options.js replace unbind with off in autocompletion.js Do not sync settings when the lounge is set to public. fix eslint error Fix merge error Do not show sync warning after page refresh when sync is enabled Move setting sync label in actual label. Improve server setting sync handling performance and failure potential. Don't give impression that the desktop notificiation is off when the browser permission is denied. Refine showing and hiding of notification warnings. rename all setting socket events to singular setting. add experimental note and icon to settingsync. fix css linting error
69 lines
1.7 KiB
JavaScript
69 lines
1.7 KiB
JavaScript
"use strict";
|
|
|
|
const $ = require("jquery");
|
|
const socket = require("../socket");
|
|
const templates = require("../../views");
|
|
const options = require("../options");
|
|
const webpush = require("../webpush");
|
|
|
|
socket.on("configuration", function(data) {
|
|
if (options.initialized) {
|
|
return;
|
|
}
|
|
|
|
$("#settings").html(templates.windows.settings(data));
|
|
$("#connect").html(templates.windows.connect(data));
|
|
$("#help").html(templates.windows.help(data));
|
|
$("#changelog").html(templates.windows.changelog());
|
|
|
|
$("#play").on("click", () => {
|
|
const pop = new Audio();
|
|
pop.src = "audio/pop.ogg";
|
|
pop.play();
|
|
});
|
|
|
|
options.initialize();
|
|
webpush.initialize();
|
|
|
|
const forms = $("#connect form, #change-password form");
|
|
|
|
forms.on("submit", function() {
|
|
const form = $(this);
|
|
const event = form.data("event");
|
|
|
|
form.find(".btn").prop("disabled", true);
|
|
|
|
const values = {};
|
|
$.each(form.serializeArray(), function(i, obj) {
|
|
if (obj.value !== "") {
|
|
values[obj.name] = obj.value;
|
|
}
|
|
});
|
|
|
|
socket.emit(event, values);
|
|
|
|
return false;
|
|
});
|
|
|
|
$(".nick")
|
|
.on("focusin", function() {
|
|
// Need to set the first "lastvalue", so it can be used in the below function
|
|
const nick = $(this);
|
|
nick.data("lastvalue", nick.val());
|
|
})
|
|
.on("input", function() {
|
|
const nick = $(this).val();
|
|
const usernameInput = forms.find(".username");
|
|
|
|
// Because this gets called /after/ it has already changed, we need use the previous value
|
|
const lastValue = $(this).data("lastvalue");
|
|
|
|
// They were the same before the change, so update the username field
|
|
if (usernameInput.val() === lastValue) {
|
|
usernameInput.val(nick);
|
|
}
|
|
|
|
// Store the "previous" value, for next time
|
|
$(this).data("lastvalue", nick);
|
|
});
|
|
});
|