Skip to content

Instantly share code, notes, and snippets.

@Kambfhase
Created April 27, 2016 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kambfhase/4be706891b472b6dfa84698eaeba8ade to your computer and use it in GitHub Desktop.
Save Kambfhase/4be706891b472b6dfa84698eaeba8ade to your computer and use it in GitHub Desktop.
jQuery('main').on('click', '#terminstandorte select option, .nextMonth, .prevMonth', function(){
var request = "openDates";
if (jQuery(this).get(0) == jQuery('.nextMonth').get(0) || jQuery(this).get(0) == jQuery('.prevMonth').get(0)) {
jQuery('#kalender').load('?' + jQuery(this).attr('value') + ' #thisMonth', getFreeDates);
}
function getFreeDates() {
var werk = +jQuery('#terminstandorte select option:selected').attr('value');
var firstDay = jQuery('.calDates .noDate:first').attr('id');
var lastDay = jQuery('.calDates .noDate:last').attr('id');
// RegExp‽
firstDay = firstDay.split("-");
firstDay = firstDay[1]+","+firstDay[2]+","+firstDay[0]
firstDay = parseInt(new Date(firstDay).getTime(), 10);
lastDay = lastDay.split("-");
lastDay = lastDay[1]+","+lastDay[2]+","+lastDay[0]
lastDay = parseInt(new Date(lastDay).getTime(), 10);
//Hier werden alle freien Termine für den aktuellen Monat angezeigt
jQuery.ajax({
url: CENSORED,
type: "GET",
data: {
request: request,
werk: werk,
firstDay: firstDay,
lastDay: lastDay
},
contentType: 'application/json; charset=utf-8',
beforeSend: function () {
// console.log(firstDay, lastDay);
var today = new Date(firstDay);
console.log(today.getMonth()+1);
},
success: function (data) {
var freeDates = JSON.parse(data);
freeDates.forEach(function (date) {
doSomething();
});
},
error: function () {
alert('Etwas lief schief');
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment