CC-733 : broadcast logs
adding time range selection for the log history.
This commit is contained in:
parent
7c63387dd5
commit
20db8d6fdf
8 changed files with 276 additions and 101 deletions
|
@ -16,8 +16,28 @@ class PlayoutHistoryController extends Zend_Controller_Action
|
||||||
|
|
||||||
$this->_helper->layout->setLayout('playouthistory');
|
$this->_helper->layout->setLayout('playouthistory');
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$baseUrl = $request->getBaseUrl();
|
$baseUrl = $request->getBaseUrl();
|
||||||
|
|
||||||
|
//default time is the last 24 hours.
|
||||||
|
$now = time();
|
||||||
|
$from = $request->getParam("from", $now - (24*60*60));
|
||||||
|
$to = $request->getParam("to", $now);
|
||||||
|
|
||||||
|
$start = DateTime::createFromFormat("U", $from, new DateTimeZone("UTC"));
|
||||||
|
$start->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||||
|
$end = DateTime::createFromFormat("U", $to, new DateTimeZone("UTC"));
|
||||||
|
$end->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||||
|
|
||||||
|
$form = new Application_Form_DateRange();
|
||||||
|
$form->populate(array(
|
||||||
|
'his_date_start' => $start->format("Y-m-d"),
|
||||||
|
'his_time_start' => $start->format("H:i"),
|
||||||
|
'his_date_end' => $end->format("Y-m-d"),
|
||||||
|
'his_time_end' => $end->format("H:i")
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->view->date_form = $form;
|
||||||
|
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
|
@ -25,13 +45,18 @@ class PlayoutHistoryController extends Zend_Controller_Action
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/TableTools/js/ZeroClipboard.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/TableTools/js/ZeroClipboard.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/TableTools/js/TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/TableTools/js/TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
|
|
||||||
|
$offset = date("Z") * -1;
|
||||||
|
$this->view->headScript()->appendScript("var serverTimezoneOffset = {$offset}; //in seconds");
|
||||||
|
$this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker.js','text/javascript');
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/playouthistory/historytable.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/playouthistory/historytable.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
|
|
||||||
$this->view->headLink()->appendStylesheet($baseUrl.'/js/datatables/plugin/TableTools/css/TableTools.css?'.$CC_CONFIG['airtime_version']);
|
$this->view->headLink()->appendStylesheet($baseUrl.'/js/datatables/plugin/TableTools/css/TableTools.css?'.$CC_CONFIG['airtime_version']);
|
||||||
//$this->view->headLink()->appendStylesheet($baseUrl.'/js/datatables/plugin/TableTools/css/TableTools_JUI.css?'.$CC_CONFIG['airtime_version']);
|
//$this->view->headLink()->appendStylesheet($baseUrl.'/js/datatables/plugin/TableTools/css/TableTools_JUI.css?'.$CC_CONFIG['airtime_version']);
|
||||||
|
|
||||||
|
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.ui.timepicker.css');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function playoutHistoryFeedAction()
|
public function playoutHistoryFeedAction()
|
||||||
|
|
68
airtime_mvc/application/forms/DateRange.php
Normal file
68
airtime_mvc/application/forms/DateRange.php
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class Application_Form_DateRange extends Zend_Form_SubForm
|
||||||
|
{
|
||||||
|
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
$this->setDecorators(array(
|
||||||
|
array('ViewScript', array('viewScript' => 'form/daterange.phtml'))
|
||||||
|
));
|
||||||
|
|
||||||
|
// Add start date element
|
||||||
|
$startDate = new Zend_Form_Element_Text('his_date_start');
|
||||||
|
$startDate->class = 'input_text';
|
||||||
|
$startDate->setRequired(true)
|
||||||
|
->setLabel('Date Start:')
|
||||||
|
->setValue(date("Y-m-d"))
|
||||||
|
->setFilters(array('StringTrim'))
|
||||||
|
->setValidators(array(
|
||||||
|
'NotEmpty',
|
||||||
|
array('date', false, array('YYYY-MM-DD'))))
|
||||||
|
->setDecorators(array('ViewHelper'));
|
||||||
|
$startDate->setAttrib('alt', 'date');
|
||||||
|
$this->addElement($startDate);
|
||||||
|
|
||||||
|
// Add start time element
|
||||||
|
$startTime = new Zend_Form_Element_Text('his_time_start');
|
||||||
|
$startTime->class = 'input_text';
|
||||||
|
$startTime->setRequired(true)
|
||||||
|
->setValue('00:00')
|
||||||
|
->setFilters(array('StringTrim'))
|
||||||
|
->setValidators(array(
|
||||||
|
'NotEmpty',
|
||||||
|
array('date', false, array('HH:mm')),
|
||||||
|
array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered'))))
|
||||||
|
->setDecorators(array('ViewHelper'));
|
||||||
|
$startTime->setAttrib('alt', 'time');
|
||||||
|
$this->addElement($startTime);
|
||||||
|
|
||||||
|
// Add end date element
|
||||||
|
$endDate = new Zend_Form_Element_Text('his_date_end');
|
||||||
|
$endDate->class = 'input_text';
|
||||||
|
$endDate->setRequired(true)
|
||||||
|
->setLabel('Date End:')
|
||||||
|
->setValue(date("Y-m-d"))
|
||||||
|
->setFilters(array('StringTrim'))
|
||||||
|
->setValidators(array(
|
||||||
|
'NotEmpty',
|
||||||
|
array('date', false, array('YYYY-MM-DD'))))
|
||||||
|
->setDecorators(array('ViewHelper'));
|
||||||
|
$endDate->setAttrib('alt', 'date');
|
||||||
|
$this->addElement($endDate);
|
||||||
|
|
||||||
|
// Add end time element
|
||||||
|
$endTime = new Zend_Form_Element_Text('his_time_end');
|
||||||
|
$endTime->class = 'input_text';
|
||||||
|
$endTime->setRequired(true)
|
||||||
|
->setValue('01:00')
|
||||||
|
->setFilters(array('StringTrim'))
|
||||||
|
->setValidators(array(
|
||||||
|
'NotEmpty',
|
||||||
|
array('date', false, array('HH:mm')),
|
||||||
|
array('regex', false, array('/^[0-9:]+$/', 'messages' => 'Invalid character entered'))))
|
||||||
|
->setDecorators(array('ViewHelper'));
|
||||||
|
$endTime->setAttrib('alt', 'time');
|
||||||
|
$this->addElement($endTime);
|
||||||
|
}
|
||||||
|
}
|
|
@ -51,16 +51,27 @@ class Application_Model_Datatables {
|
||||||
$orderby[] = "id";
|
$orderby[] = "id";
|
||||||
$orderby = join("," , $orderby);
|
$orderby = join("," , $orderby);
|
||||||
// End Order By clause
|
// End Order By clause
|
||||||
|
|
||||||
|
$displayLength = intval($data["iDisplayLength"]);
|
||||||
if (count($where) > 0) {
|
if (count($where) > 0) {
|
||||||
$where = join(" AND ", $where);
|
$where = join(" AND ", $where);
|
||||||
$sql = $selectorCount." FROM ".$fromTable." WHERE ".$where;
|
$sql = $selectorCount." FROM ".$fromTable." WHERE ".$where;
|
||||||
$sqlTotalDisplayRows = $sql;
|
$sqlTotalDisplayRows = $sql;
|
||||||
|
|
||||||
$sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
|
$sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby;
|
||||||
|
|
||||||
|
//limit the results returned.
|
||||||
|
if ($displayLength !== -1) {
|
||||||
|
$sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
|
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby;
|
||||||
|
|
||||||
|
//limit the results returned.
|
||||||
|
if ($displayLength !== -1) {
|
||||||
|
$sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<div class="his-timerange">
|
||||||
|
<?php echo $this->element->getElement('his_date_start') ?>
|
||||||
|
<?php echo $this->element->getElement('his_time_start') ?>
|
||||||
|
<?php echo $this->element->getElement('his_date_end') ?>
|
||||||
|
<?php echo $this->element->getElement('his_time_end') ?>
|
||||||
|
<input type="button" id="his_submit" class="ui-button ui-state-default" value="GO"></input>
|
||||||
|
</div>
|
|
@ -1 +1,2 @@
|
||||||
|
<?php echo $this->date_form; ?>
|
||||||
<table id="history_table" cellpadding="0" cellspacing="0" class="datatable"></table>
|
<table id="history_table" cellpadding="0" cellspacing="0" class="datatable"></table>
|
|
@ -9,8 +9,29 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
mod.historyTable = function() {
|
mod.historyTable = function() {
|
||||||
var oTable,
|
var oTable,
|
||||||
historyContentDiv = $("#history_content"),
|
historyContentDiv = $("#history_content"),
|
||||||
historyTableDiv = historyContentDiv.find("#history_table");
|
historyTableDiv = historyContentDiv.find("#history_table"),
|
||||||
tableHeight = historyContentDiv.height() - 140;
|
tableHeight = historyContentDiv.height() - 140,
|
||||||
|
fnServerData;
|
||||||
|
|
||||||
|
fnServerData = function ( sSource, aoData, fnCallback ) {
|
||||||
|
|
||||||
|
if (fnServerData.hasOwnProperty("start")) {
|
||||||
|
aoData.push( { name: "start", value: fnServerData.start} );
|
||||||
|
}
|
||||||
|
if (fnServerData.hasOwnProperty("end")) {
|
||||||
|
aoData.push( { name: "end", value: fnServerData.end} );
|
||||||
|
}
|
||||||
|
|
||||||
|
aoData.push( { name: "format", value: "json"} );
|
||||||
|
|
||||||
|
$.ajax( {
|
||||||
|
"dataType": 'json',
|
||||||
|
"type": "GET",
|
||||||
|
"url": sSource,
|
||||||
|
"data": aoData,
|
||||||
|
"success": fnCallback
|
||||||
|
} );
|
||||||
|
};
|
||||||
|
|
||||||
oTable = historyTableDiv.dataTable( {
|
oTable = historyTableDiv.dataTable( {
|
||||||
|
|
||||||
|
@ -28,26 +49,18 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
"sAjaxSource": "/Playouthistory/playout-history-feed",
|
"sAjaxSource": "/Playouthistory/playout-history-feed",
|
||||||
"sAjaxDataProp": "history",
|
"sAjaxDataProp": "history",
|
||||||
|
|
||||||
"fnServerData": function ( sSource, aoData, fnCallback ) {
|
"fnServerData": fnServerData,
|
||||||
|
|
||||||
aoData.push( { name: "format", value: "json"} );
|
|
||||||
|
|
||||||
$.ajax( {
|
|
||||||
"dataType": 'json',
|
|
||||||
"type": "GET",
|
|
||||||
"url": sSource,
|
|
||||||
"data": aoData,
|
|
||||||
"success": fnCallback
|
|
||||||
} );
|
|
||||||
},
|
|
||||||
|
|
||||||
"oLanguage": {
|
"oLanguage": {
|
||||||
"sSearch": ""
|
"sSearch": ""
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"aLengthMenu": [[50, 100, 500, -1], [50, 100, 500, "All"]],
|
||||||
|
"iDisplayLength": 50,
|
||||||
|
|
||||||
"sPaginationType": "full_numbers",
|
"sPaginationType": "full_numbers",
|
||||||
"bJQueryUI": true,
|
"bJQueryUI": true,
|
||||||
"bAutoWidth": false,
|
"bAutoWidth": true,
|
||||||
|
|
||||||
"sDom": 'lfr<"H"T><"dataTables_scrolling"t><"F"ip>',
|
"sDom": 'lfr<"H"T><"dataTables_scrolling"t><"F"ip>',
|
||||||
|
|
||||||
|
@ -56,6 +69,8 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
oTable.fnSetFilteringDelay(350);
|
oTable.fnSetFilteringDelay(350);
|
||||||
|
|
||||||
|
return oTable;
|
||||||
};
|
};
|
||||||
|
|
||||||
return AIRTIME;
|
return AIRTIME;
|
||||||
|
@ -67,12 +82,52 @@ $(document).ready(function(){
|
||||||
var viewport = AIRTIME.utilities.findViewportDimensions(),
|
var viewport = AIRTIME.utilities.findViewportDimensions(),
|
||||||
history_content = $("#history_content"),
|
history_content = $("#history_content"),
|
||||||
widgetHeight = viewport.height - 185,
|
widgetHeight = viewport.height - 185,
|
||||||
screenWidth = Math.floor(viewport.width - 110);
|
screenWidth = Math.floor(viewport.width - 110),
|
||||||
|
oBaseDatePickerSettings,
|
||||||
|
oBaseTimePickerSettings,
|
||||||
|
oTable,
|
||||||
|
dateStartId = "#his_date_start",
|
||||||
|
timeStartId = "#his_time_start",
|
||||||
|
dateEndId = "#his_date_end",
|
||||||
|
timeEndId = "#his_time_end";
|
||||||
|
|
||||||
history_content
|
history_content
|
||||||
.height(widgetHeight)
|
.height(widgetHeight)
|
||||||
.width(screenWidth);
|
.width(screenWidth);
|
||||||
|
|
||||||
AIRTIME.history.historyTable();
|
oBaseDatePickerSettings = {
|
||||||
|
dateFormat: 'yy-mm-dd',
|
||||||
|
onSelect: function(sDate, oDatePicker) {
|
||||||
|
$(this).datepicker( "setDate", sDate );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
oBaseTimePickerSettings = {
|
||||||
|
showPeriodLabels: false,
|
||||||
|
showCloseButton: true,
|
||||||
|
showLeadingZero: false,
|
||||||
|
defaultTime: '0:00'
|
||||||
|
};
|
||||||
|
|
||||||
|
oTable = AIRTIME.history.historyTable();
|
||||||
|
|
||||||
|
history_content.find(dateStartId).datepicker(oBaseDatePickerSettings);
|
||||||
|
history_content.find(timeStartId).timepicker(oBaseTimePickerSettings);
|
||||||
|
history_content.find(dateEndId).datepicker(oBaseDatePickerSettings);
|
||||||
|
history_content.find(timeEndId).timepicker(oBaseTimePickerSettings);
|
||||||
|
|
||||||
|
|
||||||
|
history_content.find("#his_submit").click(function(ev){
|
||||||
|
var fn,
|
||||||
|
oRange;
|
||||||
|
|
||||||
|
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
||||||
|
|
||||||
|
fn = oTable.fnSettings().fnServerData;
|
||||||
|
fn.start = oRange.start;
|
||||||
|
fn.end = oRange.end;
|
||||||
|
|
||||||
|
oTable.fnDraw();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
|
@ -7,7 +7,11 @@ $(document).ready(function(){
|
||||||
screenWidth = Math.floor(viewport.width - 110),
|
screenWidth = Math.floor(viewport.width - 110),
|
||||||
oBaseDatePickerSettings,
|
oBaseDatePickerSettings,
|
||||||
oBaseTimePickerSettings,
|
oBaseTimePickerSettings,
|
||||||
oRange;
|
oRange,
|
||||||
|
dateStartId = "#sb_date_start",
|
||||||
|
timeStartId = "#sb_time_start",
|
||||||
|
dateEndId = "#sb_date_end",
|
||||||
|
timeEndId = "#sb_time_end";
|
||||||
|
|
||||||
//set the heights of the main widgets.
|
//set the heights of the main widgets.
|
||||||
lib.height(widgetHeight);
|
lib.height(widgetHeight);
|
||||||
|
@ -30,78 +34,10 @@ $(document).ready(function(){
|
||||||
defaultTime: '0:00'
|
defaultTime: '0:00'
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
builder.find(dateStartId).datepicker(oBaseDatePickerSettings);
|
||||||
* Get the schedule range start in unix timestamp form (in seconds).
|
builder.find(timeStartId).timepicker(oBaseTimePickerSettings);
|
||||||
* defaults to NOW if nothing is selected.
|
builder.find(dateEndId).datepicker(oBaseDatePickerSettings);
|
||||||
*
|
builder.find(timeEndId).timepicker(oBaseTimePickerSettings);
|
||||||
* @param String sDatePickerId
|
|
||||||
*
|
|
||||||
* @param String sTimePickerId
|
|
||||||
*
|
|
||||||
* @return Number iTime
|
|
||||||
*/
|
|
||||||
function fnGetTimestamp(sDatePickerId, sTimePickerId) {
|
|
||||||
var date,
|
|
||||||
time,
|
|
||||||
iTime,
|
|
||||||
iServerOffset,
|
|
||||||
iClientOffset;
|
|
||||||
|
|
||||||
if ($(sDatePickerId).val() === "") {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
date = $(sDatePickerId).val();
|
|
||||||
time = $(sTimePickerId).val();
|
|
||||||
|
|
||||||
date = date.split("-");
|
|
||||||
time = time.split(":");
|
|
||||||
|
|
||||||
//0 based month in js.
|
|
||||||
oDate = new Date(date[0], date[1]-1, date[2], time[0], time[1]);
|
|
||||||
|
|
||||||
iTime = oDate.getTime(); //value is in millisec.
|
|
||||||
iTime = Math.round(iTime / 1000);
|
|
||||||
iServerOffset = serverTimezoneOffset;
|
|
||||||
iClientOffset = oDate.getTimezoneOffset() * -60;//function returns minutes
|
|
||||||
|
|
||||||
//adjust for the fact the the Date object is in client time.
|
|
||||||
iTime = iTime + iClientOffset + iServerOffset;
|
|
||||||
|
|
||||||
return iTime;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Returns an object containing a unix timestamp in seconds for the start/end range
|
|
||||||
*
|
|
||||||
* @return Object {"start", "end", "range"}
|
|
||||||
*/
|
|
||||||
function fnGetScheduleRange() {
|
|
||||||
var iStart,
|
|
||||||
iEnd,
|
|
||||||
iRange,
|
|
||||||
DEFAULT_RANGE = 60*60*24;
|
|
||||||
|
|
||||||
iStart = fnGetTimestamp("#sb_date_start", "#sb_time_start");
|
|
||||||
iEnd = fnGetTimestamp("#sb_date_end", "#sb_time_end");
|
|
||||||
|
|
||||||
iRange = iEnd - iStart;
|
|
||||||
|
|
||||||
if (iRange === 0 || iEnd < iStart) {
|
|
||||||
iEnd = iStart + DEFAULT_RANGE;
|
|
||||||
iRange = DEFAULT_RANGE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
start: iStart,
|
|
||||||
end: iEnd,
|
|
||||||
range: iRange
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#sb_date_start").datepicker(oBaseDatePickerSettings);
|
|
||||||
$("#sb_time_start").timepicker(oBaseTimePickerSettings);
|
|
||||||
$("#sb_date_end").datepicker(oBaseDatePickerSettings);
|
|
||||||
$("#sb_time_end").timepicker(oBaseTimePickerSettings);
|
|
||||||
|
|
||||||
$("#sb_submit").click(function(ev){
|
$("#sb_submit").click(function(ev){
|
||||||
var fn,
|
var fn,
|
||||||
|
@ -112,7 +48,7 @@ $(document).ready(function(){
|
||||||
//reset timestamp value since input values could have changed.
|
//reset timestamp value since input values could have changed.
|
||||||
AIRTIME.showbuilder.resetTimestamp();
|
AIRTIME.showbuilder.resetTimestamp();
|
||||||
|
|
||||||
oRange = fnGetScheduleRange();
|
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
||||||
|
|
||||||
fn = oTable.fnSettings().fnServerData;
|
fn = oTable.fnSettings().fnServerData;
|
||||||
fn.start = oRange.start;
|
fn.start = oRange.start;
|
||||||
|
@ -135,8 +71,7 @@ $(document).ready(function(){
|
||||||
var $button = $(this),
|
var $button = $(this),
|
||||||
$lib = $("#library_content"),
|
$lib = $("#library_content"),
|
||||||
$builder = $("#show_builder"),
|
$builder = $("#show_builder"),
|
||||||
schedTable = $("#show_builder_table").dataTable(),
|
schedTable = $("#show_builder_table").dataTable();
|
||||||
libTable = $lib.find("#library_display").dataTable();
|
|
||||||
|
|
||||||
if ($button.hasClass("sb-edit")) {
|
if ($button.hasClass("sb-edit")) {
|
||||||
|
|
||||||
|
@ -164,7 +99,7 @@ $(document).ready(function(){
|
||||||
schedTable.fnDraw();
|
schedTable.fnDraw();
|
||||||
});
|
});
|
||||||
|
|
||||||
oRange = fnGetScheduleRange();
|
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
|
||||||
AIRTIME.showbuilder.fnServerData.start = oRange.start;
|
AIRTIME.showbuilder.fnServerData.start = oRange.start;
|
||||||
AIRTIME.showbuilder.fnServerData.end = oRange.end;
|
AIRTIME.showbuilder.fnServerData.end = oRange.end;
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,79 @@ var AIRTIME = (function(AIRTIME){
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the schedule range start in unix timestamp form (in seconds).
|
||||||
|
* defaults to NOW if nothing is selected.
|
||||||
|
*
|
||||||
|
* @param String sDatePickerId
|
||||||
|
*
|
||||||
|
* @param String sTimePickerId
|
||||||
|
*
|
||||||
|
* @return Number iTime
|
||||||
|
*/
|
||||||
|
mod.fnGetTimestamp = function(sDateId, sTimeId) {
|
||||||
|
var date,
|
||||||
|
time,
|
||||||
|
iTime,
|
||||||
|
iServerOffset,
|
||||||
|
iClientOffset,
|
||||||
|
temp;
|
||||||
|
|
||||||
|
temp = $(sDateId).val();
|
||||||
|
if ( temp === "") {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
date = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
time = $(sTimeId).val();
|
||||||
|
|
||||||
|
date = date.split("-");
|
||||||
|
time = time.split(":");
|
||||||
|
|
||||||
|
//0 based month in js.
|
||||||
|
oDate = new Date(date[0], date[1]-1, date[2], time[0], time[1]);
|
||||||
|
|
||||||
|
iTime = oDate.getTime(); //value is in millisec.
|
||||||
|
iTime = Math.round(iTime / 1000);
|
||||||
|
iServerOffset = serverTimezoneOffset;
|
||||||
|
iClientOffset = oDate.getTimezoneOffset() * -60;//function returns minutes
|
||||||
|
|
||||||
|
//adjust for the fact the the Date object is in client time.
|
||||||
|
iTime = iTime + iClientOffset + iServerOffset;
|
||||||
|
|
||||||
|
return iTime;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns an object containing a unix timestamp in seconds for the start/end range
|
||||||
|
*
|
||||||
|
* @return Object {"start", "end", "range"}
|
||||||
|
*/
|
||||||
|
mod.fnGetScheduleRange = function(dateStart, timeStart, dateEnd, timeEnd) {
|
||||||
|
var iStart,
|
||||||
|
iEnd,
|
||||||
|
iRange,
|
||||||
|
DEFAULT_RANGE = 60*60*24;
|
||||||
|
|
||||||
|
iStart = AIRTIME.utilities.fnGetTimestamp(dateStart, timeStart);
|
||||||
|
iEnd = AIRTIME.utilities.fnGetTimestamp(dateEnd, timeEnd);
|
||||||
|
|
||||||
|
iRange = iEnd - iStart;
|
||||||
|
|
||||||
|
if (iRange === 0 || iEnd < iStart) {
|
||||||
|
iEnd = iStart + DEFAULT_RANGE;
|
||||||
|
iRange = DEFAULT_RANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
start: iStart,
|
||||||
|
end: iEnd,
|
||||||
|
range: iRange
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
return AIRTIME;
|
return AIRTIME;
|
||||||
|
|
||||||
}(AIRTIME || {}));
|
}(AIRTIME || {}));
|
Loading…
Add table
Add a link
Reference in a new issue