-
Notifications
You must be signed in to change notification settings - Fork 17
/
index.html
124 lines (118 loc) · 5.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE html>
<html lang="en" class="">
<head>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/>
<title>Install Tasmota</title>
<style>
div,fieldset,input,select{padding:5px;font-size:1em;}
fieldset{background:#4f4f4f;}
p{margin:0.5em 0;}
input{width:100%;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;background:#dddddd;color:#000000;}
input[type=checkbox],input[type=radio]{width:1em;margin-right:6px;vertical-align:-1px;}
input[type=range]{width:99%;}
select{width:100%;background:#dddddd;color:#000000;}
textarea{resize:vertical;width:98%;height:318px;padding:5px;overflow:auto;background:#1f1f1f;color:#65c115;}
body{text-align:center;font-family:verdana,sans-serif;background:#252525;}
td{padding:0px;}
button{border:0;border-radius:0.3rem;background:#1fa3ec;color:#faffff;line-height:2.4rem;font-size:1.2rem;width:100%;-webkit-transition-duration:0.4s;transition-duration:0.4s;cursor:pointer;}
button:hover{background:#0e70a4;}
.bred{background:#d43535;}
.bred:hover{background:#931f1f;}
.bgrn{background:#47c266;}
.bgrn:hover{background:#5aaf6f;}
a{color:#1fa3ec;text-decoration:none;}
.p{float:left;text-align:left;}
.q{float:right;text-align:right;}
.r{border-radius:0.3em;padding:2px;margin:6px 2px;}
.pick-variant{margin-bottom:16px;}
</style>
<script
type="module"
src="https://unpkg.com/[email protected]/dist/web/install-button.js?module"
></script>
<script>
function makeSelector(){
fetch('https://arendst.github.io/Tasmota-firmware/manifests_new.json')
.then(response => response.json())
.then(data => make_select(data));
}
function make_select(data){
var sel=document.querySelector("#pick-variant-selector");
// console.log(data);
for (opt_group in data){
var og=document.createElement('optgroup');
og.label = opt_group;
sel.appendChild(og);
console.log(opt_group,data[opt_group]);
for (fw of data[opt_group]){
// console.log(data[opt_group][fw]);
var opt=document.createElement('option');
opt.label = fw['name'];
opt.value = fw['path'];
opt.title = "Supported chipfamilies:\n"
for (chipFamily of fw['chipFamilies']){
opt.title += chipFamily + "\n";
}
console.log( opt.value);
og.appendChild(opt);
}
}
}
window.addEventListener("load", function(event) {
makeSelector();
try{
const button = document.querySelector("esp-web-install-button");
button.overrides = {
checkSameFirmware(manifest, improvInfo) {
const manifestFirmware = manifest.name.toLowerCase();
const deviceFirmware = improvInfo.firmware.toLowerCase();
return manifestFirmware.includes(deviceFirmware);
}
};
console.log(button.shadowRoot.firstChild.name);
if(button.shadowRoot.firstChild.name == 'activate'){
//success: add the select picker and some info
const selectEl = document.querySelector("#pick-variant-selector");
button.manifest = "https://arendst.github.io/Tasmota-firmware/manifest_ext/release.tasmota.manifest.json";
selectEl.addEventListener("change", () => {
button.manifest = selectEl.value;
console.log(button.manifest);
});
}
}
catch(e){
console.log(e);
}
},{ once: true });
</script>
</head>
<body>
<div style='display:inline-block;color:#eaeaea;min-width:340px;'>
<h1>Install Tasmota</h1>
<div class='pick-variant'>
<ol style='text-align:left'>
<li>Connect the ESP device to your computer</br>using USB or serial-to-USB adapter</li></br>
<li>Select the firmware variant suitable for</br>your device</li></br>
<li>Hit "Install" and select the correct port</br>or find help if <a href="https://tasmota.github.io/docs/Getting-Started/" target='_blank' style='color:#aaa;'>no device found</a></li>
</ol>
</br>
</br>
<select id="pick-variant-selector"></select>
<p>
</br>
<esp-web-install-button id="inst" style='text-align:center'>
<i slot="unsupported">
Your browser does not support Web Serial.</br>Open this page in Google Chrome or</br>Microsoft Edge instead
<span class="not-supported-i hidden">(but not on your mobile device)</span>.
</i>
</esp-web-install-button>
</p>
</div>
<div style='text-align:right;font-size:11px;'>
<hr/>
<a href="https://esphome.github.io/esp-web-tools/" target='_blank' style='color:#aaa;'>Tasmota Installer powered by ESP Web Tools</a>
</div>
</div>
</body>
</html>