A simple web page radiation alarm

More
9 years 4 months ago - 9 years 4 months ago #140 by OM1AMJ
I was a bit bored. :)

Here is a simple web page radiation alarm.
viking.home.sk/om1amj/radmon/alarm.php?user=xxxxx&alarm=xx
For example: http://viking.home.sk/om1amj/radmon/alarm.php?user=OM1AMJ&alarm=10
If the alarm value is exceeded, so font changes to red, and plays once this sound http://viking.home.sk/om1amj/radmon/nuclear_alarm.mp3
Page is updated every 60 seconds. So you can have it open in the background in the browser tab.
Sound tested in Windows/Linux Chrome, Linux Konqueror, IE11 (IE8 not work) and Android default browser (Android Chrome not work).
You can use page on my webserver, or create your own page.

Here is the code of the page. You can modify it as needed.
<!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>

<?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://radmon.org/radmon.php?function=drawsmallgraph&user=$user' alt='small_graph'>";
echo "</p>";

if (floatval($cpm) >= floatval($alarm)) {
echo "<audio id='nuclear_alarm' preload='auto' autoplay='autoplay'><source src='nuclear_alarm.mp3'></audio>";
}
?>

<p align="left">
<script type="text/javascript">
var countDownInterval=60;
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>
Last edit: 9 years 4 months ago by OM1AMJ.
The following user(s) said Thank You: Frank, Electrodemente, pilovis

Please Log in or Create an account to join the conversation.

More
9 years 4 months ago #186 by Frank
I like this, how did you do the sound file thou? and for some of my users of my site, probably a different sound file on mine, but this is a nice added feature. Can you tell me a bit more on how to do the wave file part. Thanks :)

Please Log in or Create an account to join the conversation.

More
9 years 4 months ago #187 by OM1AMJ
Audio file I downloaded from the website with ringtones for mobile phones. :)
Just upload to web server mp3 file and edit the name in this line:
echo "<audio id='nuclear_alarm' preload='auto' autoplay='autoplay'><source src='nuclear_alarm.mp3'></audio>";
For your own webpage you can create and edit PHP file. Source code is the first post. ;)

Please Log in or Create an account to join the conversation.

More
9 years 1 week ago #918 by Tocsin_bang
On my page, the alarm sounds when the page loads, the same appears to happen on your own page, It happens with Chrome an IE11, and ideas how to prevent that?

Please Log in or Create an account to join the conversation.

More
9 years 1 week ago - 9 years 1 week ago #920 by OM1AMJ
Hello.
At the end of the link is a parameter "alarm = 10"
Try to change to a higher number than the current CPM.
This parameter is to set the limit when the alarm is triggered.
Last edit: 9 years 1 week ago by OM1AMJ.

Please Log in or Create an account to join the conversation.

More
6 years 11 months ago #3131 by Electrodemente
:sick:

Hahahahaha

I hope I donĀ“t get the scary sound you show when Im in bed....


Well done!
Best Regards.

ElectroDemente

Please Log in or Create an account to join the conversation.

Moderators: Gamma-Man
Time to create page: 0.197 seconds
Powered by Kunena Forum
Everything's free. Please support us by considering a donation. Log in first!
Solar powered Raspberry Pi 4 server stats: CPU 39% Memory 13% Swap 11% CPU temp=56.0'C Uptime 19 Days