diff --git a/chata/index.html b/chata/index.html
index 2b4e947..0739d1c 100644
--- a/chata/index.html
+++ b/chata/index.html
@@ -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) {