UNPKG

listojs

Version:

a package for restaurant management

558 lines (468 loc) 21.2 kB
var locale = getLocale(); release = "d1a6f_3"; var customerid = getUrlVars()['cust']; const LanguageSelect = { pre: '<div><span><p>', suf: '</p></span></div>', }; const languageSelect = [{ "id": "en", "name": "English" }, { "id": "de", "name": "Deutsch" }, { "id": "it", "name": "Italiano" }]; function setLanguage(id) { locale = id; debug("setting language to " + id, release); console.log("setting language to " + id); apiCall_listorante_public_assignedtexts(getLayoutId(), function (data) { for (let k = 0; k < data.count; k++) { document.getElementById(data.rows[k].s[0]).innerText = data.rows[k].s[3]; } setTexts(); getcategories(); document.getElementById("languageDIV").innerHTML = ""; document.getElementById("fh5co-header").scrollIntoView(true); }, function (err) { showHttpErrorMessage("main-content", err); }); } /* 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(); 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 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">&nbsp;', anchorclose: '</i>&nbsp;</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: [], }; function getcategories() { let navHtml = ''; apiCall_listorante_public_categories(function (data) { if (data._rc > 0) { // showHttpErrorMessage("box0", data); document.getElementById("interstitial").innerHTML = "ERROR:" + data._rc; return; } else { document.getElementById("interstitial").innerHTML = "ERROR:" + data._rc; } jQuery('ul.listCategories').html(` <li class=" call-to-action"><a class="log-in" href="../adminLTE/access.html"> <span id="615">${getTextById(615)}</span> </a></li>`); 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); document.getElementById("interstitial").innerHTML = ""; }, function (err) { debug("ERROR:", release, err); showHttpErrorMessage("interstitial", err); }); } function showProducts(catID, idcatstyle) { apiCall_listorante_public_product(catID, function (products) { let 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(); hideTheIncludeSection(); } jQuery(document).ready(function () { 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); }); $(document) .on( 'click', '.set-currentLanguage', function () { console.log("select language clicked") let rowDiv = LanguageSelect.pre; $ .each( languageSelect, function (key, lang) { rowDiv += `<a href="javascript:void(0)" name="language" class="selectTheLanguage" data-lang="${lang.id}" >&nbsp;${lang.name}</a>&nbsp;`; }); rowDiv += LanguageSelect.suf; //$('#fh5co-footer').find('.languageDIV').html(rowDiv); document.getElementById("languageDIV").innerHTML = rowDiv; }); jQuery(document) .on( 'click', '.selectTheLanguage', function () { const id = $(this).attr('data-lang'); console.log("language clicked: " + id); setLanguage(id); hideTheIncludeSection(); }); function showTheIncludeSection() { //let section1 = document.getElementById("includedHTML"); //section1.hidden = false; let section2 = document.getElementById("fh5co-pricing"); let section3 = document.getElementById("fh5co-explore"); let section4 = document.getElementById("fh5co-services"); section2.hidden = true; section3.hidden = true; section4.hidden = true; } function hideTheIncludeSection() { let section1 = document.getElementById("includedHTML"); section1.innerHTML = ""; //section1.hidden = false; let section2 = document.getElementById("fh5co-pricing"); let section3 = document.getElementById("fh5co-explore"); let section4 = document.getElementById("fh5co-services"); section2.hidden = false; section3.hidden = false; section4.hidden = false; } jQuery(document).on( 'click', '.closeIncludedHTML', function () { hideTheIncludeSection(); } ); jQuery(document).on('click', '.callPage', function () { const calledPage = $(this).data("page"); let currentLanguage = locale; let calledLanguage = $(this).data("language"); if (!calledLanguage) { calledLanguage = locale; } embedHTML(calledPage, calledLanguage, "includedHTML"); showTheIncludeSection(); document.getElementById('includedHTML').scrollIntoView(true); locale = currentLanguage; }); jQuery(document).on('click', '.take-tour', function () { /*if ($("#sendMessageForm").valid()) { const mesg = document.getElementById("messageForListorante").value; debug("sending message", 0, mesg); } const closeCross = '<br><p id =\"includedHTMLCloseButton\"><a href=\"javascript:void(0)\" class=\"closeIncludedHTML\"><i class=\"glyphicon glyphicon-remove\"></i></a></p>'; apiCall_listorante_public_categories(function (data) { const tData = data; let stepsHtml = closeCross; for (let i = 0; i < 4; i++) { let rowArr = tData.rows[i].s; let imagePath = getImagePath() + '/' + rowArr[4]; stepsHtml += `${startHeadingTag('3', "", "", "style='display:none';")}${rowArr[8]}${endHeadingTag('3')}${startSection('to-animate', '', '')}${startHeadingTag('2', "project-grid to-animate-2", "", "style='display:none';")}${rowArr[10]}${endHeadingTag('2')}${startParagraph('', '', '')}${imageTag(imagePath, '', '', 'width=100')}${rowArr[2]}${endParagraph()}${endSection()}`; //stepsHtml +=rowArr[3]+imagePath; } listoHTML.createTour('#includedHTML', stepsHtml,'slideLeft','vertical'); }, function (err) { showHttpErrorMessage('includedHTML', err); });*/ //embedHTML(4, locale, 'includedHTML'); const context = $(this).data("page"); //const prevPage = $(this).data("prev"); //const nextPage = $(this).data("next"); const pageArray = [4, 5, 6] tourStepHtml(context, pageArray, function (sData, i) { const rem = i % 4; let str = `<div class="row">`; debug("rem", 0, rem, i); switch (rem) { case 0: str += `<div class="col-md-10 to-animate fadeInDown animated">${sData}</div>` break; case 1: str += `<div class="col-md-10 to-animate fadeInLeft animated">${sData}</div>` break; case 2: str += `<div class="col-md-10 to-animate fadeInRight animated">${sData}</div>` break; default: str += `<div class="col-md-10 to-animate fadeInUp animated">${sData}</div>` } str += `<br></div><br>`; return str; }); document.getElementById("includedHtml").focus(); }); function arrowStep(context, prev, next) { let start = ""; if (prev === 0) { start = `<div class="text-center to-animate-2"> <h1> <a href="javascript:void(0)" data-page="${next}" class="take-tour"><i class="glyphicon glyphicon-forward"></i></a> </h1> <br> </div>`; } else if (next === 0) { start = `<div class="text-center to-animate-2"> <h1> <a href="javascript:void(0)" data-page="${prev}" class="take-tour"><i class="glyphicon glyphicon-backward"></i></a> </h1> <br> </div>`; } else { start = `<div class="text-center to-animate-2"> <h1> <a href="javascript:void(0)" data-page="${prev}" class="take-tour"><i class="glyphicon glyphicon-backward"></i></a> <a href="javascript:void(0)" data-page="${next}" class="take-tour"><i class="glyphicon glyphicon-forward"></i></a> </h1> <br> </div>`; } return start; } function tourStepHtml(context, orderArray, surroundHtml) { apiCall_listorante_public_longtext(context, function (data) { const idx = orderArray.indexOf(context); let prev, nxt; if (idx === 0) prev = 0; else prev = orderArray[idx - 1]; if (idx === orderArray.length - 1) nxt = 0; else nxt = orderArray[idx + 1]; let stringValue = '<br><h1 class=\"text-right\"><p id =\"includedHTMLCloseButton\"><a href=\"javascript:void(0)\" class=\"closeIncludedHTML t\"><i class=\"glyphicon glyphicon-remove\"></i></a></p></h1>'; stringValue += arrowStep(context, prev, nxt); if (data.rows.length === 0) { const noSuchPage = { "responseText": getTextById(404) + " (Context " + context + ")", "status": 404 } showHttpErrorMessage("includedHTML", noSuchPage); } else { for (let i = 0; i < data.rows.length; i++) { debug("data.rows[i].s[6] ", 0, data.rows[i].s[6]); if (surroundHtml && data.rows[i].s[6] == 0) { stringValue += surroundHtml(data.rows[i].s[0], i); debug("surroundHtml ", 0, surroundHtml(data.rows[i].s[0], i)); } else stringValue += data.rows[i].s[0]; } } debug("stringValue", "" + release, stringValue); document.getElementById("includedHTML").innerHTML = stringValue; showTheIncludeSection(); }, function (err) { if (err.responseText) return err.responseText; else return "ERROR: no content found for context " + context; }); } function embedHTML(context, language, divID) { let embeddingDiv = document.getElementById(divID); locale = language; apiCall_listorante_public_longtext(context, function (data) { let stringValue = '<br><h1 class=\"text-right\"><p id =\"includedHTMLCloseButton\"><a href=\"javascript:void(0)\" class=\"closeIncludedHTML text-right\"><i class=\"glyphicon glyphicon-remove\"></i></a></p></h1>'; if (data.rows.length === 0) { const noSuchPage = { "responseText": getTextById(404), "status": 404 } showHttpErrorMessage(divID, noSuchPage); } else { for (let i = 0; i < data.rows.length; i++) stringValue += data.rows[i].s[0]; embeddingDiv.innerHTML = stringValue; showTheIncludeSection(); } }, function (err) { showHttpErrorMessage(divID, err); }); }