-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathfirmware.html
40 lines (34 loc) · 1.32 KB
/
firmware.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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<script>
function fetchFile(url, saveas) {
fetch(url)
.then((result) => {
if (result.status != 200) { throw new Error("Bad server response"); }
return result.blob();
})
.then((data) => {
console.log(data);
var url = window.URL.createObjectURL(data),
anchor = document.createElement("a");
anchor.href = url;
anchor.download = saveas;
anchor.click();
window.URL.revokeObjectURL(url);
document.removeChild(anchor);
})
.catch((error) => { console.log(error); });
}
document.addEventListener('DOMContentLoaded', function () {
const basePath = 'https://raw.githubusercontent.com/keebio/keebio-firmware/master/';
const urlParams = new URLSearchParams(window.location.search);
const filePath = urlParams.get('path');
if (filePath !== null) {
fetchFile(basePath + filePath, filePath.split('/').pop());
}
}, false);
</script>
</head>
<body></body>
</html>