1/*Site Info Banner Widget*/ 2 3 4(function ($) { 5 6 //Data service for the widget 7 function widgetDataService() { 8 9 this.getWidgetData = function (servicePath, widgetModuleItemID, successCallback, errorCallback) { 10 $.ajax({ 11 type: "POST", 12 url: servicePath, 13 data: "{'widgetModuleItemID':" + widgetModuleItemID + "}", 14 contentType: "application/json; charset=utf-8", 15 dataType: "json", 16 success: successCallback, 17 error: errorCallback 18 }); 19 }; 20 }; 21 22 //Global variable for the widget function 23 var widgetModuleItemID = 0; 24 var widgetData = null; 25 var widgetContainer = null; 26 var eventNameContentContainer = null; 27 var eventDatesContentContainer = null; 28 var numberOfDays; 29 var previouslyViewedDate = true; 30 var customConnector = null; 31 var eventLength = null; 32 var afterMessage = ''; 33 var siteInfoBannerLoaded = function () { }; 34 var countdownTextPrefix = '{#days} Days'; 35 36 //Constructor for the wiget 37 $.fn.SiteInfoBanner = function (options) { 38 39 var opts = $.extend({}, $.fn.SiteInfoBanner.defaultOptions, options); 40 41 widgetContainer = this; 42 widgetModuleItemID = opts.currentWidgetModuleItemID; 43 44 eventNameContentContainer = widgetContainer.find('#eventName'); 45 eventDatesContentContainer = widgetContainer.find('#eventDates'); 46 previouslyViewedDate = opts.previouslyViewedDate; 47 countdownTextPrefix = opts.countdownTextPrefix; 48 49 var widgetDataAdapter = new widgetDataService(); 50 51 widgetDataAdapter.getWidgetData(opts.scriptPath, opts.currentWidgetModuleItemID, getWidgetDataSuccess, getWidgetDataError); 52 53 customConnector = opts.customConnector; 54 siteInfoBannerLoaded = opts.siteInfoBannerLoaded; 55 56 }; 57 58 59 60 //Default options for the constructor to be merged with send constructor data 61 $.fn.SiteInfoBanner.defaultOptions = { 62 scriptPath: "services/eventsservice.asmx" 63 , currentWidgetModuleItemID: 0 64 , previouslyViewedDate: true 65 , customConnector: null 66 , siteInfoBannerLoaded: function(){} 67 }; 68 69 //service call worked 70 var getWidgetDataSuccess = function (data) { 71 72 widgetData = data.d; 73 initialize(); 74 }; 75 76 //service call has failed 77 var getWidgetDataError = function (data) { 78 79 console.log('Site Info Banner failed to load' 80 , '\n' + 'Status: ' + data.status + ' ' + data.statusText 81 , '\n' + data.responseText); 82 83 }; 84 85 //set up the ui 86 function initialize() { 87 88 if (!widgetData.Enabled) { 89 return; 90 } 91 92 if(widgetData.ShowAfterEventMessage == true){ 93 afterMessage = widgetData.AfterEventMessage; 94 } 95 //new properties 96 //widgetData.EventLength (in days, an event that has the same start date and end date would result in a 0) 97 //widgetData.DuringEventMessage 98 //widgetData.AfterEventMessage 99 var m = 0; 100 eventLength = widgetData.EventLength; 101 numberOfDays = widgetData.NumberOfDays; 102 if(numberOfDays <=0){ 103 m = numberOfDays + eventLength; 104 } 105 106 var i = numberOfDays + 50; 107 if (numberOfDays > 0) { 108 var until = 'until '; 109 110 if(customConnector!=null){ 111 until = customConnector; 112 } 113 114 if (widgetData.LoadedFromCountdowns) { 115 until = '' 116 } 117 118 eventDatesContentContainer.text(widgetData.DateString) 119 if (previouslyViewedDate == false) { 120 setInterval(function () { 121 if (i >= numberOfDays) { 122 if (i == 1) { 123 eventNameContentContainer.html('<span class="countdownDays">' + i + ' <span class="dayWord">day</span></span> ' + until + widgetData.EventName); 124 i--; 125 } 126 else { 127 eventNameContentContainer.html('<span class="countdownDays">' + i + ' <span class="dayWord">days</span></span> ' + until + widgetData.EventName); 128 i--; 129 } 130 131 132 } 133 }, 50); 134 } else { 135 if (numberOfDays == 1) { 136 eventNameContentContainer.html('<span class="countdownDays">' + numberOfDays + ' <span class="dayWord">day</span></span> '+until + widgetData.EventName); 137 } else { 138 eventNameContentContainer.html('<span class="countdownDays">' + numberOfDays + ' <span class="dayWord">days</span></span> '+until + widgetData.EventName); 139 } 140 141 } 142 143 } else if (m < 0) { 144 if (widgetData.EventName != null) { 145 eventDatesContentContainer.text(widgetData.EventName); 146 } 147 eventNameContentContainer.html('<span class="countdownDays">'+afterMessage+'</span>'); 148 if(afterMessage == ''){ 149 $('#widgetBanner').addClass('noThankYouMessage'); // this is NOT the preferred method (preferred method is on following line) - this is to support clients that rely on this class
150 $('body').addClass('siteInfoBannerWidgetNoThankYouMessage'); // preferred method allows a class to be added even when the widget is not added to the banner 151 } 152 $('#widgetBanner').addClass('datePast'); // this is NOT the preferred method (preferred method is on following line) - this is to support clients that rely on this class 153 $('body').addClass('siteInfoBannerWidgetDateIsPast'); // preferred method allows a class to be added even when the widget is not added to the banner 154 } 155 156 else { 157 $('#siteInfoBannerWidget').css('display', 'block'); 158 eventDatesContentContainer.text(widgetData.DateString); 159 eventNameContentContainer.css('display', 'none'); 160 $('#widgetBanner').addClass('eventHappening'); // this is NOT the preferred method (preferred method is on following line) - this is to support clients that rely on this class 161 $('body').addClass('siteInfoBannerWidgetEventHappening'); // preferred method allows a class to be added even when the widget is not added to the banner 162 } 163 164 siteInfoBannerLoaded(widgetData); 165 var infoBannerCountdownContent = $('.countdownDays').html(); 166 var infoBannerDatesContent = $('#eventDates').html(); 167 if(infoBannerCountdownContent == '' && infoBannerDatesContent == ''){ 168 $('body').addClass('siteInfoBannerOff'); 169 } else { 170 $('body').addClass('siteInfoBannerOn'); 171 } 172 widgetContainer.show(); 173 174 175 176 } 177 178})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.