/** * Javascript functions for Scheduler Tenant view */ function ajaxRequest() { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari var xmlhttp = new XMLHttpRequest(); } else {// code for IE6, IE5 var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } return xmlhttp; } function getJob(callbackFunction) { var ajaxReq = ajaxRequest(); ajaxReq.onreadystatechange = callbackFunction; ajaxReq.open("GET", "csjobdetailsajax.p?sessionid=" + sessionId + "&visit-key=" + visitKey, "true"); ajaxReq.send(); } function getUnplannedAppointments(callbackFunction) { var ajaxReq = ajaxRequest(); ajaxReq.onreadystatechange = callbackFunction; ajaxReq.open("GET", "csunplannedvisitsajax.p?sessionid=" + sessionId, "true"); ajaxReq.send(); } function getUpcomingAppointments(callbackFunction) { var ajaxReq = ajaxRequest(); ajaxReq.onreadystatechange = callbackFunction; ajaxReq.open("GET", "csupcomingvisitsajax.p?sessionid=" + sessionId, "true"); ajaxReq.send(); } function getPreferredSlots(callbackFunction) { var ajaxReq = ajaxRequest(); ajaxReq.onreadystatechange = callbackFunction; ajaxReq.open("GET", "cspreferredslotsajax.p?sessionid=" + sessionId + "&visit-key=" + visitKey, "true"); ajaxReq.send(); } function getTargetMonths(callbackFunction) { var ajaxReq = ajaxRequest(); ajaxReq.onreadystatechange = callbackFunction; ajaxReq.open("GET", "csgettargetmonthsajax.p?sessionid=" + sessionId + "&visit-key=" + visitKey, "true"); ajaxReq.send(); } function getMonthAvailability(callbackFunction) { var ajaxReq = ajaxRequest(); ajaxReq.onreadystatechange = callbackFunction; ajaxReq.open("GET", "csmonthavailabilityajax.p?sessionid=" + sessionId + "&visit-key=" + visitKey + "&start-date=" + startDate, "true"); ajaxReq.send(); } function getDaySlotAvailability(callbackFunction, date) { var ajaxReq = ajaxRequest(); ajaxReq.onreadystatechange = callbackFunction; ajaxReq.open("GET", "csdayslotavailajax.p?sessionid=" + sessionId + "&visit-key=" + visitKey + "&date=" + date, "true"); ajaxReq.send(); } function getDateString(dateToConvert) { var dd = dateToConvert.getDate(); var mm = dateToConvert.getMonth()+1; //January is 0! var yyyy = dateToConvert.getFullYear(); if(dd < 10) { dd='0'+dd } if(mm < 10) { mm='0'+mm } return dd+'/'+mm+'/'+yyyy; } function ajaxLoader (el, options) { // Becomes this.options var defaults = { bgColor : '#fff', duration : 800, opacity : 0.7, classOveride : false } this.options = jQuery.extend(defaults, options); this.container = $(el); this.init = function() { var container = this.container; // Delete any other loaders this.remove(); // Create the overlay var overlay = $('
').css({ 'background-color': this.options.bgColor, 'opacity':this.options.opacity, 'width':container.width(), 'height':container.height(), 'position':'absolute', 'top':'0px', 'left':'0px', 'z-index':99999 }).addClass('ajax_overlay'); // add an overiding class name to set new loader style if (this.options.classOveride) { overlay.addClass(this.options.classOveride); } // insert overlay and loader into DOM container.append( overlay.append( $('').addClass('ajax_loader') ).fadeIn(this.options.duration) ); }; this.remove = function(){ var overlay = this.container.children(".ajax_overlay"); if (overlay.length) { overlay.fadeOut(this.options.classOveride, function() { overlay.remove(); }); } } this.init(); }