Radiation alarm
1 year 11 months ago #6867
by FSM19
Radiation alarm was created by FSM19
There used to be a method of including a radiation alarm on a web page. I had it on an old version of my website. Sadly I am not able to get the one in the How to section to work. I am not sure even if it is still possible. Any ideas?
Please Log in or Create an account to join the conversation.
1 year 11 months ago - 1 year 11 months ago #6868
by Simomax
Personal Use License:
You may download and save my content from this website for your personal use and enjoyment only. You may not share, redistribute, or transmit it to others, or use it commercially. All rights remain my own.
https://www.blinkyslab.co.uk/content-usage-notice
Replied by Simomax on topic Radiation alarm
I have
this
old code working ok, with a caveat. The alarm.mp3 sound generally doesn't work. The text at the top changes from black to red indicating the alarm threshold, but no sound. The only way I could ever hear the alarm.mp3 is after clicking the browser window of the alarm page. This seems to do something, like activating audio from it. It's most certainly a browser thing. I find the same with Brave, Chrome and Firefox. Unless the browser window is actually clicked, no sound from the alarm happens. There may be a browser setting or some way to specify in code to work all the time but I haven't found anything. Not that I have looked much. Have a try for yourself and see if you find the same - no sound until the page is clicked:
http://wasabi.schmoozie.co.uk/radmon/alarm.php?user=Simomax&alarm=10
This is the code I am using. I have attached a zip file with the php and mp3 files.
alert.php
This is the code I am using. I have attached a zip file with the php and mp3 files.
alert.php
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Radiation alarm</title>
<meta name="robots" content="noindex,follow">
<meta name="googlebot" content="nosnippet,noarchive">
</head>
<body>
<!-- http://wasabi.schmoozie.co.uk/radmon/alarm.php?user=Simomax&alarm=20 -->
<?php
$user = $_GET["user"];
$alarm = $_GET["alarm"];
$url = "http://radmon.org/radmon.php?function=lastreading&user=$user";
$page = fopen($url, 'r');
$content = "";
while( !feof( $page ) ) {
$buffer = trim( fgets( $page, 4096 ) );
$content = $buffer;
}
$cpm = explode(' CPM ', $content);
$cpm = $cpm[0];
echo "<p align='left'>";
if (floatval($cpm) >= floatval($alarm)) {
echo "<font color='red'><h3>$content</h3></font>";
} else {
echo "<h3>$content</h3>";
}
echo "<img src='http://www.radmon.org/radmon.php?function=cpmmeter&user=$user' alt='Current CPM'>";
echo "</p>";
if (floatval($cpm) >= floatval($alarm)) {
echo "<audio id='alarm' preload='auto' autoplay='autoplay'><source src='alarm.mp3'></audio>";
}
?>
<p align="left">
<script type="text/javascript">
var countDownInterval=10;
var c_reloadwidth=200
</script>
<ilayer id="c_reload" width=&{c_reloadwidth}; ><layer id="c_reload2" width=&{c_reloadwidth}; left=0 top=0></layer></ilayer>
<script type="text/javascript">
var countDownTime=countDownInterval+1;
function countDown(){
countDownTime--;
if (countDownTime <=0){
countDownTime=countDownInterval;
clearTimeout(counter)
window.location.reload()
return
}
if (document.all) //if IE 4+
document.all.countDownText.innerText = countDownTime+" ";
else if (document.getElementById) //else if NS6+
document.getElementById("countDownText").innerHTML=countDownTime+" "
else if (document.layers){ //CHANGE TEXT BELOW TO YOUR OWN
document.c_reload.document.c_reload2.document.write('Refresh in <b id="countDownText">'+countDownTime+' </b> seconds.')
document.c_reload.document.c_reload2.document.close()
}
counter=setTimeout("countDown()", 1000);
}
function startit(){
if (document.all||document.getElementById) //CHANGE TEXT BELOW TO YOUR OWN
document.write('Refresh in <b id="countDownText">'+countDownTime+' </b> seconds.')
countDown()
}
if (document.all||document.getElementById)
startit()
else
window.onload=startit
</script>
</p>
</body>
</html>Personal Use License:
You may download and save my content from this website for your personal use and enjoyment only. You may not share, redistribute, or transmit it to others, or use it commercially. All rights remain my own.
https://www.blinkyslab.co.uk/content-usage-notice
Last edit: 1 year 11 months ago by Simomax. Reason: Forgot to put the clicky clicky thing in the linky linky
Please Log in or Create an account to join the conversation.
1 year 11 months ago #6869
by FSM19
Replied by FSM19 on topic Radiation alarm
Thanks much appreciated. I will give it a go. Currently I am doing a complete re-write of my site, so it may be a while before its uploaded.
Please Log in or Create an account to join the conversation.
Moderators: Gamma-Man
Time to create page: 0.726 seconds