From b603726a398c7967a9dc32a6a45286979ad40d08 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 9 Feb 2012 15:04:52 -0500 Subject: [PATCH] CC-3289: Widgets should have a version string so users can make sure widgets are up to date -I've updated the messages used to notify the user to be more explicit. -I've moved the constant used to track widget api versioning to /application/configs/constants.php --- airtime_mvc/application/configs/constants.php | 1 + .../application/controllers/ApiController.php | 4 ++-- widgets/js/jquery.showinfo.js | 17 ++++++++++------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/airtime_mvc/application/configs/constants.php b/airtime_mvc/application/configs/constants.php index 50008e3f8..cfe93182e 100644 --- a/airtime_mvc/application/configs/constants.php +++ b/airtime_mvc/application/configs/constants.php @@ -2,6 +2,7 @@ define('AIRTIME_COPYRIGHT_DATE', '2010-2011'); define('AIRTIME_REST_VERSION', '1.1'); +define('AIRTIME_API_VERSION', '1.0'); // Metadata Keys for files define('MDATA_KEY_FILEPATH', 'filepath'); diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 0143b374a..d15e3ca96 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -216,7 +216,7 @@ class ApiController extends Zend_Controller_Action "nextShow"=>Application_Model_Show::GetNextShows($utcTimeNow, $limit, $utcTimeEnd), "timezone"=> date("T"), "timezoneOffset"=> date("Z"), - "widgetVersion"=>"1.0"); //used by caller to determine if the airtime they are running or widgets in use is out of date. + "AIRTIME_API_VERSION"=>AIRTIME_API_VERSION); //used by caller to determine if the airtime they are running or widgets in use is out of date. //Convert from UTC to localtime for user. Application_Model_Show::ConvertToLocalTimeZone($result["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); @@ -255,7 +255,7 @@ class ApiController extends Zend_Controller_Action $result[$dow[$i]] = $shows; } - $result['widgetVersion'] = "1.0"; //used by caller to determine if the airtime they are running or widgets in use is out of date. + $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; //used by caller to determine if the airtime they are running or widgets in use is out of date. header("Content-type: text/javascript"); echo $_GET['callback'].'('.json_encode($result).')'; } else { diff --git a/widgets/js/jquery.showinfo.js b/widgets/js/jquery.showinfo.js index 6023a097a..8017081d7 100644 --- a/widgets/js/jquery.showinfo.js +++ b/widgets/js/jquery.showinfo.js @@ -1,3 +1,5 @@ + var AIRTIME_API_VERSION = "1.0"; + (function($){ $.fn.airtimeShowSchedule = function(options) { @@ -6,7 +8,7 @@ sourceDomain: "http://localhost/", //where to get show status from text: {onAirToday:"On air today"} }; - var options = $.extend(true, defaults, options); + options = $.extend(true, defaults, options); options.sourceDomain = addEndingBackslash(options.sourceDomain); return this.each(function() { @@ -158,7 +160,7 @@ dowText: {monday:"Monday", tuesday:"Tuesday", wednesday:"Wednesday", thursday:"Thursday", friday:"Friday", saturday:"Saturday", sunday:"Sunday"}, miscText: {time:"Time", programName:"Program Name", details:"Details", readMore:"Read More"} }; - var options = $.extend(true, defaults, options); + options = $.extend(true, defaults, options); options.sourceDomain = addEndingBackslash(options.sourceDomain); return this.each(function() { @@ -404,11 +406,12 @@ function convertDateToPosixTime(s){ * -If the value is less then 1 warn the user that they should upgrade the javascript to a newer version. */ function checkWidgetVersion(data){ - var widgetVersion = data['widgetVersion']; + + var airtimeServerWidgetVersion = data['AIRTIME_API_VERSION']; - if (undefined === widgetVersion || widgetVersion > 1) - throw 'The widgets you are using are out of date, please get the latest jquery.showinfo.js file.'; - else if (widgetVersion < 1) - throw 'The version of airtime that you are using should be upgraded to work with this widget.'; + if (undefined === airtimeServerWidgetVersion || airtimeServerWidgetVersion > AIRTIME_API_VERSION ) + throw "The version of widgets you are using is out of date with the Airtime installation, please update your widgets javascript file. (Airtime widget API version is "+airtimeServerWidgetVersion+", this widget's API version is "+AIRTIME_API_VERSION+")"; + else if (airtimeServerWidgetVersion < AIRTIME_API_VERSION ) + throw "The Airtime server has a different version than this widget supports. Please get the correct widget version for your Airtime installation. (Airtime widget API version is "+airtimeServerWidgetVersion+", this widget's API version is "+AIRTIME_API_VERSION+")"; }