listojs
Version:
a package for restaurant management
501 lines (406 loc) • 17 kB
JavaScript
var locale = getLocale();
var release = 0;
const calledPage = getUrlVars()['page'];
const calledLanguage = getUrlVars()['lang'];
const LanguageSelect = {
pre: '<div class="row"><div class="col-md-12"><div class="box" style="overflow: hidden; height: 300px;">'
+ '<form id="langForm"><!--select name="lang" id="langSelect"--><fieldset name="lang" id="langSelect">',
suf: '</fieldset><!--/select--></form></div></div></div>',
};
const languageSelect = [{
"id": "en",
"name": "English"
}, {
"id": "de",
"name": "Deutsch"
}, {
"id": "it",
"name": "Italiano"
}];
var footerAnimate = function () {
var faq = $('#fh5co-footer');
if (faq.length > 0) {
faq.waypoint(function (direction) {
if (direction === 'down' && !$(this.element).hasClass('animated')) {
var sec = faq.find('.to-animate').length,
sec = parseInt((sec * 200));
setTimeout(function () {
faq.find('.to-animate').each(function (k) {
var el = $(this);
setTimeout(function () {
el.addClass('fadeInUp');
}, k * 200, 'easeInOutExpo');
});
}, 100);
setTimeout(function () {
faq.find('.to-animate-2').each(function (k) {
var el = $(this);
setTimeout(function () {
el.addClass('fadeInUp');
}, k * 200, 'easeInOutExpo');
});
}, sec);
//$(this.element).addClass('animated');
}
}, {offset: '80%'});
}
};
var faqAnimate = function () {
var faq = $('section');
if (faq.length > 0) {
faq.waypoint(function (direction) {
if (direction === 'down' && !$(this.element).hasClass('animated')) {
var sec = faq.find('.to-animate').length,
sec = parseInt((sec * 20));
setTimeout(function () {
faq.find('.to-animate').each(function (k) {
var el = $(this);
setTimeout(function () {
el.addClass('fadeInUp');
}, k * 20, 'easeInOutExpo');
});
}, 100);
setTimeout(function () {
faq.find('.to-animate-2').each(function (k) {
var el = $(this);
setTimeout(function () {
el.addClass('fadeInUp');
}, k * 20, 'easeInOutExpo');
});
}, sec);
//$(this.element).addClass('animated');
}
}, {offset: '80%'});
}
};
faqAnimate();
$(document)
.on(
'click',
'#set-language',
function () {
var rowDiv = LanguageSelect.pre;
$
.each(
languageSelect,
function (key, lang) {
rowDiv += `<input type="radio" name = "language" id="${lang.id}" style="width:3em;"> ${lang.name}`;
});
rowDiv += LanguageSelect.suf;
$('#fh5co-faq').find('.languageFormRow').html(rowDiv);
jQuery('section.customsection').each(function () {
$(this).addClass('hide');
});
jQuery('#fh5co-faq').removeClass('hide');
$('.listCategories li').each(function () {
$(this).removeClass('activeNavItem');
$(this).removeClass('active');
});
$(this).parent('li').addClass('activeNavItem');
});
function setTexts() {
setElemText(47);
setElemText(225);
setElemText(614);
setElemText(615);
setElemText(713);
setElemText(723);
setElemText(735);
}
getcategories();
setTexts();
const ULStyle = {
listart: '<li>',
lianchorstart: '<a href="javascript:void(0);" class="navcategory" data-categoryid="',
datadescription: '" data-description="',
datasection: '" data-nav-section="',
datacatstyle: '" data-idcatstyle="',
lianchorspanclose: '"><span>',
lianchorclose: '</span</a>',
liclose: '</li>',
liwithclassactive: '<li class="active">',
elements: [],
};
const DIVstyle1 = {
boxdivstart: '<div class="col-md-3 style1">',
serviceboxdivstart: '<div class="box-services">',
imageBoxdiv: '<div class="product-image to-animate">',
imagetagstart: '<img src="',
imagetagclose: '" /> ',
productdivstart: '<div class="fh5co-post to-animate">',
h3tagstart: '<h3>',
h3tagclose: '</h3>',
ptagstart: '<p>',
ptagclose: '</p>',
divClose: '</div>',
elements: [],
};
/*
const DIVstyle1 = {
boxdivstart: '<div class="col-md-3 text-center style1">',
serviceboxdivstart: '<div class="box-services">',
imageBoxdiv: '<div class="product-image to-animate">',
imagetagstart: '<img src="',
imagetagclose: '" style="max-width: 300px; max-height: 150px; padding-right: 10px; padding-left: 10px;" /> ',
productdivstart: '<div class="fh5co-post to-animate">',
h3tagstart: '<h3>',
h3tagclose: '</h3>',
ptagstart: '<p>',
ptagclose: '</p>',
divClose: '</div>',
elements: [],
};*/
const DIVstyle2 = {
boxdivstart: '<div class="col-md-4">',
gridboxdivstart: '<div class="project-grid to-animate-2" style="background-image: url(',
backgroundimageclose: ');">',
productdivstart: '<div class="desc" style="padding-left:2em; padding-right:2em;">',
h3tagstart: '<h3>',
h3tagclose: '</h3>',
anchorstart: '<a><i class="glyphicon glyphicon-hand-right"> ',
anchorclose: '</i> </a>',
spanstart: '<span>',
spanclose: '</span>',
ptagstart: '<p>',
ptagclose: '</p>',
divClose: '</div>',
elements: [],
};
const DIVstyle3 = {
boxdivstart: '<div class="col-md-3 col-sm-6">',
priceboxdivstart: '<div class="price-box to-animate" style="height:400px;">',
imageBoxdiv: '<div class="price">',
imagetagstart: "<img src='",
imagetagclose: "' />",
h2tagstart: '<h2 class="pricing-plan">',
h2tagclose: '</h2>',
ptagstart: '<p style="text-align:left; font-size:16px;">',
ptagclose: '</p>',
divClose: '</div>',
elements: [],
};
const DIVstyle4 = {
boxdivstart: '<div class="col-md-4">',
gridboxdivstart: '<div class="project-grid to-animate-2" style="background-image: url(',
backgroundimageclose: ');">',
productdivstart: '<div class="desc">',
h3tagstart: '<h3>',
h3tagclose: '</h3>',
anchorstart: '<a href="',
anchorclose: '"><i class="icon-columns2"></i></a>',
spanstart: '<span>',
spanclose: '</span>',
ptagstart: '<p>',
ptagclose: '</p>',
divClose: '</div>',
elements: [],
};
function getcategories() {
var navHtml = '';
apiCall_listorante_public_categories(function (data) {
for (let i = 0; i < data.count; i++) {
if (data.rows[i].s[13] === "1") {
var idcatstyle = data.rows[i].s[12];
if (i === 0) {
navHtml += ULStyle.liwithclassactive + ULStyle.lianchorstart + data.rows[i].s[1] + ULStyle.datadescription + data.rows[i].s[2] + ULStyle.datasection + data.rows[i].s[11] + ULStyle.datacatstyle + data.rows[i].s[12] + ULStyle.lianchorspanclose + data.rows[i].s[11] + ULStyle.lianchorclose + ULStyle.liclose;
jQuery('section.style' + idcatstyle).find('.cat_description').text(data.rows[i].s[2]);
jQuery('section.style' + idcatstyle).find('.cat_title').text(data.rows[i].s[11]);
jQuery('section.style' + idcatstyle).attr("data-section", data.rows[i].s[11]);
showProducts(data.rows[i].s[1], data.rows[i].s[12]);
} else {
navHtml += ULStyle.listart + ULStyle.lianchorstart + data.rows[i].s[1] + ULStyle.datadescription + data.rows[i].s[2] + ULStyle.datasection + data.rows[i].s[11] + ULStyle.datacatstyle + data.rows[i].s[12] + ULStyle.lianchorspanclose + data.rows[i].s[11] + ULStyle.lianchorclose + ULStyle.liclose;
}
}
}
jQuery('ul.listCategories').prepend(navHtml);
}, function (err) {
debug("ERROR:", release, err);
});
}
function showProducts(catID, idcatstyle) {
apiCall_listorante_public_product(catID, function (products) {
productsHtml = '';
for (var j = 0; j < products.count; j++) {
if (idcatstyle == '1') {
productsHtml += DIVstyle1.boxdivstart + DIVstyle1.serviceboxdivstart + DIVstyle1.imageBoxdiv + DIVstyle1.imagetagstart + getImagePath() + '/' + products.rows[j].s[5] + DIVstyle1.imagetagclose + DIVstyle1.divClose + DIVstyle1.productdivstart + DIVstyle1.h3tagstart + products.rows[j].s[2] + DIVstyle1.h3tagclose + DIVstyle1.ptagstart + products.rows[j].s[8] + DIVstyle1.ptagclose + DIVstyle1.divClose + DIVstyle1.divClose + DIVstyle1.divClose;
} else if (idcatstyle == '2') {
productsHtml += DIVstyle2.boxdivstart + DIVstyle2.gridboxdivstart + getImagePath() + '/' + products.rows[j].s[5] + DIVstyle2.backgroundimageclose + DIVstyle2.productdivstart + DIVstyle2.h3tagstart + DIVstyle2.anchorstart + products.rows[j].s[2] + DIVstyle2.anchorclose + DIVstyle2.h3tagclose + DIVstyle2.spanstart + products.rows[j].s[8] + DIVstyle2.spanclose + DIVstyle2.divClose + DIVstyle2.divClose + DIVstyle2.divClose;
} else if (idcatstyle == '3') {
productsHtml += DIVstyle3.boxdivstart + DIVstyle3.priceboxdivstart + DIVstyle3.h2tagstart + products.rows[j].s[2] + DIVstyle3.h2tagclose + DIVstyle3.imageBoxdiv + DIVstyle3.imagetagstart + getImagePath() + '/' + products.rows[j].s[5] + DIVstyle3.imagetagclose + products.rows[j].s[8] + DIVstyle3.divClose + DIVstyle3.ptagstart + products.rows[j].s[3] + DIVstyle3.ptagclose + DIVstyle3.divClose + DIVstyle3.divClose;
}
}
//console.log(productsHtml);
jQuery('section.style' + idcatstyle).find('.productsRow').html(productsHtml);
jQuery('section.customsection').each(function () {
$(this).addClass('hide');
});
jQuery('section.style' + idcatstyle).removeClass('hide');
jQuery('section.style' + idcatstyle).fadeIn('slow');
}, function (err) {
debug("ERR", release, err);
});
}
function loadcategorydata(catID, cat_title, cat_description, idcatstyle) {
jQuery('.cat_description').text(cat_description);
jQuery('.cat_title').text(cat_title);
jQuery('section.style' + idcatstyle).attr("data-section", cat_title);
// jQuery('.cat_description').parents('section').attr("data-section",cat_title);
jQuery('.cat_description').parents('section').removeClass('animated');
// jQuery('.cat_description').parents('section').addClass('to-animate');
jQuery('.cat_title').parents('section').removeClass('animated');
// jQuery('.cat_title').parents('section').addClass('to-animate');
showProducts(catID, idcatstyle);
jQuery('.navbar-header .js-fh5co-nav-toggle').trigger('click');
faqAnimate();
}
jQuery(document).ready(function () {
var customerid = getUrlVars()['cust'];
var release = 2;
//console.log('check----' + customerid);
if (customerid == '9' || customerid == 9) {
} else {
const errText = getTextById(404);
const errorMessageTxt = document.getElementById('errorMessageID');
//console.log("errorMessageTxt-Object: " + errorMessageTxt);
if (errorMessageTxt) errorMessageTxt.innerText = errText;
if (customerid) window.open("err.html?lang=" + locale, "_self");
}
jQuery('#registerbutton').on('click', function () {
jQuery('section.customsection').each(function () {
$(this).addClass('hide');
});
jQuery('#fh5co-trusted').removeClass('hide');
$('.listCategories li').each(function () {
$(this).removeClass('activeNavItem');
$(this).removeClass('active');
});
$(this).parent('li').addClass('activeNavItem');
});
jQuery('#loginbutton').on('click', function () {
jQuery('section.customsection').each(function () {
$(this).addClass('hide');
});
jQuery('#fh5co-faq').removeClass('hide');
$('.listCategories li').each(function () {
$(this).removeClass('activeNavItem');
$(this).removeClass('active');
});
$(this).parent('li').addClass('activeNavItem');
});
});
jQuery(document).on('click', '.navcategory', function () {
$('.listCategories li').each(function () {
$(this).removeClass('activeNavItem');
$(this).removeClass('active');
});
$(this).parent('li').addClass('activeNavItem');
var catID = $(this).data('categoryid');
var cat_title = $(this).data('nav-section');
var cat_description = $(this).data('description');
var idcatstyle = $(this).data('idcatstyle');
loadcategorydata(catID, cat_title, cat_description, idcatstyle);
showSections();
});
jQuery(document).on('click', '#set-language', function () {
var rowDiv = LanguageSelect.pre;
$.each(
language,
function (key, lang) {
rowDiv += `<li><input type="radio" name = "language" id="${lang.id}" style="width:3em;"> ${lang.name}</li>`;
});
rowDiv += LanguageSelect.suf;
console.log("language-rowDiv: " + rowDiv);
$('.languageFormRow').html(rowDiv);
jQuery('.navbar-header .js-fh5co-nav-toggle').trigger('click');
});
$(document).on('change', '#langSelect', function () {
const radios = document.getElementsByName('language');
document.getElementById('fh5co-faq').focus();
let i = 0;
const length = radios.length;
for (; i < length; i++) {
if (radios[i].checked) {
// do whatever you want with the checked radio
const href = new URL(location.href);
href.searchParams.set('lang', radios[i].id);
location.href = href.toString();
// only one radio can be logically checked, don't check the rest
break;
}
}
});
function includeHTML(page,language) {
let includedHtml = document.getElementById("includedHTML");
let xhttp = new XMLHttpRequest();
/* Make an HTTP request using the attribute value as the file name: */
xhttp.onreadystatechange = function() {
if (this.readyState == 4) {
let closeTag = '<br><p id ="includedHTMLCloseButton"><a href="javascript:void(0)" class="closeIncludedHTML"><i class="glyphicon glyphicon-remove"></i></a></p>';
if (this.status == 200) {
console.log("including page '"+ page+".html'");
includedHtml.innerHTML = closeTag+this.responseText + "<br>";
}
if (this.status >= 400) {
if (!language) {
includeHTML(page,locale);
}
else if (languageIsAvailable(locale)){
let ERRTEXT = getLocaleTextById(this.status);
if (ERRTEXT) includedHtml.innerHTML = closeTag +"<strong>"+ERRTEXT + " ("+page+".html)</strong><br><br><br>";
else includedHtml.innerHTML = closeTag + "<strong>ERROR "+this.status+": ("+page+".html)</strong><br><br><br>";
}
else {
// This should never occur
includedHtml.innerHTML = closeTag + "ERROR "+this.status + "<br><br><br>";
}
}
}
};
let url;
if (languageIsAvailable(language)) url = page+"_"+language+".html";
else url = page+".html";
xhttp.open("GET",url,true);
/* Exit the function: */
xhttp.send();
hideSections();
return;
}
jQuery(document).on(
'click',
'.refresh',
function(){
const lg = $(this).data("language");
includeHTML(calledPage,lg);
});
function showSections(){
document.getElementById("includedHTML").innerHTML = "";
//let section1 = document.getElementById("fh5co-services");
let section2 = document.getElementById("hideforInclude");
let section2b = document.getElementById("hideforInclude2");
//let section3 = document.getElementById("fh5co-pricing");
//section1.hidden=false;
section2.hidden=false;
section2b.hidden=false;
//section3.hidden=false;
}
function hideSections(){
//let section1 = document.getElementById("fh5co-services");
let section2 = document.getElementById("hideforInclude");
let section2b = document.getElementById("hideforInclude2");
//let section3 = document.getElementById("fh5co-pricing");
//section1.hidden=true;
section2.hidden=true;
section2b.hidden=true;
//section3.hidden=true;
}
jQuery(document).on(
'click',
'.closeIncludedHTML',
function(){
showSections();
}
);
if (calledPage) {
includeHTML(calledPage, calledLanguage);
document.getElementById('includedHTML').focus();
}