window.addEventListener("load", function(){ window.cookieconsent.initialise({ "palette": { "popup": { "background": "#000000" }, "button": { "background": "#ff9900" } }, "theme": "classic", "position": "top", "content": { "message": "Diese Seite verwendet Cookies!", "dismiss": "OK", "link": "Weitere Informationen", "href": "http://www.uwekriegel.de/datenschutz/" } })}); window.onpopstate = function(event) { location.reload(); }; // AJAX function sendRequest(entity, method, json, successCallback, progressCallback) { progressCallback = (typeof progressCallback !== 'undefined') ? progressCallback : function(){ return $.ajaxSettings.xhr(); }; jsonData = {entity: entity, method: method, obj: json}; $.ajax({ contentType: 'application/json; charset=utf-8', data: JSON.stringify(jsonData), dataType: 'json', type: 'POST', url: '/server/index.php', cache: false, xhr: progressCallback }) .done(function(c){ if(typeof c.data.errors === 'undefined') c.data.errors=[]; if(c.data.errors.length>0) { alert('Ein Serverseitiger ist aufgetreten! '+c.data.errors.join('
')); } else { successCallback(c); } }) .fail(onError) .always(onCompletion) } function onError(c) { alert('Ein Kommunikationsfehler ist aufgetreten! '+c); } function onCompletion(c) { } // Categories function welcome() { $.get('/templates/welcome.php', function(tpl) { var rendered = Mustache.render(tpl, 0); $('main').html(rendered); $('.carousel').carousel(); }); } function works() { sendRequest('works','retrieve',null,function(c) { $.each(c.data.works, function(i,v) { if(v.pOID===null) { v.filename = 'placeholder.jpg'; } else { v.filename = 'mw_'+zeroFill(v.gOID,20)+zeroFill(v.pOID,20)+'.jpg'; } }); $.get('/templates/works.php', function(tpl) { var rendered = Mustache.render(tpl, c.data); $('main').html(rendered); }); }); } function worksPictures(gOID,pOID) { var jump = false; sendRequest('worksPictures','retrieve',{gOID:gOID,pOID:pOID},function(c) { $.each(c.data.pictures, function(i,v) { v.filename = 'mw_'+zeroFill(v.gOID,20)+zeroFill(v.pOID,20)+'.jpg'; v.thumb = (v.big) ? '' : 'thumb'; v.col = (v.big) ? 'col-md-12' : 'col-md-4'; v.overlay = (v.big) ? '' : 'display:none;'; jump = (v.big) ? v.pOID : jump; }); $.get('/templates/worksPictures.php', function(tpl) { var rendered = Mustache.render(tpl, c.data); $('main').html(rendered).ready(function(){ if(jump)$('html, body').animate({scrollTop:parseInt($('div[pOID="'+jump+'"]').offset().top)}, 0); }); }); }); } function infos() { sendRequest('infos','retrieve',null,function(c) { $.each(c.data.infos, function(i,v){ v.width4 = (v.width==4) ? 'selected' : ''; v.width6 = (v.width==6) ? 'selected' : ''; v.width12 = (v.width==12) ? 'selected' : ''; }); $.get('/templates/infos.php', function(tpl) { var rendered = Mustache.render(tpl, c.data); $('main').html(rendered); $('textarea#text').each(function(i){ this.value = this.value.replace(//gi,"\n"); }) }); }); } function courses() { sendRequest('courses','retrieve',{past:false},function(c) { $.each(c.data.courses, function(i,v) { v.description_nl = v.description.replace(//gi,"\n"); v.dates = v.dates.split(','); v.datestring = []; if(v.dates.length<=1) { $.each(v.dates,function(j,w){ w = w.split(';'); w[1] = new Date(w[1]*1000); w[2] = new Date(w[2]*1000); v.dates[j] = {}; v.dates[j]['no']=j+1; v.dates[j]['index']=v.oid+'-'+j; v.dates[j]['dOID']=w[0]; v.dates[j]['date']=$.format.date(w[1],'dd.MM.yyyy'); v.dates[j]['from']=$.format.date(w[1],'H:mm'); v.dates[j]['to']=$.format.date(w[2],'H:mm'); v.datestring[j]=$.format.date(w[1],'E dd.MM.yyyy'); }); } else { $.each(v.dates,function(j,w){ w = w.split(';'); w[1] = new Date(w[1]*1000); w[2] = new Date(w[2]*1000); v.dates[j] = {}; v.dates[j]['no']=j+1; v.dates[j]['index']=v.oid+'-'+j; v.dates[j]['dOID']=w[0]; v.dates[j]['date']=$.format.date(w[1],'dd.MM.yyyy'); v.dates[j]['from']=$.format.date(w[1],'H:mm'); v.dates[j]['to']=$.format.date(w[2],'H:mm'); if(j0) ? v.pending : false; v.pendingphrase = (v.pending>1) ? 'Anmeldungen' : 'Anmeldung'; v.unconfirmed = (v.unconfirmed>0) ? v.unconfirmed : false; v.unconfirmedphrase = (v.unconfirmed>1) ? 'Anmeldungen' : 'Anmeldung'; }); $.get('/templates/courses.php', function(tpl) { var rendered = Mustache.render(tpl, c.data); $('main').html(rendered); }); }); } function register(cOID) { sendRequest('courses','retrieve',{cOID:cOID},function(c) { c.data.course.dates = c.data.course.dates.split(','); $.each(c.data.course.dates,function(i,v) { v = v.split(';'); v = Object.assign({},v); v[1] = new Date(v[1]*1000); v[2] = new Date(v[2]*1000); v['index'] = i+1+'.'; v['date'] = $.format.date(v[1],'ddd, dd.MM.yyyy'); v['from'] = $.format.date(v[1],'HH:mm'); v['to'] = $.format.date(v[2],'HH:mm'); c.data.course.dates[i]=v }); c.data.course.multipleDates = (c.data.course.dates.length>1) ? 'Termine:' : 'Termin:'; $.get('/templates/registration.php', function(tpl) { var rendered = Mustache.render(tpl, c.data.course); $('main').html(rendered); }); }); } function confirm(linkhash) { sendRequest('registrations','confirm',{linkhash:linkhash},function(c) { $.get('/templates/confirmationMessage.php', function(tpl) { var rendered = Mustache.render(tpl, c.data); $('main').html(rendered); }); }); } function pastCourses() { sendRequest('courses','retrieve',{past:true},function(c) { $.each(c.data.courses, function(i,v) { if(v.pOID===null) { v.filename = 'placeholder.jpg'; } else { v.filename = zeroFill(v.oid, 20) + zeroFill(v.pOID, 20) + '.jpg'; } }); $.get('/templates/pastCourses.php', function(tpl) { var rendered = Mustache.render(tpl, c.data); $('main').html(rendered); }); }); } function coursePictures(cOID,pOID) { var jump = false; sendRequest('coursePictures','retrieve',{cOID:cOID,pOID:pOID},function(c){ $.each(c.data.pictures, function(i,v) { v.filename = zeroFill(v.cOID,20)+zeroFill(v.pOID,20)+'.jpg'; v.thumb = (v.big) ? '' : 'thumb'; v.col = (v.big) ? 'col-md-12' : 'col-md-4'; v.overlay = (v.big) ? '' : 'display:none;'; jump = (v.big) ? v.pOID : jump; }); $.get('/templates/coursePictures.php', function(tpl) { var rendered = Mustache.render(tpl, c.data); $('main').html(rendered).ready(function(){ if(jump)$('html, body').animate({scrollTop:parseInt($('div[pOID="'+jump+'"]').offset().top)}, 0); }); }); }); } function reviews() { sendRequest('reviews','retrieve',null,function(c){ $.each(c.data.reviews, function(i,v){ v.added = new Date(v.added*1000); v.added = $.format.date(v.added,'dd.MM.yyyy'); v.approved = (v.approved==null) ? false : true; v.text_nl = v.text.replace(//gi,"\n"); }); $.get('/templates/reviews.php', function(tpl) { var rendered = Mustache.render(tpl, c.data); $('main').html(rendered); }); }); } function contact() { $.get('/templates/contact.php', function(tpl) { var rendered = Mustache.render(tpl, null); $('main').html(rendered); }); } function privacy() { $.get('/templates/privacy.php', function(tpl) { var rendered = Mustache.render(tpl, null); $('main').html(rendered); }); } // Helper Functions function invoke(target,functions) { return (functions[target.name] || function(){}); } function zeroFill(number, width) { width -= number.toString().length; if (width>0) { return new Array( width + (/\./.test( number ) ? 2 : 1) ).join( '0' ) + number; } return number + ""; } // Navigation $('.nav-hook').off().on('click',function(e){ e.preventDefault(); var fn = (window[e.target.id]) ? window[e.target.id] : window[$(e.target).closest('a').attr('id')]; if(typeof fn === 'function') fn(); window.history.pushState(null, null, e.target.pathname); });