1/* ------------------------------ */ 2/* Radio Station Countdown Script */ 3/* ------------------------------ */ 4 5/* Countdown Loop */ 6function radio_countdown() { 7 8 radio.time.current = Math.floor( (new Date()).getTime() / 1000 ); 9 radio.time.user = radio.time.current - radio.timezone.useroffset; 10 radio.time.server = radio.time.current + radio.timezone.offset; 11 12 if (radio.clock_debug) { 13 console.log('Current Time: ' + (new Date()).toISOString() + '(' + radio.time.current + ')'); 14 console.log('User Offset: ' + radio.timezone.useroffset + ' - Server Offset: ' + radio.timezone.offset); 15 userdatetime = new Date(radio.time.user * 1000); 16 serverdatetime = new Date(radio.time.server * 1000); 17 console.log('User Time: ' + userdatetime.toISOString() + '(' + userdatetime.getDate() + ')'); 18 console.log('Server Time: '+ serverdatetime.toISOString() + '(' + serverdatetime.getDate() + ')'); 19 } 20 21 /* Current Show Countdown */ 22 jQuery('.current-show-list.countdown .current-show-end').each(function() { 23 showendtime = parseInt(jQuery(this).val()); 24 diff = showendtime - radio.time.current; 25 if (radio.clock_debug) { 26 showend = new Date(showendtime * 1000); 27 console.log('Show End: ' + showendtime + ' : ' + showend.toISOString() + '(' + showend.getTime() + ')'); 28 console.log('Current Show Ends in: '+diff+'s'); 29 } 30 if (diff < 1) {countdown = radio.labels.showended; jQuery(this).removeClass('current-show-end');} 31 else {countdown = radio_countdown_display(diff, radio.labels.timeremaining);} 32 jQuery(this).closest('.current-show-list').find('.rs-countdown').html(countdown); 33 }); 34 35 /* Upcoming Show Countdown */ 36 jQuery('.upcoming-shows-list.countdown .upcoming-show-times').each(function() { 37 times = jQuery(this).val().split('-'); 38 times[0] = parseInt(times[0]); diffa = times[0] - radio.time.current; 39 times[1] = parseInt(times[1]); diffb = times[1] - radio.time.current; 40 if (radio.clock_debug) { 41 nextstart = new Date( times[0] * 1000 ); nextend = new Date( times[1] * 1000 ); 42 console.log('Next Show Start: ' + nextstart.toISOString() + '(' + nextstart.getTime() + ')'); 43 console.log('Next Show End: ' + nextend.toISOString() + '(' + nextend.getTime() + ')'); 44 console.log('Next Show Start in: '+diffa+'s - Next Show End in:'+diffb+'s'); 45 } 46 if (diffa < 1) { 47 if (diffb < 1) {countdown = radio.labels.showended; jQuery(this).removeClass('upcoming-show-times');} 48 else {countdown = radio.labels.showstarted;} 49 } else {countdown = radio_countdown_display(diffa, radio.labels.timecommencing);} 50 jQuery(this).closest('.upcoming-shows-list').find('.rs-countdown').html(countdown); 51 }); 52 53 /* Current Playlist Countdown */ 54 jQuery('current-playlist.countdown .current-playlist-end').each(function() { 55 diff = parseInt(jQuery(this).val()) - radio.time.current; 56 if (radio.clock_debug) {console.log('Current Playlist Ends in: '+diff);} 57 if (diff < 1) {countdown = radio.labels.playlistended; jQuery(this).removeClass('current-playlist-end');} 58 else {countdown = radio_countdown_display(diff, radio.labels.timeremaining);} 59 jQuery(this).closest('.current-playlist').find('.rs-countdown').html(countdown); 60 }); 61 62 /* Continue Countdown */ 63 if ( jQuery('.current-show-list.countdown .current-show-end') 64 || jQuery('.upcoming-shows-list.countdown .upcoming-show-times') 65 || jQuery('.current-playlist.countdown .current-playlist-end') ) { 66 setTimeout('radio_countdown();', 1000); 67 } 68} 69 70/* Get Countdown Display */ 71function radio_countdown_display(diff, label) { 72 hours = Math.floor( diff / 3600 ); 73 if (hours > 0) {diff = diff - (hours * 3600);} 74 minutes = Math.floor( diff / 60 ); 75 if (minutes > 0) {diff = diff - (minutes * 60);} 76 if (minutes < 10) {minutes = '0'+minutes;} 77 seconds = diff; 78 if (seconds < 10) {seconds = '0'+seconds;} 79 display = '<span class="rs-label">'+label+'</span>: <span class="rs-hours">'+hours+'</span><span class="rs-sep rs-time-sep">'+radio.sep+'</span>'; 80 display += '<span class="rs-minutes">'+minutes+'</span><span class="rs-sep rs-time-sep">'+radio.sep+'</span><span class="rs-seconds">'+seconds+'</span>';
81 return display; 82} 83 84/* Start Countdown on Pageload */ 85jQuery(document).ready(function() { 86 radio_countdown(); 87});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.