$(document).ready(function() { $('.slider').each(function() { $(this).Slider({ speed: 200, interval: 5000, effect: 'slide', auto: 1, addcontrols: 1, livecontrols: 1, addnextprev: 0, livenextprev: 0, }); }); $('.carrousel').Carrousel({ speed: 200, interval: 5000, center: 0, auto: 0, addnextprev: 1, livenextprev: 0 }); $("a.fancybox").fancybox({'closeBtn': false}); $('.gallery').children('.photo').hover( function() { $(this).find('span.description').slideToggle(); } ); $('input[name="captcha"]').val(5).hide(); if (!!('ontouchstart' in window)) { $('div.wrap').click(function() { $("#show-menu").next('ul').hide(); }); $('#show-menu').click(function(event) { event.stopPropagation(); $(this).next('ul').toggle(); }); } // zobrazi formular pre zabudnute heslo $('#forgot').click(function() { $('.loginPage .login-right').show('slow'); }); // kalendarove veci $('body').on('click', '.changeMonth', function(event) { event.preventDefault(); month = $(this).data('month'); year = $(this).data('year'); tpl = $(this).data('tpl'); sport = $(this).data('sport'); setCalendar(month, year, sport, tpl); }); $('body').on('click', '.sportIcon', function() { month = $(this).data('month'); year = $(this).data('year'); court = $(this).data('court'); sport = $(this).data('sport'); tpl = $(this).data('tpl'); setCalendar(month, year, sport, tpl); }); $('body').bind("ajaxSend", function() { $.fancybox.showLoading(); //$.fancybox.helpers.overlay.open({parent: 'body'}); }).bind("ajaxComplete", function() { $.fancybox.hideLoading(); //$.fancybox.helpers.overlay.close({parent: 'body'}); }); // var fromTime; var toTime; var click = 0; $('body').on('click', '.timeRange .free', function() { $(this).addClass('selected'); var clicked = $(this).data('rank'); var numItems = $('.selected').length; click++; if (click == 1) { fromTime = clicked; } else if (click == 2) { toTime = clicked; $('.timeRange div').removeClass('selected'); click = 0; } // ak najskor klikne na datum do a potom na od if (toTime < fromTime) { var saveTime = fromTime; fromTime = toTime; toTime = saveTime; } // for (var i = fromTime; i <= toTime; i++) { $('.timeRange div[data-rank="' + i + '"]').addClass('selected'); } //console.log(fromTime + ' ' + toTime); }); $(document).on('click', '[data-detail="cookieDetailsSettings"]', function(event) { event.preventDefault(); $('.cookie-notice').toggleClass('details'); }); $('.cookie-notice button[name="cookie_accept_all"]').click(function () { $('.cookie-notice input[name="cookie_marketing"]').prop('checked', true); $('.cookie-notice input[name="cookies_analytics"]').prop('checked', true); $.ajax({ url: '/saveCookies', type: "GET", data: {"cookies_general": true, "cookies_marketing": true, "cookies_analytics": true}, success: function (response) { window.location.reload(); } }); }); $('.cookie-notice button[name="cookie_save"]').click(function () { $.ajax({ url: '/saveCookies', type: "GET", data: { "cookies_general": $('.cookie-notice input[name="cookie_general"]').prop('checked'), "cookies_marketing": $('.cookie-notice input[name="cookie_marketing"]').prop('checked'), "cookies_analytics": $('.cookie-notice input[name="cookies_analytics"]').prop('checked'), }, success: function (response) { window.location.reload(); } }); }); }); function getCourtAvaibility(court, date){ $('.court-select').find('a.court').removeClass('active'); $('.court-select').find('a.court.c'+court).addClass('active'); $('.courtId').val(court); $.ajax({ url: basePath + 'ajax/getcourtavaibility/', type: "GET", data: ({ court: court, date: date }) }).done(function(data) { $('#court').html(data); }); } function setCalendar(month, year, sport, template) { //var template = $(this).data('tpl'); //console.log(template); $.ajax({ url: basePath + 'ajax/hpcalendar/', type: "GET", data: ({ month: month, year: year, sport: sport, template: template }) }).done(function(data) { $('#calendar').html(data); }); } var strColorOn = '#162543'; var strColorOff = '#ffffff'; function GetHexValue(strRGBColor) { var aryRGBValues; var strR; var strG; var strB; var strHexValue; strRGBColor = strRGBColor.replace(/\s*/g, ''); strRGBColor = strRGBColor.replace(/rgb\(|\)/g, ''); aryRGBValues = strRGBColor.split(','); strR = aryRGBValues[0]; strG = aryRGBValues[1]; strB = aryRGBValues[2]; strHexValue = '#' + RGBtoHex(strR, strG, strB) return strHexValue.toLowerCase(); } function RGBtoHex(strR, strG, strB) { var intR = strR * 1; var intG = strG * 1; var intB = strB * 1; return intR.toString(16) + intG.toString(16) + intB.toString(16) } function ToggleTimeslot(tdTimeslot) { var strBackgroundColor; if (tdTimeslot.style.backgroundColor == 'undefined' || tdTimeslot.style.backgroundColor == 'null' || tdTimeslot.style.backgroundColor == '') { tdTimeslot.style.backgroundColor = strColorOn; ViewSelectedTimeslots(); return; } strBackgroundColor = tdTimeslot.style.backgroundColor; if (strBackgroundColor.substr(0, 1) != '#') { strBackgroundColor = GetHexValue(strBackgroundColor); } if (strBackgroundColor == strColorOff) { tdTimeslot.style.backgroundColor = strColorOn; } else { tdTimeslot.style.backgroundColor = strColorOff; } ViewSelectedTimeslots(); // } function GetTimeSlotValue(intTimeslot, strStartOrEnd, element) { var strTimeslot; console.log(element); if(strStartOrEnd == 'start') { strTimeslot = element.getAttribute('data-start-date'); } else { strTimeslot = element.getAttribute('data-start-date'); } // switch (intTimeslot) // { // case 1: // if (strStartOrEnd == 'start') // { // strTimeslot = '8:00'; // } // else // { // strTimeslot = '8:30'; // } // break; // case 2: // if (strStartOrEnd == 'start') // { // strTimeslot = '8:30'; // } // else // { // strTimeslot = '9:00'; // } // break; // case 3: // if (strStartOrEnd == 'start') // { // strTimeslot = '9:00'; // } // else // { // strTimeslot = '9:30'; // } // break; // case 4: // if (strStartOrEnd == 'start') // { // strTimeslot = '9:30'; // } // else // { // strTimeslot = '10:00'; // } // break; // case 5: // if (strStartOrEnd == 'start') // { // strTimeslot = '10:00'; // } // else // { // strTimeslot = '10:30'; // } // break; // case 6: // if (strStartOrEnd == 'start') // { // strTimeslot = '10:30'; // } // else // { // strTimeslot = '11:00'; // } // break; // case 7: // if (strStartOrEnd == 'start') // { // strTimeslot = '11:00'; // } // else // { // strTimeslot = '11:30'; // } // break; // case 8: // if (strStartOrEnd == 'start') // { // strTimeslot = '11:30'; // } // else // { // strTimeslot = '12:00'; // } // break; // case 9: // if (strStartOrEnd == 'start') // { // strTimeslot = '12:00'; // } // else // { // strTimeslot = '12:30'; // } // break; // case 10: // if (strStartOrEnd == 'start') // { // strTimeslot = '12:30'; // } // else // { // strTimeslot = '13:00'; // } // break; // case 11: // if (strStartOrEnd == 'start') // { // strTimeslot = '13:00'; // } // else // { // strTimeslot = '13:30'; // } // break; // case 12: // if (strStartOrEnd == 'start') // { // strTimeslot = '13:30'; // } // else // { // strTimeslot = '14:00'; // } // break; // case 13: // if (strStartOrEnd == 'start') // { // strTimeslot = '14:00'; // } // else // { // strTimeslot = '14:30'; // } // break; // case 14: // if (strStartOrEnd == 'start') // { // strTimeslot = '14:30'; // } // else // { // strTimeslot = '15:00'; // } // break; // case 15: // if (strStartOrEnd == 'start') // { // strTimeslot = '15:00'; // } // else // { // strTimeslot = '15:30'; // } // break; // case 16: // if (strStartOrEnd == 'start') // { // strTimeslot = '15:30'; // } // else // { // strTimeslot = '16:00'; // } // break; // case 17: // if (strStartOrEnd == 'start') // { // strTimeslot = '16:00'; // } // else // { // strTimeslot = '16:30'; // } // break; // case 18: // if (strStartOrEnd == 'start') // { // strTimeslot = '16:30'; // } // else // { // strTimeslot = '17:00'; // } // break; // case 19: // if (strStartOrEnd == 'start') // { // strTimeslot = '17:00'; // } // else // { // strTimeslot = '17:30'; // } // break; // case 20: // if (strStartOrEnd == 'start') // { // strTimeslot = '17:30'; // } // else // { // strTimeslot = '18:00'; // } // break; // case 21: // if (strStartOrEnd == 'start') // { // strTimeslot = '18:00'; // } // else // { // strTimeslot = '18:30'; // } // break; // case 22: // if (strStartOrEnd == 'start') // { // strTimeslot = '18:30'; // } // else // { // strTimeslot = '19:00'; // } // break; // case 23: // if (strStartOrEnd == 'start') // { // strTimeslot = '19:00'; // } // else // { // strTimeslot = '19:30'; // } // break; // case 24: // if (strStartOrEnd == 'start') // { // strTimeslot = '19:30'; // } // else // { // strTimeslot = '20:00'; // } // break; // case 25: // if (strStartOrEnd == 'start') // { // strTimeslot = '20:00'; // } // else // { // strTimeslot = '20:30'; // } // break; // case 26: // if (strStartOrEnd == 'start') // { // strTimeslot = '20:30'; // } // else // { // strTimeslot = '21:00'; // } // break; // case 27: // if (strStartOrEnd == 'start') // { // strTimeslot = '21:00'; // } // else // { // strTimeslot = '21:30'; // } // break; // case 28: // if (strStartOrEnd == 'start') // { // strTimeslot = '21:30'; // } // else // { // strTimeslot = '22:00'; // } // break; // default: // strTimeslot = ''; // } return strTimeslot; } function GetSelectedTimeslots(strDay) { var strTimeslots = ''; var intLastSelectedTimeslot = -1; var strBackgroundColor; var ret; var intCounter; var intNumOfTimeslots = $('.timeslots tbody tr .canclicked').length; // zratat pomocou js console.log(intNumOfTimeslots); intCounter = 1; while (intCounter <= intNumOfTimeslots) { strBackgroundColor = document.getElementById('td' + strDay + intCounter).style.backgroundColor; console.log(strBackgroundColor); if (strBackgroundColor.substr(0, 1) != '#') { strBackgroundColor = GetHexValue(strBackgroundColor); } if (strBackgroundColor == strColorOn) { if (intCounter != (intLastSelectedTimeslot + 1)) { strTimeslots = strTimeslots + GetTimeSlotValue(intCounter, 'start', document.getElementById('td' + strDay + intCounter)); } intLastSelectedTimeslot = intCounter; } else { if (intCounter == (intLastSelectedTimeslot + 1)) { strTimeslots = strTimeslots + '-' + GetTimeSlotValue(intLastSelectedTimeslot, 'end', document.getElementById('td' + strDay + intCounter)) + ', '; } } intCounter++ } if (intLastSelectedTimeslot == intNumOfTimeslots) { strTimeslots = strTimeslots + '-' + GetTimeSlotValue(intLastSelectedTimeslot, 'end', document.getElementById('td' + strDay + intCounter)) + ', '; } strTimeslots = strTimeslots.substr(0, (strTimeslots.length - 2)); if (strTimeslots == '-') { strTimeslots = ''; } return strTimeslots; } function ViewSelectedTimeslots() { var strMessage = ''; strMessage = GetSelectedTimeslots('Mon'); // console.log(strMessage); $('.times').val(strMessage); }