 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
 |
|
 |
03-24-2010, 03:38 AM
|
#1 (permalink)
|
|
The Wanderer
Join Date: Jan 2010
Posts: 22
Thanks: 2
|
Java Text Countdown - Weekly Loop
Hello,
I need help with a little project. I have a 3 hour radio show every week on a New Zealand Radio station (95bFM if anyone's interested). And I want to have a text countdown on my Blogspot http://askew.tv
I want it to countdown to 1am on Thursday morning each week. But, I want it to display 'On Air, click here to stream the show live' between 1am and 3am on Thursday morning.
Is this possible?
Cheers,
Dave
|
|
|
|
03-24-2010, 04:36 AM
|
#2 (permalink)
|
|
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
|
Sure is, check out this javascript for a great starting place. From there you could easily engineer a php script to automatically update the supplied date everytime a show ended.
|
|
|
|
03-25-2010, 02:13 AM
|
#3 (permalink)
|
|
The Wanderer
Join Date: Jan 2010
Posts: 22
Thanks: 2
|
Thanks for the tutorial. I am really new to Java, I'm much better at PHP than Java so I'm going to need some help with this one I'm afraid.
Can anyone change the code in the tutorial above to the spec at the top of this thread?
Any help on this would be very much appreciated 
|
|
|
|
03-25-2010, 06:03 AM
|
#4 (permalink)
|
|
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
|
Thanks to date() and strototime() you hardly have to do any work at all. :)
php Code:
if ( date( 'w' ) != 4 ) { $thursday = strtotime( 'next Thursday 1am' ); }else { if ( date( 'G' ) < 5 ) { $thursday = strtotime( 'today 1am' ); } else { $thursday = strtotime( 'next Thursday 1am' ); }}$thursday = date( 'F j, Y G:i:a', $thursday );
Now forget about the one I linked to above, it only works for dates, not specific times. I found this one that will serve your purpose better. The instructions on the page should be more than adequate for getting it installed. In step two, where it says new cdtime( ... simply replace the date they are using with
and you'll be golden. After that it's just a matter of implementing your own styles.
|
|
|
|
03-25-2010, 08:50 AM
|
#5 (permalink)
|
|
The Wanderer
Join Date: Jan 2010
Posts: 22
Thanks: 2
|
Thanks delayedinsanity, but because I'm using Blogspot, I can't use PHP unfortunately. Otherwise, that would be a really neat solution. Also, I really want a Java dynamic countdown that ticks down the seconds until the show. Is their a way of getting a Java countdown in this format:
3 days, 7 hours, 23 minutes, 17 seconds
that changes without having to reload the page? And then for the three hours that the show is on, I want it to read:
On Air: Click here to stream the show live
And then after the three hour show can it reset itself so it counts down to the show the week after? eg. 6 days, 20 hours, 59 minutes, 59 seconds
|
|
|
|
03-25-2010, 04:44 PM
|
#6 (permalink)
|
|
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
|
You could always ditch blogspot. That's my first suggestion to anybody who uses blogspot, regardless of the underlying question. :D
You never mentioned that originally... yes you did, I just didn't see it.
And then to top it off, I've just been a bag full of forget the past couple days on here. This is the script I was referring to in the above post but never actually linked to. It will do what you want, you just have to change the styles to match your needs, and you will have to manually update the next show time every week.
|
|
|
|
03-25-2010, 11:12 PM
|
#7 (permalink)
|
|
The Wanderer
Join Date: Jan 2010
Posts: 22
Thanks: 2
|
Thanks delayedinsanity,
I though you had forgotten the link, in your previous post. Ah well, easy mistake. That tutorial is excellent, I'm getting a lot closer now.
That tutorial displays 2 countdown, one is for a single date and once that date has past it displays a message. The second is a countdown for christmas and it manages to loop every year. So once it reaches midnight on Christmas eve, it resets and starts counting down to next christmas.
I think that is this bit:
Code:
var currentyear=new Date().getFullYear()
//dynamically get this Christmas' year value. If Christmas already passed, then year=current year+1
var thischristmasyear=(new Date().getMonth()>=11 && new Date().getDate()>25)? currentyear+1 : currentyear
var christmas=new cdtime("countdowncontainer2", "December 25, "+thischristmasyear+" 0:0:00")
christmas.displaycountdown("days", formatresults2)
So is there a way of combining these two so that the countdown loops every 7 days (similar to countdown2 in the tutorial), but pauses for 3 hours once it hits zero and displays a message (closer to the behavior of countdown1 in the tutorial).
If not, I can always use countdown1 and reset the date each week like you said.
|
|
|
|
03-25-2010, 11:24 PM
|
#8 (permalink)
|
|
The Wanderer
Join Date: Jan 2010
Posts: 22
Thanks: 2
|
Ah crap, I just spotted another problem. It uses the date set on the users computer. This is a problem because I've got listeners in New Zealand and the UK so perhaps the simplest solution is to have 2 countdowns:
In New Zealand
3 days, 1 hours, 12 minutes, 30 seconds
In the UK
2 days, 12 hours, 12 minutes, 30 seconds
Unless there is a way to do this server side? A messy solution would be to guess at what country the user is in and then display the date for that country.
|
|
|
|
03-27-2010, 07:14 AM
|
#9 (permalink)
|
|
The Wanderer
Join Date: Jan 2010
Posts: 22
Thanks: 2
|
I'm having trouble using the previous script in BlogSpot. It won't let me put the script in to the head of the page. Is their a way of using java to do this countdown without putting anything in the head of the page?
|
|
|
|
03-27-2010, 06:19 PM
|
#10 (permalink)
|
|
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
|
Scripts don't necessarily have to go in the head to work. Try placing it at the bottom of your page before the closing BODY element would be. See if that works for you, and then strongly consider bailing on blogspot for a self hosted solution. :D I'm strongly biased against blogspot, so I probably won't stop suggesting this, but honestly, for less than $10 a month (sometimes as little as $3-4) you can have complete control over these kind of things.
|
|
|
|
03-27-2010, 11:30 PM
|
#11 (permalink)
|
|
The Wanderer
Join Date: Jan 2010
Posts: 22
Thanks: 2
|
Thanks. Yeah, I know having your own site gives a lot more freedom but it's also a lot more work. Especially when it comes to RSS feeds and the ability to allow users to leave comments. I had my own .co.uk site last year and I couldn't do a lot of the stuff BlogSpot does automatically.
I have got the countdown on my site now http://imaskew.blogspot.com
Thanks for all the help.
|
|
|
|
03-27-2010, 11:44 PM
|
#12 (permalink)
|
|
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
|
WordPress.org makes blogspot look like a pager next to a smartphone. Glad it's working though!
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| PDF Creation - Help! |
Sam Granger |
General |
7 |
10-31-2007 11:32 AM |
|