-fixed bug where a song would appear as current song and next song simultaneously.

-show background color switching on the list-view should now be instant.
This commit is contained in:
martin 2011-02-13 15:35:41 -05:00
parent bb82dc2f4a
commit 416c6ceb10
5 changed files with 29 additions and 40 deletions

View File

@ -75,23 +75,27 @@ class Application_Model_Nowplaying
foreach ($previous as $item){
array_push($rows, array("p", $item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
$item["album_title"], $item["name"], $item["show_name"], $item["current_show"], $item["group_id"]));
$item["album_title"], $item["name"], $item["show_name"], $item["instance_id"], $item["group_id"]));
}
foreach ($current as $item){
array_push($rows, array("c", $item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
$item["album_title"], $item["name"], $item["show_name"], $item["current_show"], $item["group_id"]));
$item["album_title"], $item["name"], $item["show_name"], $item["instance_id"], $item["group_id"]));
}
foreach ($next as $item){
array_push($rows, array("n", $item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
$item["album_title"], $item["name"], $item["show_name"], $item["current_show"], $item["group_id"]));
$item["album_title"], $item["name"], $item["show_name"], $item["instance_id"], $item["group_id"]));
}
$rows = Application_Model_Nowplaying::FindGaps($rows);
$data = array("rows"=>$rows);
$date = new Application_Model_DateHelper;
$timeNow = $date->getDate();
$data = array("currentShow"=>Show_DAL::GetCurrentShow($timeNow), "rows"=>$rows);
return $data;
}
}

View File

@ -469,11 +469,8 @@ class Schedule {
*/
public static function Get_Scheduled_Item_Data($timeStamp, $timePeriod=0, $count = 0, $interval="0 hours"){
global $CC_CONFIG, $CC_DBC;
$date = new Application_Model_DateHelper;
$timeNow = $date->getDate();
$sql = "SELECT DISTINCT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, st.group_id, show.name as show_name, (si.starts <= TIMESTAMP '$timeNow' AND si.ends > TIMESTAMP '$timeNow') as current_show"
$sql = "SELECT DISTINCT pt.name, ft.track_title, ft.artist_name, ft.album_title, st.starts, st.ends, st.clip_length, st.group_id, show.name as show_name, st.instance_id"
." FROM $CC_CONFIG[scheduleTable] st, $CC_CONFIG[filesTable] ft, $CC_CONFIG[playListTable] pt, $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] show"
." WHERE st.playlist_id = pt.id"
." AND st.file_id = ft.id"
@ -487,9 +484,9 @@ class Schedule {
." LIMIT $count";
} else if ($timePeriod == 0){
$sql .= " AND st.starts <= TIMESTAMP '$timeStamp'"
." AND st.ends > TIMESTAMP '$timeStamp'";
." AND st.ends >= TIMESTAMP '$timeStamp'";
} else if ($timePeriod > 0){
$sql .= " AND st.starts >= TIMESTAMP '$timeStamp'"
$sql .= " AND st.starts > TIMESTAMP '$timeStamp'"
." AND st.starts < (TIMESTAMP '$timeStamp' + INTERVAL '$interval')"
." ORDER BY st.starts"
." LIMIT $count";

View File

@ -733,7 +733,7 @@ class Show_DAL{
$date = $timestamp[0];
$time = $timestamp[1];
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id"
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id"
." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
." WHERE si.show_id = s.id"
." AND si.starts <= TIMESTAMP '$timeNow'"

View File

@ -1,5 +1,5 @@
var registered = false;
var datagridData = null;
var currentShowInstanceID = -1;
function getDateText(obj){
var str = obj.aData[ obj.iDataColumn ].toString();
@ -32,7 +32,7 @@ function changeTimePrecision(str){
return str;
}
function notifySongEnd(){
function notifySongStart(){
for (var i=0; i<datagridData.rows.length; i++){
if (datagridData.rows[i][0] == "c")
datagridData.rows[i][0] = "p";
@ -45,6 +45,11 @@ function notifySongEnd(){
updateDataTable();
}
function notifyShowStart(show){
currentShowInstanceID = show.instance_id;
updateDataTable();
}
var columns = [{"sTitle": "type", "bVisible":false},
{"sTitle":"Date"},
{"sTitle":"Start"},
@ -88,6 +93,8 @@ function updateDataTable(){
function getData(){
$.ajax({ url: getAJAXURL(), dataType:"json", success:function(data){
datagridData = data.entries;
if (datagridData.currentShow.length > 0)
currentShowInstanceID = datagridData.currentShow[0].instance_id;
updateDataTable();
}});
}
@ -95,13 +102,7 @@ function getData(){
function init2(){
getData();
if (typeof registerSongEndListener == 'function' && !registered){
registered = true;
registerSongEndListener(notifySongEnd);
}
setTimeout(init2, 5000);
}
function redirect(url){
@ -124,7 +125,7 @@ function createDataGrid(){
"bPaginate": false,
"aoColumns": columns,
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
if (aData[aData.length-2] == "t")
if (aData[aData.length-2] == currentShowInstanceID)
$(nRow).addClass("playing-list");
if (aData[0] == "c")
$(nRow).attr("class", "playing-song");

View File

@ -13,8 +13,6 @@ var currentElem;
var serverUpdateInterval = 5000;
var uiUpdateInterval = 200;
var songEndFunc;
//set to "development" if we are developing :). Useful to disable alerts
//when entering production mode.
var APPLICATION_ENV = "";
@ -25,20 +23,6 @@ var APPLICATION_ENV = "";
var nextSongPrepare = true;
var nextShowPrepare = true;
/* Another script can register its function here
* when it wishes to know when a song ends. */
function registerSongEndListener(func){
songEndFunc = func;
}
function notifySongEndListener(){
if (typeof songEndFunc == "function"){
//create a slight delay in execution to allow the browser
//to update the display.
setTimeout(songEndFunc, 50);
}
}
function getTrackInfo(song){
var str = "";
@ -66,12 +50,15 @@ function newSongStart(){
nextSongPrepare = true;
currentSong[0] = nextSongs.shift();
notifySongEndListener();
notifySongStart();
}
function nextShowStart(){
nextShowPrepare = true;
currentShow[0] = nextShow.shift();
//call function in nowplayingdatagrid.js
notifyShowStart(currentShow[0]);
}
/* Called every "uiUpdateInterval" mseconds. */