PDA

View Full Version : Community Radio Script - "What''s playing now" (sorry, that old chestnut again)



RadioJcom
10-26-2015, 05:27 PM
Sorry folks. It's this old script again to place a "what' playing now" on our radio website.
I've tried to assemble this below from previous examples doing the rounds, but it refuses to work.
Is there anyone here (everyone, in my case!) with more experience than me (be kind, my experience is basic so it will have to be in "download from the web" rather than "web scraping" (ugh!) terminology!) who might be able to identify why this isn't working?

Many thanks indeed
Ed - the Hon Webmaster



The code I have placed in the page header is (I have removed some of the daily schedule because this forum limits me to 10,000 characters). It's the same each day, divided into on-the-hour lines:
-------------------------------------------


function getSchedule(day)
{
var schedule = "" ;
for(i = 0 ; i < 24 ; i++)
{
if(DH[day][i] != "")
schedule += DH[day][i] ;
}
return schedule ;
}

--------------------------------------------------------------------

The full code placed in an HTML box on our web page is:
--------------------------------------------------------------------


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.1 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 */
#NowOn {
border: 0px solid black;
font-size: 11.5px;
color: black;
background: transparent;
height: 55px;
width: 350px;
}
</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[0][0] = 'Saturday at midnight<br>Press Review<br>followed at 12.30am by<br>New to You';
DH[0][1] = 'Sunday at 1am<br>Ed's Surreal Hour';
DH[0][2] = 'Sunday at 2am<br>Country Music';
DH[0][3] = 'Sunday at 3am<br>Rock Music';
DH[0][4] = 'Sunday at 4am<br>Half Hour Special<br>followed at 4.30am by<br>Music';
DH[0][5] = 'Sunday at 5am<br>Donisthorpe Diary<br>followed at 5.30am by<br>The Merry Widower';
DH[0][6] = 'Sunday at 6am<br>What's on in Leeds<br>followed at 6.30am by<br>Comedy Capers';
DH[0][7] = 'Sunday at 7am<br>Seven Day Ramble<br>followed at 7.30am by<br>Mankoff's Half Hour';
DH[0][8] = 'Sunday at 8am<br>Music<br>followed at 8.30am by<br>Live and Let Live';
DH[0][9] = 'Sunday at 9am<br>Poets' Corner<br>followed at 9.30am by<br>Israel Viewpoint';
DH[0][10] = 'Sunday at 10am<br>Today with Lesley';
DH[0][11] = 'Sunday at 11am<br>Pop Music';
DH[0][12] = 'Sunday at 12pm<br>Press Review<br>followed at 12.30pm by<br>Comedy Capers';
DH[0][13] = 'Sunday at 1pm<br>Listen';
DH[0][14] = 'Sunday at 2pm<br>Torah Talk<br>followed at 2.30pm by<br>The Merry Widower';
DH[0][15] = 'Sunday at 3pm<br>Ed's Surreal Hour';
DH[0][16] = 'Sunday at 4pm<br>New to You<br>followed at 4.30pm by<br>Money Matters';
DH[0][17] = 'Sunday at 5pm<br>Community Hour';
DH[0][18] = 'Sunday at 6pm<br>J-Talk<br>followed at 6.30pm by<br>Classic HM';
DH[0][19] = 'Sunday at 7pm<br>Relax with Harry';
DH[0][20] = 'Sunday at 8pm<br>Mankoff's Half Hour<br>followed at 8.30pm by<br>Seven Day Ramble';
DH[0][21] = 'Sunday at 9pm<br>Poets' Corner<br>followed at 9.30pm by<br>Meet your Rep';
DH[0][22] = 'Sunday at 10pm<br>Rock Music';
DH[0][23] = 'Sunday at 11pm<br>Police Forum<br>followed at 11.30pmby<br>Music';
DH[1][0] = 'Sunday at Midnight<br>Donisthorpe Diaries<br>followed at Monday 12.30am by<br>Music';
DH[1][1] = 'Monday at 1am<br>Press Review<br>followed at 1.30am by<br>Mankoff's Half Hour';
DH[1][2] = 'Monday at 2am<br>Jazz Music';
DH[1][3] = 'Monday at 3am<br>Torah Talk<br>followed 3.30am by<br>New to You';
DH[1][4] = 'Monday at 4am<br>Israel Viewpoint<br>followed at 4.30am by<br>J-Talk';
DH[1][5] = 'Monday at 5am<br>Brass Music';
DH[1][6] = 'Monday at 6am<br>Relax with Harry';
DH[1][7] = 'Monday at 7am<br>No People like Show People<br>with Barry Abis';
DH[1][8] = 'Monday at 8am<br>Today with Lesley';
DH[1][9] = 'Monday at 9am<br>The Merry Widower<br>followed at 9.30am by<br>Music';
DH[1][10] = 'Monday at 10am<br>Comedy Capers<br>followed at 10.30am by<br>Classic HM';
DH[1][11] = 'Monday at 11am<br>Mankoff's Half Hour<br>followed at 11.30am by<br>Seven Day Ramble';
DH[1][12] = 'Monday at 12pm<br>Money Matters<br>followed at 12.30pm by<br>Police Forum';
DH[1][13] = 'Monday at 1pm<br>70's to 90's Music';
DH[1][14] = 'Monday at 2pm<br>Meet your Rep<br>followed at 2.30pm by<br>Music';
DH[1][15] = 'Monday at 3pm<br>Ed's Surreal Hour';
DH[1][16] = 'Monday at 4pm<br>J-Talk<br>followed at 4.30pm by<br>New to You';
DH[1][17] = 'Monday at 5pm<br>Israel Viewpoint<br>followed at 5.30pm by<br>Music';
DH[1][18] = 'Monday at 6pm<br>Half-hour Special<br>followed at 6.30pm by<br>Music';
DH[1][19] = 'Monday at 7pm<br>Poet's Corner<br>followed at 7.30pm by<br>Music';
DH[1][20] = 'Monday at 8pm<br>Relax with Harry';
DH[1][21] = 'Monday at 9pm<br>What's on in Leeds<br>followed at 9.30pm by<br>Music';
DH[1][22] = 'Monday at 10pm<br>Listen';
DH[1][23] = 'Monday at 11pm<br>Comedy Capers<br>followed at 11.30pm by<br>Seven Day Ramble';
DH[2][0] = 'Monday at Midnight<br>Music<br>followed at 1.30am by<br>Torah Talk';
DH[2][1] = 'Tuesday at 1am<br>Relax with Harry';
DH[2][2] = 'Tuesday at 2am<br>Donisthorpe Diary<br>followed at 2.30am by<br>Israel Viewpoint';
DH[2][3] = 'Tuesday at 3am<br>Mankoff's Half Hour<br>followed at 3.30am by<br>Meet your rep';
DH[2][4] = 'Tuesday at 4am<br>Money Matters<br>followed at 4.30am by<br>The Merry Widower';
Remainder of days in week follows this format, then to end of Friday:
DH[5][21] = 'No broadcasting<br>Shabbat break<br>Back at 9pm tomorrow';
DH[5][22] = 'No broadcasting<br>Shabbat break<br>Back at 9pm tomorrow';
DH[5][23] = 'No broadcasting<br>Shabbat break<br>Back at 9pm tomorrow';
DH[6][0] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][1] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][2] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][3] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][4] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][5] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][6] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][7] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][8] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][9] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][10] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][11] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][12] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][13] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][14] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][15] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][16] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][17] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][18] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][19] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][20] = 'No broadcasting<br>Shabbat break<br>Back at 9pm this evening';
DH[6][21] = 'Saturday at 9pm<br>Relax with Harry';
DH[6][22] = 'Saturday at 10pm<br>Today with Lesley';
DH[6][23] = 'Saturday at 11pm<br>Saturday Music Hour';

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+'\n\nNo Show Scheduled'; }
alert(showOn);
}

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 Scheduled'; }
document.getElementById('NowOn').innerHTML = showOn;
}
</script>
</head>
<BODY onLoad="NowON()">
<!-- Unhide this if table display desired
<script type="text/javascript">
document.write(TableStationSchedule())
</script>
-->
<script type="text/javascript">
document.write(NowON());
</script>
<div id='NowOn' onClick="NowON()">Click For Now On KSWH</div>
</body>
</html>

Beverleyh
10-26-2015, 06:43 PM
It's this old script againOld to who? Your introduction implies that we should be familiar with the script - either being your own continuation of a past problem (we have no previous posts to refer to because you're a new member) or that it originates from the DD library here maybe (if so, please provide a link to the demo page).


I've tried to assemble this below from previous examples doing the roundsWhat rounds would these be? If there are examples online that you've copied from (assuming that there's a working demo amongst them) then please provide a link to the source.

Ultimately, it will be easier to start with a working example and modify it, than it will be to troubleshoot a composite broken one. A live web page to demonstrate the script would also be useful.

RadioJcom
10-26-2015, 06:59 PM
Thank you for that - here is the page I adapted my script from. The one on this page works when I test it

http://www.dynamicdrive.com/forums/showthread.php?28249-ON-AIR-Radio-Display-Script

Beverleyh
10-26-2015, 07:15 PM
Great. If that works, start again using that as your base and then gradually introduce/replace your own array items. Don't forget to escape apostrophes;
DH[0][0] = 'Saturday\'s show';
Or replace the apostrophes surrounding the strings with double-quotation marks so they don't clash;
DH[0][0] = "Saturday's show";

styxlawyer
10-27-2015, 12:48 PM
Great. If that works, start again using that as your base and then gradually introduce/replace your own array items. Don't forget to escape apostrophes;
DH[0][0] = 'Saturday\'s show';
Or replace the apostrophes surrounding the strings with double-quotation marks so they don't clash;
DH[0][0] = "Saturday's show";

A third alternative to the apostrophe problem is to replace the appropriate ones with the equivalent HTML entity. For example, replace this line:


DH[0][9] = 'Sunday at 9am<br>Poets' Corner<br>followed at 9.30am by<br>Israel Viewpoint';


with this line:



DH[0][9] = 'Sunday at 9am<br>Poets&rsquo; Corner<br>followed at 9.30am by<br>Israel Viewpoint';

RadioJcom
10-27-2015, 10:37 PM
Thank you both for your kind help thus far

It all works fine . . . . . . . . .BUT only if I exclude Sunday from the schedule. Have you any suggestions on this?

Regards

Beverleyh
10-28-2015, 07:58 AM
We can't troubleshoot something we can't see - please post a link to your page so we can assess the problem.

RadioJcom
10-28-2015, 11:30 AM
We can't troubleshoot something we can't see - please post a link to your page so we can assess the problem.

Thank you for that. Sorry, I assumed it was something stupid and obvious. I've been testing it locally as Net Objects allows me to preview in a browser.
I'll set up a page somewhere and send you the link if I may.

Thank you again
Ed

RadioJcom
10-28-2015, 11:43 AM
I've placed it here http://www.radiojcom.com/Test/test.html

Now the script is appearing along the head of the page (I placed the following in the body html)

function getSchedule(day)
{
var schedule = "" ;
for(i = 0 ; i < 24 ; i++)
{
if(DH[day][i] != "")
schedule += DH[day][i] ;
}
return schedule ;
}

The details of the schedule are coded in the small white box

Many thanks

styxlawyer
10-28-2015, 03:45 PM
I suggest that you first clean up your code. For example at line 62 you have the following:



<p style="margin-bottom: 0px;"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.1 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>


Unfortunately those lines appear inside the <body....</body> tags of your page which will cause all sorts of errors. There may be many others but that's the first one I found.

You may also find these results intesting:

https://validator.w3.org/nu/?doc=http%3A%2F%2Fwww.radiojcom.com%2FTest%2Ftest.html

RadioJcom
10-28-2015, 04:51 PM
I suggest that you first clean up your code. For example at line 62 you have the following:



<p style="margin-bottom: 0px;"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.1 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>


Unfortunately those lines appear inside the <body....</body> tags of your page which will cause all sorts of errors. There may be many others but that's the first one I found.

You may also find these results intesting:

https://validator.w3.org/nu/?doc=http%3A%2F%2Fwww.radiojcom.com%2FTest%2Ftest.html



Many thanks indeed
I really am an amateur at this
Your assistance is greatly appreciated

JMRKER
10-31-2015, 11:57 PM
You have a JS definition in the middle of your HTML code without any <script> tags surrounding it.
Hence the top line function display when you start the program.


<body style="background-repeat: repeat-x;">
function getSchedule(day)
{
var schedule = "" ;
for(i = 0 ; i < 24 ; i++)
{
if(DH[day][i] != "")
schedule += DH[day][i] ;
}
return schedule ;
}
<div id="LayoutLYR">