Merge pull request #15 from hurnhu/refresh-interval

Close #1: Add support for refresh interval
This commit is contained in:
Chris C 2020-10-02 12:20:09 -04:00 committed by GitHub
commit ed490669b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,6 +90,15 @@
#social img:hover { #social img:hover {
opacity: 1; opacity: 1;
} }
#settings {
position: fixed;
left: 5px;
bottom: 5px;
padding: 5px;
}
#settings select:focus {
box-shadow: none;
}
</style> </style>
</head> </head>
<body> <body>
@ -128,9 +137,26 @@
</a> </a>
</div> </div>
<div id="settings">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<div class="input-group-text">&#x21bb;</div>
</div>
<select class="form-control form-control-sm" id="refresh-rate">
<option value="10">10s</option>
<option value="30" selected>30s</option>
<option value="60">1m</option>
<option value="120">2m</option>
<option value="300">5m</option>
<option value="600">10m</option>
</select>
</div>
</div>
<script> <script>
let serviceStatuses = {}; let serviceStatuses = {};
let timerHandler = 0; let timerHandler = 0;
let refreshIntervalHandler = 0;
let userClickedStatus = false; let userClickedStatus = false;
function showTooltip(serviceName, index, element) { function showTooltip(serviceName, index, element) {
@ -291,10 +317,19 @@
.replace(/'/g, '&apos;'); .replace(/'/g, '&apos;');
} }
refreshResults(); function setRefreshInterval(seconds) {
setInterval(function() {
refreshResults(); refreshResults();
}, 30000); refreshIntervalHandler = setInterval(function() {
refreshResults();
}, seconds * 1000)
}
$("#refresh-rate").change(function() {
clearInterval(refreshIntervalHandler);
setRefreshInterval($(this).val())
});
setRefreshInterval(30);
$("#refresh-rate").val(30);
</script> </script>
</body> </body>
</html> </html>