CC-3174 : showbuilder

creating smart refresh timeout for now playing.
This commit is contained in:
Naomi Aro 2012-03-02 16:27:14 +01:00
parent 98d50ae4a7
commit 29b03c1181
2 changed files with 20 additions and 10 deletions

View File

@ -88,14 +88,13 @@ class Application_Model_ShowBuilder {
$row["timestamp"] = $ts;
}
private function isCurrent($p_epochItemStart, $p_epochItemEnd) {
$current = false;
private function isCurrent($p_epochItemStart, $p_epochItemEnd, &$row) {
if ($this->epoch_now >= $p_epochItemStart && $this->epoch_now < $p_epochItemEnd) {
$current = true;
$row["current"] = true;
//how many seconds the view should wait to redraw itself.
$row["refresh"] = $p_epochItemEnd - $this->epoch_now;
}
return $current;
}
private function makeHeaderRow($p_item) {
@ -143,9 +142,7 @@ class Application_Model_ShowBuilder {
$showEndEpoch = intval($showEndDT->format("U"));
//don't want an overbooked item to stay marked as current.
if ($this->isCurrent($startsEpoch, min($endsEpoch, $showEndEpoch))) {
$row["current"] = true;
}
$this->isCurrent($startsEpoch, min($endsEpoch, $showEndEpoch), $row);
$row["id"] = intval($p_item["sched_id"]);
$row["instance"] = intval($p_item["si_id"]);

View File

@ -268,7 +268,8 @@ var AIRTIME = (function(AIRTIME){
var wrapperDiv,
markerDiv,
td,
$lib = $("#library_content");
$lib = $("#library_content"),
tr;
//only create the cursor arrows if the library is on the page.
if ($lib.length > 0 && $lib.filter(":visible").length > 0) {
@ -293,6 +294,18 @@ var AIRTIME = (function(AIRTIME){
td.append(markerDiv).wrapInner(wrapperDiv);
});
}
//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");
setTimeout(function(){
oTable.fnDraw();
}, aData.refresh * 1000); //need refresh in milliseconds
}
},
"fnHeaderCallback": function(nHead) {
$(nHead).find("input[type=checkbox]").attr("checked", false);