CC-3174 : showbuilder

setting a timeout to refresh when the first item on the timeline starts incse there is no "current" item.
This commit is contained in:
Naomi Aro 2012-03-12 13:25:03 +01:00
parent 20db8d6fdf
commit 3b32a16813
2 changed files with 31 additions and 4 deletions

View File

@ -17,6 +17,8 @@ class Application_Model_ShowBuilder {
private $contentDT;
private $epoch_now;
private $hasCurrent;
private $defaultRowArray = array(
"header" => false,
@ -51,6 +53,8 @@ class Application_Model_ShowBuilder {
$this->user = Application_Model_User::GetCurrentUser();
$this->opts = $p_opts;
$this->epoch_now = time();
$this->hasCurrent = false;
}
//check to see if this row should be editable.
@ -98,6 +102,8 @@ class Application_Model_ShowBuilder {
$row["current"] = true;
//how many seconds the view should wait to redraw itself.
$row["refresh"] = $p_epochItemEnd - $this->epoch_now;
$this->hasCurrent = true;
}
}
@ -115,6 +121,7 @@ class Application_Model_ShowBuilder {
$row["header"] = true;
$row["starts"] = $showStartDT->format("Y-m-d H:i");
$row["timeUntil"] = intval($showStartDT->format("U")) - $this->epoch_now;
$row["ends"] = $showEndDT->format("Y-m-d H:i");
$row["duration"] = $showEndDT->format("U") - $showStartDT->format("U");
$row["title"] = $p_item["show_name"];
@ -266,7 +273,7 @@ class Application_Model_ShowBuilder {
//pass in the previous row as it's the last row for the previous show.
$display_items[] = $this->makeFooterRow($scheduled_items[$i-1]);
}
$display_items[] = $this->makeHeaderRow($item);
$current_id = $item["si_id"];
@ -284,6 +291,10 @@ class Application_Model_ShowBuilder {
if (count($scheduled_items) > 0) {
$display_items[] = $this->makeFooterRow($scheduled_items[count($scheduled_items)-1]);
}
if (!$this->hasCurrent) {
}
return $display_items;
}

View File

@ -14,6 +14,8 @@ var AIRTIME = (function(AIRTIME){
}
}
mod.timeout = undefined;
mod.resetTimestamp = function() {
var timestamp = $("#sb_timestamp");
//reset timestamp value since input values could have changed.
@ -301,7 +303,11 @@ var AIRTIME = (function(AIRTIME){
markerDiv,
td,
$lib = $("#library_content"),
tr;
tr,
oTable = $('#show_builder_table').dataTable(),
aData;
clearTimeout(AIRTIME.showbuilder.timeout);
//only create the cursor arrows if the library is on the page.
if ($lib.length > 0 && $lib.filter(":visible").length > 0) {
@ -329,15 +335,25 @@ var AIRTIME = (function(AIRTIME){
//if the now playing song is visible set a timeout to redraw the table at the start of the next song.
tr = tableDiv.find("tr.sb-now-playing");
if (tr.length > 0) {
var oTable = $('#show_builder_table').dataTable(),
aData = tr.data("aData");
aData = tr.data("aData");
setTimeout(function(){
AIRTIME.showbuilder.resetTimestamp();
oTable.fnDraw();
}, aData.refresh * 1000); //need refresh in milliseconds
}
//current song is not set, set a timeout to refresh when the first item on the timeline starts.
else {
tr = tableDiv.find("tbody tr:first");
aData = tr.data("aData");
AIRTIME.showbuilder.timeout = setTimeout(function(){
AIRTIME.showbuilder.resetTimestamp();
oTable.fnDraw();
}, aData.timeUntil * 1000); //need refresh in milliseconds
}
},
"fnHeaderCallback": function(nHead) {
$(nHead).find("input[type=checkbox]").attr("checked", false);