javascript updates the image instead of reloading the page
This commit is contained in:
+11
-6
@@ -1,11 +1,16 @@
|
||||
<?php
|
||||
if (file_exists('thisrun.txt')) {
|
||||
$config = parse_ini_file('thisrun.txt');
|
||||
} elseif (file_exists('firstrun.ini')) {
|
||||
$config = parse_ini_file('firstrun.ini');
|
||||
if (file_exists('./scripts/thisrun.txt')) {
|
||||
$config = parse_ini_file('./scripts/thisrun.txt');
|
||||
} elseif (file_exists('./scripts/firstrun.ini')) {
|
||||
$config = parse_ini_file('./scripts/firstrun.ini');
|
||||
}
|
||||
$refresh = $config['RECORDING_LENGTH'];
|
||||
$time = time();
|
||||
echo "<img style=\"width:100%;height:100%\" src=\"/spectrogram.png?nocache=$time\">";
|
||||
header("Refresh: $refresh;");
|
||||
echo "<img id=\"spectrogramimage\" style=\"width:100%;height:100%\" src=\"/spectrogram.png?nocache=$time\">";
|
||||
?>
|
||||
<script>
|
||||
// every $refresh seconds, this loop will run and refresh the spectrogram image
|
||||
window.setInterval(function(){
|
||||
document.getElementById("spectrogramimage").src = "/spectrogram.png?nocache="+Date.now();
|
||||
}, <?php echo $refresh; ?>*1000);
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user