From b6d2b0f942f02dd073f4e7db7161e7f30a01f246 Mon Sep 17 00:00:00 2001 From: martin Date: Mon, 7 Feb 2011 00:26:16 -0500 Subject: [PATCH] -fixed potential bug for incorrect return value type. --- application/models/Schedule.php | 5 +++-- public/js/playlist/helperfunctions.js | 26 +++++++++++++++++++------ public/js/playlist/playlist.js | 28 +++++++++------------------ 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/application/models/Schedule.php b/application/models/Schedule.php index fede7eb25..1383f4b23 100644 --- a/application/models/Schedule.php +++ b/application/models/Schedule.php @@ -444,12 +444,13 @@ class Schedule { public static function GetPlayOrderRange($prev = 1, $next = 1) { if (!is_int($prev) || !is_int($next)){ //must enter integers to specify ranges - return "{}"; + return array(); } $date = Schedule::GetSchedulerTime(); $timeNow = $date->getDate(); - return array("schedulerTime"=>gmdate("Y-m-d H:i:s"), + return array("env"=>APPLICATION_ENV, + "schedulerTime"=>gmdate("Y-m-d H:i:s"), "previous"=>Schedule::Get_Scheduled_Item_Data($timeNow, -1, $prev, "24 hours"), "current"=>Schedule::Get_Scheduled_Item_Data($timeNow, 0), "next"=>Schedule::Get_Scheduled_Item_Data($timeNow, 1, $next, "48 hours"), diff --git a/public/js/playlist/helperfunctions.js b/public/js/playlist/helperfunctions.js index 805a1b0bb..9b341dc2a 100644 --- a/public/js/playlist/helperfunctions.js +++ b/public/js/playlist/helperfunctions.js @@ -1,3 +1,17 @@ +/* function to create popup window */ +function popup(mylink){ + if (!window.focus) + return true; + var href; + if (typeof(mylink) == 'string') + href=mylink; + else + href=mylink.href; + window.open(href, "player", 'width=300,height=100,scrollbars=yes'); + return false; +} + + /* Takes an input parameter of milliseconds and converts these into * the format HH:MM:SS */ function convertToHHMMSS(timeInMS){ @@ -100,10 +114,10 @@ function convertDateToHHMMSS(epochTime){ * and converts this to epoch/posix time. */ function convertDateToPosixTime(s){ - var temp = s.split(" "); + var datetime = s.split(" "); - var date = temp[0].split("-"); - var time = temp[1].split(":"); + var date = datetime[0].split("-"); + var time = datetime[1].split(":"); var year = date[0]; var month = date[1]; @@ -114,9 +128,9 @@ function convertDateToPosixTime(s){ var msec = 0; if (time[2].indexOf(".") != -1){ - var temp1 = time[2].split("."); - sec = temp1[0]; - msec = temp1[1]; + var temp = time[2].split("."); + sec = temp[0]; + msec = temp[1]; } else sec = time[2]; diff --git a/public/js/playlist/playlist.js b/public/js/playlist/playlist.js index 96e8ce9c1..e59dcc548 100644 --- a/public/js/playlist/playlist.js +++ b/public/js/playlist/playlist.js @@ -15,10 +15,9 @@ var uiUpdateInterval = 200; var songEndFunc; -//var showStartPosixTime = 0; -//var showEndPosixTime = 0; -//var showLengthMs = 1; -//var currentShowName = ""; +//set to "development" if we are developing :). Useful to disable alerts +//when entering production mode. +var APPLICATION_ENV = ""; /* boolean flag to let us know if we should prepare to execute a function * that flips the playlist to the next song. This flags purpose is to @@ -108,8 +107,9 @@ function updateProgressBarValue(){ if (diff < serverUpdateInterval && diff >= 0){ nextSongPrepare = false; setTimeout(newSongStart, diff); - } else if (diff < 0){ - alert ("Warning: estimatedSchedulePosixTime > songStartPosixTime"); + } else if (diff < 0 && APPLICATION_ENV == "development"){ + alert ("Warning: estimatedSchedulePosixTime > songStartPosixTime"); + alert (estimatedSchedulePosixTime + " " + nextSongs[0].songStartPosixTime); } } @@ -119,7 +119,7 @@ function updateProgressBarValue(){ if (diff < serverUpdateInterval && diff >= 0){ nextShowPrepare = false; setTimeout(nextShowStart, diff); - } else if (diff < 0){ + } else if (diff < 0 && APPLICATION_ENV == "development"){ alert ("Warning: estimatedSchedulePosixTime > showStartPosixTime"); } } @@ -202,6 +202,8 @@ function calcAdditionalShowData(show){ } function parseItems(obj){ + APPLICATION_ENV = obj.env; + var schedulePosixTime = convertDateToPosixTime(obj.schedulerTime); schedulePosixTime += parseInt(obj.timezoneOffset)*1000; @@ -244,18 +246,6 @@ function init() { secondsTimer(); } -function popup(mylink){ - if (!window.focus) - return true; - var href; - if (typeof(mylink) == 'string') - href=mylink; - else - href=mylink.href; - window.open(href, "player", 'width=300,height=100,scrollbars=yes'); - return false; -} - $(document).ready(function() { init(); });