After a successful firmware update, redirect to the new status page.
@@ -146,10 +146,12 @@ function upload(form,data) {
classmod(form, [['ok',ok],['err',!ok],['running',0],['done',1]]);
- // Automatically reload the page after successful upload
- const rf = parseInt(xhr.getResponseHeader('Refresh'));
- if (rf && ok)
- setTimeout(() => window.location.reload(), rf * 1000);
+ // Optionally redirect elsewhere after success
+ const reft = parseFloat(form.dataset.ref) * 1000;
+ if (ok && reft >= 0.0) {
+ const refh = form.dataset.refUrl || window.location.href;
+ setTimeout(() => { window.location.href = refh; }, reft);
+ }
}, PassiveListener);
xhr.open(form.method, form.action);
@@ -8,8 +8,9 @@
<body>
<script>inc("head.html")</script>
<h1 class="update">Update</h1>
- <form id="upload" class="idle" action="sys/fwupdate"
- method="post" onsubmit="uploadfile()">
+ <form id="upload" class="idle"
+ action="sys/fwupdate" method="post" onsubmit="uploadfile()"
+ data-ref="10" data-ref-url="status.html">
<fieldset class="firmware">
<legend>Firmware</legend>
<input type="file" name="file" hidden accept=".fw" onchange="uploadfile()" />