Hello,
I work for a radio station and would like to have a javascript on our website that changes by the hour so people will know what DJ/show is on. This script would have to include different schedules for each day as well.
This would work similar to the “Time of Day” script but I have no idea how to change that to make it do what I want.
If somebody knows how to code something like that I would like it to have the 1st line with a little bigger text for the “Show name”. Have the 2nd and 3rd lines be normal/smaller text with them being the DJ and the 3rd line being the time that their show is.
Thanks, I know I’m asking for a lot!
storm71852
[code=php]
<script type="text/javascript">
var thedate = new Date();
var dayofweek = thedate.getUTCDay();
var hourofday = thedate.getUTCHours();
function onAir(dow,hod) {
if ((dayofweek == dow) && (hourofday == hod)) { return true; } else { return false; }
}
</script>
[/code]
[code=php]
if (onAir(1,1)) {
document.write("<h2>No Show Scheduled<br>KSWH Weekend<br>1:00 a.m.</h2>");
}
if (onAir(1,2)) {
document.write("<h2>No Show Scheduled<br>KSWH Weekend<br>2:00 a.m.</h2>");
}
...
...
if (onAir(7,23)) {
document.write("<h2>No Show Scheduled<br>KSWH Weekend<br>11:00 p.m.</h2>");
}
if (onAir(7,24)) {
document.write("<h2>No Show Scheduled<br>KSWH Weekend<br>12:00 p.m.</h2>");
}
[/code]
[code=php]
<html>
<head>
<title>Station Times</title>
<script type="text/javascript">
var thedate = new Date();
var dayofweek = thedate.getUTCDay();
var hourofday = thedate.getUTCHours();
var NoShow = '<h2>No Show Scheduled<br>KSWH ';
// The following could be cleaned up some
var DH412 = "<h2><font color='red'>The EZ Show<br>with DJ EZ<br>12:00 p.m.</font></h2>";
var DH415 = "<h2><font color='red'>Stormtracker News<br>with the Weatherman and ? ";
var H15 = "<br>3:00 to 5:00 p.m.</font></h2>";
var H16 = "<br>4:00 p.m.</font></h2>";
var DH416 = DH415+H16;
DH415 += H15;
// The above could be cleaned up some
var DayOfWeek = new Array('','Weekend','Monday','Tuesday','Wednesday','Thursday','Friday','Weekend');
function onAir(dow,hod) {
var HOD = hod+' a.m.</h2>';
if (hod == 12) { HOD = hod+' p.m.</h2>'; }
if (hod > 12) { HOD = (hod-12)+' p.m.</h2>'; }
if (hod == 24) { HOD = (hod-12)+' a.m.</h2>'; }
var DOWHOD = NoShow+DayOfWeek[dow]+'<br>'+HOD;
if ((dow == 4) && (hod == 12)) { DOWHOD = DH412; }
if ((dow == 4) && (hod == 15)) { DOWHOD = DH415; }
if ((dow == 4) && (hod == 16)) { DOWHOD = DH416; }
if ((dayofweek == dow) && (hourofday == hod)) { document.write(DOWHOD); }
// document.write(DOWHOD); // use this line for testing purposes only
}
</script>
</head>
<body>
<script type="text/javascript">
for (var day=1; day<=7; day++) {
for (var hour=1; hour<=24; hour++) { onAir(day,hour); }
}
</script>
</body>
</html>
[/code]
[code=php]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Station Activity</title>
<style type="text/css">
div.Station {
position:absolute;
left:56px;
top:47px;
width:420px;
height:135px;
z-index:1;
background-color:#CCCCCC;
layer-background-color:#CCCCCC;
border:1px solid red; /* none #000000; */
}
</style>
<script type="text/javascript">
var thedate = new Date();
var dayofweek = thedate.getUTCDay();
var hourofday = thedate.getUTCHours();
var DayOfWeek = new Array('','Weekend','Monday','Tuesday','Wednesday','Thursday','Friday','Weekend');
var NoShow = '<h2>No Show Scheduled<br>KSWH Weekend<br>';
var DH412 = '<h2>The EZ Show<br>with DJ EZ<br>Wednesday 12:00 p.m.</h2>';
var DH415 = '<h2>Stormtracker News<br>with the Weatherman and ?<br>Wednesday 3:00 to 5:00 p.m.</h2>';
var DH416 = '<h2>Stormtracker News<br>with the Weatherman and ?<br>Wednesday 4:00 p.m.</h2>';
// Add more when schedule is known. Note: there may be better ways to do this when information is known.
function onAir(dow,hod) {
var HOD = hod+' a.m.</h2>';
if (hod == 12) { HOD = hod+' p.m.</h2>'; }
if (hod > 12) { HOD = (hod-12)+' p.m.</h2>'; }
if (hod == 24) { HOD = (hod-12)+' a.m.</h2>'; }
var DOWHOD = NoShow+DayOfWeek[dow]+' '+HOD;
if ((dow == 4) && (hod == 12)) { DOWHOD = DH412; }
if ((dow == 4) && (hod == 15)) { DOWHOD = DH415; }
if ((dow == 4) && (hod == 16)) { DOWHOD = DH416; }
// Add more when schedule is known. Nogd; may be better ways to do this when information is known.
if ((dayofweek == dow) && (hourofday == hod)) { document.getElementById('Layer1').innerHTML = DOWHOD; }
// document.write(DOWHOD); } // use for testing without line above
// document.write(DOWHOD); // use this line for testing purposes only to show all possibilities
}
function StationSchedule() {
for (var day=1; day<=7; day++) {
for (var hour=1; hour<=24; hour++) { onAir(day,hour); }
}
}
</script>
</head>
<body>
<div id="Layer1" class="Station">Station Schedule information here is replaced!</div>
<script type="text/javascript">StationSchedule()</script>
<div id="content" style="position:absolute; top:175px;">
<h1>Rest of your website goes here.</h1>
</div>
</body>
</html>
[/code]
[code=php]
<script type="text/javascript">
<style type="text/css">
[/code]
[code=php]
// if ((dayofweek == dow) && (hourofday == hod)) { //document.getElementById('Layer1').innerHTML = DOWHOD; }
document.write(DOWHOD); // use this line for testing purposes only to show all possibilities
[/code]
offset = new Date().getTimezoneOffset();
offset = new Date().getTimezoneOffset()/60;
offset = -1 * new Date().getTimezoneOffset()/60;
[code=php]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Station Activity</title>
<style type="text/css">
h2 { font-size:0.6em; } /* temporary for testing purposes */
</style>
<script type="text/javascript">
var thedate = new Date();
var dayofweek = thedate.getUTCDay();
var hourofday = thedate.getUTCHours();
var GMT = new Date().getTimezoneOffset();
var offsetGMT = -5 * new Date().getTimezoneOffset()/60;
// Sun=0 1 2 3 4 5 Sat=6
var DayOfWeek = new Array('Weekend','Monday','Tuesday','Wednesday','Thursday','Friday','Weekend');
var NoShow = '<h2>No Show Scheduled KSWH ';
var DH312 = '<h2>The EZ Show<br>with DJ EZ<br>Wednesday 12:00 p.m.</h2>';
var DH315 = '<h2>Stormtracker News<br>with the Weatherman and ?<br>Wednesday 3:00 to 5:00 p.m.</h2>';
var DH316 = '<h2>Stormtracker News<br>with the Weatherman and ?<br>Wednesday 4:00 p.m.</h2>';
// Add more when schedule is known. Note: there may be better ways to do this when information is known.
function onAir(dow,hod) {
var HOD = hod+' a.m.</h2>';
if (hod == 0) { HOD = (hod+12)+' a.m.</h2>'; }
if (hod == 12) { HOD = hod+' p.m.</h2>'; }
if (hod > 12) { HOD = (hod-12)+' p.m.</h2>'; }
var DOWHOD = NoShow+'<br />'+DayOfWeek[dow]+' '+HOD;
if (dow == 3) { // FONT stuff for testing purposes only
if (hod == 12) { DOWHOD = '<font color="red">'+DH312+'</font>'; }
if (hod == 15) { DOWHOD = '<font color="red">'+DH315+'</font>'; }
if (hod == 16) { DOWHOD = '<font color="red">'+DH316+'</font>'; }
// uncomment following to see effects of getTimezoneOffset() function
// if ((hod >=12) && (hod <=16)) {
// DOWHOD += '<br />'+GMT+'<br />'+offsetGMT+'<br />'+(hod+offsetGMT);
// alert('dow:'+dow+'nhod:'+hod+'nGMT:'+GMT+'noffsetGMT:'+offsetGMT+'nlocal:'+(hod+offsetGMT)); }
// }
}
// Add more when schedule is known. Note: may be better ways to do this when information is known.
return DOWHOD;
}
function TableStationSchedule() {
var str = '<table border="1" width="100%">';
str += '<th>Days<br />0-6<p />Hour<br />0-23</th>';
for (var i=0; i<7; i++) { str += '<th>('+i+') '+DayOfWeek[i]+'</th>'; }
str += '</tr>';
for (var hour=0; hour<24; hour++) {
str += '<tr><th>'+hour+'</th>';
for (var day=0; day<7; day++) { str += '<td>'+onAir(day,hour)+'</td>'; }
str += '</tr>';
document.write(str);
str = '';
}
str += '</table>';
}
</script>
</head>
<body>
<script type="text/javascript">TableStationSchedule()</script>
</body>
</html>
[/code]
function getDow(a){return (['Sun','Mon','Tue','Wednes','Thurs','Fri','Sat'][a] + 'day');}
server_offset_in_hours = -5; // expressed as - for behind GMT and + for ahead of GMT
// server offset in milliseconds, hardcoded as it doesnt change
server = { offset:server_offset_in_hours * (60 * 60 * 1000) };
// calculate client time
with(new Date)
{
client = {
offset:getTimezoneOffset() * (60*1000),
ticks:getTime(),
dls:getUTCHours()-getHours(),
time:{ hours:getUTCHours(),
minutes:getUTCMinutes(),
seconds:getUTCSeconds(),
dow:getDay()
dd:getDate(),
mm:1+getMonth(),
yy:getFullYear()
},
<i> </i> };
}
// calculate the server time based on the given data
with(new Date(client.ticks+server.offset)){
server.time = {
hours:getUTCHours(),
minutes:getUTCMinutes(),
seconds:getUTCSeconds(),
dd:getDate(),
mm:1+getMonth(),
yy:getFullYear(),
dow:getDay()
};
};
// now you can extract the server time and the cleint time from the objects directly
with(server.time){
server_time = [hours,minutes,seconds].join(':');
server_time = getDow(server.time.dow) + " " + server_time;
}
with(client.time){
client_time = [hours-client.dls,minutes,seconds].join(':');
client_time = getDow(client.time.dow) + " " + client_time;
}
alert("Server: "+server_time+"rnClient: "+client_time);
[code=php]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Station Activity</title>
<style type="text/css">
td { font-size:0.6em; } /* temporary for testing purposes */
</style>
<script type="text/javascript">
/* NOT CURRENTLY USED
var thedate = new Date();
var dayofweek = thedate.getDay();
var hourofday = thedate.getHours();
var GMT = new Date().getTimezoneOffset();
var offsetGMT = -5 * new Date().getTimezoneOffset()/60;
*/
// Sun=0 1 2 3 4 5 Sat=6
var DayOfWeek = new Array('Weekend','Monday','Tuesday','Wednesday','Thursday','Friday','Weekend');
var NoShow = 'No Show Scheduled<br />for KSWH';
var DH = new Array (7);
for (d=0; d<7; d++) {
DH[d] = new Array (24);
for (h=0; h<24; h++) { DH[d][h] = ''; }
}
DH[1][10] = 'No Show Name<br>with Cody Graves<br>Monday at 10 AM<hr>No Genre';
DH[1][12] = 'No Show Name<br>with DJ JT<br>Monday at Noon<hr>No Genre';
DH[1][14] = 'Real Talk<br>with DJ Yella<br>Monday at 2 PM<br>No Genre';
DH[1][16] = 'No Show Name<br>with Katy Cox<br>Monday at 4 PM<br>Rap';
DH[1][17] = 'The Greatest<br>with DJ Fresh<br>Monday at 5 PM<br>No Genre';
DH[1][18] = 'Revolution Corner<br>with Randy Underwood<br>Monday at 6 PM<br>No Genre';
DH[1][20] = 'Daily Affirmation<br>with DJ Hightower<br>Monday at 8 PM<br>No Genre';
DH[1][22] = 'No Show Name<br>with David Doggett<br>Monday 10 to Midnight<br>No Genre';
DH[1][23] = 'No Show Name<br>with David Doggett<br>Monday at 11 PM<br>No Genre';
DH[2][13] = 'No Show Name<br>with Michelle Caillouet<br>Tuesday at 1 PM<br>Rock';
DH[2][16] = 'No Show Name<br>with Sweet Action Jackson<br>Tuesday at 4 PM<br>Rock';
DH[2][20] = 'The Rock Hour<br>with Dan the Man<br>Tuesday at 8 PM<br>No Genre';
DH[3][10] = 'Love Me! Hate Me!<br>with DJ Nia<br>Wednesday at 10 AM<br>No Genre';
DH[3][11] = 'Westcoast Wednesdays<br>with DJ Smoove<br>Wednesday at 11 AM<br>No Genre';
DH[3][15] = 'The Storm Hour<br>with the Weatherman and Reba<br>Wednesday 3 to 5 PM<br>Classic Rock';
DH[3][16] = 'The Storm Hour<br>with the Weatherman and Reba<br>Wednesday at 4 PM<br>Classic Rock';
DH[3][22] = 'EZ Does It<br>with DJ EZ<br>Wednesday at 10 PM<br>Rap';
DH[4][12] = 'The Quad Show<br>with J Bean & LongJohn<br>Thursday Noon to 2 PM<br>Rap/Urban';
DH[4][13] = 'The Quad Show<br>with J Bean & LongJohn<br>Thursday at 1 PM<br>Rap/Urban';
DH[4][14] = 'The Hour<br>with DJ V-Jeezy<br>Thursday at 2 PM<br>No Genre';
DH[4][15] = 'No Show Name<br>with DJ Savana<br>Thursday at 3 PM<br>No Genre';
DH[5][10] = 'The Christian Hour<br>with Jammin J<br>Friday 10 to Noon<br>Christian';
DH[5][11] = 'The Christian Hour<br>with Jammin J<br>Friday at 11 AM<br>Christian';
DH[5][12] = 'The Em and Tag Show<br>with Em and Tag<br>Friday Noon to 2 PM<br>Rock';
DH[5][13] = 'The Em and Tag Show<br>with Em and Tag<br>Friday at 1 PM<br>Rock';
DH[5][14] = 'No Show Name<br>with DJ Kevin<br>Friday at 3 PM<br>No Genre';
DH[5][15] = 'Big Hamptons Block<br>with Big Hampton<br>Friday 4 to 6 PM<br>Rap';
DH[5][16] = 'Big Hamptons Block<br>with Big Hampton<br>Friday at 5 PM<br>Rap';
DH[5][22] = 'Rockin till Midnight<br>with DJ Werewolf<br>Friday 10 to Midnight<br>Rock';
DH[5][23] = 'Rockin till Midnight<br>with DJ Werewolf<br>Friday at 11 PM<br>Rock';
// Add more when schedule is known. Note: there may be better ways to do this when information is known.
function TableStationSchedule() {
var str = '<table border="1" width="100%">';
str += '<th>Days<br />0-6<p />Hour<br />0-23</th>';
for (var i=0; i<7; i++) { str += '<th>('+i+') '+DayOfWeek[i]+'</th>'; }
str += '</tr>';
for (var h=0; h<24; h++) {
str += "<tr><td>"+h+"</td>";
for (var d=0; d<7; d++) {
if (DH[d][h] == '') { str += '<td>'+NoShow+'</td>'; }
else { str += "<td><font color='red'>" + DH[d][h] + "</font></td>"; }
}
str += "</tr>";
}
str += "</table>";
return str;
}
</script>
</head>
<body>
<script type="text/javascript">document.write(TableStationSchedule())</script>
</body>
</html>
[/code]
[code=php]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Station Activity</title>
<style type="text/css">
td { font-size:0.6em; } /* temporary for testing purposes */
</style>
<script type="text/javascript">
/* NOT CURRENTLY USED
var thedate = new Date();
var dayofweek = thedate.getDay();
var hourofday = thedate.getHours();
var GMT = new Date().getTimezoneOffset();
var offsetGMT = -5 * new Date().getTimezoneOffset()/60;
*/
// Sun=0 1 2 3 4 5 Sat=6
var DayOfWeek = new Array('Weekend','Monday','Tuesday','Wednesday','Thursday','Friday','Weekend');
var NoShow = 'No Show Scheduled<br />for KSWH';
var DH = new Array (7);
for (d=0; d<7; d++) {
DH[d] = new Array (24);
for (h=0; h<24; h++) { DH[d][h] = ''; }
}
DH[1][10] = 'No Show Name<br>with Cody Graves<br>Monday at 10 AM<hr>No Genre';
DH[1][12] = 'No Show Name<br>with DJ JT<br>Monday at Noon<hr>No Genre';
DH[1][14] = 'Real Talk<br>with DJ Yella<br>Monday at 2 PM<br>No Genre';
DH[1][16] = 'No Show Name<br>with Katy Cox<br>Monday at 4 PM<br>Rap';
DH[1][17] = 'The Greatest<br>with DJ Fresh<br>Monday at 5 PM<br>No Genre';
DH[1][18] = 'Revolution Corner<br>with Randy Underwood<br>Monday at 6 PM<br>No Genre';
DH[1][20] = 'Daily Affirmation<br>with DJ Hightower<br>Monday at 8 PM<br>No Genre';
DH[1][22] = 'No Show Name<br>with David Doggett<br>Monday 10 to Midnight<br>No Genre';
DH[1][23] = 'No Show Name<br>with David Doggett<br>Monday at 11 PM<br>No Genre';
DH[2][13] = 'No Show Name<br>with Michelle Caillouet<br>Tuesday at 1 PM<br>Rock';
DH[2][16] = 'No Show Name<br>with Sweet Action Jackson<br>Tuesday at 4 PM<br>Rock';
DH[2][20] = 'The Rock Hour<br>with Dan the Man<br>Tuesday at 8 PM<br>No Genre';
DH[3][10] = 'Love Me! Hate Me!<br>with DJ Nia<br>Wednesday at 10 AM<br>No Genre';
DH[3][11] = 'Westcoast Wednesdays<br>with DJ Smoove<br>Wednesday at 11 AM<br>No Genre';
DH[3][15] = 'The Storm Hour<br>with the Weatherman and Reba<br>Wednesday 3 to 5 PM<br>Classic Rock';
DH[3][16] = 'The Storm Hour<br>with the Weatherman and Reba<br>Wednesday at 4 PM<br>Classic Rock';
DH[3][22] = 'EZ Does It<br>with DJ EZ<br>Wednesday at 10 PM<br>Rap';
DH[4][12] = 'The Quad Show<br>with J Bean & LongJohn<br>Thursday Noon to 2 PM<br>Rap/Urban';
DH[4][13] = 'The Quad Show<br>with J Bean & LongJohn<br>Thursday at 1 PM<br>Rap/Urban';
DH[4][14] = 'The Hour<br>with DJ V-Jeezy<br>Thursday at 2 PM<br>No Genre';
DH[4][15] = 'No Show Name<br>with DJ Savana<br>Thursday at 3 PM<br>No Genre';
DH[5][10] = 'The Christian Hour<br>with Jammin J<br>Friday 10 to Noon<br>Christian';
DH[5][11] = 'The Christian Hour<br>with Jammin J<br>Friday at 11 AM<br>Christian';
DH[5][12] = 'The Em and Tag Show<br>with Em and Tag<br>Friday Noon to 2 PM<br>Rock';
DH[5][13] = 'The Em and Tag Show<br>with Em and Tag<br>Friday at 1 PM<br>Rock';
DH[5][14] = 'No Show Name<br>with DJ Kevin<br>Friday at 3 PM<br>No Genre';
DH[5][15] = 'Big Hamptons Block<br>with Big Hampton<br>Friday 4 to 6 PM<br>Rap';
DH[5][16] = 'Big Hamptons Block<br>with Big Hampton<br>Friday at 5 PM<br>Rap';
DH[5][22] = 'Rockin till Midnight<br>with DJ Werewolf<br>Friday 10 to Midnight<br>Rock';
DH[5][23] = 'Rockin till Midnight<br>with DJ Werewolf<br>Friday at 11 PM<br>Rock';
// Add more when schedule is known. Note: there may be better ways to do this when information is known.
// delete this function if table display is NOT desired.
function TableStationSchedule() {
var str = '<table border="1" width="100%">';
// str += '<th>Days<br />0-6<p />Hour<br />0-23</th>';
str += '<th><button onClick="OnNow()">On Now</button></th>';
for (var i=0; i<7; i++) { str += '<th>'+DayOfWeek[i]+'</th>'; }
str += '</tr>';
for (var h=0; h<24; h++) {
var hr;
if (h == 0) { hr = '12 am'; }
if ((h >0) && (h<12)) { hr = h+' am'; }
if (h == 12) { hr = '12 pm'; }
if (h > 12) { hr = (h-12)+' pm'; }
str += "<tr><td>"+hr+"</td>";
for (var d=0; d<7; d++) {
if (DH[d][h] == '') { str += '<td>'+NoShow+'</td>'; }
else { str += "<td><font color='red'>" + DH[d][h] + "</font></td>"; }
}
str += "</tr>";
}
str += "</table>";
return str;
}
function OnNow() {
var thedate = new Date();
var dayofweek = thedate.getDay();
var hourofday = thedate.getHours();
// alert(dayofweek+':'+hourofday+'<br />'+DH[dayofweek][hourofday]);
var showOn = DH[dayofweek][hourofday];
if (showOn == '') { showOn = thedate+'nnNo Show Currently Scheduled for KSWH'; }
alert(showOn);
}
</script>
</head>
<body>
<!-- Unhide this if table display desired
<script type="text/javascript">
document.write(TableStationSchedule())
</script>
-->
<script type="text/javascript">
document.write('<button onClick="OnNow()">Now On KSWH</button>');
</script>
</body>
</html>
[/code]
[code=php]
<style type="text/css">
td { font-size:0.6em; } /* temporary for testing purposes */
#NowOn {
border: 2px solid red;
font-size: 1.5em;
color: red;
background: yellow;
height: 200px;
width: 400px;
}
</style>
[/code]
[code=php]
function NowON() {
var thedate = new Date();
var dayofweek = thedate.getDay();
var hourofday = thedate.getHours();
var showOn = DH[dayofweek][hourofday];
if (showOn == '') { showOn = thedate+'<p />No Show Currently Scheduled for KSWH'; }
document.getElementById('NowOn').innerHTML = showOn;
}
[/code]
[code=php]
<script type="text/javascript">
document.write('<button onClick="OnNow()">Now On KSWH</button>');
</script>
<div id='NowOn' onClick="NowON()">Click For Now On KSWH</div>
[/code]
0.1.9 — BETA 5.18