diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php
index f9a62c9f6..cf4d08731 100644
--- a/airtime_mvc/application/Bootstrap.php
+++ b/airtime_mvc/application/Bootstrap.php
@@ -71,8 +71,8 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
$view->headScript()->appendFile($baseUrl.'/js/qtip/jquery.qtip-1.0.0.min.js','text/javascript');
//scripts for now playing bar
- $view->headScript()->appendFile($baseUrl.'/js/playlist/helperfunctions.js','text/javascript');
- $view->headScript()->appendFile($baseUrl.'/js/playlist/playlist.js','text/javascript');
+ $view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/helperfunctions.js','text/javascript');
+ $view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/playlist.js','text/javascript');
$view->headScript()->appendFile($baseUrl.'/js/airtime/common/common.js','text/javascript');
}
diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php
index 50fe4cc59..7bd4397ee 100644
--- a/airtime_mvc/application/controllers/ApiController.php
+++ b/airtime_mvc/application/controllers/ApiController.php
@@ -113,8 +113,6 @@ class ApiController extends Zend_Controller_Action
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
- $result = Schedule::GetPlayOrderRange(0, 1);
-
$date = new DateHelper;
$timeNow = $date->getTimestamp();
$result = array("env"=>APPLICATION_ENV,
diff --git a/airtime_mvc/application/controllers/DashboardController.php b/airtime_mvc/application/controllers/DashboardController.php
new file mode 100644
index 000000000..55652fc12
--- /dev/null
+++ b/airtime_mvc/application/controllers/DashboardController.php
@@ -0,0 +1,22 @@
+$showInstance->getName(),
+ "starts"=>$showInstance->getShowStart(),
+ "ends"=>$showInstance->getShowEnd());
+ } else {
+ //return the one that started later.
+ if ($row[0]["starts"] >= $showInstance->getShowStart()){
+ return array("name"=>$row[0]["artist_name"]." - ".$row[0]["track_title"],
+ "starts"=>$row[0]["starts"],
+ "ends"=>$row[0]["ends"]);
+ } else {
+ return array("name"=>$showInstance->getName(),
+ "starts"=>$showInstance->getShowStart(),
+ "ends"=>$showInstance->getShowEnd());
+ }
+ }
+ }
+ }
+
+ public static function GetCurrentItem($p_timeNow){
+ //get previous show and previous item in the schedule table.
+ //Compare the two and if the last show was recorded and started
+ //after the last item in the schedule table, then return the show's
+ //name. Else return the last item from the schedule.
+
+ $showInstance = ShowInstance::GetCurrentShowInstance($p_timeNow);
+ $row = Schedule::GetCurrentScheduleItem($p_timeNow);
+
+ if (is_null($showInstance)){
+ if (count($row) == 0){
+ return null;
+ } else {
+ //should never reach here. Doesnt make sense to have
+ //a schedule item not within a show_instance.
+ }
+ } else {
+ if (count($row) == 0){
+ //last item is a show instance
+ return array("name"=>$showInstance->getName(),
+ "starts"=>$showInstance->getShowStart(),
+ "ends"=>$showInstance->getShowEnd(),
+ "media_item_played"=>false, //TODO
+ "record"=>$showInstance->isRecorded()); //TODO
+ } else {
+ return array("name"=>$row[0]["artist_name"]." - ".$row[0]["track_title"],
+ "starts"=>$row[0]["starts"],
+ "ends"=>$row[0]["ends"],
+ "media_item_played"=>$row[0]["media_item_played"],
+ "record"=>0);
+ }
+ }
+ }
+
+ public static function GetNextItem($p_timeNow){
+ //get previous show and previous item in the schedule table.
+ //Compare the two and if the last show was recorded and started
+ //after the last item in the schedule table, then return the show's
+ //name. Else return the last item from the schedule.
+
+ $showInstance = ShowInstance::GetNextShowInstance($p_timeNow);
+ $row = Schedule::GetNextScheduleItem($p_timeNow);
+
+ if (is_null($showInstance)){
+ if (count($row) == 0){
+ return null;
+ } else {
+ //should never reach here. Doesnt make sense to have
+ //a schedule item not within a show_instance.
+ }
+ } else {
+ if (count($row) == 0){
+ //last item is a show instance
+ return array("name"=>$showInstance->getName(),
+ "starts"=>$showInstance->getShowStart(),
+ "ends"=>$showInstance->getShowEnd());
+ } else {
+ //return the one that starts sooner.
+
+ if ($row[0]["starts"] <= $showInstance->getShowStart()){
+ return array("name"=>$row[0]["artist_name"]." - ".$row[0]["track_title"],
+ "starts"=>$row[0]["starts"],
+ "ends"=>$row[0]["ends"]);
+ } else {
+ return array("name"=>$showInstance->getName(),
+ "starts"=>$showInstance->getShowStart(),
+ "ends"=>$showInstance->getShowEnd());
+ }
+ }
+ }
+ }
+
+}
diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php
index d83056522..d6a647d8e 100644
--- a/airtime_mvc/application/models/Schedule.php
+++ b/airtime_mvc/application/models/Schedule.php
@@ -365,9 +365,12 @@ class Schedule {
$timeNow = $date->getTimestamp();
return array("env"=>APPLICATION_ENV,
"schedulerTime"=>gmdate("Y-m-d H:i:s"),
- "previous"=>Schedule::GetScheduledItemData($timeNow, -1, $prev, "24 hours"),
- "current"=>Schedule::GetScheduledItemData($timeNow, 0),
- "next"=>Schedule::GetScheduledItemData($timeNow, 1, $next, "48 hours"),
+ //"previous"=>Schedule::GetScheduledItemData($timeNow, -1, $prev, "24 hours"),
+ //"current"=>Schedule::GetScheduledItemData($timeNow, 0),
+ //"next"=>Schedule::GetScheduledItemData($timeNow, 1, $next, "48 hours"),
+ "previous"=>Application_Model_Dashboard::GetPreviousItem($timeNow),
+ "current"=>Application_Model_Dashboard::GetCurrentItem($timeNow),
+ "next"=>Application_Model_Dashboard::GetNextItem($timeNow),
"currentShow"=>Show_DAL::GetCurrentShow($timeNow),
"nextShow"=>Show_DAL::GetNextShows($timeNow, 1),
"timezone"=> date("T"),
@@ -375,6 +378,52 @@ class Schedule {
"apiKey"=>$CC_CONFIG['apiKey'][0]);
}
+ public static function GetLastScheduleItem($p_timeNow){
+ global $CC_CONFIG, $CC_DBC;
+
+ $sql = "SELECT *"
+ ." FROM $CC_CONFIG[scheduleTable] st"
+ ." LEFT JOIN $CC_CONFIG[filesTable] ft"
+ ." ON st.file_id = ft.id"
+ ." WHERE st.ends < TIMESTAMP '$p_timeNow'"
+ ." ORDER BY st.ends DESC"
+ ." LIMIT 1";
+
+ $row = $CC_DBC->GetAll($sql);
+ return $row;
+ }
+
+
+ public static function GetCurrentScheduleItem($p_timeNow){
+ global $CC_CONFIG, $CC_DBC;
+
+ $sql = "SELECT *"
+ ." FROM $CC_CONFIG[scheduleTable] st"
+ ." LEFT JOIN $CC_CONFIG[filesTable] ft"
+ ." ON st.file_id = ft.id"
+ ." WHERE st.starts <= TIMESTAMP '$p_timeNow'"
+ ." AND st.ends > TIMESTAMP '$p_timeNow'"
+ ." LIMIT 1";
+
+ $row = $CC_DBC->GetAll($sql);
+ return $row;
+ }
+
+ public static function GetNextScheduleItem($p_timeNow){
+ global $CC_CONFIG, $CC_DBC;
+
+ $sql = "SELECT *"
+ ." FROM $CC_CONFIG[scheduleTable] st"
+ ." LEFT JOIN $CC_CONFIG[filesTable] ft"
+ ." ON st.file_id = ft.id"
+ ." WHERE st.starts > TIMESTAMP '$p_timeNow'"
+ ." ORDER BY st.starts"
+ ." LIMIT 1";
+
+ $row = $CC_DBC->GetAll($sql);
+ return $row;
+ }
+
/**
* Builds an SQL Query for accessing scheduled item information from
* the database.
diff --git a/airtime_mvc/application/models/Shows.php b/airtime_mvc/application/models/Shows.php
index 088b8b49f..7b8a8d21e 100644
--- a/airtime_mvc/application/models/Shows.php
+++ b/airtime_mvc/application/models/Shows.php
@@ -1718,6 +1718,57 @@ class ShowInstance {
return ($diff < 0) ? 0 : $diff;
}
+
+ public static function GetLastShowInstance($p_timeNow){
+ global $CC_CONFIG, $CC_DBC;
+
+ $sql = "SELECT si.id"
+ ." FROM $CC_CONFIG[showInstances] si"
+ ." WHERE si.ends < TIMESTAMP '$p_timeNow'"
+ ." ORDER BY si.ends DESC"
+ ." LIMIT 1";
+
+ $id = $CC_DBC->GetOne($sql);
+ if (is_null($id)){
+ return null;
+ } else {
+ return new ShowInstance($id);
+ }
+ }
+
+ public static function GetCurrentShowInstance($p_timeNow){
+ global $CC_CONFIG, $CC_DBC;
+
+ $sql = "SELECT si.id"
+ ." FROM $CC_CONFIG[showInstances] si"
+ ." WHERE si.starts <= TIMESTAMP '$p_timeNow'"
+ ." AND si.ends > TIMESTAMP '$p_timeNow'"
+ ." LIMIT 1";
+
+ $id = $CC_DBC->GetOne($sql);
+ if (is_null($id)){
+ return null;
+ } else {
+ return new ShowInstance($id);
+ }
+ }
+
+ public static function GetNextShowInstance($p_timeNow){
+ global $CC_CONFIG, $CC_DBC;
+
+ $sql = "SELECT si.id"
+ ." FROM $CC_CONFIG[showInstances] si"
+ ." WHERE si.starts > TIMESTAMP '$p_timeNow'"
+ ." ORDER BY si.starts"
+ ." LIMIT 1";
+
+ $id = $CC_DBC->GetOne($sql);
+ if (is_null($id)){
+ return null;
+ } else {
+ return new ShowInstance($id);
+ }
+ }
}
/* Show Data Access Layer */
diff --git a/airtime_mvc/public/js/playlist/helperfunctions.js b/airtime_mvc/public/js/airtime/dashboard/helperfunctions.js
similarity index 100%
rename from airtime_mvc/public/js/playlist/helperfunctions.js
rename to airtime_mvc/public/js/airtime/dashboard/helperfunctions.js
diff --git a/airtime_mvc/public/js/playlist/playlist.js b/airtime_mvc/public/js/airtime/dashboard/playlist.js
similarity index 72%
rename from airtime_mvc/public/js/playlist/playlist.js
rename to airtime_mvc/public/js/airtime/dashboard/playlist.js
index c6c37c213..1b2177a1e 100644
--- a/airtime_mvc/public/js/playlist/playlist.js
+++ b/airtime_mvc/public/js/airtime/dashboard/playlist.js
@@ -1,9 +1,9 @@
var estimatedSchedulePosixTime = null;
var localRemoteTimeOffset = null;
-var previousSongs = new Array();
-var currentSong = new Array();
-var nextSongs = new Array();
+var previousSong = null;
+var currentSong = null;
+var nextSong = null;
var currentShow = new Array();
var nextShow = new Array();
@@ -25,21 +25,8 @@ var nextShowPrepare = true;
var apiKey = "";
-function getTrackInfo(song){
- var str = "";
-
- if (song.track_title != null)
- str += song.track_title;
- if (song.artist_name != null)
- str += " - " + song.artist_name;
-
- str += ","
-
- return str;
-}
-
function secondsTimer(){
- if (localRemoteTimeOffset != null){
+ if (localRemoteTimeOffset !== null){
var date = new Date();
estimatedSchedulePosixTime = date.getTime() - localRemoteTimeOffset;
updateProgressBarValue();
@@ -50,9 +37,10 @@ function secondsTimer(){
function newSongStart(){
nextSongPrepare = true;
- currentSong[0] = nextSongs.shift();
+ currentSong = nextSong;
+ nextSong = null;
- if (typeof notifySongStart == "function")
+ if (typeof notifySongStart == "function")
notifySongStart();
}
@@ -80,13 +68,13 @@ function updateProgressBarValue(){
$('#progress-show').attr("style", "width:"+showPercentDone+"%");
var songPercentDone = 0;
- if (currentSong.length > 0){
- songPercentDone = (estimatedSchedulePosixTime - currentSong[0].songStartPosixTime)/currentSong[0].songLengthMs*100;
+ if (currentSong !== null){
+ songPercentDone = (estimatedSchedulePosixTime - currentSong.songStartPosixTime)/currentSong.songLengthMs*100;
if (songPercentDone < 0 || songPercentDone > 100){
songPercentDone = 0;
- currentSong = new Array();
+ currentSong = null;
} else {
- if (currentSong[0].media_item_played == "t" && currentShow.length > 0)
+ if (currentSong.media_item_played == "t" && currentShow.length > 0)
$('#on-air-info').attr("class", "on-air-info on");
else
$('#on-air-info').attr("class", "on-air-info off");
@@ -99,8 +87,8 @@ function updateProgressBarValue(){
$('#progress-bar').attr("style", "width:"+songPercentDone+"%");
//calculate how much time left to next song if there is any
- if (nextSongs.length > 0 && nextSongPrepare){
- var diff = nextSongs[0].songStartPosixTime - estimatedSchedulePosixTime;
+ if (nextSong !== null && nextSongPrepare){
+ var diff = nextSong.songStartPosixTime - estimatedSchedulePosixTime;
if (diff < serverUpdateInterval){
//sometimes the diff is negative (-100ms for example). Still looking
@@ -133,20 +121,26 @@ function updatePlaybar(){
$('#current').html("Current: Nothing Scheduled");
$('#next').empty();
$('#next-length').empty();
- if (previousSongs.length > 0){
- $('#previous').text(getTrackInfo(previousSongs[previousSongs.length-1]));
- $('#prev-length').text(convertToHHMMSSmm(previousSongs[previousSongs.length-1].songLengthMs));
+ if (previousSong !== null){
+ $('#previous').text(previousSong.name+",");
+ $('#prev-length').text(convertToHHMMSSmm(previousSong.songLengthMs));
}
- if (currentSong.length > 0){
- $('#current').text(getTrackInfo(currentSong[0]));
- } else if (currentShow.length > 0){
+ if (currentSong !== null){
+ if (currentSong.record == "1")
+ $('#current').html("Recording: "+currentSong.name+",");
+ else
+ $('#current').text(currentSong.name+",");
+ }
+ /*
+ else if (currentShow.length > 0){
if (currentShow[0].record == "1"){
$('#current').html("Current: Recording");
}
}
- if (nextSongs.length > 0){
- $('#next').text(getTrackInfo(nextSongs[0]));
- $('#next-length').text(convertToHHMMSSmm(nextSongs[0].songLengthMs));
+ * */
+ if (nextSong !== null){
+ $('#next').text(nextSong.name+",");
+ $('#next-length').text(convertToHHMMSSmm(nextSong.songLengthMs));
}
$('#start').empty();
@@ -154,18 +148,18 @@ function updatePlaybar(){
$('#time-elapsed').empty();
$('#time-remaining').empty();
$('#song-length').empty();
- for (var i=0; i 0){
- currentSong = obj.current;
- calcAdditionalData(currentSong);
- }
nextShow = obj.nextShow;
calcAdditionalShowData(obj.currentShow);
@@ -238,17 +231,10 @@ function getScheduleFromServer(){
setTimeout(getScheduleFromServer, serverUpdateInterval);
}
-
-function init() {
- //begin producer "thread"
- getScheduleFromServer();
-
- //begin consumer "thread"
- secondsTimer();
-
+function setupQtip(){
var qtipElem = $('#about-link');
- if (qtipElem.length > 0)
+ if (qtipElem.length > 0){
qtipElem.qtip({
content: $('#about-txt').html(),
show: 'mouseover',
@@ -267,6 +253,17 @@ function init() {
name: 'light' // Use the default light style
}
});
+ }
+}
+
+function init() {
+ //begin producer "thread"
+ getScheduleFromServer();
+
+ //begin consumer "thread"
+ secondsTimer();
+
+ setupQtip();
}
$(document).ready(function() {
diff --git a/airtime_mvc/public/js/playlist/showlistview.js b/airtime_mvc/public/js/playlist/showlistview.js
deleted file mode 100644
index 6e2bb6b57..000000000
--- a/airtime_mvc/public/js/playlist/showlistview.js
+++ /dev/null
@@ -1,69 +0,0 @@
-function createDataGrid(datagridData){
-
- var columnHeaders = [
- { "sTitle": "name" },
- { "sTitle": "date" },
- { "sTitle": "start time" },
- { "sTitle": "end time" }
- ];
-
- $('#demo').html( '' );
- $('#nowplayingtable').dataTable( {
- "bSort" : false,
- "bJQueryUI": true,
- "bFilter": false,
- "bInfo": false,
- "bLengthChange": false,
- "aaData": datagridData.rows,
- "aoColumns": columnHeaders
- } );
-
-
- var options1 = [
-
- {title:"Menu Item 1 - Go TO www.google.com", action:{type:"gourl",url:"http://www.google.com/"}},
- {title:"Menu Item 2 - do nothing"},
- {title:"Menu Item 3 - submenu", type:"sub", src:[{title:"Submenu 1"},{title:"Submenu 2"},{title:"Submenu 3"}, {title:"Submenu 4 - submenu", type:"sub", src:[{title:"SubSubmenu 1"},{title:"SubSubmenu 2"}]}]},
- {title:"Menu Item 4 - Js function", action:{type:"fn",callback:"(function(){ alert('THIS IS THE TEST'); })"}}
- ];
-
-
- var userData = {};
-
- var effects = {
- show:"default", //type of show effect
- orientation: "auto", //type of menu orientation - to top, to bottom, auto (to bottom, if doesn't fit on screen - to top)
- xposition:"mouse", // position of menu (left side or right side of trigger element)
- yposition:"mouse"
- }
-
- $('#demo').jjmenu('both', options1, userData, effects );
-}
-
-function initShowListView(){
-
-
- $.ajax({ url: "/Schedule/get-show-data/format/json", dataType:"text", success:function(data){
- $('#json-string').text(data);
- }});
-
-
-
- $.ajax({ url: "/Schedule/get-show-data/format/json", dataType:"json", success:function(data){
- var temp = data.data;
- var rows = new Array();
- for (var i=0; i