Skip to content

Instantly share code, notes, and snippets.

@Kambfhase Kambfhase/foo.js
Created Apr 27, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.