homebridge-midea-platform 1.2.6-beta.7 → 1.2.6-beta.8
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 +50 -15
- package/package.json +1 -1
|
@@ -286,27 +286,62 @@
|
|
|
286
286
|
download_btn.className = 'btn btn-outline-secondary btn-sm';
|
|
287
287
|
download_btn.addEventListener('click', async () => {
|
|
288
288
|
try {
|
|
289
|
+
homebridge.showSpinner();
|
|
289
290
|
const file_data_str = await homebridge.request('/downloadLua', { deviceType: device.type, deviceSn: device.sn });
|
|
290
|
-
const blob = new Blob([file_data_str], { type: 'text/plain' });
|
|
291
291
|
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
292
|
+
const modal = document.createElement("div");
|
|
293
|
+
modal.className = 'modal fade';
|
|
294
|
+
modal.id = 'luaCodeModal';
|
|
295
|
+
modal.setAttribute('tabindex', '-1');
|
|
296
|
+
modal.setAttribute('aria-labelledby', 'luaCodeModalLabel');
|
|
297
|
+
modal.setAttribute('aria-hidden', 'true');
|
|
298
|
+
|
|
299
|
+
modal.innerHTML = `
|
|
300
|
+
<div class="modal-dialog modal-lg modal-dialog-scrollable">
|
|
301
|
+
<div class="modal-content">
|
|
302
|
+
<div class="modal-header">
|
|
303
|
+
<h5 class="modal-title" id="luaCodeModalLabel">Lua Code for ${device.model}</h5>
|
|
304
|
+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
305
|
+
</div>
|
|
306
|
+
<div class="modal-body">
|
|
307
|
+
<div class="mb-3">
|
|
308
|
+
<button id="copyLuaBtn" class="btn btn-primary">Copy to Clipboard</button>
|
|
309
|
+
<small class="text-muted ms-2">Save this as ${device.type.toString(16)}_${device.model}.lua</small>
|
|
310
|
+
</div>
|
|
311
|
+
<pre style="max-height: 500px; overflow-y: auto; white-space: pre-wrap; word-break: break-all;">${file_data_str}</pre>
|
|
312
|
+
</div>
|
|
313
|
+
<div class="modal-footer">
|
|
314
|
+
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
|
315
|
+
</div>
|
|
316
|
+
</div>
|
|
317
|
+
</div>
|
|
318
|
+
`;
|
|
319
|
+
|
|
320
|
+
document.body.appendChild(modal);
|
|
321
|
+
|
|
322
|
+
// Initialize the Bootstrap modal
|
|
323
|
+
const bootstrapModal = new bootstrap.Modal(modal);
|
|
324
|
+
bootstrapModal.show();
|
|
325
|
+
|
|
326
|
+
// Add event listener for the copy button
|
|
327
|
+
document.getElementById('copyLuaBtn').addEventListener('click', async () => {
|
|
328
|
+
try {
|
|
329
|
+
await navigator.clipboard.writeText(file_data_str);
|
|
330
|
+
homebridge.toast.success('Lua code copied to clipboard!');
|
|
331
|
+
} catch (e) {
|
|
332
|
+
homebridge.toast.error('Failed to copy to clipboard. Please select and copy the code manually.');
|
|
333
|
+
}
|
|
334
|
+
});
|
|
297
335
|
|
|
298
|
-
|
|
336
|
+
// Clean up when modal is hidden
|
|
337
|
+
modal.addEventListener('hidden.bs.modal', () => {
|
|
338
|
+
document.body.removeChild(modal);
|
|
339
|
+
});
|
|
299
340
|
|
|
300
|
-
|
|
301
|
-
new MouseEvent('click', {
|
|
302
|
-
bubbles: true,
|
|
303
|
-
cancelable: true,
|
|
304
|
-
view: window
|
|
305
|
-
})
|
|
306
|
-
);
|
|
341
|
+
homebridge.hideSpinner();
|
|
307
342
|
|
|
308
|
-
document.body.removeChild(a);
|
|
309
343
|
} catch (e) {
|
|
344
|
+
homebridge.hideSpinner();
|
|
310
345
|
homebridge.toast.error(e.message);
|
|
311
346
|
}
|
|
312
347
|
});
|
package/package.json
CHANGED