var base_url = "https://www.ibike-box.com";
if (base_url != window.location.origin) {
base_url = window.location.origin;
if (base_url == "http://127.0.0.1")
base_url += "/ebikebox/CI_CRUD";
}
(function () {
// 'use strict';
$.expr[":"].contains = $.expr.createPseudo(function(arg) {
return function( elem ) {
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
};
});
function generateOutPutDate(toconvert) {
var outputdate = "'" + with_leading_zeros(toconvert.getDate()) + "." + with_leading_zeros(toconvert.getMonth() + 1) + "." + toconvert.getFullYear() + " " + with_leading_zeros(toconvert.getHours()) + ":" + with_leading_zeros(toconvert.getMinutes()) + "'";
return outputdate;
}
Date.prototype.addHours = function (h) {
this.setTime(this.getTime() + (h * 60 * 60 * 1000));
return this;
}
Date.prototype.addDays = function (d) {
this.setTime(this.getTime() + (d * 24 * 60 * 60 * 1000));
return this;
}
function initCheckCard() {
if ($('#checkcard').length > 0) {
$("#checkcard").click(function () {
var whichcard = $("#whichcard").val();
var cardno = $("#cardnumber").val();
var for_pid = $("#for_pid").val();
var pgid = $(this).attr("data-productgroup");
$("#cardrow").hide();
$("#cards-info").html("... Karte wird momentan überprüft ...");
//console.log(whichcard + " = "+cardno);
$.ajax({
url: base_url + "/bi/ext_api/feratel/"+whichcard+"/"+cardno,
method: "GET", //First change type to method here
success: function (response) {
// alert(response);
var response_splitted = response.split(";");
// console.log(response_splitted);
// alert(response_splitted[0] + " " + response_splitted[1]);
if(response_splitted[0] == 1)
{
// $("#cardrow").hide();
$.ajax({
url: base_url + "/cart/add_card",
method: "POST", //First change type to method here
data: {
whichcard:whichcard,
cardnumber:cardno,
for_product_id: for_pid,
},
success: function (response) {
console.log("success" + response);
if(response < 1)
$("#cardrow").show();
if(response == 1)
$("#cards-info").html("Die Kartennummer wurde erfolgreich mit unserem Produkt verknüpft und die entsprechende %-Aktion in der Kasse berücksichtigt.
Zum Warenkorb");
if(response == "-1")
$("#cards-info").html("Wir konnten das Produkt nicht finden");
if(response == "-2")
$("#cards-info").html("Die Karte ist bereits mit dem Produkt verknüpft.");
if(response == "-3")
$("#cards-info").html("Die Karte ist bereits mit einem anderen Produkt verknüpft.");
if(response == "-4")
$("#cards-info").html("Die Kartennummer ist nicht gültig, bitte Nummer überprüfen.");
if(response == "-5")
$("#cards-info").html("Die Kartennummer wurde bereits benutzt.");
//alert("save in session now");
// initProductButtons();
//initCartButtons();
//updateCartNotification(productsincart);
// console.log("end success");
},
error: function () {
alert("error");
}
});
}
else
//if(response_splitted[0] == 0)
{
$("#cardrow").show();
if(response_splitted[1] == "notfound")
$("#cards-info").html("Es konnte keine gültige Karte mit dieser Nummer gefunden werden.");
else
{
response = response_splitted[0];
if(response < 1)
$("#cardrow").show();
if(response == 1)
$("#cards-info").html("Die Kartennummer wurde erfolgreich mit unserem Produkt verknüpft und die entsprechende %-Aktion in der Kasse berücksichtigt.
Zum Warenkorb");
if(response == "-1")
$("#cards-info").html("Wir konnten das Produkt nicht finden");
if(response == "-2")
$("#cards-info").html("Die Karte ist bereits mit dem Produkt verknüpft.");
if(response == "-3")
$("#cards-info").html("Die Karte ist bereits mit einem anderen Produkt verknüpft.");
if(response == "-4")
$("#cards-info").html("Die Kartennummer ist nicht gültig, bitte Nummer überprüfen.");
if(response == "-5")
$("#cards-info").html("Die Kartennummer wurde bereits benutzt.");
$("#cards-info").html(response_splitted[1]);
}
}
},
error: function () {
// alert("error");
}
});
});
}
}
function initTimeSelection() {
// alert(hoursdisabled_cat);
var currentdate = new Date();
var currentdate_before = new Date();
if ($("#bike_search_from").attr('data-beforetoday-hours')) {
currentdate_before = currentdate_before.addHours(-1 * parseInt($("#bike_search_from").attr('data-beforetoday-hours')));
}
if ($("#bike_search_from").attr('data-beforetoday-days')) {
currentdate_before = currentdate_before.addDays(-1 * parseInt($("#bike_search_from").attr('data-beforetoday-days')));
}
var outputdate = generateOutPutDate(currentdate);
var outputdate_before = generateOutPutDate(currentdate_before);
if ($("#bike_search_from").attr('date-startdate')) {
outputdate_before = outputdate = $("#bike_search_from").attr("date-startdate");// generateOutPutDate($("#bike_search_from").attr("date-startdate"));
}
/*
var currentdate = new Date();
var currentdate_before = new Date();
if ($("#bike_search_from").attr('data-beforetoday-hours')) {
currentdate_before = currentdate_before.addHours(-1 * parseInt($("#bike_search_from").attr('data-beforetoday-hours')));
}
if ($("#bike_search_from").attr('data-beforetoday-days')) {
currentdate_before = currentdate_before.addDays(-1 * parseInt($("#bike_search_from").attr('data-beforetoday-days')));
}
var outputdate = generateOutPutDate(currentdate);
var outputdate_before = generateOutPutDate(currentdate_before);
*/
if ($('#bike_search_from').length > 0) {
$('#bike_search_from').datetimepicker({
minView: 1,
autoclose: true,
language: 'de',
weekStart: 1,
format: 'dd.mm.yyyy hh:ii',
outputformat: 'dd.mm.yyyy hh:00',
startDate: outputdate_before, //outputdate,
todayBtn: 1,
// hoursDisabled: [0, 1, 2, 3, 4, 5, 6, 7, 21, 22, 23, 24],
todayHighlight: 1,
pickerPosition: "container-left",
startView: 2,
minuteStep: 60,
forceParse: 1,
showMeridian: 0,
//linkField: "bike_search_until",
linkFormat: "dd.mm.yyyy hh:ii",
icons: {
time: "fa fa-clock-o",
date: "fa fa-calendar",
up: "fa fa-arrow-up",
down: "fa fa-arrow-down"
}
});
$('#bike_search_until').datetimepicker({
language: 'de',
weekStart: 1,
format: 'dd.mm.yyyy hh:ii',
outputformat: 'dd.mm.yyyy hh:00',
startDate: outputdate,
todayBtn: 1,
// hoursDisabled: [0, 1, 2, 3, 4, 5, 6, 7, 21, 22, 23, 24],
autoclose: 1,
todayHighlight: 1,
pickerPosition: "container-left",
startView: 2,
minView: 1,
minuteStep: 60,
forceParse: 1,
showMeridian: 0,
icons: {
time: "fa fa-clock-o",
date: "fa fa-calendar",
up: "fa fa-arrow-up",
down: "fa fa-arrow-down"
}
});
$('.form_datetime[data-readonly="1"] input').css('cursor', 'pointer').attr('disabled', 'disabled');
$('.form_datetime[data-readonly="1"]').on('click', function () {
$(this).find('.input-group-addon').trigger('click');
});
$('#bike_search_from').datetimepicker().on('changeDate', function (e) {
var first = new Date(e.date.setMinutes(0));
// console.log($("#bike_search_until").attr('data-minspan-hours'));
if ($("#bike_search_until").attr('data-minspan-hours')) {
first = first.addHours(parseInt($("#bike_search_until").attr('data-minspan-hours')));
}
//console.log(first);
if ($("#bike_search_until").attr('data-minspan-days')) {
first = first.addDays(parseInt($("#bike_search_until").attr('data-minspan-days')));
}
$("#bike_search_until").datetimepicker('setDate', first);
$("#bike_search_until").datetimepicker('setStartDate', generateOutPutDate(first));
});
$('#bike_search_from').datetimepicker().on('outOfRange', function (e) {
});
$('#bike_search_until').datetimepicker().on('changeDate', function (e) {
$("#form_search_bikes_submit").trigger("click");
//OLD TYPE
// $("#form_search_bikes").submit();
});
}
/*
// alert(hoursdisabled_cat);
var currentdate = new Date();
outputdate = generateOutPutDate(currentdate);
if ($('#bike_search_from').length > 0) {
//alert($("#bike_search_from").attr("date-startdate"));
outputdate = $("#bike_search_from").attr("date-startdate");// generateOutPutDate($("#bike_search_from").attr("date-startdate"));
$('#bike_search_from').datetimepicker({
minView: 1,
autoclose: true,
language: 'de',
weekStart: 1,
format: 'dd.mm.yyyy hh:ii',
outputformat: 'dd.mm.yyyy hh:00',
startDate: outputdate, //outputdate,
todayBtn: 1,
// hoursDisabled: [0, 1, 2, 3, 4, 5, 6, 7, 21, 22, 23, 24],
todayHighlight: 1,
pickerPosition: "container-left",
startView: 2,
minuteStep: 60,
forceParse: 1,
showMeridian: 0,
linkField: "bike_search_until",
linkFormat: "dd.mm.yyyy hh:ii",
icons: {
time: "fa fa-clock-o",
date: "fa fa-calendar",
up: "fa fa-arrow-up",
down: "fa fa-arrow-down"
}
});
$('#bike_search_until').datetimepicker({
language: 'de',
weekStart: 1,
format: 'dd.mm.yyyy hh:ii',
outputformat: 'dd.mm.yyyy hh:00',
startDate: outputdate,
todayBtn: 1,
// hoursDisabled: [0, 1, 2, 3, 4, 5, 6, 7, 21, 22, 23, 24],
autoclose: 1,
todayHighlight: 1,
pickerPosition: "container-left",
startView: 2,
minView: 1,
minuteStep: 60,
forceParse: 1,
showMeridian: 0,
icons: {
time: "fa fa-clock-o",
date: "fa fa-calendar",
up: "fa fa-arrow-up",
down: "fa fa-arrow-down"
}
});
$('#bike_search_from').datetimepicker().on('changeDate', function (e) {
// var first = new Date(e.date.setMinutes(0));
// first.setHours(first.getHours()+first.getTimezoneOffset()/60); //timezone correction
// console.log(first);
// alert("changed");
// $("#bike_search_until").datetimepicker('setStartDate', generateOutPutDate(first));
});
$('#bike_search_from').datetimepicker().on('outOfRange', function (e) {
});
$('#bike_search_until').datetimepicker().on('changeDate', function (e) {
// $("#form_search_bikes").submit();
});
}
*/
}
function with_leading_zeros(value) {
return (value < 10 ? '0' : '') + value;
}
function initCartButtons() {
$("#cart #cart-content .button-removefromcart").click(function () {
// console.log("REMOVE");
// alert("REMOVE");
var pid = $(this).attr("pid");
var for_pid = $(this).attr("for_pid");
// console.log("remove3 " + pid + " fp:" + for_pid);
// alert("Remove " + pid + " " + for_pid);
$.ajax({
url: base_url + "/cart/remove",
method: "POST", //First change type to method here
data: {
product_id: pid,
for_product_id: for_pid,
},
success: function (response) {
productsincart = getProductsInCart(response);
// alert("Responsge success" + pid + " " + for_pid);
response = getCartResult(response);
$("#cart-content").html(response);
self.location.reload();
initCartButtons();
updateCartNotification(productsincart);
},
error: function () {
// alert("error");
}
});
// alert("Remove done " + pid + " " + for_pid);
});
}
function check_username(value) {
//console.log("CHECK USERNAME");
Cookies.set("nocache", 1, {expires: 1});
$.ajax({
url: base_url + '/data/checkUserperMail',
method: "POST", //First change type to method here
data: {
email: value, // Second add quotes on the value.
},
success: function (resp) {
// alert('in success JSON');
//console.log(resp.response)
if (resp == "1") {
document.getElementById("e-mail-info").style.display = "block";
//$("#e-mail-info").show();
// $("#customer-information .button-next").hide();
}
},
error: function (resp) {
}
});
}
function validateCustomerInfo(firstrun = false) {
//console.log("Validate");
valid = true;
zip = $("#zip")[0].value;
street = $("#street")[0].value;
town = $("#town")[0].value;
phone = $("#phone")[0].value;
mail = $("#email")[0].value;
firstname = $("#firstname")[0].value;
lastname = $("#lastname")[0].value;
$('#customer-information input').removeClass("error");
if (mail.length < 6 || !isEmail(mail)) {
valid = false;
if (!firstrun)
$("#email").addClass("error");
}
if (firstname.length < 2) {
valid = false;
if (!firstrun)
$("#firstname").addClass("error");
}
if (lastname.length < 2) {
valid = false;
if (!firstrun)
$("#lastname").addClass("error");
}
// console.log("street: " + street.length);
if (street.length < 6) {
valid = false;
// console.log($("#street").val().length + " = " + $("#street").val());
if (!firstrun)
$("#street").addClass("error");
}
if (phone.length < 6) {
valid = false;
// console.log($("#street").val().length + " = " + $("#street").val());
if (!firstrun)
$("#phone").addClass("error");
}
// console.log("ZIP: " + zip.length);
if (zip.length < 4) {
valid = false;
if (!firstrun)
$("#zip").addClass("error");
}
// console.log("town: " + town.length);
if (town.length < 2) {
valid = false;
if (!firstrun)
$("#town").addClass("error");
}
if (valid == true) {
$("#customer-information .button-next").show();
$('#customer-information input').removeClass("error");
// $('#payment-information .content').show();
// $('html, body').animate({scrollTop: $('#payment-information').offset().top}, 200);
/*$(this).parent().hide();*/
}
//else
// $("#customer-information .button-next").hide();
return valid;
}
function getCartResult(response) {
seperator = response.indexOf("||");
if (seperator > 0) {
len = response.length;
seperator += 2;
// alert(seperator);
response = response.substring(seperator, len);
//console.log(response);
return response;
} else return response;
}
function getProductsInCart(response) {
seperator = response.indexOf("||");
// alert(seperator);
productsincart = 0;
if (seperator > 0) {
productsincart = response.substring(0, seperator);
//alert(productsincart);
}
return productsincart;
}
function isEmail(email) {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return regex.test(email);
}
function updateCartNotification(value) {
// console.log("UPDATEID");
$("#cart-notification").removeClass("pulsate");
$("#cart-notification").html(value);
$("#cart-notification").addClass("pulsate");
setTimeout(function () {
$("#cart-notification").removeClass('pulsate');
}, 2000);
}
function closeSafetyPackageBadges() {
$(".close-safety").click(function () {
$(".add-safety-package").hide();
});
}
$.fn.classes = function (callback) {
var classes = [];
$.each(this, function (i, v) {
var splitClassName = v.className.split(/\s+/);
for (var j = 0; j < splitClassName.length; j++) {
var className = splitClassName[j];
if (-1 === classes.indexOf(className)) {
classes.push(className);
}
}
});
if ('function' === typeof callback) {
for (var i in classes) {
callback(classes[i]);
}
}
return classes;
};
function initFilterButtons() {
// console.log($(".product-row").length);
if ($(".product-row").length > 0) {
var all = $(".product-row").classes();
// console.log(all);
if ($(all).length > 0) {
var typesfound = 0;
$(all).each(function (index, value) {
// console.log($(value));
if (value.startsWith("producttype-") && value != "producttype-") {
$("#filterselect-" + value.replace('producttype-', '')).addClass("available");
typesfound++;
}
});
// console.log("FOUND " + typesfound);
$("#type_filter").show();
if ($("#filter-available").length > 0) {
$("#type_filter").show();
$("#filter-available").addClass("available");
$("#filter-available").click(function () {
$(this).toggleClass("active");
$(".enabled-0").toggle();
});
}
if (typesfound > 0) {
$("#type_filter").show();
$(".filterselect_icon,.filterselect").click(function () {
if ($(this).hasClass("active")) {
$(".filterselect_icon,.filterselect").removeClass("active");
$(".product-row").show();
$(".product-row").removeClass("dont-show");
} else {
$(".filterselect_icon,.filterselect").removeClass("active");
$(".product-row").addClass("dont-show");
var activeid = $(this).attr("id");
setTimeout(function () {
$(".product-row").hide();
$(".producttype-" + activeid.replace('filterselect-', '')).show().removeClass("dont-show");
}, 300);
$(this).addClass("active");
}
// $(this).toggleClass("active");
});
}
}
}
}
function initSellFormRequests(submiturl) {
//alert('init SFR')
$("#form-sell-request").on("submit", function(event){
event.preventDefault();
var formValues= $(this).serialize();
// console.log(submiturl)
// console.log(formValues);
firstname = $("#firstname")[0].value;
lastname = $("#lastname")[0].value;
if (firstname.length > 2) {
$("#firstname").removeClass("error");
if (lastname.length > 2) {
$("#lastname").removeClass("error");
if (isEmail($("#email").val())) {
$.post(submiturl, formValues, function(data){
// Display the returned data in browser
$("#additional-products .content").html(data);
});
} else
$("#email").addClass("error");
}
else
$("#lastname").addClass("error");
}
else $("#firstname").addClass("error");
});
}
function initProductButtons(which) {
if (typeof which == 'undefined')
which = ".button-addtocart";
// console.log("HICH IS" + which);
$(which).click(function () {
//CORONA Shutdown
// alert('Buchung nicht möglich.');
// return true;
// closeSafetyPackageBadges();
//var safetypackage = $(this).parent(".add-safety-package");
var pid = $(this).attr("pid");
var for_pid = $(this).attr("for_pid");
var pgid = $(this).attr("data-productgroup");
if (pgid == "0")
pgid = "";
Cookies.set("nocache", 1, {expires: 1});
// return true;
/*
****
*
* return tru = debugging / test;
*
*
****
*/
// console.log(this);
$.ajax({
url: base_url + "/cart/add",
curobj: this,
for_pid: for_pid,
pid: pid,
pgid: pgid,
method: "POST", //First change type to method here
data: {
product_id: pid,
for_product_id: for_pid,
},
success: function (response) {
// console.log($(this.curobj).parent(".product-row-cartaction").find(".in-cart"));
$(this.curobj).parent(".product-row-cartaction").find(".in-cart").toggleClass("hidden");
$(this.curobj).toggle();
productsincart = getProductsInCart(response);
response = getCartResult(response);
$("#cart-content").html(response);
// console.log($("#product-row-safetypackage-"+pid).parent());
//$("#product-row-safetypackage-" + pid).parent().show();
// console.log($(this.curobj).attr("id") + ": " + $(this.curobj).hasClass("add-additional-product"));
// alert("DONE" + pgid);
if (pgid.length >= 1 && which != ".add-additional-product") {
Cookies.set("nocache", 1, {expires: 1});
// console.log("Sent request " + this.for_pid + " " + this.pgid);
$.ajax({
url: base_url + "/products/additional",
method: "POST", //First change type to method here
data: {
for_product_id: this.pid,
productgroup: this.pgid
},
success: function (response) {
//alert("DONE");
// console.log(response.length);
if (response.length > 0) {
startAdditionalOverlay(response);
/*$("#additional-products .content").html(response);
$("#additional-overlay-container").show();
$("#additional-products .close-additional").click(function () {
$("#additional-overlay-container").hide();
});*/
}
initProductButtons(".add-additional-product");
// console.log(response);
},
error: function (response) {
alert("error " + response);
}
});
// console.log("ENd Sent request");
}
// initProductButtons();
initCartButtons();
updateCartNotification(productsincart);
// console.log("end success");
},
error: function () {
// alert("error");
}
});
});
/*
$(".button-add-safety-package").click(function () {
var pid = $(this).attr("pid");
var for_pid = $(this).attr("for_pid");
// console.log("remove " + pid + " fp:" + for_pid);
// alert("SUCCESS");
$.ajax({
url: base_url + "/cart/add",
method: "POST", //First change type to method here
data: {
product_id: pid,
for_product_id: for_pid,
},
success: function (response) {
productsincart = getProductsInCart(response);
response = getCartResult(response);
$("#cart-content").html(response);
initCartButtons();
updateCartNotification(productsincart);
$(".add-safety-package").hide();
closeSafetyPackageBadges();
},
error: function () {
// alert("error");
}
});
});*/
if ($(".sell-badge").length > 0) {
// console.log("Found Changebike);
$(".sell-badge").click(function () {
var for_pid = $(this).attr("for_pid");
var processurl = base_url + "/bi/getsellinfo/" + for_pid+"/process";
$.ajax({
type: "GET",
dataType: ' text',
url: base_url + "/bi/getsellinfo/" + for_pid,
success: function (response) {
startAdditionalOverlay(response);
initSellFormRequests(processurl);
},
error: function () {
}
});
});
}
$(".button-removefromcart").click(function () {
// console.log("REMOVE");
var pid = $(this).attr("pid");
var for_pid = $(this).attr("for_pid");
// console.log("remove2 " + pid + " fp:" + for_pid);
// alert("SUCCESS");
var buttonclicked = this;
$.ajax({
url: base_url + "/cart/remove",
method: "POST", //First change type to method here
data: {
product_id: pid, // Second add quotes on the value.
for_product_id: for_pid, // Second add quotes on the value.
},
success: function (response) {
// console.log("SUCCESS " + response);
// alert("SCUCESS");
if ($(buttonclicked).hasClass("button-checkout")) {
self.location.href = base_url + "/checkout";
return false;
} else {
productsincart = getProductsInCart(response);
response = getCartResult(response);
$("#cart-content").html(response);
initCartButtons();
updateCartNotification(productsincart);
}
},
error: function () {
// alert("error");
self.location.href = base_url + "/checkout";
return false;
}
});
});
/*
$("#checkout-cart .button-removefromcart").click(function () {
var pid = $(this).attr("pid");
// console.log("remove " + pid);
console.log("remove check" + pid);
$.ajax({
url: base_url + "/cart/remove",
method: "POST", //First change type to method here
data: {
product_id: pid, // Second add quotes on the value.
},
success: function (response) {
productsincart = getProductsInCart(response);
response = getCartResult(response);
$("#cart-content").html(response);
initCartButtons();
updateCartNotification(productsincart);
},
error: function () {
// alert("error");
}
});
});*/
}
function checkAgreements() {
var agb = document.getElementById("agree-agb");
var dsgvo = document.getElementById("agree-dsgvo");
var rent = document.getElementById("agree-rent");
var external = document.getElementById("agree-externalagreement");
// alert($("#additionalinfos").val().length);
// Get the output text
var text = document.getElementById("pay-now-container");
var options = document.getElementsByName('paymentoption');
var selectedoption = "";
for (var i = 0; i < options.length; i++) {
if (options[i].checked) {
selectedoption = options[i].value;
}
}
// console.log("checking SO:" + selectedoption + " " + agb.checked + " " + dsgvo.checked + " " + rent.checked);
// If the checkbox is checked, display the output text
if (($("#agree-externalagreement").length <= 0 || ($("#agree-externalagreement").length > 0 && external.checked == true)) && agb.checked == true && dsgvo.checked == true && rent.checked == true && selectedoption != "") {
$("#pay-now-container").removeClass("hideit");
$("#data-missing").addClass("hideit");
return true; // = valid
// text.style.display = "block";
} else {
//text.style.display = "none";
$("#data-missing").removeClass("hideit");
$("#pay-now-container").addClass("hideit");
return false; // = not valid
}
}
function validateCheckout() {
valid = false;
valid = validateCustomerInfo(false);
valid = checkAgreements();
var external = document.getElementById("agree-externalagreement");
if ($("#additionalinfos").val().length < 5 && external.checked == true) {
valid = false;
$("#additionalinfos").addClass("error");
}
//valid = true; // debuggin
if (valid == true) {
}
return valid;
}
var cart;
$(document.body).on('touchmove', onScroll); // for mobile
$(window).on('scroll', onScroll);
// callback
function onScroll() {
//if (window.matchMedia('(min-width: 1025px)').matches) #
{
if ($(document).scrollTop() >= 50) {
// user scrolled 50 pixels or more;
// do stuff
$("body").addClass("scrolled");
} else {
$("body").removeClass("scrolled");
}
}
if ($(window).scrollTop() + window.innerHeight >= document.body.scrollHeight) {
}
}
function validateEmail(email) {
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
}
$(document).scroll(function () {
});
function hideNLPopup() {
// alert("HIDE IT");
Cookies.set("nlshown", 1, {expires: 4});
}
$(window).load(function () {
var newsletter_shown = Cookies.get("nlshown");
var newsletter_registered = Cookies.get("nlreged");
if (typeof newsletter_shown == 'undefined')
newsletter_shown = 0;
if (typeof newsletter_registered == 'undefined')
newsletter_registered = 0;
$("#sib-form-submit").on("click", function () {
// alert("SUBTM MIT");
if (validateEmail($("#EMAIL").val()) && $('#OPT_IN').is(':checked')) {
$("#sib-form").submit();
hideNLPopup();
Cookies.set("nlreged", 1, {expires: 365});
}
});
newsletter_shown = 1; // END
if (!window.location.pathname.endsWith("newsletter-gewinnspiel") && newsletter_shown <= 0 && newsletter_registered <= 0) {
newsletter_shown++;
$("#close-popup").click(function () {
$("#newsletter-popup").hide();
hideNLPopup();
});
setTimeout(function () {
// $("#cart-notification").removeClass('pulsate');
$("#newsletter-popup").show();
// hideNLPopup();
hideNLPopup();
}, 10000);
}
if ($(".testimonials").length > 0) {
var testimonials_carousel = $('.testimonials');
testimonials_carousel.owlCarousel({
items:4,
loop:true,
margin:20,
autoplay:true,
autoplayTimeout:3000,
autoplayHoverPause:true
});
}
if ($(".banner").length > 0) {
// console.log("INIT CAROUSEL ");
const $owlCarousel = $('.banner').owlCarousel({
items: 1,
margin: 0,
autoplay: true,
autoPlay: 4000,
nav: false,
dots: true,
autoplayTimeout: 5000,
loop: true,
stagePadding: 0,
onChanged: function (e) {
// console.log("onchanged")
$(".owl-slide-animated, .enjoy, .your-ride").removeClass("is-transitioned");
const $currentOwlItem = $(".owl-item").eq(e.item.index);
setTimeout(function () {
$currentOwlItem.find(".owl-slide-animated").addClass("is-transitioned");
// $("section").show();
},
3000
)
;
setTimeout(function () {
$currentOwlItem.find(".enjoy").addClass("is-transitioned");
//$("section").show();
},
1500
)
;
setTimeout(function () {
$currentOwlItem.find(".your-ride").addClass("is-transitioned");
//$("section").show();
},
2100
)
;
/*
$currentOwlItem.find(".owl-slide-animated").addClass("is-transitioned");
$currentOwlItem.find(".enjoy").addClass("is-transitioned");
$currentOwlItem.find(".your-ride").addClass("is-transitioned");*/
},
onInitialized: function () {
// console.log("ON INIT CAROU");
setTimeout(function () {
$(".owl-item.active .owl-slide-animated"
).addClass("is-transitioned");
// $("section").show();
},
3000
)
;
setTimeout(function () {
$(".owl-item.active .enjoy"
).addClass("is-transitioned");
//$("section").show();
},
1500
)
;
setTimeout(function () {
$(".owl-item.active .your-ride"
).addClass("is-transitioned");
//$("section").show();
},
2100
)
;
}
})
;
/*
console.log($owlCarousel);
console.log($(".owl-carousel"));
$(".owl-carousel").on("initialized.owl.carousel", () => {
console.log("ON INIT CAROU");
setTimeout(() => {
$(".owl-item.active .owl-slide-animated").addClass("is-transitioned");
$("section").show();
// console.log("SHOW TRANS");
}, 3000);
setTimeout(() => {
$(".owl-item.active .enjoy").addClass("is-transitioned");
$("section").show();
}, 1500);
setTimeout(() => {
$(".owl-item.active .your-ride").addClass("is-transitioned");
$("section").show();
}, 2100);
});
$owlCarousel.on("changed.owl.carousel", e => {
console.log("ON CHANGE CAROU");
$(".owl-slide-animated, .enjoy, .your-ride").removeClass("is-transitioned");
const $currentOwlItem = $(".owl-item").eq(e.item.index);
$currentOwlItem.find(".owl-slide-animated").addClass("is-transitioned");
$currentOwlItem.find(".enjoy").addClass("is-transitioned");
$currentOwlItem.find(".your-ride").addClass("is-transitioned");
});
*/
}
$("#splashscreen").hide();
});
function initChangeTimeProcessing() {
if ($("#process-change-time").length > 0) {
$("#process-change-time").click(function () {
var changeurl = $(this).attr('data-url');
//console.log("ULR " + changeurl);
// alert($("#datefrom").val());
if (changeurl.length > 0) {
datefrom =$("#datefrom").val();
dateuntil =$("#dateuntil").val();
if(datefrom.length <= 0)
{
datefrom =$("#datefrom-input").val();
dateuntil =$("#dateuntil-input").val();
}
/* console.log(datefrom);
console.log(dateuntil);
var date1 = new Date(datefrom);
var date2 = new Date(dateuntil);
console.log(date1);
console.log(date2);
// if(date1 < date2)
alert();
exit();*/
$.ajax({
url: changeurl,
method: "POST", //First change type to method here
data: {
type : "process",
from: datefrom,
until: dateuntil, // Second add quotes on the value.
},
success: function (response) {
$("#additional-products .content").html(response);
$("#additional-overlay-container").show();
$("#additional-products .close-additional").click(function () {
$("#additional-overlay-container").hide();
});
return false;
},
error: function () {
}
});
//else
// alert("Bitte gültige Zeiten eingeben.");
}
});
}
}
function startAdditionalOverlay(content)
{
$("#additional-products .content").html(content);
initCheckCard();
$("#additional-overlay-container").show();
$("#additional-products .close-additional").click(function () {
$("#additional-overlay-container").hide();
});
}
function showProgress() {
// $('.progress-bar').width('83%');
// $('.node__5').addClass('node--active').prevAll('.node').addClass('node--complete');
}
$(document).ready(function () {
$("#form_search_bikes_submit").click(function(){
$("#product-container-results .search-results,.form_search_bikes_submit-container").hide("slow");
$("#product-container-results #loading-search-results").show();
catid = $(".category-container").attr("data-cat-id");
datefrom =$("#f_from").val().replace(/\s/g, '+');
dateuntil =$("#f_until").val().replace(/\s/g, '+');
if(catid > 0)
{
$.ajax({
type: "GET",
dataType:' text',
url: base_url + "/bi/bikes/search/"+ catid + "/"+datefrom+"/"+dateuntil+"/list",
// data: 'name=' + $(this).val(),
beforeSend: function() {
},
success: function(data) {
//alert(data);
$("#product-container-results .search-results").html(data);
$("#product-container-results #loading-search-results").hide();
$("#product-container-results .search-results, .form_search_bikes_submit-container").show("slow");
//initSellFormRequests();
initProductButtons();
initFilterButtons();
},
error: function(xhr, status, error) {
//$("#product-container-results .search-results").html(xhr.responseText);
//alert(xhr.responseText);
// var err = eval("(" + xhr.responseText + ")");
// alert(err.Message);
}
});}
else console.log("no catid for searching");
// alert("Search for it");
return false;
});
$("#form_search_bikes_submit").trigger("click");
if ($('.print-page').length > 0) {
$('.print-page').click(function () {
window.print();
});
}
if (window.location.href.indexOf("mieten/") > -1) { // etc
Cookies.set("nocache", 1, {expires: 1});
}
if ($('.iframe-btn').length > 0)
$('.iframe-btn').fancybox({
'width': 900,
'height': 600,
'type': 'iframe',
'autoScale': false
});
$(".admin-submenu-headline").click(function(){
$(this).siblings(".admin-submenu").toggle();
});
if ($("#partner-footer .partner").length > 0 && typeof $('#partner-footer').owlCarousel !== "undefined") {
// console.log("init pf");
$('#partner-footer').owlCarousel({
loop: true,
margin: 40,
nav: true,
autoplay: true,
autoplayTimeout: 3000,
autoplayHoverPause: true,
responsive: {
0: {
items: 2
},
600: {
items: 4
},
1000: {
items: 6
},
1400: {
items: 8
}
}
});
}
if ($("#booking-container-bikes").length > 0)
initTimeSelection();
$("#sib-form-submit").on("click", function () {
});
if($("#bikestatus").length > 0)
$("#loading-search-results").hide();
$("#map-activator").on("click", function () {
$("#map, #map-activator .on, #map-activator .off").toggle();
});
$(".mobile-category-info-icon").click(function () {
$(this).find("span").toggle();
$(".mobile-category-info, .category-info").toggle();
});
$(".notification-badge").click(function () {
$(".notification-badge > div").toggle();
$(".notification-overlay").toggle();
});
$("#main-menu-switch").click(function () {
$("#cart").hide();
$("#navigation_main").toggleClass("is-active");
$("#main-menu-switch").toggleClass("is-active");
});
$("#main-admin-switch").click(function () {
$("#cart").hide();
$("#admin-navi").toggleClass("is-active");
$("#main-admin-switch").toggleClass("is-active");
});
$("#delcoupon").click(function () {
// console.log("delco");
$.ajax({
url: base_url + "/cart/remove",
method: "POST",
data: {
product_id: "coupons", // Second add quotes on the value.
},
success: function (response) {
//$("#fullcart-content").html(response);
location.reload();
},
error: function () {
// alert("error");
location.reload();
}
});
});
function checkPriceToPay() {
if ($("#paymentoption_free").length > 0) {
// alert("CHECK PTP");
pricetopay = parseFloat($("#fullcart-content #pricetopay").text().replace(',', '.'));
//console.log(pricetopay);
// alert(pricetopay);
if (pricetopay == 0) {
//console.log("show it");
setTimeout(function () {
$("#paymentoption_free_container").removeClass("hide");
$("#paymentoption_free").prop('checked', true);
}, 1000);
setTimeout(function () {
$(".paymentoption_money").addClass("hide");
}, 1000);
// setTimeout(
} else {
setTimeout(function () {
$(".paymentoption_money").removeClass("hide");
}, 1000);
setTimeout(function () {
$("#paymentoption_free_container").addClass("hide");
}, 1000);
}
}
// else console.log("Free not found");
}
$("#checkcoupon").click(function () {
// console.log($("#coupon").val());
if ($("#coupon").val().length > 3) {
// self.location.href="/checkout/coupon/" + $("#coupon").val();
Cookies.set("nocache", 1, {expires: 1});
$.ajax({
url: base_url + "/cart/add",
method: "POST", //First change type to method here
data: {
coupon: $("#coupon").val(),
product_id: -10, // Second add quotes on the value.
},
success: function (response) {
$("#fullcart-content").html(response);
checkPriceToPay();
// if($().val() == 0)
// location.reload();
},
error: function () {
// alert("error");
// location.reload();
}
});
}
checkPriceToPay();
// alert();
});
checkPriceToPay();
// alert("INIT READY");
$("#splashscreen").on("click", function () {
$(this).hide();
});
setTimeout(function () {
$('#splashscreen').hide();
}, 6000);
$(".booking-container > .container-head,.collapsible-container > .container-head").on("click", function () {
$(this).toggleClass("collapsed");
$(this).parent().find(".collapsible").toggleClass("hidden");
$(this).parent().find(".fa").toggleClass("hidden");
});
if ($(".expanding-box-header").length > 0)
$(".expanding-box-header").on("click", function () {
//console.log("click");
$(this).parent().find(".expanding-box-text").toggleClass("expanded");
$(this).find(".expanding-icons").find(".minus").toggle();
$(this).find(".expanding-icons").find(".plus").toggle();
var boxoffset = $(this).offset().top + 200;
$('html,body').animate({scrollTop: boxoffset}, 700, 'swing');
});
/*
OLD BANNER
*/
/*
setTimeout(function () {
$(".overlay.animate").animate({
opacity: 1
}, {duration: 700});
setTimeout(function () {
$(".booking-button").animate({
opacity: 1
}, {duration: 700});
}, 2500);
}, 2500);
*/
// $('#bike_search_from').datetimepicker('setStartDate', "'" + currentdate.getFullYear() + ":" + currentdate.getMonth() + ":" + currentdate.getDay() + ":" + currentdate.getHours() + ":" + currentdate.getMinutes() + ":" + currentdate.getSeconds());
$("#payment-information input").change(function () {
// alert("HCNAGE");
$("#button-paymentoptions-next").show();
});
if ($("#customer-information .button-next").length > 0)
validateCustomerInfo(true);
$(".checkout-agreement input, .paymentoption").click(function () {
checkAgreements();
});
$('.checkout').on('submit', function (e) {
// console.log("submit it");
//console.log($("#confirm-information .container-content").is(':visible'));
if ($("#confirm-information .container-content").css('display', 'none') == true) {
e.preventDefault();
// console.log("no submit");
} else {
//e.preventDefault();
// console.log("do submit");
// this.submit();
}
// if(!$("").is(":visble"))
/* var len = $('#username').val().length;
if (len < 6 && len > 1) {
this.submit();
}*/
});
$("#pay-now").click(function () {
if (validateCheckout() == true) {
//alert("now");
//return false;
return true;
} else {
return false;
}
});
$("#customer-information .button-next").click(function () {
if (validateCustomerInfo(false) == true) {
$('#payment-information .content').show();
$('html, body').animate({scrollTop: $('#payment-information').offset().top}, 200);
}
//validateCheckAgreements();
});
$(document).on('focus', '#email', function () {
$(this).addClass('input2').removeClass('input1');
});
if ($('#customer-information .content').length > 0) {
$('input:radio[name="paymentoption"]').change(
function () {
console.log($(this).val());
if ($(this).is(':checked') && $(this).val() == 'genusscard') {
$("#genusscardno").show();
} else $("#genusscardno").hide();
});
$('#customer-information input').focus(function () {
$(this).removeClass("error");
});
$(document).on('blur', '#email', function () {
// validateCustomerInfo(false);
//console.log("CHECK USERNAME");
if (isEmail($("#email").val())) {
check_username($("#email").val());
$("#email").removeClass("error");
} else
$("#email").addClass("error");
//$(this).addClass('input1').removeClass('input2');
});
$(document).on('blur', '#town', function () {
validateCustomerInfo(false);
});
/* $('#customer-information .content').show();
$("#email").on('blur', function () {
check_username($(this).val());
});*/
// $('#customer-information .content').hide();
}
initProductButtons();
//initSellFormRequests();
$("#button-cart-empty").click(function () {
$.ajax({
url: base_url + "/cart/remove",
method: "POST",
data: {product_id: "all",},
success: function (response) {
$("#cart-content").html(response);
}
});
});
if ($(".viewselect_icon").length > 0) {
// console.log("ICONS found");
$("#viewselect_list").on("click", function () {
$(".viewselect_icon").removeClass("active");
$(this).addClass("active");
$(".booking-container").removeClass("view-grid");
$(".booking-container").addClass("view-list");
});
$("#viewselect_grid").on("click", function () {
$(".viewselect_icon").removeClass("active");
$(".booking-container").addClass("view-grid");
$(".booking-container").removeClass("view-list");
});
}
$(".cart-icon").click(function () {
$("#login-form").hide();
$("#cart").toggle();
});
$("#showlogin").click(function () {
$("#cart").hide();
$("#login-form").toggle();
return false;
});
if ($('#flash-message').length > 0) {
// $("#flash-message").addClass("pulsate");
$('#flash-message').click(function () {
$(this).hide();
});
setTimeout(function () {
$('#flash-message').hide();
}, 10000);
}
}
)
;
}());