correct localSettings
This commit is contained in:
parent
49768a7849
commit
0f3cfc59cb
1 changed files with 11 additions and 6 deletions
|
@ -54,15 +54,19 @@
|
||||||
var client;
|
var client;
|
||||||
function ManagePwd () {
|
function ManagePwd () {
|
||||||
const pass = localStorage.getItem('mqtt_password');
|
const pass = localStorage.getItem('mqtt_password');
|
||||||
if (!pass) localStorage.setItem('mqtt_password', document.getElementById('pass').value);
|
if (pass) document.getElementById('pass').value = pass;
|
||||||
else 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 ();
|
ManagePwd ();
|
||||||
function Connection() {
|
function Connection() {
|
||||||
if (!mqtt) {
|
if (!mqtt) {
|
||||||
TextOut.value = 'MQTT not supported !!!\n';
|
TextOut.value = 'MQTT not supported !!!\n'; return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
options.password = document.getElementById('pass').value;
|
options.password = document.getElementById('pass').value;
|
||||||
// console.log (options);
|
// console.log (options);
|
||||||
|
@ -72,15 +76,16 @@
|
||||||
ConnBtn.innerHTML = 'Connect';
|
ConnBtn.innerHTML = 'Connect';
|
||||||
Main.btn.disabled = true;
|
Main.btn.disabled = true;
|
||||||
Refr.btn.disabled = true;
|
Refr.btn.disabled = true;
|
||||||
TextOut.value = "Disconnected\n"
|
TextOut.value = "Disconnected\n";
|
||||||
} else {
|
} else {
|
||||||
client = mqtt.connect(url, options)
|
client = mqtt.connect(url, options);
|
||||||
client.on('connect', function () {
|
client.on('connect', function () {
|
||||||
Connected = true;
|
Connected = true;
|
||||||
TextOut.value += 'Connected to ' + url + '\n';
|
TextOut.value += 'Connected to ' + url + '\n';
|
||||||
ConnBtn.innerHTML = 'Disconnect';
|
ConnBtn.innerHTML = 'Disconnect';
|
||||||
Main.btn.disabled = false;
|
Main.btn.disabled = false;
|
||||||
Refr.btn.disabled = false;
|
Refr.btn.disabled = false;
|
||||||
|
SetPwd ();
|
||||||
// Subscribe to a topic
|
// Subscribe to a topic
|
||||||
client.subscribe(InpTops + '#', function (err) {
|
client.subscribe(InpTops + '#', function (err) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
|
|
Loading…
Reference in a new issue