"&&!s?p.childNodes:[];for(i=t.length-1;i>=0;--i)f.nodeName(t[i],"tbody")&&!t[i].childNodes.length&&t[i].parentNode.removeChild(t[i])}!f.support.leadingWhitespace&&X.test(l)&&p.insertBefore(b.createTextNode(X.exec(l)[0]),p.firstChild),l=p.childNodes,p&&(p.parentNode.removeChild(p),q.length>0&&(r=q[q.length-1],r&&r.parentNode&&r.parentNode.removeChild(r)))}var u;if(!f.support.appendChecked)if(l[0]&&typeof (u=l.length)=="number")for(i=0;i1)},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=by(a,"opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d,h==="string"&&(g=bu.exec(d))&&(d=+(g[1]+1)*+g[2]+parseFloat(f.css(a,c)),h="number");if(d==null||h==="number"&&isNaN(d))return;h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;if(by)return by(a,c)},swap:function(a,b,c){var d={},e,f;for(f in b)d[f]=a.style[f],a.style[f]=b[f];e=c.call(a);for(f in b)a.style[f]=d[f];return e}}),f.curCSS=f.css,c.defaultView&&c.defaultView.getComputedStyle&&(bz=function(a,b){var c,d,e,g,h=a.style;b=b.replace(br,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b))),!f.support.pixelMargin&&e&&bv.test(b)&&bt.test(c)&&(g=h.width,h.width=c,c=e.width,h.width=g);return c}),c.documentElement.currentStyle&&(bA=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f==null&&g&&(e=g[b])&&(f=e),bt.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),by=bz||bA,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){if(c)return a.offsetWidth!==0?bB(a,b,d):f.swap(a,bw,function(){return bB(a,b,d)})},set:function(a,b){return bs.test(b)?b+"px":b}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bq.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bp,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bp.test(g)?g.replace(bp,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){return f.swap(a,{display:"inline-block"},function(){return b?by(a,"margin-right"):a.style.marginRight})}})}),f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)}),f.each({margin:"",padding:"",border:"Width"},function(a,b){f.cssHooks[a+b]={expand:function(c){var d,e=typeof c=="string"?c.split(" "):[c],f={};for(d=0;d<4;d++)f[a+bx[d]+b]=e[d]||e[d-2]||e[0];return f}}});var bC=/%20/g,bD=/\[\]$/,bE=/\r?\n/g,bF=/#.*$/,bG=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bH=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bI=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bJ=/^(?:GET|HEAD)$/,bK=/^\/\//,bL=/\?/,bM=/");
//this is the IE way
windowHandle.document.title = jBody.find("[cwfield='title']").text();
var jPrintLink = $(windowHandle.document).find('#cwuiprintlink')
jPrintLink.text("Close Window");
jPrintLink.css({cursor:"pointer"});
jPrintLink.bind('click', function(){windowHandle.close()});
jBody.find("a").css({color:"#000000"});
jBody.find("[cwui=downloadlink]").hide();
jBody.find("[cwui=emaillink]").hide();
jBody.find("[cwui=remindlink]").hide();
jBody.find("[cwfield='weatherlink']").hide();
jBody.find("[cwfield='maplink']").hide();
windowHandle.print();
return false;
}
}
function createSubHead(doc, container, subHead){
var subHeadDIV = container.appendChild(doc.createElement("div"));
$(subHeadDIV).text(subHead).css({"font-weight":"bold", "padding-top":"5px", "padding-bottom":"5px"}).attr("cwfield", "detaillabel");
}
function createElement(doc, name, container, fieldName){
var newElement = doc.createElement(name);
newElement.setAttribute("cwfield", fieldName);
return container.appendChild(newElement);
}
function createLabeledElement(doc, label, container, fieldName){
var newDIV = doc.createElement("div");
$(newDIV).css({"padding-top":"5px"});
$(newDIV).attr("id", "div_"+fieldName);
var contentSPAN = doc.createElement("span");
contentSPAN.setAttribute("cwfield", fieldName);
var labelSPAN = doc.createElement("span");
var jLabelSPAN = $(labelSPAN);
jLabelSPAN.attr("cwfield", "detaillabel");
jLabelSPAN.text(label + ": ");
jLabelSPAN.css({"font-weight":"bold"});
newDIV.appendChild(labelSPAN);
newDIV.appendChild(contentSPAN);
return container.appendChild(newDIV);
}
function widgetStylesCallback(data, result){
if (data.status.code != 200) {
if(data.status.code == 999){
alert(data.status.msg);
return;
}
document.write(data.status.msg);
return;
} else {
that.widgetStyles = data.styles;
that.applyStyles(that.widgetStyles, true);
}
}
function applyDetailStyles(styles, notDesigner){
var jTitleBar = jDetailDIV.closest(".ui-dialog").find(".ui-dialog-titlebar");
//jTitleBar.css({"padding-left" : "10px", "padding-top" : "0px", "padding-bottom" : "0px", "color" : styles.srch_head_text_color, "font-size" : "12pt"});
jTitleBar.css({"color" : styles.srch_head_text_color, "font-size" : "10pt", "padding-left" : "10px", "margin-bottom" : "5px", "cursor" : "grab"});
if(NameValues["indesigner"]) {
jTitleBar.css({background:"#CCCCCC url(http://www.calendarwiz.com/jquery/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png) repeat-x scroll 50% 50%", border:"#CCCCCC"});
}
jDetailDIV.css({"background-color":styles.event_bg_color, color:styles.event_text_color, "font-family":styles.event_font, "font-size":styles.event_size + "pt", 'text-align' : 'left'});
jDetailDIV.find("a").css({color:styles.event_text_color});
jDetailDIV.find("input, select, textarea").css({"background-color":"#FFFFFF", color:"#000000", "font-family":styles.event_font, "font-size":styles.event_size + "pt"});
jDetailDIV.find("input[type='button']").css({"background-color":"#D1D1D1"});
jEmailBodyDIV.find("input, textarea").css({"font-family":"Arial", "font-size":"12px"});
jRemindBodyDIV.find("input, textarea, select").css({"font-family":"Arial", "font-size":"12px"});
if (notDesigner == undefined || !jDetailDIV.dialog('isOpen')) {
jDetailDIV.dialog('option', 'width', parseInt(styles.pop_width));
jDetailDIV.dialog('option', 'height', parseInt(styles.pop_height));
jDetailDIV.bind( "dialogclose", function() {
jRemindBodyDIV.hide();
jEmailBodyDIV.hide();
jMsgDiv.hide();
});
if(jDetailDIV.dialog('isOpen')) {
var offset = jDetailDIV.offset(); // relative to the document
jDetailDIV.dialog('close');
jDetailDIV.dialog('open');
jDetailDIV.dialog('option', 'position', [offset.left - 4, offset.top - 31]);
}
}
}
function navMonth(e){
if ('0' == '0') { showThis(jPleaseWaitDIV, that.widget); }
// Set day to 15th of month to prevent skipping month when on last days of
// month and those days don't exist in month being navigated to (e.g. current
// date is Oct 31st and navigatin to Nov which only has 30 days) - bug fix 131031
that.date.setDate(15);
if($(e.currentTarget).attr("cwui") == "next"){
//alert("A " + that.date);
that.date.setMonth(that.date.getMonth() + 1);
//alert("B " + that.date);
render(that.date);
}
else{
that.date.setMonth(that.date.getMonth() - 1);
render(that.date);
}
}
function showThis(elementToShow, centerOnThis){
if(elementToShow.css("display") != "none")
return;
if(centerOnThis){
elementToShow.css({top:(centerOnThis.offsetTop + parseInt(centerOnThis.scrollHeight/2)) + "px"});
elementToShow.css({left:(centerOnThis.offsetLeft + parseInt(centerOnThis.scrollWidth/2)) + "px"});
}
else{
elementToShow.css({top:parseInt((page.height() - elementToShow.height())/2) + "px"});
elementToShow.css({left:parseInt((page.width() - elementToShow.width())/2) + "px"});
}
$(elementToShow).show();
}
function dateToInt(date){
var month = date.getMonth() + 1;
if(month < 10){
month = "0" + month;
}
else{
month = month.toString();
}
var day = date.getDate();
if(day < 10){
day = "0" + day;
}
else{
day = day.toString();
}
// Adjustment for YAHOO conflict in global.js and IE9 whereby the year comes back as
// number of years since 1900 not current full year
var fullyear = date.getFullYear();
if (fullyear < 2000) { fullyear = fullyear + 1900; }
// Old code where getFullYear not giving full year but rather num years since 1900
//return parseInt(date.getFullYear().toString() + month + day);
return parseInt(fullyear.toString() + month + day);
}
function commonAjaxCallback(data, result){
ajaxActive = false;
if(data == undefined){
return false;
}
if(data.status.PHPSESSID){
gPHPSESSID = "?PHPSESSID=" + data.status.PHPSESSID;
gData = data;
if(data.settings){
etitle_gomore = data.settings.etitle_gomore;
gomore_action = data.settings.gomore_action;
}
}
return true;
}
function navDay(e){
if ('0' == '0') { showThis(jPleaseWaitDIV, dayDIV); }
if($(e.target).attr("cwui") == "nextday"){
that.date.setDate(that.date.getDate() + 1);
}
else{
that.date.setDate(that.date.getDate() - 1)
}
that.getEvents();
}
/* Duplicate function, Commented out
function tsToDate(cw_event, tsPropertyName, timeZoneOffsetPropertyName){
return new Date((parseInt(cw_event[tsPropertyName]) + 3600*parseInt(cw_event[timeZoneOffsetPropertyName])) * 1000)
}
*/
function eventCallback(data, result){
commonAjaxCallback(data, result);
if(data.status.code == 200){
var cw_event = data.eventdetails[0];
// Event date(s)
if (data.settings.military == '1') {
var timeformatstr = "UTC:HHMM";
} else {
var timeformatstr = "UTC:h:MMtt";
}
that.date = new Date(parseInt(cw_event["event_year"]), parseInt(cw_event["event_month"])-1, parseInt(cw_event["event_day"])); // start date obj
if (cw_event["isbanner"]) {
that.end_date = new Date(parseInt(cw_event["end_event_year"]), parseInt(cw_event["end_event_month"])-1, parseInt(cw_event["end_event_day"])); // end date obj
var bandatetimestr = dateFormat(that.date, "ddd, mmm d, yyyy");
if (!cw_event["allday"]) {
bandatetimestr += " " + dateFormat(tsToDate(cw_event, "start_timestamp_gmt", "start_tzoffset"), timeformatstr);
}
bandatetimestr += ' - ' + dateFormat(that.end_date, "ddd, mmm d, yyyy");
if ((!cw_event["noend"]) && (!cw_event["allday"])) {
bandatetimestr += " " + dateFormat(tsToDate(cw_event, "end_timestamp_gmt", "end_tzoffset"), timeformatstr);
} else if (!cw_event["allday"]){
//bandatetimestr += " no end time ";
} else {
bandatetimestr += " All Day ";
}
jDetailDIV.find("[cwfield=detaildate]").text(bandatetimestr);
} else {
jDetailDIV.find("[cwfield=detaildate]").text(dateFormat(that.date, "ddd, mmm d, yyyy"));
}
// Hide or show reminder button
if(cw_event.inpast){
jDetailDIV.find("[cwui=remindlink]").hide();
}else{
jDetailDIV.find("[cwui=remindlink]").show();
}
for(var p in cw_event){
if(p == 'event_id'){
jDetailDIV.find("[cwui=downloadlink]").attr("href", urlPrefix + "/calendars/popcal.php" + gPHPSESSID + "&eid=" + cw_event[p]);
}
//we need to find the label
var jCell = jDetailDIV.find("[cwfield='"+p+"']");
if(jCell.length == 0){
continue;
}
var jLabel = jCell.prev("[cwfield=detaillabel]");
if(jLabel.length == 0){
jLabel = jCell.closest("[cwfield=detaillabel]");
}
// Show or hide depending if value not blank
if(cw_event[p] != "" && cw_event[p] != null){
jLabel.show();
} else {
jLabel.hide();
jCell.html("");
// Need to also hide parent div for some fields that have missing values so don't create line gap
if (p == "contact" || p == "email" || p == "phone" || p == "url" || p == "location_contact" || p == "location_phone") {
jCell.parent().hide();
}
continue;
}
if(p == "description" || p == "privatenote" || p == "location_directions" || p == "location_guidelines") {
if ((p == "description") && (cw_event[p].search("") != -1)) {
var testdescription = cw_event[p].replace(//g, "");
if (testdescription != '') {
// Descripiton from html editor so just display as html
jCell.html(cw_event[p]);
} else {
jCell.html('');
jLabel.hide();
}
} else {
// Not from html editor so change newlines to brs
jCell.html(cw_event[p].replace(/\n/g, " "));
}
}
else if(p == "location_name"){
//should only do this the first time
var location = cw_event[p];
if(location){
jCell.slice(1).html(location);
if(cw_event.location_map_url || cw_event.location_weather_url){
w = screen.availWidth - 100;
h = screen.availHeight - 225;
var features = "width="+w+",height="+h+",left=50,top=50";
features += ",screenX=50,screenY=50";
features += ",scrollbars=1,resizable=1,location=1";
features += ",menubar=1,toolbar=1,status=1";
if(cw_event.location_map_url){
location += " (map)";
}
if(cw_event.location_weather_url){
location += " (weather)";
}
}
jCell.eq(0).html(location);
jCell.find("a").css("color", jDetailBodyDIV.find("a").css("color"));
}else{
jCell.text("");
}
}
else if(p == "url"){
var url = cw_event[p];
if(url){
if(!url.match(/^https?/)){
url = "http://" + url;
}
jCell.html('' + cw_event[p] + '');
jCell.find("a").css("color", jDetailBodyDIV.find("a").css("color"));
}else{
jCell.text("");
}
}
else if(p == "email"){
var email = cw_event[p];
if(email){
if(email.match(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i)){
jCell.html('' + email + '');
jCell.find("a").css("color", jDetailBodyDIV.find("a").css("color"));
}else{
jCell.text(cw_event[p]);
}
}else{
jCell.text("");
}
}else{
if(!cw_event[p]){
jCell.text("");
}
jCell.text(cw_event[p]);
}
}
jDetailBodyDIV.show();
// In case event detail has google maps iframe
$("#cw_srch_detail_dialog iframe").css("max-width", "100%");
jRemindBodyDIV.hide();
jEmailBodyDIV.hide();
if (!cw_event["isbanner"]) {
displayStartEndTime(jDetailDIV, cw_event, data.settings);
$("#div_startendtime").show();
} else {
$("#div_startendtime").hide();
}
jPleaseWaitDIV.hide();
if(!jDetailDIV.dialog('isOpen')){
var offset = jDayDIV.offset();
jDetailDIV.dialog('option', 'position', [offset.left + 100, offset.top - $(window).scrollTop()]);
}
if (!jDetailDIV.dialog("isOpen")) { jDetailDIV.dialog('open'); }
if (window.is_cw_search_button) {
// If this is search from navbar button then need to handle
// z-index settings manually because search form opens in div
// but the search div is not a jquery dialog so jquery does
// not include in 'moveToTop' because that only affects true
// jquery ui dialogs as are the day list and detail dialogs
var daydivZ = parseInt($('div[aria-labelledby="ui-dialog-title-cw_srch_daylist_dialog"]').css("z-index"));
// Note: need to set the z-index in both the jDetailDIV object and the div being displayed
jDetailDIV.dialog( "option", "zIndex", parseInt(daydivZ + 1) );
$('div[aria-labelledby="ui-dialog-title-cw_srch_detail_dialog"]').css({"z-index":parseInt(daydivZ + 1)});
jDetailDIV.dialog('moveToTop');
} else {
jDetailDIV.dialog('moveToTop');
}
} else {
if(data.status.code == 999){
alert(data.status.msg);
return;
}
//debug(data.status.msg);
}
}
$.ajaxSetup({"error":function(XMLHttpRequest,textStatus, errorThrown) {
alert(textStatus + " " + errorThrown);
alert(XMLHttpRequest.responseText);
ajaxActive = false;
}});
function eventsCallback(data, result){
commonAjaxCallback(data, result);
if(data.status.code == 200 || data.status.code == 204){
jDayEventsDIV.empty();
jPleaseWaitDIV.hide();
if(that.isMiniCal){
jDayDateSPAN.text(dateFormat(that.date, "ddd, mmmm d, yyyy"));
}
if(data.status.code == 204){
var jEventDiv = createDayEvent(window.document, true);
jEventDiv.find("[cwfield='title']").text("No events found");
that.numFound = 0;
dayEventsDIV.appendChild(jEventDiv[0]);
// If popup window option then update window
if ('0' == 1) {
applyDayStyles(that.widgetStyles, true);
// Open popup in window when url option popwin is set to 1
if ((typeof listwindowHandle != 'undefined') && (listwindowHandle != null) && (!listwindowHandle.closed)) {
listwindowHandle.focus();
that.loadpopbody_list();
} else {
return false;
w = that.widgetStyles.pop_width;
h = that.widgetStyles.pop_height;
l = (screen.availWidth - w) / 2;
t = (screen.availHeight - h) / 2;
var features = "width="+w+",height="+h+",left="+l+",top="+t;
features += ",screenX="+l+",screenY="+t;
features += ",scrollbars=0,resizable=1,location=0";
features += ",menubar=0,toolbar=0,status=0";
var listurl = urlPrefix + '/common/popwin_list.html?nameofwidget=' + that.nameofwidget + '&crd=' + gCalendar;
listurl += '&etitle_gomore=' + etitle_gomore + '&gomore_action=' + gomore_action + '&pop_height=' + h + '&pop_width=' + w;
listwindowHandle = window.open(listurl, "cwlistwin", features);
}
}
/*
// If popup window option then update window
if ('0' == 1) {
that.loadpopbody_list();
}
*/
}else{
that.numFound = data.eventsummaries.length;
for (i = 0; i < data.eventsummaries.length; i++){
var cw_event = data.eventsummaries[i];
// For show busy events
if ((data.eventsummaries[i].canedit == false) && (data.settings.calshowbusy == 1)) {
// If widget is search, don't show event at all because could infer content via search term
// Note: This logic now in cwapi.php, the api does better job because it considers if
// the search contained a test string and only skips if there was text string. The code
// below rejects all search results even if search did not include text string.
// So the api allows display based on date range and other fields that don't give away
// busy privacy. Also, the api prevents looking at the json response to see info
// THIS CODE CAN BE REMOVED AT SOME TIME - DWM 121219
//if ('MyCwSrch' == 'MyCwSrch') { that.numFound--; continue; }
jEventDiv = createDayEvent(window.document, true);
} else {
jEventDiv = createDayEvent(window.document, false);
}
jEventDiv.attr("cw_id", cw_event.event_id);
jEventDiv.attr("rpt_master_id", cw_event.repeat_id);
if (cw_event.url !== null) { jEventDiv.attr("cw_url", cw_event.url); } else { jEventDiv.attr("cw_url", ""); }
dayEventsDIV.appendChild(jEventDiv[0]);
jEventDiv.find("[cwfield='title']").text(cw_event.title);
// If pop up window option is set
if ('0' == 1) {
if ((data.settings.calshowbusy != 1) || (cw_event.canedit)) {
jEventDiv.attr("onclick", 'epopup(\'' + cw_event.event_id + '\'); return false;');
} else {
jEventDiv.css({cursor:"default"}); // Default cursor for busy events, no popup
}
}
jEventDiv.find("[cwfield='category']").text(cw_event.category_name + " ");
if(cw_event.location_name){
jEventDiv.find("[cwfield='location']").text(" " + that.widgetStyles.location_prefix + " " + cw_event.location_name);
}else{
jEventDiv.find("[cwfield='location']").text("");
}
var formatString;
// Events list date and time
if(cw_event.allday){
if (cw_event.isbanner) {
var banner_beg_date = new Date(parseInt(cw_event.event_year), parseInt(cw_event.event_month)-1, parseInt(cw_event.event_day)); // end date obj
var banner_end_date = new Date(parseInt(cw_event.end_event_year), parseInt(cw_event.end_event_month)-1, parseInt(cw_event.end_event_day)); // end date obj
if (that.nameofwidget != "MyCwSrch") {
if (that.date.getFullYear() == banner_beg_date.getFullYear()) {
var formatStringbeg = "UTC:ddd, mmm d";
} else {
var formatStringbeg = "UTC:ddd, mmm d, yyyy";
}
if (that.date.getFullYear() == banner_end_date.getFullYear()) {
var formatStringend = "UTC:ddd, mmm d";
} else {
var formatStringend = "UTC:ddd, mmm d, yyyy";
}
} else {
// Search has no overall list date so need to show years
var formatStringbeg = "UTC:ddd, mmm d, yyyy";
var formatStringend = "UTC:ddd, mmm d, yyyy";
}
var bandatetext = dateFormat(tsToDate(cw_event, "start_timestamp_gmt", "start_tzoffset"), formatStringbeg);
bandatetext += " - " + dateFormat(tsToDate(cw_event, "end_timestamp_gmt", "end_tzoffset"), formatStringend);
jEventDiv.find("[cwfield='start']").text(bandatetext);
jEventDiv.find("[cwfield='end']").text(" - All Day");
} else {
formatString = "UTC:ddd, mmm d, yyyy";
jEventDiv.find("[cwfield='start']").text(dateFormat(tsToDate(cw_event, "start_timestamp_gmt", "start_tzoffset"), formatString));
jEventDiv.find("[cwfield='end']").text(" - All Day");
}
}else{
if (cw_event.isbanner) {
if(data.settings.military == '1'){
var formatStringtime = "UTC:HHMM";
}else{
var formatStringtime = "UTC:h:MMtt";
}
var banstarttext = ""; // will hold banner start and end dates
var banendtext = ""; // will hold banner start and end times
var banner_beg_date = new Date(parseInt(cw_event.event_year), parseInt(cw_event.event_month)-1, parseInt(cw_event.event_day)); // end date obj
var banner_end_date = new Date(parseInt(cw_event.end_event_year), parseInt(cw_event.end_event_month)-1, parseInt(cw_event.end_event_day)); // end date obj
if (that.nameofwidget != "MyCwSrch") {
if (that.date.getFullYear() == banner_beg_date.getFullYear()) {
var formatStringbeg = "UTC:ddd, mmm d";
} else {
var formatStringbeg = "UTC:ddd, mmm d, yyyy";
}
if (that.date.getFullYear() == banner_end_date.getFullYear()) {
var formatStringend = "UTC:ddd, mmm d";
} else {
var formatStringend = "UTC:ddd, mmm d, yyyy";
}
} else {
// Search has no overall list date so need to show years
var formatStringbeg = "UTC:ddd, mmm d, yyyy";
var formatStringend = "UTC:ddd, mmm d, yyyy";
}
var banstarttext = dateFormat(tsToDate(cw_event, "start_timestamp_gmt", "start_tzoffset"), formatStringbeg);
banstarttext += " at " + dateFormat(tsToDate(cw_event, "start_timestamp_gmt", "start_tzoffset"), formatStringtime);
var banendtext = " - " + dateFormat(tsToDate(cw_event, "end_timestamp_gmt", "end_tzoffset"), formatStringend);
if(!cw_event.noend){
banendtext += " at " + dateFormat(tsToDate(cw_event, "end_timestamp_gmt", "end_tzoffset"), formatStringtime);
} else {
//banendtext += " no end time "
}
jEventDiv.find("[cwfield='start']").text(banstarttext+banendtext);
} else {
if(data.settings.military == '1'){
formatString = "UTC:ddd, mmm d, yyyy HHMM";
if(that.isMiniCal){
formatString = "UTC:HHMM";
}
var endText = "";
if(!cw_event.noend){
endText = " - " + dateFormat(tsToDate(cw_event, "end_timestamp_gmt", "end_tzoffset"), "UTC:HHMM");
}
jEventDiv.find("[cwfield='start']").text(dateFormat(tsToDate(cw_event, "start_timestamp_gmt", "start_tzoffset"), formatString));
jEventDiv.find("[cwfield='end']").text(endText);
}else{
formatString = "UTC:ddd, mmm d, yyyy h:MM TT";
if(that.isMiniCal){
formatString = "UTC:h:MM TT";
}
endText = "";
if(!cw_event.noend){
endText = " - " + dateFormat(tsToDate(cw_event, "end_timestamp_gmt", "end_tzoffset"), "UTC:h:MM TT");
}
jEventDiv.find("[cwfield='start']").text(dateFormat(tsToDate(cw_event, "start_timestamp_gmt", "start_tzoffset"), formatString));
jEventDiv.find("[cwfield='end']").text(endText);
}
}
}
}
}
applyDayStyles(that.widgetStyles, true);
if ('0' == 1) {
// Open popup in window when url option popwin is set to 1
if ((typeof listwindowHandle != 'undefined') && (listwindowHandle != null) && (!listwindowHandle.closed)) {
listwindowHandle.focus();
that.loadpopbody_list();
}
} else {
// Using in-page div for popups
if (!jDayDIV.dialog("isOpen")) { jDayDIV.dialog('open'); }
if (window.is_cw_search_button) {
// If this is search from navbar button then need to handle
// z-index settings programatically because search form opens in div
// but the search div is not a jquery dialog so jquery does
// not include in 'moveToTop' because that only affects true
// jquery ui dialogs as are the day list and detail dialogs
var srchZ = parseInt($("#searchdiv").css("z-index")); // Get z-index of search div
// Note: need to set the z-index in both the jDayDIV object and the div
jDayDIV.dialog( 'option', 'zIndex', parseInt(srchZ + 1));
$('div[aria-labelledby="ui-dialog-title-cw_srch_daylist_dialog"]').css({"z-index":parseInt(srchZ + 1)});
jDayDIV.dialog('moveToTop');
} else {
jDayDIV.dialog('moveToTop');
}
}
} else {
if(data.status.code == 999){
alert(data.status.msg);
return;
} else {
alert(data.status.msg + "\n" + data.status.code);
render(that.date);
jPleaseWaitDIV.hide();
$(that.widget).show();
}
}
if(!that.isMiniCal){
var foundtitle = "Found " + that.numFound + " Events";
jDayDIV.dialog('option', 'title', foundtitle);
}
//alert(jDayDIV.find(".ui-dialog-titlebar").html())
//jDayDIV.find(".ui-dialog-titlebar").css('cursor','grab');
//$(".ui-dialog-titlebar").css('cursor','grab');
}
// Following function is for when url parameter popwin set to 1 so uses windows for popups
// This is called by body onload in popwin_list.html to load the event list contents
this.loadpopbody_list = function () {
var jBody = $(listwindowHandle.document.body);
jBody.html(jDayDIV.html());
jBody.find("[cwui='nextday']").bind('click', function(event) {
navDay(event);
that.loadpopbody_list();
});
jBody.find("[cwui='prevday']").bind('click', function(event) {
navDay(event);
that.loadpopbody_list();
});
}
function getEvent(calendar, id, callback){
// Note: this does NOT get called when popup window option is set
ajaxActive = true;
$.getJSON(urlPrefix + "/cwapi.php" + gPHPSESSID + that.themeNV + "&callback=?&eid[]=" + id, {fmt:"json", view:"d", crd:calendar}, callback);
}
function getReminder(e){
ajaxActive = true;
var jDetailDIV = $(e.target).closest("[cwui='detaildiv']");
g_cw_id = jDetailDIV.find("[cwfield='event_id']").text();
g_rpt_master_id = jDetailDIV.find("[cwfield='repeat_id']").text();
$.getJSON(urlPrefix + "/cwapi.php" + gPHPSESSID + "&callback=?", {event_id:g_cw_id, repeat_id:g_rpt_master_id, fmt:"json", view:"getremind", crd:gCalendar}, reminderCallback);
return false;
}
function setReminder(e){
ajaxActive = true;
var jDetailDIV = $(e.target).closest("[cwui='detaildiv']");
g_cw_id = jDetailDIV.find("[cwfield='event_id']").text();
g_rpt_master_id = jDetailDIV.find("[cwfield='repeat_id']").text();
var priortime = jRemindBodyDIV.find("[cwui=priortime]").val();
var email = jRemindBodyDIV.find("[cwui=email]").val();
if(!jRemindBodyDIV.reminder_id){
jRemindBodyDIV.reminder_id = 0;
}
if(email.match(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i)){
if (g_rpt_master_id > 0) { g_repeat_mode = 'all'; } else { g_repeat_mode = 'single'; }
$.getJSON(urlPrefix + "/cwapi.php" + gPHPSESSID + "&callback=?", {reminder_id:jRemindBodyDIV.reminder_id, email:email, priortime:priortime, repeat_mode:g_repeat_mode, event_id:g_cw_id, repeat_id:g_rpt_master_id, fmt:"json", view:"setremind", crd:gCalendar}, reminderCallback);
} else {
jMsg.text("Please enter a valid email address");
jMsgDiv.removeClass("ui-state-highlight").addClass("ui-state-error");
jMsgDiv.find(".ui-icon").removeClass("ui-icon-info").addClass("ui-icon-alert");
jMsgDiv.show("slow");
}
}
function deleteReminder(e){
ajaxActive = true;
var jDetailDIV = $(e.target).closest("[cwui='detaildiv']");
g_cw_id = jDetailDIV.find("[cwfield='event_id']").text();
g_rpt_master_id = jDetailDIV.find("[cwfield='repeat_id']").text();
if (g_rpt_master_id > 0) { g_repeat_mode = 'all'; } else { g_repeat_mode = 'single'; }
$.getJSON(urlPrefix + "/cwapi.php" + gPHPSESSID + "&callback=?", {reminder_id:jRemindBodyDIV.reminder_id, repeat_mode:g_repeat_mode, event_id:g_cw_id, repeat_id:g_rpt_master_id, fmt:"json", view:"delremind", crd:gCalendar}, reminderCallback);
}
function reminderCallback(data, result){
commonAjaxCallback(data, result);
if(data.status.code == 200 || data.status.code == 201){
if(data.status.view == "getremind"){
//here we need to display the reminder form and hide the event display
jDetailBodyDIV.hide();
jRemindBodyDIV.show();
jRemindBodyDIV.find("[cwui=priortime]").val(data.remindersettings.priortime);
jRemindBodyDIV.find("[cwui=email]").val(data.remindersettings.email);
jRemindBodyDIV.reminder_id = data.remindersettings.reminder_id;
if(data.remindersettings.reminder_id){
jRemindBodyDIV.find("[cwui=delete]").show();
jRemindBodyDIV.find("[cwui=setremind]").val("Update Reminder");
}else{
jRemindBodyDIV.find("[cwui=setremind]").val("Set Reminder");
jRemindBodyDIV.find("[cwui=delete]").hide();
}
}else{
//here we show the error status msg
jMsg.text(data.status.msg);
jMsgDiv.removeClass("ui-state-error").addClass("ui-state-highlight");
jMsgDiv.find(".ui-icon").removeClass("ui-icon-alert").addClass("ui-icon-info");
jMsgDiv.show("slow");
}
var minHeight = jDetailDIV.find("[cwfield='title']").outerHeight(true) + jRemindBodyDIV.outerHeight(true) + jRemindBodyDIV.scrollTop() + jDetailDIV.parent().find(".ui-dialog-titlebar").outerHeight(true) + 10;
if(jDetailDIV.dialog('option', 'height') < minHeight){
jDetailDIV.dialog('option', 'height', minHeight);
jDetailDIV.height(jDetailDIV.find("[cwfield='title']").outerHeight(true) + jRemindBodyDIV.outerHeight(true) + jRemindBodyDIV.scrollTop());
}
} else {
if(data.status.code == 999){
alert(data.status.msg);
return;
}
//debug(data.status.msg);
}
}
var jEmailBodyDIV;
function openNewEmail(e){
var jDetailDIV = $(e.target).closest("[cwui='detaildiv']");
jDetailBodyDIV.hide();
jEmailBodyDIV.show();
jEmailBodyDIV.find("[cwui=emailto]").val(gData.status.email);
// Custom code
if (gCalendar != 'ohiouniversitylancaster') {
jEmailBodyDIV.find("[cwui=emailfrom]").val(gData.status.email);
}
jEmailBodyDIV.find("[cwui=subject]").val("Calendar Note: " + jDetailDIV.find("[cwfield='title']").text());
jEmailBodyDIV.find("[cwui=intronote]").val("Dear,\n\nI thought you might be interested in this event.\n\nThank you").trigger('keyup');
var minHeight = jDetailDIV.find("[cwfield='title']").outerHeight(true) + jEmailBodyDIV.outerHeight(true) + jEmailBodyDIV.scrollTop() + jDetailDIV.parent().find(".ui-dialog-titlebar").outerHeight(true) + 10;
if(jDetailDIV.dialog('option', 'height') < minHeight){
jDetailDIV.dialog('option', 'height', minHeight);
jDetailDIV.height(jDetailDIV.find("[cwfield='title']").outerHeight(true) + jEmailBodyDIV.outerHeight(true) + jEmailBodyDIV.scrollTop());
}
return false;
}
function sendEmail(e){
ajaxActive = true;
var jDetailDIV = $(e.target).closest("[cwui='detaildiv']");
g_cw_id = jDetailDIV.find("[cwfield='event_id']").text();
g_rpt_master_id = jDetailDIV.find("[cwfield='repeat_id']").text();
var emailto = jEmailBodyDIV.find("[cwui=emailto]").val();
var emailfrom = jEmailBodyDIV.find("[cwui=emailfrom]").val();
if(!emailto.match(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i)){
jEmailBodyDIV.find("[cwui=emailto]").focus();
jMsg.text("Please enter a valid to email address");
jMsgDiv.removeClass("ui-state-highlight").addClass("ui-state-error");
jMsgDiv.find(".ui-icon").removeClass("ui-icon-info").addClass("ui-icon-alert");
jMsgDiv.show("slow");
jDetailDIV.scrollTop(0);
return;
}
if(!emailfrom.match(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i)){
jEmailBodyDIV.find("[cwui=emailfrom]").focus();
jMsg.text("Please enter a valid from email address");
jMsgDiv.removeClass("ui-state-highlight").addClass("ui-state-error");
jMsgDiv.find(".ui-icon").removeClass("ui-icon-info").addClass("ui-icon-alert");
jMsgDiv.show("slow");
jDetailDIV.scrollTop(0);
return;
}
var subject = jEmailBodyDIV.find("[cwui=subject]").val();
var note = jEmailBodyDIV.find("[cwui=intronote]").val();
if(subject == ""){
jEmailBodyDIV.find("[cwui=subject]").focus();
jMsg.text("Please enter a subject");
jMsgDiv.removeClass("ui-state-highlight").addClass("ui-state-error");
jMsgDiv.find(".ui-icon").removeClass("ui-icon-info").addClass("ui-icon-alert");
jMsgDiv.show("slow");
jDetailDIV.scrollTop(0);
return;
}
if(note.length > introNoteMaxLength){
jEmailBodyDIV.find("[cwui=intronote]").focus();
jMsg.text("Please shorten your introduction to " + introNoteMaxLength + " characters.");
jMsgDiv.removeClass("ui-state-highlight").addClass("ui-state-error");
jMsgDiv.find(".ui-icon").removeClass("ui-icon-info").addClass("ui-icon-alert");
jMsgDiv.show("slow");
jDetailDIV.scrollTop(0);
return;
}
$.getJSON(urlPrefix + "/cwapi.php" + gPHPSESSID + "&callback=?", {subject:subject, intronote:note, fromemail:emailfrom, toemail:emailto, event_id:g_cw_id, repeat_id:g_rpt_master_id, fmt:"json", view:"sendevent", crd:gCalendar}, emailCallback);
}
function emailCallback(data, result){
commonAjaxCallback(data, result);
if(data.status.code == "200"){
//here we show the status msg
jMsg.text(data.status.msg);
jMsgDiv.removeClass("ui-state-error").addClass("ui-state-highlight");
jMsgDiv.find(".ui-icon").removeClass("ui-icon-alert").addClass("ui-icon-info");
jMsgDiv.show("slow");
}else{
if(data.status.code == 999){
alert(data.status.msg);
return;
}
jMsg.text(data.status.msg);
jMsgDiv.removeClass("ui-state-highlight").addClass("ui-state-error");
jMsgDiv.find(".ui-icon").removeClass("ui-icon-info").addClass("ui-icon-alert");
jMsgDiv.show("slow");
}
jDetailDIV.scrollTop(0);
}
function selectedDate(e){
that.date = $(e.target).closest("td").data("date");
if ('0' == '0') { showThis(jPleaseWaitDIV, that.widget); }
that.getEvents();
}
function displayEvent(e){
if(etitle_gomore == '1') {
g_cw_url = $(e.target).closest("[cw_url]").attr("cw_url");
if (g_cw_url != '') {
goMoreURL(g_cw_url);
return;
}
}
gCameFromDetail = true;
if(typeof(e) == "string"){
g_cw_id = e;
}
else{
g_cw_id = $(e.target).closest("[cw_id]").attr("cw_id");
g_rpt_master_id = $(e.target).closest("[rpt_master_id]").attr("rpt_master_id");
}
if ('0' == '0') { showThis(jPleaseWaitDIV, that.widget); }
getEvent(gCalendar, g_cw_id, eventCallback);
}
function goMoreURL(g_cw_url) {
if ((g_cw_url.substring(0, 7) != "http://") && (g_cw_url.substring(0, 8) != "https://")) {
g_cw_url = 'http://' + g_cw_url;
}
if (gomore_action == '_top') {
top.location.href = g_cw_url;
}
if (gomore_action == '_self') {
self.location.href = g_cw_url;
}
if (gomore_action == '_parent') {
parent.location.href = g_cw_url;
}
if ((gomore_action == '') || (gomore_action == '_blank')) {
var cname = 'custom_win';
w = screen.availWidth - 13;
h = screen.availHeight - 143;
l = 0;
t = 0;
features = "width="+w+",height="+h+",left="+l+",top="+t;
features += ",screenX="+l+",screenY="+t;
features += ",scrollbars=1,resizable=1,location=1";
features += ",menubar=1,toolbar=1,status=1";
window.open(g_cw_url,cname, features);
}
}
function debug(txt){
$("#debug").text($("#debug").text() + " " + txt);
}
function goToToday(){
if ('0' == '0') { showThis(jPleaseWaitDIV, that.widget); }
var tday = new Date();
render(tday, false);
return false;
}
function clearCache(){
monthEvents = undefined;
}
//#################################### Format Functions ##############################
function displayStartEndTime(jDiv, cw_event, settings){
if(cw_event.allday){
jDiv.find("[cwfield=startendtime]").text("All Day");
}
else{
if(settings.military == '1'){
var endText = "";
if(!cw_event.noend){
endText = " - " + dateFormat(tsToDate(cw_event, "end_timestamp_gmt", "end_tzoffset"), "UTC:HHMM");
}
var startText = dateFormat(tsToDate(cw_event, "start_timestamp_gmt", "start_tzoffset"), "UTC:HHMM");
jDiv.find("[cwfield=startendtime]").text(startText + " " + endText);
}
else{
endText = "";
if(!cw_event.noend){
endText = " - " + dateFormat(tsToDate(cw_event, "end_timestamp_gmt", "end_tzoffset"), "UTC:h:MM TT");
}
startText = dateFormat(tsToDate(cw_event, "start_timestamp_gmt", "start_tzoffset"), "UTC:h:MM TT");
jDiv.find("[cwfield=startendtime]").text(startText + " " + endText);
}
}
}
function tsToDate(cw_event, tsPropertyName, timeZoneOffsetPropertyName){
//return new Date((parseInt(cw_event[tsPropertyName]) + 3600*parseInt(cw_event[timeZoneOffsetPropertyName])) * 1000)
return new Date((parseInt(cw_event[tsPropertyName]) + 3600*parseFloat(cw_event[timeZoneOffsetPropertyName])) * 1000)
}
/*
* Date Format 1.2.3
* (c) 2007-2009 Steven Levithan
* MIT license
*
* Includes enhancements by Scott Trenda
* and Kris Kowal
*
* Accepts a date, a mask, or a date and a mask.
* Returns a formatted version of the given date.
* The date defaults to the current date/time.
* The mask defaults to dateFormat.masks.default.
*/
var dateFormat = function () {
var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
timezoneClip = /[^-+\dA-Z]/g;
function pad(val, len) {
val = String(val);
len = len || 2;
while (val.length < len) val = "0" + val;
return val;
};
// Regexes and supporting functions are cached through closure
return function (date, mask, utc) {
var dF = dateFormat;
// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
mask = date;
date = undefined;
}
// Passing date through Date applies Date.parse, if necessary
date = date ? new Date(date) : new Date;
if (isNaN(date)) throw SyntaxError("invalid date");
mask = String(dF.masks[mask] || mask || dF.masks["default"]);
// Allow setting the utc argument via the mask
if (mask.slice(0, 4) == "UTC:") {
mask = mask.slice(4);
utc = true;
}
// Adjustment for YAHOO conflict in global.js and IE9 whereby the year comes back as
// number of years since 1900 not current full year
if (date.getFullYear() < 2000) { yearadjust = 1900; } else { yearadjust = 0; }
var _ = utc ? "getUTC" : "get",
d = date[_ + "Date"](),
D = date[_ + "Day"](),
m = date[_ + "Month"](),
y = date[_ + "FullYear"]() + yearadjust,
H = date[_ + "Hours"](),
M = date[_ + "Minutes"](),
s = date[_ + "Seconds"](),
L = date[_ + "Milliseconds"](),
o = utc ? 0 : date.getTimezoneOffset(),
flags = {
d: d,
dd: pad(d),
ddd: dF.i18n.dayNames[D],
dddd: dF.i18n.dayNames[D + 7],
m: m + 1,
mm: pad(m + 1),
mmm: dF.i18n.monthNames[m],
mmmm: dF.i18n.monthNames[m + 12],
yy: String(y).slice(2),
yyyy: y,
h: H % 12 || 12,
hh: pad(H % 12 || 12),
H: H,
HH: pad(H),
M: M,
MM: pad(M),
s: s,
ss: pad(s),
l: pad(L, 3),
L: pad(L > 99 ? Math.round(L / 10) : L),
t: H < 12 ? "a" : "p",
tt: H < 12 ? "am" : "pm",
T: H < 12 ? "A" : "P",
TT: H < 12 ? "AM" : "PM",
Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
};
return mask.replace(token, function ($0) {
return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
});
};
}();
// Some common format strings
dateFormat.masks = {
"default": "ddd mmm dd yyyy HH:MM:ss",
shortDate: "m/d/yy",
mediumDate: "mmm d, yyyy",
longDate: "mmmm d, yyyy",
fullDate: "dddd, mmmm d, yyyy",
shortTime: "h:MM TT",
mediumTime: "h:MM:ss TT",
longTime: "h:MM:ss TT Z",
isoDate: "yyyy-mm-dd",
isoTime: "HH:MM:ss",
isoDateTime: "yyyy-mm-dd'T'HH:MM:ss",
isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};
// Internationalization strings
dateFormat.i18n = {
dayNames: [
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
],
monthNames: [
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
]
};
dateFormat.daysInMonth = [0,31,28,31,30,31,30,31,31,30,31,30,31];
var page = {
width: function() {
return self.innerWidth || (document.documentElement.clientWidth || document.body.clientWidth);
},
height: function() {
return self.innerHeight || (document.documentElement.clientHeight || document.body.clientHeight);
}
};
var jWidget;
var pleaseWaitDIV;
var pleaseWaitGIF;
var jPleaseWaitDIV;
var jTodayLink;
var jMonthHeaderTD;
var jMonthHeaderTR;
var dayDIV;
var jDayDIV;
var dayNavDIV;
var daydatenavDIV;
var prevDayIMG;
var nextDayIMG;
var dayDateSPAN;
var jDayDateSPAN;
var jDayNavDIV;
var dayEventsDIV;
var jDayEventsDIV;
var detailDIV;
var jDetailDIV;
function parseQueryString(queryString){
var queryNameValuePairs = queryString.split("&");
var NameValues = new Object();
for (var i = 0; i < queryNameValuePairs.length; i++){
var queryNameValuePair = queryNameValuePairs[i].split("=");
NameValues[unescape(queryNameValuePair[0])] = unescape(queryNameValuePair[1]);
}
return NameValues;
}
this.getEvents = function() {
var sObj = document.getElementById('searchformid');
// Check date range valid
var beginDate = new Date(parseInt(sObj.by.value), parseInt(sObj.bm.value) - 1, parseInt(sObj.bd.value));
var endDate = new Date(parseInt(sObj.ey.value), parseInt(sObj.em.value) - 1, parseInt(sObj.ed.value));
if(beginDate > endDate){
alert("Please make your search start date on or before your search end date.");
return false;
}
// Disable search button and show spinner in button
$("#btnsearch").attr("disabled", true)
.removeClass("btn-save")
.html(" Searching...")
.css("font-size","12px");
// Show ajax spinner
if ('0' == '0') {
showThis(jPleaseWaitDIV, that.widget);
}
gCameFromDetail = false;
ajaxActive = true;
gCameFromMonth = false;
// Create non-date search arguments
var srchArg = createSrchArgs(sObj);
if(srchArg == undefined){
return false;
}
// Create date search arguments
var bm = sObj.bm.value;
var bd = sObj.bd.value;
var by = sObj.by.value;
var em = sObj.em.value;
var ed = sObj.ed.value;
var ey = sObj.ey.value;
var ajaxyrsspan = ey - by + 1;
var ajaxyrsdone = 0;
// Loop thru and do api call for each year to break up query
// to lessen impact of many year search on dense calendars
for(slyear=by;slyear<=ey;slyear++) {
// Date filter
var ysrchArg = srchArg;
if (ajaxyrsspan == 1) {
//console.log('ajaxyrsspan == zero');
ysrchArg += '&bm=' + bm + '&bd=' + bd + '&by=' + by;
ysrchArg += '&em=' + em + '&ed=' + ed + '&ey=' + ey;
} else if (slyear == by) {
//console.log('slyear == bm');
ysrchArg += '&bm=' + bm + '&bd=' + bd + '&by=' + by;
ysrchArg += '&em=' + '12' + '&ed=' + '31' + '&ey=' + by;
} else if (slyear < ey) {
//console.log('slyear < ey');
ysrchArg += '&bm=' + '1' + '&bd=' + '1' + '&by=' + slyear;
ysrchArg += '&em=' + '12' + '&ed=' + '31' + '&ey=' + slyear;
} else {
//console.log('slyear == ey');
ysrchArg += '&bm=' + '1' + '&bd=' + '1' + '&by=' + ey;
ysrchArg += '&em=' + em + '&ed=' + ed + '&ey=' + ey;
}
var searchResponse = {};
if ('0' == 1) { // For url option to use windows for popups
// Note: Need to use ajax with async false because window.open is blocked within ajax call
// so need to execute ajax and do window.open outside ajax
// Also need to do ajax async false because looping thru years to break up query
// Build ajax URL - has callback so will use jsonp for cross domain support for standalone plugins hosted on customer page
var strURL = urlPrefix + "/cwapi.php" + gPHPSESSID + ysrchArg + that.themeNV + "&fmt=json&view=s" + "&crd=" + gCalendar + "&callback=?";
// Ajax call, async false,
$.getJSON(strURL, function(data){
// Get status for first year in loop, will not change on subsequent calls in years loop
if (typeof searchResponse.status == 'undefined') {
searchResponse.status = data.status;
}
if ((data.status.code == 200) || (data.status.code == 204)) { // Either found events or fount no events
success = true;
// If found events then accumulate eventsummaries
if (data.status.code == 200) {
if (typeof searchResponse.eventsummaries == 'undefined') {
searchResponse.eventsummaries = data.eventsummaries; // First events found so create summaries sub object
searchResponse.settings = data.settings; // Will only be in data if found event(s). Will be same for all ajax calls
} else {
searchResponse.eventsummaries = searchResponse.eventsummaries.concat(data.eventsummaries); // Adds to event summaries
}
}
} else {
// Something wrong
success = false;
if(data.status.code == 999){
alert(data.status.msg);
return;
}
}
ajaxyrsdone++; // Increment search years completed
// If all years done then wrap up and call eventsCallback to display results
if (ajaxyrsspan == ajaxyrsdone) {
// Reset search button to not disabled
$("#btnsearch").attr("disabled", false).addClass("btn-save").html("Submit Search");
// If any events were found need to make sure status code is 200 since original set may be 204
if (typeof searchResponse.eventsummaries == 'undefined') {
searchResponse.status.code = 204;
} else {
searchResponse.status.code = 200;
// Need to sort event summaries because different years may be returned from ajax calls not in order
searchResponse.eventsummaries = sortByKeyAsc(searchResponse.eventsummaries, "start_timestamp_gmt");
}
// Call function to display events or not found message
eventsCallback(searchResponse);
}
return false;
});
w = that.widgetStyles.pop_width;
h = that.widgetStyles.pop_height;
l = (screen.availWidth - w) / 2;
t = (screen.availHeight - h) / 2;
var features = "width="+w+",height="+h+",left="+l+",top="+t;
features += ",screenX="+l+",screenY="+t;
features += ",scrollbars=0,resizable=1,location=0";
features += ",menubar=0,toolbar=0,status=0";
// Need to set some value for these two vars since no events found does
// not return status object from api
if (typeof etitle_gomore == 'undefined') { etitle_gomore = 0; }
if (typeof gomore_action == 'undefined') { gomore_action = '_blank'; }
var listurl = urlPrefix + '/common/popwin_list.html?nameofwidget=' + that.nameofwidget + '&crd=' + gCalendar;
listurl += '&etitle_gomore=' + etitle_gomore + '&gomore_action=' + gomore_action + '&pop_height=' + h + '&pop_width=' + w;
listwindowHandle = window.open(listurl, "cwlistwin", features);
} else { // For normal search operation to show events in /common/popup.js (either search button on calendar or standalong seadrch plugin)
// Build ajax URL - has callback so will use jsonp for cross domain support for standalone plugins hosted on customer page
var strURL = urlPrefix + "/cwapi.php" + gPHPSESSID + ysrchArg + that.themeNV + "&fmt=json&view=s" + "&crd=" + gCalendar + "&callback=?";
// Ajax call, async false,
$.getJSON(strURL, function(data){
// Get status for first year in loop, will not change on subsequent calls in years loop
if (typeof searchResponse.status == 'undefined') {
searchResponse.status = data.status;
}
if ((data.status.code == 200) || (data.status.code == 204)) { // Either found events or fount no events
success = true;
// If found events then accumulate eventsummaries
if (data.status.code == 200) {
if (typeof searchResponse.eventsummaries == 'undefined') {
searchResponse.eventsummaries = data.eventsummaries; // First events found so create summaries sub object
searchResponse.settings = data.settings; // Will only be in data if found event(s). Will be same for all ajax calls
} else {
searchResponse.eventsummaries = searchResponse.eventsummaries.concat(data.eventsummaries); // Adds to event summaries
}
}
} else {
// Something wrong
success = false;
if(data.status.code == 999){
alert(data.status.msg);
return;
}
}
ajaxyrsdone++; // Increment search years completed
// If all years done then wrap up and call eventsCallback to display results
if (ajaxyrsspan == ajaxyrsdone) {
// Reset search button to not disabled
$("#btnsearch").attr("disabled", false).addClass("btn-save").html("Submit Search");
// If any events were found need to make sure status code is 200 since original set may be 204
if (typeof searchResponse.eventsummaries == 'undefined') {
searchResponse.status.code = 204;
} else {
searchResponse.status.code = 200;
// Need to sort event summaries because different years may be returned from ajax calls not in order
searchResponse.eventsummaries = sortByKeyAsc(searchResponse.eventsummaries, "start_timestamp_gmt");
}
// Call function to display events or not found message
eventsCallback(searchResponse);
}
return false;
});
}
}
return false; // Done search
}
// Search functions for eventsummaris array back from search
// events in cronological order (years may be returned not in order)
function sortByKeyDesc(array, key) {
return array.sort(function (a, b) {
var x = a[key]; var y = b[key];
return ((x > y) ? -1 : ((x < y) ? 1 : 0));
});
}
function sortByKeyAsc(array, key) {
return array.sort(function (a, b) {
var x = a[key]; var y = b[key];
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
});
}
function render(){
//stub that does nothing in cwsearch
}
function createSrchArgs(sObj) {
//console.log(sObj);
var srchArg = '';
// Text string filter
if (sObj.str.value != '') {
srchArg += '&str=' + encodeURIComponent(sObj.str.value);
}
// Categories filter
var cObj = sObj.categories;
var catlist = '';
for(var i = 0; i < cObj.length; i++) {
if (cObj.options[i].value == 'all') {
// Do not submit all option, only used to select all in form list
// Otherwise the cwapi will return across all categories not just
// those showing in search theme form
continue;
}
if(cObj.options[i].selected == true) {
catlist += '&cid[]=' + cObj.options[i].value;
}
}
srchArg += catlist;
// Locations filter
var lObj = sObj.locations;
//console.log(lObj);
var loclist = '';
for(var i = 0; i < lObj.length; i++) {
if(lObj.options[i].selected == true) {
loclist += '&lid[]=' + lObj.options[i].value;
if (lObj.options[i].value == 'all') {
// If location option all is set then only need
// to submit that all option and not the rest of
// the lid values since cwapi.php will pick up on
// that option and search all locations in calendar
// Note: this is different handling than categories
break;
}
}
}
srchArg += loclist;
// Zip Code Proximity
if (sObj.pzip.value != '') {
srchArg += '&pzip=' + sObj.pzip.value + '&pmiles=' + sObj.pmiles.value;
}
// Location values filter
if (sObj.elements['lon[]'].value != '') { srchArg += '&lon[]=' + sObj.elements['lon[]'].value; }
if (sObj.elements['loa[]'].value != '') { srchArg += '&loa[]=' + sObj.elements['loa[]'].value; }
if (sObj.elements['loc[]'].value != '') { srchArg += '&loc[]=' + sObj.elements['loc[]'].value; }
if (sObj.elements['los[]'].value != '') { srchArg += '&los[]=' + sObj.elements['los[]'].value; }
if (sObj.elements['loz[]'].value != '') { srchArg += '&loz[]=' + sObj.elements['loz[]'].value; }
return srchArg ;
}
var NameValues;
function init() {
that.numFound = 0;
var scripts = document.getElementsByTagName("script");
for(var s = 0; s < scripts.length; s++) {
var src = $(scripts[s]).attr("src");
if(src && src.match(/cwsearch\/cwsearch\.js\?(.*)$/)) {
NameValues = parseQueryString(RegExp.$1)
}
}
$(that.widget).find("#btnsearch").click(that.getEvents);
if(NameValues["crd"]) {
gCalendar = NameValues["crd"];
}
if(NameValues["srtheme"]) {
that.themeNV = "&srtheme=" + escape(NameValues["srtheme"]);
} else {
that.themeNV = "&srtheme=master";
}
that.date = null;
that.selectedDate = selectedDate;
that.clearCache = clearCache;
that.days = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
that.ENABLED = 1;
that.DISABLED = 0;
that.FETCHING = -1;
jWidget = $(that.widget);
pleaseWaitDIV = document.createElement("div");
pleaseWaitGIF = document.createElement("img");
pleaseWaitGIF.setAttribute("src", urlPrefix + "/common/images/pleasewait.gif");
pleaseWaitDIV.appendChild(pleaseWaitGIF);
pleaseWaitDIV.style.position = "absolute";
pleaseWaitDIV.style.zIndex = 100;
that.widget.parentNode.appendChild(pleaseWaitDIV);
jPleaseWaitDIV = $(pleaseWaitDIV);
createDayListing();
detailDIV = createEventDetail(window.document);
jDetailDIV = $(detailDIV);
// Configure dialog, conditional bgiframe for IE6
var dialogConfig = {autoOpen: false};
if(navigator.userAgent.match(/MSIE 6/)) { dialogConfig.bgiframe = true; }
jDetailDIV.dialog(dialogConfig);
detaildialogtitle = "Event Details";
jDetailDIV.dialog('option', 'title', detaildialogtitle);
getWidgetStyles(gCalendar);
setNumDays('b');
setNumDays('e');
}
$(document).ready(function(){
$('head').append('');$('head').append('');$('head').append('');
// Set global ajax error handler. This catches all ajax errors.
// If just return false then this causes blind failure. If alerts
// are uncommented then the error info is displayed in an alert so
// only do that if testing otherwise widgets throw alerts on customer
// web pages which is not good. Future may have call to send message
// to CalendarWiz Staff. Could also move this to common script?
// Currently in minical.js and cwsearch.js
$.ajaxSetup({"error":function(XMLHttpRequest,textStatus, errorThrown) {
jPleaseWaitDIV.hide();
// Return false for production so customer web page does not thro alert
return false;
}});
init();
// This line is to fix issue in Firefox and Safari whereby the append of jquery.ui.css to head
// cause the dialog position to become relative and when opened, moved, reopened it scrolled to top
jDayDIV.parent().css({'position' : 'absolute'});
jDetailDIV.parent().css({'position' : 'absolute'});
});
}; //end of the cwWidget object
// -------------------------------------------------------------------
// Search Widget JavaScript
// -------------------------------------------------------------------
// Function to set correct number of days for selected month and year
function setNumDays(prefix){
//we need to make the eday dropdown have the right number of days in it.
//also have to change the selected day if it is greater than the number of days in the month
if(typeof(prefix) != "string")
{
prefix = $(prefix.target).attr("setnumdaysprefix");
}
var feb = 28;
if((parseInt($("[cwui='" + prefix + "yid']").val()) % 4) == 0){
feb = 29;
}
var days = dateFormat.daysInMonth[parseInt($("[cwui='" + prefix + "mid']").val())];
if(days == 28){
days = feb;
}
var dayDD = $("[cwui='" + prefix + "did']")[0];
var len = dayDD.options.length;
if(len == days)return;
if(len < days){
for(var i = len; i < days; i++){
dayDD[i] = new Option(i + 1, i + 1);
}
}
else{
var selectedIndex = dayDD.selectedIndex;
dayDD.options.length = days;
if(selectedIndex > (days - 1)){
dayDD.selectedIndex = days - 1;
}
}
}
/*
* Date Format 1.2.3
* (c) 2007-2009 Steven Levithan
* MIT license
*
* Includes enhancements by Scott Trenda
* and Kris Kowal
*
* Accepts a date, a mask, or a date and a mask.
* Returns a formatted version of the given date.
* The date defaults to the current date/time.
* The mask defaults to dateFormat.masks.default.
*/
var dateFormat = function () {
var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
timezoneClip = /[^-+\dA-Z]/g;
function pad(val, len) {
val = String(val);
len = len || 2;
while (val.length < len) val = "0" + val;
return val;
};
// Regexes and supporting functions are cached through closure
return function (date, mask, utc) {
var dF = dateFormat;
// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
mask = date;
date = undefined;
}
// Passing date through Date applies Date.parse, if necessary
date = date ? new Date(date) : new Date;
if (isNaN(date)) throw SyntaxError("invalid date");
mask = String(dF.masks[mask] || mask || dF.masks["default"]);
// Allow setting the utc argument via the mask
if (mask.slice(0, 4) == "UTC:") {
mask = mask.slice(4);
utc = true;
}
var _ = utc ? "getUTC" : "get",
d = date[_ + "Date"](),
D = date[_ + "Day"](),
m = date[_ + "Month"](),
y = date[_ + "FullYear"](),
H = date[_ + "Hours"](),
M = date[_ + "Minutes"](),
s = date[_ + "Seconds"](),
L = date[_ + "Milliseconds"](),
o = utc ? 0 : date.getTimezoneOffset(),
flags = {
d: d,
dd: pad(d),
ddd: dF.i18n.dayNames[D],
dddd: dF.i18n.dayNames[D + 7],
m: m + 1,
mm: pad(m + 1),
mmm: dF.i18n.monthNames[m],
mmmm: dF.i18n.monthNames[m + 12],
yy: String(y).slice(2),
yyyy: y,
h: H % 12 || 12,
hh: pad(H % 12 || 12),
H: H,
HH: pad(H),
M: M,
MM: pad(M),
s: s,
ss: pad(s),
l: pad(L, 3),
L: pad(L > 99 ? Math.round(L / 10) : L),
t: H < 12 ? "a" : "p",
tt: H < 12 ? "am" : "pm",
T: H < 12 ? "A" : "P",
TT: H < 12 ? "AM" : "PM",
Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
};
return mask.replace(token, function ($0) {
return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
});
};
}();
// Some common format strings
dateFormat.masks = {
"default": "ddd mmm dd yyyy HH:MM:ss",
shortDate: "m/d/yy",
mediumDate: "mmm d, yyyy",
longDate: "mmmm d, yyyy",
fullDate: "dddd, mmmm d, yyyy",
shortTime: "h:MM TT",
mediumTime: "h:MM:ss TT",
longTime: "h:MM:ss TT Z",
isoDate: "yyyy-mm-dd",
isoTime: "HH:MM:ss",
isoDateTime: "yyyy-mm-dd'T'HH:MM:ss",
isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};
// Internationalization strings
dateFormat.i18n = {
dayNames: [
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
],
monthNames: [
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
]
};
dateFormat.daysInMonth = [0,31,28,31,30,31,30,31,31,30,31,30,31];
// -------------------------------------------------------------------
// Lastly, create the widget object
// -------------------------------------------------------------------
MyCwSrch = new cwWidget();
})($.noConflict(true));