setInterval(function () { stillAlive(); }, 60000); function stillAlive() { $.get('/Main/stillAlive'); } jQuery(function ($) { stillAlive(); //#main-slider $(function () { $('#main-slider.carousel').carousel({ interval: 8000 }); }); $('#main-slider').on('slid.bs.carousel', function () { $('.centered').each(function (e) { $(this).css('margin-top', ($('#main-slider').height() - $(this).height()) / 2); }); }); $('.centered').each(function (e) { $(this).css('margin-top', ($('#main-slider').height() - $(this).height()) / 2); }); $(window).resize(function () { $('.centered').each(function (e) { $(this).css('margin-top', ($('#main-slider').height() - $(this).height()) / 2); }); }); //contact form var form = $('.contact-form'); form.submit(function () { $this = $(this); $.post($(this).attr('action'), function (data) { $this.prev().text(data.message).fadeIn().delay(3000).fadeOut(); }, 'json'); return false; }); //goto top $('.gototop').click(function (event) { event.preventDefault(); $('html, body').animate({ scrollTop: $("body").offset().top }, 500); }); if (!getCookie('agreedToCookies') || getCookie('agreedToCookies') == null) { $('body').append(` `); } $('#cookie-alert').on('close.bs.alert', function () { setCookie('agreedToCookies', true); }); $('#cookie-confirm').on('click', function () { setCookie('agreedToCookies', true); $('#cookie-alert').alert('close'); }); }); if (window.matchMedia("(min-width: 992px)").matches) { jQuery('ul.nav li.dropdown').hover(function () { jQuery(this).find('.dropdown-menu').stop(true, true).slideDown(200); jQuery(this).addClass('hovered'); }, function () { jQuery(this).find('.dropdown-menu').stop(true, true).slideUp(200); jQuery(this).removeClass('hovered'); }); } else { $('a.dropdown-toggle').attr('data-toggle', 'dropdown'); } function getCookie(key) { var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)'); return keyValue ? keyValue[2] : null; } function setCookie(key, value) { document.cookie = key + '=' + value + ';'; } // Feedback Form function sendFeedback() { var message = $('#feedbackModal textarea[name=message]').val(); var anonymous = $('#feedbackModal input[name=anonymous]').is(':checked'); var url = window.location.pathname; if (message === "") { $('#feedbackModal #message').addClass('has-error'); } else { $.ajax({ url: "/Main/addFeedback", method: "POST", data: { message: message, anonymous: anonymous, url: url }, beforeSend: function () { $('#feedbackModal .modal-body').append(''); $('#feedbackModalSend').button('loading'); }, success: function (data) { $('#feedbackModal .modal-loading-container .modal-loading-icon').removeClass('fa-cog fa-spin').addClass('fa-check success').append('Vielen Dank für dein Feedback!'); }, error: console.log }); } } // Contact form function sendContactMessage() { var message = $('#contact-message textarea').val(); var email = ""; if ($('#email-address input').val() !== null) { email = $('#email-address input').val() } $('#contactModal .modal-body').append(''); $('#contactModalSend').button('loading'); $.ajax({ url: "/Main/contactTeam", method: "POST", data: { message: message, email: email }, success: function (data) { if (data.type) { $('#contactModal .modal-loading-container .modal-loading-icon i').removeClass('fa-cog fa-spin').addClass('fa-check').parents('.modal-loading-icon').addClass('success').append('' + data.message + ''); } else { $('#contactModal .modal-loading-container .modal-loading-icon i').removeClass('fa-cog fa-spin').addClass('fa-times').parents('.modal-loading-icon').addClass('error').append('' + data.message + ''); } }, error: function (data) { console.log(data); $('#contactModal .modal-loading-container .modal-loading-icon i').removeClass('fa-cog fa-spin').addClass('fa-times').parents('.modal-loading-icon').addClass('error').append('Ein unbekannter Fehler ist aufgetreten'); } }); } $(function () { $('.menu-icon').click(function () { $(this).toggleClass('is-open'); $('.side-navigation').toggleClass('active'); $('.side-navigation-background ').toggleClass('active'); }); }); const btnFloat = document.querySelector('.btn-floating .btn'); const btnShadow = document.querySelector('.btn-floating-shadow'); btnFloat.addEventListener('click', function () { const btnParent = btnFloat.parentElement; btnParent.classList.toggle('active'); btnIsActive(btnParent); }); btnShadow.addEventListener('click', function () { const btnParent = btnFloat.parentElement; btnParent.classList.remove('active'); btnIsActive(btnParent); }); // function for asign a dinamic position to the ".btn-floating-list" // I mean if you want to put more than 3 buttons this automatic take the correct top function btnIsActive(btnFloat) { var LiHeight = btnFloat.querySelector('ul.btn-floating-list li').offsetHeight; var LiLength = btnFloat.querySelectorAll('ul.btn-floating-list li').length; if (btnFloat.className === "btn-floating active") { var LiMargin = ((LiLength + 1) * 10) / LiLength; var btnTop = (LiHeight + LiMargin) * LiLength; btnFloat.querySelector('ul.btn-floating-list').style.top = -btnTop + 'px'; } else { btnFloat.querySelector('ul.btn-floating-list').style.top = LiHeight + 'px'; } } $('.side-navigation-background').click(function () { $(this).removeClass('active'); $('.side-navigation').removeClass('active'); $('.menu-icon').removeClass('is-open'); }); $('.side-navigation-content .dropdown > a').on("click", function (e) { e.preventDefault(); $(".sub-menu", $(this).parent()).slideToggle(200); console.log($('.fa-angle-down', $(this))); $('.fa-angle-down', $(this)).toggleClass('opened'); }); $('#navbar-swipe-open').on('swiperight', function () { $(".side-navigation").addClass('active'); $('.side-navigation-background').addClass('active'); $('.menu-icon').addClass('is-open'); }); $(document).on('swipeleft', function () { if ($('.side-navigation').hasClass('active')) { $('.side-navigation-background').removeClass('active'); $('.side-navigation').removeClass('active'); $('.menu-icon').removeClass('is-open'); } }); $(function () { $.each($(".share-btn"), function () { $(this).on("click", function (event) { var width = 650, height = 450; event.preventDefault(); window.open($(this).attr('href'), 'Share Dialog', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=' + width + ',height=' + height + ',top=' + (screen.height / 2 - height / 2) + ',left=' + (screen.width / 2 - width / 2)); }); }); }); $(document).scroll(function () { if ($(this).scrollTop() > 0) { $('.navbar-inverse').css('box-shadow', '0 3px 6px 0 rgba(0, 0, 0, 0.18)').css('-webkit-box-shadow', '0 3px 6px 0 rgba(0, 0, 0, 0.18)').css('background-color', '#2272fff2'); } else { $('.navbar-inverse').removeAttr('style'); } }); $(function () { $('[data-toggle="tooltip"]').tooltip(); }); function toggleMenu() { $('.side-navigation').toggleClass('active'); $('.side-navigation-background').toggleClass('active'); $('.menu-icon').toggleClass('is-open'); } $(document).keyup(function (e) { if (e.keyCode === 27) { toggleMenu(); } }); function addReadMoreBtns() { $('.comment-well .content-container').each(function () { $('.content .read-more-btn', $(this)).remove(); if ($('.content', $(this)).outerHeight() > $(this).outerHeight()) { $('.content', $(this)).append('

Mehr lesen

'); } }); $('.comment-well .read-more-btn a').click(function (e) { e.preventDefault(); const parent = $(this).parent().parent().parent().parent(); const totalHeight = $('.content', parent).outerHeight() + 55; parent.css({ "height": parent.height(), "max-height": 9999 }).animate({ "height": totalHeight }, 200); $(this).parent().fadeOut(); return false; }); } $('#notificationMenuButton').click(() => { $.ajax({ url: '/Main/notificationsRead', method: 'post', success: (data) => { if (data.success) { loadNotificationsAsync(); } } }); }); const notificationCount = 5; let notificationOffset = 0; function loadNotificationsAsync() { $.ajax({ url: '/Main/getNotifications', method: 'POST', data: { count: notificationCount, offset: notificationOffset }, beforeSend: () => { $('#notificationMenu').find('.fa').removeClass('fa-frown text-danger').addClass('fa-spin fa-cog'); }, success: (data) => { $('#notificationMenu').find('.text-center').remove(); if (data.status === 'success') { const container = $('#notificationMenu .list-group'); for (let notification of data.notifications) { console.log(notification); container.append(`
${notification.sender}
${notification.time}

${notification.message}

`) } if (data.notifications.length > 0) { const unread = data.notifications.filter(e => e.unread); if (unread.length > 0) { $('#notificationCount').text(unread.length); } notificationOffset++; } else { $('#notificationMenu .list-group p.list-group-item').remove(); $('#notificationMenu .list-group').append(`

Keine neuen Benachrichtigungen

`) } } }, error: () => { $('#notificationMenu').find('.fa').removeClass('fa-spin fa-cog').addClass('fa-frown text-danger'); } }); } loadNotificationsAsync(); $('#switchDarkmode').click(function (event) { event.preventDefault(); $('body').toggleClass('dark'); if($('body').hasClass('dark')) { $(this).find('.fa-moon').removeClass('fa').addClass('far'); $(this).attr('data-title', 'Light Theme') } else { $(this).find('.fa-moon').removeClass('far').addClass('fa'); $(this).attr('data-title', 'Dark Theme') } });