Skip to content

Commit

Permalink
Changed paths to relative to support home-assistant ingress (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhubott authored Aug 25, 2024
1 parent 7e7c31a commit b181723
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions homepage/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
if(isset($_GET['filename'])) {
$filename = $_GET['filename'];
echo "
<iframe src=\"/views.php?view=Recordings&filename=$filename\"></iframe>";
<iframe src=\"views.php?view=Recordings&filename=$filename\"></iframe>";
} else {
echo "
<iframe src=\"/views.php\"></iframe>";
<iframe src=\"views.php\"></iframe>";
}
6 changes: 3 additions & 3 deletions homepage/views.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ function copyOutput(elem) {
include('scripts/service_controls.php');
}
if($_GET['view'] == "Spectrogram"){include('spectrogram.php');}
if($_GET['view'] == "View Log"){echo "<body style=\"scroll:no;overflow-x:hidden;\"><iframe style=\"width:calc( 100% + 1em);\" src=\"/log\"></iframe></body>";}
if($_GET['view'] == "View Log"){echo "<body style=\"scroll:no;overflow-x:hidden;\"><iframe style=\"width:calc( 100% + 1em);\" src=\"log\"></iframe></body>";}
if($_GET['view'] == "Overview"){include('overview.php');}
if($_GET['view'] == "Todays Detections"){include('todays_detections.php');}
if($_GET['view'] == "Kiosk"){$kiosk = true;include('todays_detections.php');}
if($_GET['view'] == "Species Stats"){include('stats.php');}
if($_GET['view'] == "Weekly Report"){include('weekly_report.php');}
if($_GET['view'] == "Streamlit"){echo "<iframe src=\"/stats\"></iframe>";}
if($_GET['view'] == "Streamlit"){echo "<iframe src=\"stats\"></iframe>";}
if($_GET['view'] == "Daily Charts"){include('history.php');}
if($_GET['view'] == "Tools"){
ensure_authenticated();
Expand Down Expand Up @@ -240,7 +240,7 @@ function copyOutput(elem) {
}
if($_GET['view'] == "Webterm"){
ensure_authenticated('You cannot access the web terminal');
echo "<iframe src='/terminal'></iframe>";
echo "<iframe src='terminal'></iframe>";
}
} elseif(isset($_GET['submit'])) {
ensure_authenticated();
Expand Down
12 changes: 6 additions & 6 deletions scripts/overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@
$comname = preg_replace('/ /', '_', $mostrecent['Com_Name']);
$sciname = preg_replace('/ /', '_', $mostrecent['Sci_Name']);
$comname = preg_replace('/\'/', '', $comname);
$filename = "/By_Date/".$mostrecent['Date']."/".$comname."/".$mostrecent['File_Name'];
$filename = "By_Date/".$mostrecent['Date']."/".$comname."/".$mostrecent['File_Name'];

// check to make sure the image actually exists, sometimes it takes a minute to be created\
if(file_exists($home."/BirdSongs/Extracted".$filename.".png")){
if(file_exists($home."/BirdSongs/Extracted/".$filename.".png")){
if($_GET['previous_detection_identifier'] == $filename) { die(); }
if($_GET['only_name'] == "true") { echo $comname.",".$filename;die(); }

Expand Down Expand Up @@ -272,7 +272,7 @@ function setModalText(iter, title, text, authorlink, photolink, licenseurl) {
}
$time = time();
if (file_exists('./Charts/'.$chart)) {
echo "<img id='chart' src=\"/Charts/$chart?nocache=$time\">";
echo "<img id='chart' src=\"Charts/$chart?nocache=$time\">";
}
?>
</div>
Expand All @@ -286,7 +286,7 @@ function setModalText(iter, title, text, authorlink, photolink, licenseurl) {
<?php
$refresh = $config['RECORDING_LENGTH'];
$time = time();
echo "<img id=\"spectrogramimage\" src=\"/spectrogram.png?nocache=$time\">";
echo "<img id=\"spectrogramimage\" src=\"spectrogram.png?nocache=$time\">";

?>

Expand Down Expand Up @@ -328,7 +328,7 @@ function refreshTopTen() {
const xhttp = new XMLHttpRequest();
xhttp.onload = function() {
if(this.responseText.length > 0 && !this.responseText.includes("Database is busy") && !this.responseText.includes("No Detections") || previous_detection_identifier == undefined) {
document.getElementById("chart").src = "/Charts/"+this.responseText+"?nocache="+Date.now();
document.getElementById("chart").src = "Charts/"+this.responseText+"?nocache="+Date.now();
}
}
xhttp.open("GET", "overview.php?fetch_chart_string=true", true);
Expand Down Expand Up @@ -378,7 +378,7 @@ function updateCustomImage() {
}
function startAutoRefresh() {
i_fn1 = window.setInterval(function(){
document.getElementById("spectrogramimage").src = "/spectrogram.png?nocache="+Date.now();
document.getElementById("spectrogramimage").src = "spectrogram.png?nocache="+Date.now();
}, <?php echo $refresh; ?>*1000);
i_fn2 = window.setInterval(refreshDetection, <?php echo intval($dividedrefresh); ?>*1000);
if (customImage) i_fn3 = window.setInterval(refreshCustomImage, 1000);
Expand Down
14 changes: 7 additions & 7 deletions scripts/spectrogram.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
?>
// every $refresh seconds, this loop will run and refresh the spectrogram image
window.setInterval(function(){
document.getElementById("spectrogramimage").src = "/spectrogram.png?nocache="+Date.now();
document.getElementById("spectrogramimage").src = "spectrogram.png?nocache="+Date.now();
}, <?php echo $refresh; ?>*1000);
} else {
document.getElementById("spectrogramimage").remove();
Expand Down Expand Up @@ -274,7 +274,7 @@ function toggleFreqshift(state) {
// Create the XMLHttpRequest object.
const xhr = new XMLHttpRequest();
// Initialize the request
xhr.open("GET", './views.php?activate_freqshift_in_livestream=' + state + '&view=Advanced&submit=advanced');
xhr.open("GET", 'views.php?activate_freqshift_in_livestream=' + state + '&view=Advanced&submit=advanced');
// Send the request
xhr.send();
// Fired once the request completes successfully
Expand All @@ -289,7 +289,7 @@ function toggleFreqshift(state) {
setTimeout(function () {
console.log("Restarting connection with livestream");
audio_player.pause();
audio_player.setAttribute('src', '/stream');
audio_player.setAttribute('src', 'stream');
audio_player.load();
audio_player.play();

Expand Down Expand Up @@ -405,7 +405,7 @@ function loop(time) {
}
</style>

<img id="spectrogramimage" style="width:100%;height:100%;display:none" src="/spectrogram.png?nocache=<?php echo $time;?>">
<img id="spectrogramimage" style="width:100%;height:100%;display:none" src="spectrogram.png?nocache=<?php echo $time;?>">

<div class="centered">
<?php
Expand Down Expand Up @@ -471,7 +471,7 @@ function loop(time) {
</div>
</div>

<audio style="display:none" controls="" crossorigin="anonymous" id='player' preload="none"><source id="playersrc" src="/stream"></audio>
<audio style="display:none" controls="" crossorigin="anonymous" id='player' preload="none"><source id="playersrc" src="stream"></audio>
<h1 id="loading-h1">Loading...</h1>
<canvas></canvas>

Expand All @@ -495,7 +495,7 @@ function loop(time) {
// Create the XMLHttpRequest object.
const xhr = new XMLHttpRequest();
// Initialize the request
xhr.open("GET", './views.php?rtsp_stream_to_livestream=' + this.value + '&view=Advanced&submit=advanced');
xhr.open("GET", 'views.php?rtsp_stream_to_livestream=' + this.value + '&view=Advanced&submit=advanced');
// Send the request
xhr.send();
// Fired once the request completes successfully
Expand All @@ -508,7 +508,7 @@ function loop(time) {
//Wait 5 seconds before restarting the stream
setTimeout(function () {
audio_player.pause();
audio_player.setAttribute('src', '/stream');
audio_player.setAttribute('src', 'stream');
audio_player.load();
audio_player.play();

Expand Down

0 comments on commit b181723

Please sign in to comment.