Skip to content

Commit

Permalink
Prevent form submit when updating firmware
Browse files Browse the repository at this point in the history
  • Loading branch information
sidoh committed Oct 21, 2024
1 parent 82809a1 commit 907db8d
Show file tree
Hide file tree
Showing 11 changed files with 494 additions and 20 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ platformio run -e d1_mini --target upload
Alternatively, you can download a pre-compiled firmware image from the [releases](https://github.com/sidoh/esp8266_milight_hub/releases). This can be used with [`esptool.py`](https://github.com/espressif/esptool):

```
esptool.py write_flash 0x1000 <firmware_file.bin>
esptool.py write_flash 0x0 <firmware_file.bin>
```

Make sure you read instructions

### Configure WiFi

This project uses [WiFiManager](https://github.com/tzapu/WiFiManager) to avoid the need to hardcode AP credentials in the firmware.
Expand Down
6 changes: 3 additions & 3 deletions dist/bundle.js.gz.h

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/index.html.gz.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define index_html_gz_len 1834
static const char index_html_filename[] = "/dist/index.19e2cb4f.html";
static const char index_html_gz[] PROGMEM = {31,139,8,0,0,0,0,0,2,10,237,88,109,115,218,184,22,254,222,153,253,15,90,223,238,140,25,19,139,164,16,8,9,153,43,108,210,164,37,196,180,201,238,166,59,59,91,99,203,47,193,216,92,89,96,72,134,255,126,143,108,3,54,144,182,31,238,183,91,207,96,89,210,209,209,115,30,157,23,13,111,46,126,213,239,180,251,71,163,135,60,62,9,46,223,92,136,6,5,102,232,118,36,26,74,98,128,154,54,52,19,202,77,100,121,38,139,41,239,72,15,247,87,71,45,105,61,28,154,19,218,145,230,62,77,166,17,227,18,178,162,144,211,16,196,18,223,230,94,199,166,115,223,162,71,105,167,138,252,208,231,190,25,28,197,150,25,208,206,177,90,19,106,184,207,3,122,121,235,247,125,215,227,232,122,54,186,192,217,208,155,139,192,15,199,200,99,212,233,72,182,201,205,182,63,49,93,138,23,71,62,236,114,62,50,99,122,90,175,18,66,186,132,244,72,15,222,162,213,72,55,234,14,9,185,114,161,171,137,23,25,138,215,13,89,207,175,159,30,41,63,229,62,126,215,26,144,174,174,104,137,142,159,134,49,57,155,62,220,145,238,167,25,134,254,245,48,33,138,107,48,98,212,111,71,132,124,105,57,45,162,45,70,103,208,127,63,78,180,63,48,137,136,254,248,164,16,163,113,166,13,245,230,21,25,19,13,227,144,124,120,252,136,135,100,136,147,58,177,220,57,38,70,243,88,75,180,207,186,209,34,10,25,63,66,159,129,25,3,172,212,8,94,244,44,98,28,51,45,33,183,56,26,19,221,81,174,201,13,110,130,73,125,220,136,137,110,156,53,8,169,61,0,158,58,118,161,255,39,83,128,137,59,236,234,129,134,65,223,188,54,32,228,29,238,37,221,122,15,240,181,18,214,36,70,237,134,130,254,166,81,39,35,167,213,39,100,246,1,39,218,239,250,28,228,61,235,61,209,174,21,221,237,62,227,36,6,251,154,152,116,239,149,47,67,114,171,205,107,196,116,67,76,62,220,99,125,168,43,61,67,236,223,140,201,157,131,117,162,99,125,1,120,221,19,56,137,250,0,187,221,26,118,19,162,127,121,134,245,125,224,11,240,119,31,137,146,252,231,150,252,124,126,62,63,159,255,243,7,242,92,233,121,136,225,165,12,18,66,222,63,223,108,70,111,158,106,228,163,71,200,181,215,202,71,34,241,26,164,159,221,36,77,209,240,43,172,72,159,9,17,41,95,143,159,10,99,159,251,201,43,80,186,183,225,160,60,194,110,245,228,247,254,167,114,45,208,245,7,251,53,107,62,232,5,89,237,161,46,154,143,122,217,196,43,77,200,88,226,243,180,80,107,254,204,65,136,154,244,71,223,37,38,217,226,236,127,132,170,117,55,20,122,234,101,48,221,177,177,249,54,26,192,129,62,249,2,235,90,99,224,169,63,7,156,154,163,192,218,103,12,233,214,192,130,35,71,129,215,53,118,243,62,84,27,144,15,241,56,151,215,151,247,208,111,76,172,92,31,233,72,136,209,160,35,137,50,43,33,190,156,66,133,47,150,94,9,97,40,206,49,95,138,34,141,208,191,130,200,180,253,208,69,47,208,65,104,26,197,80,229,163,176,141,28,127,65,237,243,116,144,71,211,54,106,212,126,203,122,1,117,120,161,203,153,25,198,78,196,38,237,236,51,48,57,149,143,96,186,138,196,187,146,73,57,112,179,56,138,253,103,218,70,39,245,233,162,48,232,152,19,63,88,182,17,97,112,185,168,162,24,84,28,197,148,249,142,144,89,189,185,192,57,212,139,216,98,254,148,95,202,206,44,180,4,68,36,87,208,203,47,32,4,70,197,28,89,118,216,133,75,5,234,32,201,227,124,26,183,49,134,33,245,41,182,105,224,207,153,26,82,142,93,15,199,190,29,121,152,198,211,214,201,233,233,63,176,181,184,184,252,227,205,70,255,78,232,232,4,167,47,219,143,57,158,83,22,195,46,49,134,155,142,90,199,210,249,118,43,199,15,104,12,27,253,245,75,106,198,75,214,160,148,236,54,146,82,192,177,71,41,151,170,235,41,128,98,152,220,107,111,96,42,72,26,205,66,59,160,170,21,199,91,185,32,130,219,85,38,41,165,48,214,66,244,236,180,57,178,70,101,233,140,208,169,184,219,221,132,92,150,90,239,26,199,82,21,29,215,42,185,200,170,250,10,196,148,203,31,130,247,244,3,232,206,90,181,230,169,245,206,42,9,239,130,59,57,62,107,213,79,15,192,251,27,168,21,237,230,96,45,70,193,137,62,111,104,236,195,77,82,22,55,201,202,218,144,236,28,210,27,102,7,217,145,53,155,192,181,85,205,214,245,2,42,122,178,36,166,165,202,121,182,66,116,84,8,12,225,31,133,3,42,206,138,29,96,90,52,249,48,163,124,198,194,116,54,29,89,29,6,154,146,41,199,204,218,193,151,177,252,13,132,249,49,172,49,102,93,21,20,193,26,120,151,135,109,234,80,6,19,156,205,104,25,95,38,112,16,33,103,203,62,4,248,3,11,228,25,19,225,5,135,82,21,235,216,82,139,102,161,0,87,171,162,137,185,248,4,67,126,234,213,141,141,21,185,122,135,114,203,19,203,43,235,163,85,185,71,67,89,102,16,70,96,40,173,160,206,229,214,197,16,242,29,36,255,186,158,84,163,113,165,56,9,62,232,177,40,65,33,77,80,143,177,136,201,210,128,242,36,98,99,180,94,130,18,51,70,97,196,81,180,61,191,212,93,182,159,57,52,131,69,19,31,246,128,149,81,48,167,91,68,155,85,171,45,104,203,20,118,200,84,108,122,8,114,129,149,139,2,37,59,232,197,209,70,224,243,137,201,66,249,171,144,89,138,244,249,246,5,8,90,33,249,237,75,65,141,130,142,87,248,237,203,86,215,170,242,181,104,208,198,142,239,30,19,104,42,30,83,137,21,68,3,224,236,0,197,169,165,135,248,91,85,190,229,44,87,144,222,100,145,227,118,220,217,143,117,58,167,65,52,21,206,43,226,104,202,34,123,150,46,149,80,167,3,3,246,118,126,29,89,130,216,210,194,2,157,251,198,139,93,213,77,150,169,166,153,86,205,200,0,55,173,173,205,222,53,249,21,69,121,86,219,87,179,118,5,225,5,91,122,126,24,71,99,227,83,27,64,135,232,20,149,213,128,194,43,111,76,14,40,212,169,25,99,64,131,32,249,38,180,233,66,68,96,158,0,119,214,14,232,34,21,147,11,148,9,58,247,52,92,118,178,146,164,6,52,116,185,87,114,216,77,234,113,41,207,243,78,119,121,99,67,118,204,234,190,84,81,211,116,168,66,62,159,6,230,82,156,107,24,133,84,58,223,13,182,109,72,173,209,22,235,33,202,49,252,181,139,238,239,243,173,248,158,131,109,247,248,78,74,249,110,82,57,144,86,174,76,216,194,134,219,75,202,102,10,79,42,71,223,234,64,40,110,182,24,5,209,72,46,5,218,62,92,33,179,15,53,99,5,2,25,72,121,248,212,207,179,254,221,232,137,90,28,250,217,170,18,16,225,24,52,59,157,2,93,107,179,83,239,19,149,59,139,178,66,249,218,35,33,87,2,27,31,44,162,34,137,151,25,200,34,233,208,46,121,109,250,238,14,89,245,219,215,92,182,99,227,135,226,111,41,213,156,78,105,104,107,158,31,216,114,174,176,188,122,215,139,20,165,204,87,41,60,94,59,163,111,37,252,109,34,79,167,229,175,7,188,165,13,89,189,152,72,86,95,171,89,78,253,95,97,221,102,143,236,3,99,244,153,155,140,163,245,165,60,13,169,60,119,236,171,201,215,109,168,53,109,187,55,135,143,62,92,205,104,72,33,4,244,187,91,45,251,79,79,196,29,181,225,246,37,23,153,216,166,168,76,161,104,86,149,180,7,23,239,236,194,13,95,249,95,137,163,200,94,34,43,48,227,88,252,165,199,198,226,15,64,219,159,35,223,238,72,83,208,82,236,175,211,203,101,63,251,80,85,245,2,46,214,115,161,46,111,132,186,84,123,250,7,230,127,1,25,134,246,251,210,20,0,0};
#define index_html_gz_len 1832
static const char index_html_filename[] = "/dist/index.87cf0a9b.html";
static const char index_html_gz[] PROGMEM = {31,139,8,0,0,0,0,0,2,10,237,88,109,115,218,184,22,254,222,153,253,15,90,223,238,140,25,19,139,164,16,8,9,153,43,108,210,164,37,196,180,201,238,166,59,59,91,99,203,47,193,216,92,89,96,72,134,255,126,143,108,3,54,144,182,31,238,183,91,207,96,89,210,209,209,115,30,157,23,13,111,46,126,213,239,180,251,71,163,135,60,62,9,46,223,92,136,6,5,102,232,118,36,26,74,98,128,154,54,52,19,202,77,100,121,38,139,41,239,72,15,247,87,71,45,105,61,28,154,19,218,145,230,62,77,166,17,227,18,178,162,144,211,16,196,18,223,230,94,199,166,115,223,162,71,105,167,138,252,208,231,190,25,28,197,150,25,208,206,177,90,19,106,184,207,3,122,121,235,247,125,215,227,232,122,54,186,192,217,208,155,139,192,15,199,200,99,212,233,72,182,201,205,182,63,49,93,138,23,71,62,236,114,62,50,99,122,90,175,18,66,186,132,244,72,15,222,162,213,72,55,234,14,9,185,114,161,171,137,23,25,138,215,13,89,207,175,159,30,41,63,229,62,126,215,26,144,174,174,104,137,142,159,134,49,57,155,62,220,145,238,167,25,134,254,245,48,33,138,107,48,98,212,111,71,132,124,105,57,45,162,45,70,103,208,127,63,78,180,63,48,137,136,254,248,164,16,163,113,166,13,245,230,21,25,19,13,227,144,124,120,252,136,135,100,136,147,58,177,220,57,38,70,243,88,75,180,207,186,209,34,10,25,63,66,159,129,25,3,172,212,8,94,244,44,98,28,51,45,33,183,56,26,19,221,81,174,201,13,110,130,73,125,220,136,137,110,156,53,8,169,61,0,158,58,118,161,255,39,83,128,137,59,236,234,129,134,65,223,188,54,32,228,29,238,37,221,122,15,240,181,18,214,36,70,237,134,130,254,166,81,39,35,167,213,39,100,246,1,39,218,239,250,28,228,61,235,61,209,174,21,221,237,62,227,36,6,251,154,152,116,239,149,47,67,114,171,205,107,196,116,67,76,62,220,99,125,168,43,61,67,236,223,140,201,157,131,117,162,99,125,1,120,221,19,56,137,250,0,187,221,26,118,19,162,127,121,134,245,125,224,11,240,119,31,137,146,252,231,150,252,124,126,62,63,159,255,243,7,242,92,233,121,136,225,165,12,18,66,222,63,223,108,70,111,158,106,228,163,71,200,181,215,202,71,34,241,26,164,159,221,36,77,209,240,43,172,72,159,9,17,41,95,143,159,10,99,159,251,201,43,80,186,183,225,160,60,194,110,245,228,247,254,167,114,45,208,245,7,251,53,107,62,232,5,89,237,161,46,154,143,122,217,196,43,77,200,88,226,243,180,80,107,254,204,65,136,154,244,71,223,37,38,217,226,236,127,132,170,117,55,20,122,234,101,48,221,177,177,249,54,26,192,129,62,249,2,235,90,99,224,169,63,7,156,154,163,192,218,103,12,233,214,192,130,35,71,129,215,53,118,243,62,84,27,144,15,241,56,151,215,151,247,208,111,76,172,92,31,233,72,136,209,160,35,137,50,43,33,190,156,66,133,47,150,94,9,97,40,206,49,95,138,34,141,208,191,130,200,180,253,208,69,47,208,65,104,26,197,80,229,163,176,141,28,127,65,237,243,116,144,71,211,54,106,212,126,203,122,1,117,120,161,203,153,25,198,78,196,38,237,236,51,48,57,149,143,96,186,138,196,187,146,73,57,112,179,56,138,253,103,218,70,39,245,233,162,48,232,152,19,63,88,182,17,97,112,185,168,162,24,84,28,197,148,249,142,144,89,189,185,192,57,212,139,216,98,254,148,95,202,206,44,180,4,68,36,87,208,203,47,32,4,70,197,28,89,118,216,133,75,5,234,32,201,227,124,26,183,49,134,33,245,41,182,105,224,207,153,26,82,142,93,15,199,190,29,121,152,198,211,214,201,233,233,63,176,181,184,184,252,227,205,70,255,78,232,232,4,167,47,219,143,57,158,83,22,195,46,49,134,155,142,218,192,210,249,118,43,199,15,104,12,27,253,245,75,106,198,75,214,160,148,236,54,146,82,192,177,71,41,151,170,235,41,128,98,152,220,107,111,96,42,72,26,205,66,59,160,170,21,199,91,185,32,130,219,85,38,41,165,48,214,66,244,236,180,57,178,70,101,233,140,208,169,184,219,221,132,92,150,90,239,26,199,82,21,29,215,42,185,200,170,250,10,196,148,203,31,130,247,244,35,232,154,117,243,216,58,113,74,194,187,224,78,142,207,90,103,167,7,224,253,13,212,138,118,115,176,22,163,224,68,159,55,52,246,225,38,41,139,155,100,101,109,72,118,14,233,13,179,131,236,200,154,77,224,218,170,102,235,122,1,21,61,89,18,211,82,229,60,91,33,58,42,4,134,240,143,194,1,21,103,197,14,48,45,154,124,152,81,62,99,97,58,155,142,172,14,3,77,201,148,99,102,237,224,203,88,254,6,194,252,24,214,24,179,174,10,138,96,13,188,203,195,54,117,40,131,9,206,102,180,140,47,19,56,136,144,179,101,31,2,252,129,5,242,140,137,240,130,67,169,138,117,108,169,69,179,80,128,171,85,209,196,92,124,130,33,63,245,234,198,198,138,92,189,67,185,229,137,229,149,245,209,170,220,163,161,44,51,8,35,48,148,86,80,231,114,235,98,8,249,14,146,127,93,79,170,209,184,82,156,4,31,244,88,148,160,144,38,168,199,88,196,100,105,64,121,18,177,49,90,47,65,137,25,163,48,226,40,218,158,95,234,46,219,207,28,154,193,162,137,15,123,192,202,40,152,211,45,162,205,170,213,22,180,101,10,59,100,42,54,61,4,185,192,202,69,129,146,29,244,226,104,35,240,249,196,100,161,252,85,200,44,69,250,124,251,2,4,173,144,252,246,165,160,70,65,199,43,252,246,101,171,107,85,249,90,52,104,99,199,119,143,9,52,21,143,169,196,10,162,1,112,118,128,226,212,210,67,252,173,42,223,114,150,43,72,111,178,200,113,59,238,236,199,58,157,211,32,154,10,231,21,113,52,101,145,61,75,151,74,168,211,129,1,123,59,191,142,44,65,108,105,97,129,206,125,227,197,174,234,38,203,84,211,76,171,102,100,128,155,214,214,102,239,154,252,138,162,60,171,237,171,89,187,130,240,130,45,61,63,140,163,177,241,169,13,160,67,116,138,202,106,64,225,149,55,38,7,20,234,212,140,49,160,65,144,124,19,218,116,33,34,48,79,128,59,107,7,116,145,138,201,5,202,4,157,123,26,46,59,89,73,82,3,26,186,220,43,57,236,38,245,184,148,231,121,167,187,188,177,33,59,102,117,95,170,168,105,58,84,33,159,79,3,115,41,206,53,140,66,42,157,239,6,219,54,164,214,104,139,245,16,229,24,254,218,69,247,247,249,86,124,207,193,182,123,124,39,165,124,55,169,28,72,43,87,38,108,97,195,237,37,101,51,133,39,149,163,111,117,32,20,55,91,140,130,104,36,151,2,109,31,174,144,217,135,154,177,2,129,12,164,60,124,234,231,89,255,110,244,68,45,14,253,108,85,9,136,112,12,154,157,78,129,174,181,217,169,247,137,202,157,69,89,161,124,237,145,144,43,129,141,15,22,81,145,196,203,12,100,145,116,104,151,188,54,125,119,135,172,250,237,107,46,219,177,241,67,241,183,148,106,78,167,52,180,53,207,15,108,57,87,88,94,189,235,69,138,82,230,171,20,30,175,157,209,183,18,254,54,145,167,211,242,215,3,222,210,134,172,94,76,36,171,175,213,44,167,254,175,176,110,179,71,246,129,49,250,204,77,198,209,250,82,158,134,84,158,59,246,213,228,235,54,212,154,182,221,155,195,71,31,174,102,52,164,16,2,250,221,173,150,253,167,39,226,142,218,112,251,146,139,76,108,83,84,166,80,52,171,74,218,131,139,119,118,225,134,175,252,175,196,81,100,47,145,21,152,113,44,254,210,99,99,241,7,160,237,207,145,111,119,164,41,104,41,246,215,233,229,178,159,125,168,170,122,1,23,235,185,80,151,55,66,93,170,61,253,3,243,191,212,80,90,180,210,20,0,0};
2 changes: 1 addition & 1 deletion web2/dist/versions/1.0.4/bundle.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions web2/dist/versions/1.0.4/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
{
type: "script",
cdnPath: cdnBase + "bundle.js",
localPath: "dist/bundle.98076c3c.js",
size: parseInt("219846", 10),
localPath: "dist/bundle.6478f19e.js",
size: parseInt("219851", 10),
},
];

Expand Down
1 change: 1 addition & 0 deletions web2/dist/versions/1.0.5/bundle.css

Large diffs are not rendered by default.

327 changes: 327 additions & 0 deletions web2/dist/versions/1.0.5/bundle.js

Large diffs are not rendered by default.

133 changes: 133 additions & 0 deletions web2/dist/versions/1.0.5/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MiLight Hub</title>
<link href="data:image/x-icon;base64,AAABAAEAEBAAAAEACABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAA/38NABD+CwD/jQsA9pUOABRu/wD/HQwA+gPrAP4MbAAZ8f8ACxb9AP4GkwCW/AoADYj+AP59CQD7FAkAC//nAJYK/QAQ/w4Acgv/AP71CwCSDP8A+AkYAP7rBAAN/+0A/xEcAP1rCwAM/okADf+HAI/7CgAL/5sADP95AA0U/wD4/gsADXr+ABAO/gDlC/8A+v0NAA3/EwB4Ef8A8wr7AP0IeAAN7P4Abf8LAAuJ/wCVDv8A+hcGACH+DgBz/wsA+g7/ABT+ZQAMCv0Aagn/AJT/DQD+EPsADP7sAOf/DAD/Dx0A/g2AAB4N/gB0/gwADZz/ABLu/wAM/BYA+wqMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkYAAAAAAAAAAAAAAUsAAA+NwAAGzIAAAAAAAAAIj0AKhAAHh8AAAAAAAoAAAANAAAAABwAAAA/AAAzIAAAAAAAAAAAAAAmAgAAADsjAAAAAAAAAAASLwAAAAAAAAAAAAAAAAAAAAAAABMnNAAAAAAAAAAAAAArMDwVLREAAAAAAAAAAAAADDUdAAAAAAAAAAAAAAAAAAAAAAAAJDEAAAAAAAAAACU4AAAAKDYAAAAAAAAAAAAAFCEAAAcAAAA6AAAAAAEAAAAXAAAAAABACAAWLgAaAwAAAAAAAAALKQAAOQYAAA4EAAAAAAAAAAAAABkPAAAAAAAAAP5/AADmZwAA8k8AALvdAACf+QAAz/MAAP//AAAf+AAAH/gAAP//AADP8wAAn/kAALvdAADyTwAA5mcAAP5/AAA=" rel="icon" type="image/x-icon" />
<style>
#loading {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 24px;
font-family: Arial, sans-serif;
}
</style>
<script>(function () {
const cdnBase = "https://cdn.jsdelivr.net/gh/sidoh/esp8266_milight_hub@web2/web2/dist/versions/1.0.5/";
const files = [
{
type: "stylesheet",
cdnPath: cdnBase + "bundle.css",
localPath: "dist/bundle.ce967bcb.css",
size: parseInt("8351", 10),
},
{
type: "script",
cdnPath: cdnBase + "bundle.js",
localPath: "dist/bundle.c74a1c2f.js",
size: parseInt("219896", 10),
},
];

function createStylesheetLink(href) {
const link = document.createElement("link");
link.rel = "stylesheet";
link.href = href;
return link;
}

function createScript(src) {
const script = document.createElement("script");
script.src = src;
script.defer = true;
return script;
}

function tryLoadUrl(url, size, retryCount = 0, maxRetries = 5) {
return fetch(url)
.then((response) => {
if (!response.ok) {
throw new Error("Network response was not ok");
}
return Promise.resolve(response);
})
.catch((error) => {
if (retryCount < maxRetries) {
console.warn(`Retrying ${url} (${retryCount + 1}/${maxRetries})`);
return tryLoadUrl(url, size, retryCount + 1, maxRetries);
} else {
throw error;
}
});
}

function tryLoadFile(file) {
const isDevelopment = "production" === "development";
if (isDevelopment) {
return tryLoadUrl(file.localPath, file.size, 0, 0);
} else {
return tryLoadUrl(file.cdnPath, file.size, 0, 0).catch(() =>
tryLoadUrl(file.localPath, file.size, 0, 5)
);
}
}

function loadPage() {
let currentFileIndex = 0;

function loadNextFile() {
if (currentFileIndex >= files.length) {
document.getElementById("loading").style.display = "none";
return;
}

const file = files[currentFileIndex];

tryLoadFile(file)
.then((response) => {
if (!response.ok) {
throw new Error("Failed to load file");
}
return response.blob();
})
.then((blob) => {
const url = URL.createObjectURL(blob);
let element;

if (file.type === "stylesheet") {
element = createStylesheetLink(url);
} else if (file.type === "script") {
element = createScript(url);
}

document.head.appendChild(element);
currentFileIndex++;
loadNextFile();
})
.catch((error) => {
console.error(`Failed to load file: ${file.cdnPath}`, error);
currentFileIndex++;
loadNextFile();
});
}

// Start loading files
loadNextFile();
}

document.addEventListener("DOMContentLoaded", () => {
loadPage();
});
})();
</script>
</head>
<body class="dark">
<div id="page">
<div id="loading">Loading...</div>
</div>
</body>
</html>
4 changes: 2 additions & 2 deletions web2/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "esp8266_milight_hub_ui",
"version": "1.0.4",
"version": "1.0.5",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
Loading

0 comments on commit 907db8d

Please sign in to comment.