mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-13 15:37:03 +00:00
63 lines
2.2 KiB
HTML
63 lines
2.2 KiB
HTML
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>AMS reader - Restarting, please wait</title>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<link rel="stylesheet" type="text/css" href="boot.css"/>
|
|
</head>
|
|
<body class="bg-light">
|
|
<main role="main" class="container">
|
|
<header class="navbar navbar-expand navbar-dark flex-column flex-md-row bg-purple rounded mt-2 mb-4" style="background-color: var(--purple);">
|
|
<a href="/" class=""><h6 class="navbar-brand">AMS reader <small>${version}</small></h6></a>
|
|
<ul class="navbar-nav flex-row ml-md-auto d-none d-md-flex">
|
|
<li class="nav-item">
|
|
<a class="nav-link p-2" href="https://github.com/gskjold/AmsToMqttBridge" target="_blank" rel="noopener" aria-label="GitHub">
|
|
<img class="d-inline-block align-text-top" style="width: 2rem; height: 2rem;" src="github.svg"/>
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</header>
|
|
<div class="my-3 p-3 bg-white rounded shadow">
|
|
Device is rebooting. You will be redirected to the main page when it is available again.
|
|
</div>
|
|
</main>
|
|
<script>
|
|
var tries = 0;
|
|
var ip = "${ip}";
|
|
var hostname = "${hostname}";
|
|
var url;
|
|
var fetch = function() {
|
|
tries++;
|
|
|
|
if(ip && tries%3 == 0) {
|
|
url = "http://" + ip;
|
|
} else if(hostname && tries%3 == 1) {
|
|
url = "http://" + hostname;
|
|
} else if(hostname && tries%3 == 2) {
|
|
url = "http://" + hostname + ".local";
|
|
} else {
|
|
url = "";
|
|
}
|
|
if(console) console.log("Trying url " + url);
|
|
|
|
var retry = function() {
|
|
setTimeout(fetch, 1000);
|
|
};
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.timeout = 5000;
|
|
xhr.addEventListener('abort', retry);
|
|
xhr.addEventListener('error', retry);
|
|
xhr.addEventListener('timeout', retry);
|
|
xhr.addEventListener('load', function(e) {
|
|
window.location.href = url ? url : "/";
|
|
});
|
|
xhr.open("GET", url + "/is-alive", true);
|
|
xhr.send();
|
|
};
|
|
setTimeout(fetch, 10000);
|
|
</script>
|
|
</body>
|
|
</html>
|