correct localSettings

This commit is contained in:
Kizarm 2024-07-05 19:16:42 +02:00
parent 49768a7849
commit 0f3cfc59cb

View file

@ -54,15 +54,19 @@
var client;
function ManagePwd () {
const pass = localStorage.getItem('mqtt_password');
if (!pass) localStorage.setItem('mqtt_password', document.getElementById('pass').value);
else document.getElementById('pass').value = pass;
if (pass) document.getElementById('pass').value = pass;
};
function SetPwd () {
const pass = localStorage.getItem('mqtt_password');
if (!pass || pass.length === 0) {
localStorage.setItem('mqtt_password', document.getElementById('pass').value);
}
}
ManagePwd ();
function Connection() {
if (!mqtt) {
TextOut.value = 'MQTT not supported !!!\n';
return;
TextOut.value = 'MQTT not supported !!!\n'; return;
}
options.password = document.getElementById('pass').value;
// console.log (options);
@ -72,15 +76,16 @@
ConnBtn.innerHTML = 'Connect';
Main.btn.disabled = true;
Refr.btn.disabled = true;
TextOut.value = "Disconnected\n"
TextOut.value = "Disconnected\n";
} else {
client = mqtt.connect(url, options)
client = mqtt.connect(url, options);
client.on('connect', function () {
Connected = true;
TextOut.value += 'Connected to ' + url + '\n';
ConnBtn.innerHTML = 'Disconnect';
Main.btn.disabled = false;
Refr.btn.disabled = false;
SetPwd ();
// Subscribe to a topic
client.subscribe(InpTops + '#', function (err) {
if (!err) {