javascript updates the image instead of reloading the page
This commit is contained in:
+11
-6
@@ -1,11 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
if (file_exists('thisrun.txt')) {
|
if (file_exists('./scripts/thisrun.txt')) {
|
||||||
$config = parse_ini_file('thisrun.txt');
|
$config = parse_ini_file('./scripts/thisrun.txt');
|
||||||
} elseif (file_exists('firstrun.ini')) {
|
} elseif (file_exists('./scripts/firstrun.ini')) {
|
||||||
$config = parse_ini_file('firstrun.ini');
|
$config = parse_ini_file('./scripts/firstrun.ini');
|
||||||
}
|
}
|
||||||
$refresh = $config['RECORDING_LENGTH'];
|
$refresh = $config['RECORDING_LENGTH'];
|
||||||
$time = time();
|
$time = time();
|
||||||
echo "<img style=\"width:100%;height:100%\" src=\"/spectrogram.png?nocache=$time\">";
|
echo "<img id=\"spectrogramimage\" style=\"width:100%;height:100%\" src=\"/spectrogram.png?nocache=$time\">";
|
||||||
header("Refresh: $refresh;");
|
|
||||||
?>
|
?>
|
||||||
|
<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