diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 29eecf9ad..813a9739a 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -54,6 +54,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap $view->headScript()->appendFile('/js/libs/jquery-1.4.4.min.js','text/javascript'); $view->headScript()->appendFile('/js/libs/jquery-ui-1.8.8.custom.min.js','text/javascript'); $view->headScript()->appendFile('/js/libs/stuHover.js','text/javascript'); + $view->headScript()->appendFile('/js/playlist/helperfunctions.js','text/javascript'); $view->headScript()->appendFile('/js/playlist/playlist.js','text/javascript'); } diff --git a/application/configs/navigation.php b/application/configs/navigation.php index c6a66b77e..8749f3b5b 100644 --- a/application/configs/navigation.php +++ b/application/configs/navigation.php @@ -17,11 +17,15 @@ $pages = array( ), array( 'label' => 'Schedule', - 'module' => 'default', - 'controller' => 'Schedule', - 'action' => 'index', - 'resource' => 'schedule', + 'uri' => 'javascript:void(null)', 'pages' => array( + array( + 'label' => 'View', + 'module' => 'default', + 'controller' => 'Schedule', + 'action' => 'index', + 'resource' => 'schedule' + ), array( 'label' => 'Add Show', 'module' => 'default', @@ -55,8 +59,7 @@ $pages = array( ), array( 'label' => 'Configure', - 'module' => 'default', - 'controller' => 'Nowplaying', + 'uri' => 'javascript:void(null)', 'pages' => array( array( 'label' => 'Preferences', diff --git a/public/js/playlist/helperfunctions.js b/public/js/playlist/helperfunctions.js new file mode 100644 index 000000000..0aeea357e --- /dev/null +++ b/public/js/playlist/helperfunctions.js @@ -0,0 +1,98 @@ +/* Takes an input parameter of milliseconds and converts these into + * the format HH:MM:SS */ +function convertToHHMMSS(timeInMS){ + var time = parseInt(timeInMS); + + var hours = parseInt(time / 3600000); + time -= 3600000*hours; + + var minutes = parseInt(time / 60000); + time -= 60000*minutes; + + var seconds = parseInt(time / 1000); + + hours = hours.toString(); + minutes = minutes.toString(); + seconds = seconds.toString(); + + if (hours.length == 1) + hours = "0" + hours; + if (minutes.length == 1) + minutes = "0" + minutes; + if (seconds.length == 1) + seconds = "0" + seconds; + if (hours == "00") + return minutes + ":" + seconds; + else + return "" + hours + ":" + minutes + ":" + seconds; +} + +function convertToHHMMSSmm(timeInMS){ + var time = parseInt(timeInMS); + + var hours = parseInt(time / 3600000); + time -= 3600000*hours; + + var minutes = parseInt(time / 60000); + time -= 60000*minutes; + + var seconds = parseInt(time / 1000); + time -= 1000*seconds; + + var ms = parseInt(time); + + hours = hours.toString(); + minutes = minutes.toString(); + seconds = seconds.toString(); + ms = ms.toString(); + + if (hours.length == 1) + hours = "0" + hours; + if (minutes.length == 1) + minutes = "0" + minutes; + if (seconds.length == 1) + seconds = "0" + seconds; + + if (ms.length == 3) + ms = ms.substring(0, 2); + else if (ms.length == 2) + ms = "0" + ms.substring(0,1); + else if (ms.length == 1) + ms = "00"; + + if (hours == "00") + return minutes + ":" + seconds + "." + ms; + else + return "" + hours + ":" + minutes + ":" + seconds+ "." + ms; +} + +function convertDateToHHMMSS(epochTime){ + var d = new Date(epochTime); + + var hours = d.getUTCHours().toString(); + var minutes = d.getUTCMinutes().toString(); + var seconds = d.getUTCSeconds().toString(); + + if (hours.length == 1) + hours = "0" + hours; + if (minutes.length == 1) + minutes = "0" + minutes; + if (seconds.length == 1) + seconds = "0" + seconds; + return "" + hours + ":" + minutes + ":" + seconds; +} + +function convertDateToPosixTime(s){ + var year = s.substring(0, 4); + var month = s.substring(5, 7); + var day = s.substring(8, 10); + var hour = s.substring(11, 13); + var minute = s.substring(14, 16); + var sec = s.substring(17, 19); + var msec = 0; + if (s.length >= 20){ + msec = s.substring(20); + } + + return Date.UTC(year, month, day, hour, minute, sec, msec); +} \ No newline at end of file diff --git a/public/js/playlist/playlist.js b/public/js/playlist/playlist.js index fec342ad0..60dc91172 100644 --- a/public/js/playlist/playlist.js +++ b/public/js/playlist/playlist.js @@ -25,132 +25,36 @@ var nextSongPrepare = true; /* Another script can register its function here * when it wishes to know when a song ends. */ function registerSongEndListener(func){ - songEndFunc = func; + songEndFunc = func; } function notifySongEndListener(){ - if (typeof songEndFunc == "function") - songEndFunc(); -} - -/* Takes an input parameter of milliseconds and converts these into - * the format HH:MM:SS */ -function convertToHHMMSS(timeInMS){ - var time = parseInt(timeInMS); - - var hours = parseInt(time / 3600000); - time -= 3600000*hours; - - var minutes = parseInt(time / 60000); - time -= 60000*minutes; - - var seconds = parseInt(time / 1000); - - hours = hours.toString(); - minutes = minutes.toString(); - seconds = seconds.toString(); - - if (hours.length == 1) - hours = "0" + hours; - if (minutes.length == 1) - minutes = "0" + minutes; - if (seconds.length == 1) - seconds = "0" + seconds; - if (hours == "00") - return minutes + ":" + seconds; - else - return "" + hours + ":" + minutes + ":" + seconds; -} - -function convertToHHMMSSmm(timeInMS){ - var time = parseInt(timeInMS); - - var hours = parseInt(time / 3600000); - time -= 3600000*hours; - - var minutes = parseInt(time / 60000); - time -= 60000*minutes; - - var seconds = parseInt(time / 1000); - time -= 1000*seconds; - - var ms = parseInt(time); - - hours = hours.toString(); - minutes = minutes.toString(); - seconds = seconds.toString(); - ms = ms.toString(); - - if (hours.length == 1) - hours = "0" + hours; - if (minutes.length == 1) - minutes = "0" + minutes; - if (seconds.length == 1) - seconds = "0" + seconds; - - if (ms.length == 3) - ms = ms.substring(0, 2); - else if (ms.length == 2) - ms = "0" + ms.substring(0,1); - else if (ms.length == 1) - ms = "00"; - - if (hours == "00") - return minutes + ":" + seconds + "." + ms; - else - return "" + hours + ":" + minutes + ":" + seconds+ "." + ms; -} - -function convertDateToHHMMSS(epochTime){ - var d = new Date(epochTime); - - var hours = d.getUTCHours().toString(); - var minutes = d.getUTCMinutes().toString(); - var seconds = d.getUTCSeconds().toString(); - - if (hours.length == 1) - hours = "0" + hours; - if (minutes.length == 1) - minutes = "0" + minutes; - if (seconds.length == 1) - seconds = "0" + seconds; - return "" + hours + ":" + minutes + ":" + seconds; -} - -function convertDateToPosixTime(s){ - var year = s.substring(0, 4); - var month = s.substring(5, 7); - var day = s.substring(8, 10); - var hour = s.substring(11, 13); - var minute = s.substring(14, 16); - var sec = s.substring(17, 19); - var msec = 0; - if (s.length >= 20){ - msec = s.substring(20); - } - - return Date.UTC(year, month, day, hour, minute, sec, msec); + if (typeof songEndFunc == "function"){ + //create a slight pause in execution to allow the browser + //to update the display. + setTimeout(songEndFunc, 50); + } } function getTrackInfo(song){ - var str = ""; - - if (song.track_title != null) - str += song.track_title; - if (song.artist_name != null) - str += " - " + song.artist_name; - //if (song.album_title != null) - //str += " - " + song.album_title; - - str += "," - - return str; + var str = ""; + + if (song.track_title != null) + str += song.track_title; + if (song.artist_name != null) + str += " - " + song.artist_name; + //if (song.album_title != null) + //str += " - " + song.album_title; + + str += "," + + return str; } function secondsTimer(){ - var date = new Date(); - estimatedSchedulePosixTime = date.getTime() - localRemoteTimeOffset; - updateProgressBarValue(); + var date = new Date(); + estimatedSchedulePosixTime = date.getTime() - localRemoteTimeOffset; + updateProgressBarValue(); } function updateGlobalValues(obj){ @@ -161,35 +65,35 @@ function updateGlobalValues(obj){ function newSongStart(){ nextSongPrepare = true; - currentSong[0] = nextSongs.shift(); + currentSong[0] = nextSongs.shift(); updateGlobalValues(currentSong[0]); updatePlaybar(); - + notifySongEndListener(); } /* Called every "uiUpdateInterval" mseconds. */ function updateProgressBarValue(){ - if (estimatedSchedulePosixTime != -1){ + if (estimatedSchedulePosixTime != -1){ if (showStartPosixTime != 0){ var showPercentDone = (estimatedSchedulePosixTime - showStartPosixTime)/showLengthMs*100; if (showPercentDone < 0 || showPercentDone > 100){ showPercentDone = 0; - $('#on-air-info').attr("class", "on-air-info off"); + $('#on-air-info').attr("class", "on-air-info off"); } else { - $('#on-air-info').attr("class", "on-air-info on"); - } - $('#progress-show').attr("style", "width:"+showPercentDone+"%"); + $('#on-air-info').attr("class", "on-air-info on"); + } + $('#progress-show').attr("style", "width:"+showPercentDone+"%"); } var songPercentDone = 0; - if (currentSong.length > 0){ - songPercentDone = (estimatedSchedulePosixTime - currentSong[0].songStartPosixTime)/currentSong[0].songLengthMs*100; - if (songPercentDone < 0 || songPercentDone > 100){ - songPercentDone = 0; + if (currentSong.length > 0){ + songPercentDone = (estimatedSchedulePosixTime - currentSong[0].songStartPosixTime)/currentSong[0].songLengthMs*100; + if (songPercentDone < 0 || songPercentDone > 100){ + songPercentDone = 0; currentSong = new Array(); - } - } + } + } $('#progress-bar').attr("style", "width:"+songPercentDone+"%"); //calculate how much time left to next song if there is any @@ -199,31 +103,31 @@ function updateProgressBarValue(){ setTimeout(newSongStart, nextSongs[0].songStartPosixTime - estimatedSchedulePosixTime); } } - - updatePlaybar(); - } - setTimeout(secondsTimer, uiUpdateInterval); + + updatePlaybar(); + } + setTimeout(secondsTimer, uiUpdateInterval); } function updatePlaybar(){ - /* Column 0 update */ + /* Column 0 update */ $('#previous').text("Prev Song: N/A"); $('#prev-length').text("n/a,"); $('#current').text("Current Song: N/A"); $('#next').text("Next Song: N/A"); $('#next-length').empty(); - if (previousSongs.length > 0){ - $('#previous').text(getTrackInfo(previousSongs[previousSongs.length-1])); - $('#prev-length').text(convertToHHMMSSmm(previousSongs[previousSongs.length-1].songLengthMs)); - } - if (currentSong.length > 0){ - $('#current').text(getTrackInfo(currentSong[0])); - } - if (nextSongs.length > 0){ - $('#next').text(getTrackInfo(nextSongs[0])); - $('#next-length').text(convertToHHMMSSmm(nextSongs[0].songLengthMs)); - } - + if (previousSongs.length > 0){ + $('#previous').text(getTrackInfo(previousSongs[previousSongs.length-1])); + $('#prev-length').text(convertToHHMMSSmm(previousSongs[previousSongs.length-1].songLengthMs)); + } + if (currentSong.length > 0){ + $('#current').text(getTrackInfo(currentSong[0])); + } + if (nextSongs.length > 0){ + $('#next').text(getTrackInfo(nextSongs[0])); + $('#next-length').text(convertToHHMMSSmm(nextSongs[0].songLengthMs)); + } + $('#start').empty(); $('#end').empty(); $('#time-elapsed').empty(); @@ -231,39 +135,39 @@ function updatePlaybar(){ $('#song-length').empty(); $('#showposition').empty(); $('#showlength').empty(); - for (var i=0; i