|
Server IP : 2a02:4780:11:1359:0:1d43:a566:2 / Your IP : 216.73.216.20 Web Server : LiteSpeed System : Linux in-mum-web1259.main-hosting.eu 4.18.0-553.37.1.lve.el8.x86_64 #1 SMP Mon Feb 10 22:45:17 UTC 2025 x86_64 User : u490972518 ( 490972518) PHP Version : 5.6.40 Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail MySQL : ON | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0755) : /home/u490972518/domains/ppschool.org.in/public_html/admin/hj/../ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Auto School Bell - Multiple Bell Types</title>
<style>
body {
font-family: sans-serif;
text-align: center;
padding-top: 40px;
background: #f2f2f2;
}
h1 {
margin-bottom: 10px;
}
#status {
font-size: 20px;
margin-top: 20px;
}
button {
padding: 10px 20px;
font-size: 18px;
}
</style>
</head>
<script>
let wakeLock = null;
async function requestWakeLock() {
try {
wakeLock = await navigator.wakeLock.request('screen');
console.log('Wake Lock is active.');
// Automatically re-acquire the lock if it is released (e.g., screen orientation changes)
wakeLock.addEventListener('release', () => {
console.log('Wake Lock was released.');
});
} catch (err) {
console.error(`${err.name}, ${err.message}`);
}
}
// Re-request wake lock on visibility change
document.addEventListener('visibilitychange', async () => {
if (wakeLock !== null && document.visibilityState === 'visible') {
await requestWakeLock();
}
});
// Call this when the page is loaded or when needed
requestWakeLock();
</script>
<body>
<?php include("../link/databaseconnection.php"); ?>
<h1>🔔 Auto School Bell System</h1>
<p id="status">Click "Start" to activate the bell system.</p>
<button id="startBtn">Start</button>
<!-- Audio elements -->
<?php
$selc="select * from bell";
$resc=mysqli_query($conn,$selc);
?>
<?php
while($rowc=mysqli_fetch_array($resc,MYSQLI_BOTH))
{
?>
<audio id="<?php echo $rowc['period']?>" src="../code/img/<?php echo $rowc['ringtone']?>"></audio>
<?php
}
?>
<script>
const statusEl = document.getElementById("status");
const bellSchedule = [
<?php
$selc="select * from bell";
$resc=mysqli_query($conn,$selc);
?>
<?php
while($rowc=mysqli_fetch_array($resc,MYSQLI_BOTH))
{
?>
{ time: "<?php echo $rowc['hours']?>:<?php echo $rowc['min']?>", type: "<?php echo $rowc['period']?>" },
<?php
}
?>
];
const bells = {
<?php
$selc="select * from bell";
$resc=mysqli_query($conn,$selc);
?>
<?php
while($rowc=mysqli_fetch_array($resc,MYSQLI_BOTH))
{
?>
<?php echo $rowc['period']?>: document.getElementById("<?php echo $rowc['period']?>"),
<?php
}
?>
};
let lastTime = "";
function getCurrentTime() {
const now = new Date();
return now.toTimeString().slice(0, 5); // "HH:MM"
}
function checkBell() {
const timeNow = getCurrentTime();
const event = bellSchedule.find(e => e.time === timeNow);
if (event && timeNow !== lastTime) {
lastTime = timeNow;
const bellType = event.type;
bells[bellType].play().then(() => {
statusEl.innerText = `🔔 ${bellType.toUpperCase()} bell at ${timeNow}`;
}).catch(err => {
statusEl.innerText = `⚠️ Bell blocked: ${err.message}`;
});
} else {
statusEl.innerText = `⏳ Waiting... (${timeNow})`;
}
}
document.getElementById("startBtn").addEventListener("click", () => {
statusEl.innerText = "✅ Bell system started.";
checkBell(); // Check now
setInterval(checkBell, 10000); // Check every 10 seconds
});
</script>
<br/><br/><br/>
<center>
<table style="border:1px solid;font-size:20px">
<tr style="border:1px solid"><th style="border:1px solid">Period</th><th style="border:1px solid">Time</th></tr>
<?php
$selc="select * from bell";
$resc=mysqli_query($conn,$selc);
?>
<?php
while($rowc=mysqli_fetch_array($resc,MYSQLI_BOTH))
{
?>
<tr style="border:1px solid"><td style="border:1px solid"><?php echo $rowc['period']?></td><td style="border:1px solid"><?php echo $rowc['hours']?>:<?php echo $rowc['min']?></td></tr>
<?php
}
?>
</table>
</center>
</body>
</html>