homebridge-melcloud-control 4.0.0-beta.233 → 4.0.0-beta.235
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/homebridge-ui/public/index.html +52 -40
- package/package.json +1 -1
|
@@ -96,78 +96,90 @@
|
|
|
96
96
|
|
|
97
97
|
<script>
|
|
98
98
|
(async () => {
|
|
99
|
-
const
|
|
99
|
+
const pluginConfig = await homebridge.getPluginConfig();
|
|
100
100
|
|
|
101
|
-
if (!
|
|
102
|
-
|
|
103
|
-
await homebridge.updatePluginConfig(
|
|
101
|
+
if (!pluginConfig.length) {
|
|
102
|
+
pluginConfig.push({});
|
|
103
|
+
await homebridge.updatePluginConfig(pluginConfig);
|
|
104
104
|
homebridge.showSchemaForm();
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
config[0].accounts ??= [];
|
|
109
|
-
|
|
110
|
-
// 🧩 Deep clone — UI-safe copy (JSON method resets references)
|
|
111
|
-
const pluginConfig = JSON.parse(JSON.stringify(config));
|
|
112
|
-
|
|
113
108
|
this.accountIndex = 0;
|
|
114
|
-
const
|
|
109
|
+
const accounts = pluginConfig[0].accounts || [];
|
|
110
|
+
const accountsCount = accounts.length;
|
|
115
111
|
|
|
116
112
|
const container = document.getElementById("accountButton");
|
|
117
113
|
container.style.display = 'flex';
|
|
118
114
|
container.style.flexWrap = 'wrap';
|
|
119
115
|
container.style.justifyContent = 'center';
|
|
120
116
|
container.style.gap = '0.25rem';
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
117
|
+
container.style.alignItems = 'center';
|
|
118
|
+
|
|
119
|
+
const formElements = {
|
|
120
|
+
name: document.getElementById('name'),
|
|
121
|
+
user: document.getElementById('user'),
|
|
122
|
+
passwd: document.getElementById('passwd'),
|
|
123
|
+
language: document.getElementById('language'),
|
|
124
|
+
accountType: document.getElementById('accountType'),
|
|
125
|
+
logIn: document.getElementById('logIn'),
|
|
126
|
+
accountName: document.getElementById('accountName')
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// Tworzenie przycisków
|
|
130
|
+
accounts.forEach((account, i) => {
|
|
124
131
|
const button = document.createElement("button");
|
|
125
132
|
button.type = "button";
|
|
126
133
|
button.id = `button${i}`;
|
|
127
134
|
button.className = "btn btn-primary";
|
|
128
135
|
button.style.textTransform = 'none';
|
|
129
|
-
button.innerText =
|
|
136
|
+
button.innerText = account.name || `Account ${i + 1}`;
|
|
130
137
|
container.appendChild(button);
|
|
131
138
|
|
|
132
139
|
button.addEventListener('click', async () => {
|
|
133
|
-
|
|
134
|
-
document.getElementById(`button${j}`).className = (j === i ? 'btn btn-primary' : 'btn btn-secondary');
|
|
135
|
-
}
|
|
140
|
+
this.accountIndex = i;
|
|
136
141
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
document.getElementById('passwd').value = acc.passwd || '';
|
|
142
|
-
document.getElementById('language').value = acc.language || '0';
|
|
143
|
-
document.getElementById('accountType').value = acc.type || 'disabled';
|
|
144
|
-
document.getElementById('logIn').disabled = !(acc.name && acc.user && acc.passwd && acc.language && acc.type);
|
|
145
|
-
});
|
|
142
|
+
// Zmieniamy klasę wszystkich przycisków
|
|
143
|
+
accounts.forEach((_, j) => {
|
|
144
|
+
document.getElementById(`button${j}`).className = (j === i ? 'btn btn-primary' : 'btn btn-secondary');
|
|
145
|
+
});
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
// Ustawiamy formularz
|
|
148
|
+
formElements.accountName.innerText = account.name || '';
|
|
149
|
+
formElements.name.value = account.name || '';
|
|
150
|
+
formElements.user.value = account.user || '';
|
|
151
|
+
formElements.passwd.value = account.passwd || '';
|
|
152
|
+
formElements.language.value = account.language || '0';
|
|
153
|
+
formElements.accountType.value = account.type || 'disabled';
|
|
149
154
|
|
|
150
|
-
|
|
151
|
-
|
|
155
|
+
formElements.logIn.disabled = !(account.name && account.user && account.passwd && account.language && account.type);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
152
158
|
|
|
153
|
-
|
|
159
|
+
// Klikamy pierwszy przycisk po zakończeniu pętli
|
|
160
|
+
if (accountsCount > 0) document.getElementById('button0').click();
|
|
154
161
|
|
|
155
|
-
//
|
|
162
|
+
// Jeden listener input dla całego formularza
|
|
156
163
|
document.getElementById('configForm').addEventListener('input', async () => {
|
|
157
|
-
const
|
|
158
|
-
if (!
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
+
const account = accounts[this.accountIndex];
|
|
165
|
+
if (!account) return;
|
|
166
|
+
|
|
167
|
+
account.name = formElements.name.value;
|
|
168
|
+
account.user = formElements.user.value;
|
|
169
|
+
account.passwd = formElements.passwd.value;
|
|
170
|
+
account.language = formElements.language.value;
|
|
171
|
+
account.type = formElements.accountType.value;
|
|
164
172
|
|
|
165
|
-
|
|
173
|
+
formElements.logIn.disabled = !(account.name && account.user && account.passwd && account.language && account.type);
|
|
166
174
|
|
|
167
175
|
await homebridge.updatePluginConfig(pluginConfig);
|
|
168
176
|
await homebridge.savePluginConfig(pluginConfig);
|
|
169
177
|
});
|
|
170
178
|
|
|
179
|
+
document.getElementById('melCloudAccount').style.display = 'block';
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
171
183
|
// --- Config Button Toggle ---
|
|
172
184
|
const configButton = document.getElementById('configButton');
|
|
173
185
|
let configButtonState = false;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.235",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|