Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error info: Use correct element id for errors #119

Merged
merged 1 commit into from
Aug 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1881,22 +1881,22 @@ class Somfy {
let fnValDup = (o, name) => {
let val = o[name];
if (typeof val === 'undefined' || isNaN(val)) {
ui.errorMessage(document.getElementById('fsSomfySettings'), 'You must define all the pins for the radio.');
ui.errorMessage(document.getElementById('divSomfySettings'), 'You must define all the pins for the radio.');
return false;
}
for (let s in o) {
if (s.endsWith('Pin') && s !== name) {
let sval = o[s];
if (typeof sval === 'undefined' || isNaN(sval)) {
ui.errorMessage(document.getElementById('fsSomfySettings'), 'You must define all the pins for the radio.');
ui.errorMessage(document.getElementById('divSomfySettings'), 'You must define all the pins for the radio.');
return false;
}
if (sval === val) {
if ((name === 'TXPin' && s === 'RXPin') ||
(name === 'RXPin' && s === 'TXPin'))
continue; // The RX and TX pins can share the same value. In this instance the radio will only use GDO0.
else {
ui.errorMessage(document.getElementById('fsSomfySettings'), `The ${name.replace('Pin', '')} pin is duplicated by the ${s.replace('Pin', '')}. All pin definitions must be unique`);
ui.errorMessage(document.getElementById('divSomfySettings'), `The ${name.replace('Pin', '')} pin is duplicated by the ${s.replace('Pin', '')}. All pin definitions must be unique`);
valid = false;
return false;
}
Expand Down Expand Up @@ -2591,19 +2591,19 @@ class Somfy {
let obj = ui.fromElement(document.getElementById('somfyShade'));
let valid = true;
if (valid && (isNaN(obj.remoteAddress) || obj.remoteAddress < 1 || obj.remoteAddress > 16777215)) {
ui.errorMessage(document.getElementById('fsSomfySettings'), 'The remote address must be a number between 1 and 16777215. This number must be unique for all shades.');
ui.errorMessage(document.getElementById('divSomfySettings'), 'The remote address must be a number between 1 and 16777215. This number must be unique for all shades.');
valid = false;
}
if (valid && (typeof obj.name !== 'string' || obj.name === '' || obj.name.length > 20)) {
ui.errorMessage(document.getElementById('fsSomfySettings'), 'You must provide a name for the shade between 1 and 20 characters.');
ui.errorMessage(document.getElementById('divSomfySettings'), 'You must provide a name for the shade between 1 and 20 characters.');
valid = false;
}
if (valid && (isNaN(obj.upTime) || obj.upTime < 1 || obj.upTime > 4294967295)) {
ui.errorMessage(document.getElementById('fsSomfySettings'), 'Up Time must be a value between 0 and 4,294,967,295 milliseconds. This is the travel time to go from full closed to full open.');
ui.errorMessage(document.getElementById('divSomfySettings'), 'Up Time must be a value between 0 and 4,294,967,295 milliseconds. This is the travel time to go from full closed to full open.');
valid = false;
}
if (valid && (isNaN(obj.downTime) || obj.downTime < 1 || obj.downTime > 4294967295)) {
ui.errorMessage(document.getElementById('fsSomfySettings'), 'Down Time must be a value between 0 and 4,294,967,295 milliseconds. This is the travel time to go from full open to full closed.');
ui.errorMessage(document.getElementById('divSomfySettings'), 'Down Time must be a value between 0 and 4,294,967,295 milliseconds. This is the travel time to go from full open to full closed.');
valid = false;
}
if (valid) {
Expand Down Expand Up @@ -2814,7 +2814,7 @@ class Somfy {
}
setRollingCode(shadeId, rollingCode) {
putJSONSync('/setRollingCode', { shadeId: shadeId, rollingCode: rollingCode }, (err, shade) => {
if (err) ui.serviceError(document.getElementById('fsSomfySettings'), err);
if (err) ui.serviceError(document.getElementById('divSomfySettings'), err);
else {
let dlg = document.getElementById('divRollingCode');
if (dlg) dlg.remove();
Expand Down