"use strict"; var usr, l, k, ln, uid, deletedItem, cats, menus, products, people, options, staff, office, shop, tOrder, ono = 0, to, tables, snacktime, dollar, euro, cmbI = 0, lastItem, timeEdit, timeNote, tAdd, online = 1; shop = 0; //function setData() { //console.log('data set'); function setData() { cats = localStorage.getItem('cats') ? JSON.parse(localStorage.cats) : '[]'; menus = localStorage.getItem('menus') ? JSON.parse(localStorage.menus) : '[]'; products = localStorage.getItem('products') ? JSON.parse(localStorage.products) : '[]'; office = localStorage.getItem('office') ? JSON.parse(localStorage.office) : '[1,1]'; dollar = office[0]; euro = office[1]; options = localStorage.getItem('options') ? JSON.parse(localStorage.options) : '[]'; tables = localStorage.getItem('tables') ? JSON.parse(localStorage.tables) : '[]'; // people = localStorage.getItem('people') ? JSON.parse(localStorage.tables) : '[]'; } var $ = function (id) { return document.getElementById(id); } //function showHistory(x) { // var img = new Image(), // foto = $('foto'); // img.className = 'foto'; // foto.className = 'fotoWrap'; // foto.innerHTML = svgLoad(); // img.onload = function () { // foto.innerHTML = ''; // foto.appendChild(img); // } // img.src = 'https://storage.googleapis.com/negocompa01/' + x; //} function showHistory(x) { // if ($('trash').className == 'disN') { // $('trash').removeAttribute('class'); var i, j, k, hist, item, id, note, invDate, note, product, dPrice, pid, ckd, oclass, oMeta, istat, opsD, opA, o, ict1 = 0, ladd = 'disN', align = 'aL', trash = '', tItems = '', total = 0, totalprice = 0, foto = $('foto'); // console.log('show history'); foto.addEventListener("click", function () { closeFoto(x); }); foto.className = 'fotoWrap'; o = orders[x]; invDate = o[0]['updated'].toLocaleString(); hist = ''; hist += ''; hist += ''; hist += ''; hist += ''; if (o[0]['status'] == 6) { hist += ''; } else { hist += ''; } hist += ''; hist += ''; for (j = 1; j < o.length; j++) { // console.log(); ict1++; item = o[j]; total += Number(item.price); hist += ''; hist += ''; hist += ''; hist += ''; // hist += ''; hist += ''; hist += ''; hist += ''; hist += ''; hist += ''; hist += ''; hist += tItems + '
DIRTY MARTINI
Payment Pending . . .' + l[44] + '' + invDate.substring(0, invDate.length - 3); + '
' + item.item + '' + Number(item.price) + '
'; // hist += '
'; // hist += '
'; // hist += '
'; // hist += '
'; // price = item.price; // product = getProduct(item.pid); // note = item.note; // pid = item.id; // opsD = ''; // opA = item.ops; // // for (k = 0; k < opA.length; k++) { // // opsD += options[opA[k]][ln] + ' '; // // } // tItems += '
' + product + ' ' + opsD + '
'; } hist += '
' + total.toLocaleString("en-US", { style: "currency", currency: "USD", minimumFractionDigits: 0 }) + '
'; // } foto.innerHTML = hist; // $('trash').innerHTML = trash; // } else { // $('trash').className = 'disN'; // } } function onlyUnique(value, index, self) { return self.indexOf(value) === index; } function saveName(x) { var tOrder = orders[ono], tItem = tOrder[x]; if (timeNote) { clearTimeout(timeNote); } timeNote = setTimeout(function () { tItem['note'] = $('note' + x).value; tItem['update'].indexOf('note') === -1 ? tItem['update'].push('note') : ''; // tItem['update'] = tItem['update'].push('note'); strO(); }, 750); }; function startNote(x) { var note = $('note' + x); note.style.height = 0; note.style.height = note.scrollHeight + "px"; } function scrollNote(x) { var note = $('note' + x); note.style.height = 0; note.style.height = note.scrollHeight + "px"; } function saveNoteO(x) { var note = $('noteO'), tOrder = orders[ono], tMeta = tOrder[0]; // tnote = note.value.trim(); note.style.height = 0; note.style.height = note.scrollHeight + "px"; // note.value = tnote; tMeta['note'] = note.value.trim(); tMeta['update'].indexOf('note') === -1 ? tMeta['update'].push('note') : ''; timeNote ? clearTimeout(timeNote) : ''; timeNote = setTimeout(function () { if (tMeta['status'] > 1) { updateItem(x, 'note'); } strO(); showSnack('snackG', 'saved', 200); }, 500); } function online() { var x = navigator.onLine; return x; } function ckOnline() { var x = "Is the browser online? " + navigator.onLine; document.getElementById("demo").innerHTML = x; } function saveNote(x) { var note = $('note' + x), tOrder = orders[ono], tItem = tOrder[x]; // tnote = note.value.trim(); note.style.height = 0; note.style.height = note.scrollHeight + "px"; // note.value = tnote; tItem['note'] = note.value.trim(); tItem['update'].indexOf('note') === -1 ? tItem['update'].push('note') : ''; timeNote ? clearTimeout(timeNote) : ''; timeNote = setTimeout(function () { if (tItem['iid'] > 0) { updateItem(x, 'note'); } strO(); showSnack('snackG', 'saved', 1000); }, 500); } function timeAdd() { clearTimeout(tAdd); tAdd = setTimeout(function () { $('dupe').className = 'disN'; }, 2500); } function fUSD(x) { return (x.toLocaleString('en-US', { maximumFractionDigits: 0, style: "currency", currency: "USD" })); } function iNav() { var x = $("iNav3"), n = $("iNavN"), x2 = $("iNav2"), x2a = $("iNav2a"), y = $("iTable"), z = $("dropLoc"); if (x.className == 'disN') { x.className = ''; n.className = 'iNavN'; x2.className = 'disN'; x2a.className = 'iNav2a'; // y.className = 'tableLd'; z.className = 'dropLoc1'; $("noteO").focus(); } else { showItems(); } } function markAll() { var i, m, n, cl, r, mA = [], tOrder = orders[ono], oMeta = tOrder.shift(), mrk = document.getElementsByClassName('mrk'); for (i = 0; i < mrk.length; i++) { if (mrk[i].checked == true) { mA.push(mrk[i].id); } } if (mA.length == mrk.length) { m = false; n = 0; cl = ''; } else { m = true; n = 1; cl = 'opRow'; } for (i = 0; i < mrk.length; i++) { r = 'pr' + (i + 1); mrk[i].checked = m; tOrder[i].status = n; $(r).className = cl; } $('checkAll').checked = false; tOrder.unshift(oMeta); strO(); sessionStorage.setItem('unmark', JSON.stringify(mA)); undoMark(); } function uMark() { var i, j, mk, cl, r, tOrder = orders[ono], oMeta = tOrder.shift(), mA = JSON.parse(sessionStorage.unmark), mrk = document.getElementsByClassName('mrk'); for (i = 0; i < mrk.length; i++) { r = 'pr' + (i + 1); mrk[i].checked = false; tOrder[i].status = 0; $(r).className = ''; } for (j = 0; j < mA.length; j++) { r = 'pr' + mA[j].substr(1); $(mA[j]).checked = true; tOrder[j].status = 1; $(r).className = 'opRow'; } tOrder.unshift(oMeta); strO(); } function undoMark() { var x = $("undobar"); x.innerHTML = '
undox
'; x.className = "show"; setTimeout(function () { x.className = x.className.replace("show", ""); }, 1500); } function getPeople(x) { var i, people = JSON.parse(localStorage.people); console.log(x); for (i = 0; i < people.length; i++) { if (people[i][3] == x) { if (x == 0) { return people; } else { return people[i]; } break; } } } function getStaffName(x) { var i, people = JSON.parse(localStorage.people); for (i = 0; i < people.length; i++) { if (people[i][2] == x) { return people[i][0]; } } } //function setStaff() { // var i, // staff = [], // people = JSON.parse(localStorage.people); // for (i = 0; i < people.length; i++) { // if (people[i][3] > 0) { // staff.push([people[i][2], people[i][1]]); // } // } // localStorage.setItem('staff', JSON.stringify(staff)); //} function setPeso(x) { var totalprice = $('iTable').getAttribute('data-ototal'); dollar = office[0]; euro = office[1]; console.log(localStorage.getItem('euro')); $('tpeso').innerHTML = totalprice; $('tdollar').innerHTML = (totalprice / dollar).toFixed(2); $('teuro').innerHTML = (totalprice / euro).toFixed(2); $('peso').className = 'peso0'; $('dollar').className = 'peso0'; $('euro').className = 'peso0'; $('pAt').innerHTML = 'peso'; $('dAt').innerHTML = 'dollar @' + dollar; $('eAt').innerHTML = 'euro @' + euro; $('tpeso').className = 'tpeso0'; $('tdollar').className = 'tpeso0'; $('teuro').className = 'tpeso0'; $('change1').className = 'disN'; $('change3').className = 'disN'; $(x).className = 'peso1'; $('t' + x).className = 'tpeso1'; $('showchange').onclick = function () { showChange(x, totalprice); }; } //function payDrop() { // var sel; // sel += ''; //} function showChange(x, y) { var t, c, curr, p = prompt('enter ' + x + ' amount'); $('change3').className = 'disN'; $('change1').className = 'disN'; if (p) { $('change1').className = ''; p = p.replace(/\,/g, ''); //a=parseInt(a,10); if (isNaN(p)) { $('change2').innerHTML = 'numbers only'; $('change2').className = 'tpesoR'; } else { if (x == 'peso') { c = (p - y); p = p.toLocaleString(); y = y.toLocaleString(); if (c < 0) { $('change2').innerHTML = p + ' is not enough'; $('change2').className = 'tpesoR'; } else { c = c.toLocaleString(); $('change2').innerHTML = '
' + c + '
change in pesos
'; $('change4').innerHTML = p + ' - ' + y + ' = ' + c; $('change2').className = 'tpesoB'; } } else { if (x == 'dollar') { t = (p * dollar); curr = dollar; } else { t = (p * euro); curr = euro; } c = (t - y); t = t.toLocaleString(); p = p.toLocaleString(); if (c < 0) { $('change2').innerHTML = t + ' is not enough'; $('change4').innerHTML = p + ' @ ' + curr + ' = ' + t; $('change2').className = 'tpesoR'; $('change3').className = 's24'; } else { c = c.toLocaleString(); $('change2').innerHTML = '
' + c + '
change in pesos
'; $('change4').innerHTML = p + ' @ ' + curr + ' = ' + t + '
' + t + ' - ' + y + ' = ' + c; $('change2').className = 'tpesoB'; $('change3').className = 's24 lh30'; } } } } } function getCat(x) { var i; for (i = 0; i < cats.length; i++) { if (cats[i][0] == x) { return (cats[i]); } } } function getSub(x) { var i, subs = JSON.parse(localStorage.cats); for (i = 0; i < subs.length; i++) { if (subs[i][0] == x) { return (subs[i]); } } } function fn(x) { var y = x == 0 ? 0 : x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); return y; } function mPatt() { return /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,6})$/; } function getProduct(x) { var pA = products.filter(p => p[0] == x); return pA[0]; } function getON(x) { var oA = options.filter(o => o[0] == x); return oA[ln]; } function getPN(x) { var pA = products.filter(p => p[0] == x); return pA[0][ln]; } function isNegative(n) { return ((n = +n) || 1 / n) < 0; } function setLang() { usr.lang = ln; $('lang').innerHTML = ln == 2 ? 'english' : 'espaƱol' } function getUpeep() { var x = []; if (localStorage.upeep) { x = JSON.parse(localStorage.upeep); } return x; } function trunc() { document.trunc.submit(); } function checkConn() { return navigator.onLine; }; function newDate() { var ymd, hm, x = new Date().toISOString(); return x.substr(0, 10) + ' ' + x.substr(11, 8); } function pattern() { return /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,6})$/; } function tmatch() { return /@"^\d{10}$"/; } function statCA() { var y = ['', 'fB1', 'fO1', 'fBR1', 'f9', 'fG2', 'f9']; return y; } function statNA() { // var l = getLang(), y = [l[7], l[8], l[9], l[11], l[125], 'name5', 'name6']; return y; } function checkSubM(x) { var i, y = 0, z = 0, r; for (i = 0; i < cats.length; i++) { if (cats[i][10] == x) { y++; z = cats[i][0]; } } r = [y, z]; return r; } function showCats(x) { var i, cks, pos, disp, cid, staff_only, tcats = ''; $('topNav').className = 'disN'; $('catNav').className = 'topNav'; $('mCats').className = shop == 1 || staff == 1 ? 'mCatsL' : 'mCatsM'; $('oItems').className = 'disN'; $('oList').className = 'disN'; // $('editDiv').className = 'disN'; $('hideforcats').className = 'disN'; navMenu(x); for (i = 0; i < cats.length; i++) { staff_only = cats[i][12]; cid = cats[i][0]; // if ((staff_only == 1 && staff == 1) || (staff == 0 && staff_only == 0)) { disp = cats[i][ln]; // } if (cats[i][11] == x.substr(1) || cats[i][10] == x.substr(1)) { if ((staff_only == 1 && staff == 1) || staff_only == 0) { if (staff_only == 1) { disp = disp + ' ' + l[145] + ''; } cks = checkSubC(cats[i][0]); pos = cks[0]; if (cks[0] == 1) { cid = cks[1]; pos = 0; } cid = 'c' + cid; if (pos == 0) { tcats += '
' + disp + '
'; } else { tcats += '
' + disp + '
'; } } } } $('mCats').innerHTML = tcats; } function checkSubC(x) { var i, y = 0, z = 0, r; for (i = 0; i < cats.length; i++) { if (cats[i][11] == x) { y++; z = cats[i][0]; } } r = [y, z]; return r; } function sortProduct(a, b) { if (a[ln] === b[ln]) { return 0; } else { return (a[ln] < b[ln]) ? -1 : 1; } } function navMenu(x) { var click, cname, name, vX; $('topNav').className = 'disN'; if (event.target.id == 'nnn') { $('cRow').removeChild($('cRow').lastChild); $('nnn').className = 'tabOn'; $('mItems').className = 'disN'; $('mCats').className = shop == 1 || staff == 1 ? 'mCatsL' : 'mCatsM'; } else { $('catNav').className = 'topNav'; click = $(x).getAttribute('onclick'); cname = $(x).className; name = $(x).innerHTML; vX = '
<<
'; if (x == 'm1') { vX += '
' + l[133] + '
'; $('mItems').className = ''; } else if (x == 'm2') { vX += '
' + l[134] + '
'; $('mItems').className = 'disN'; } else if (x == 'm3') { vX += '
' + l[135] + '
'; $('mItems').className = 'disN'; } else { vX = $('cRow').innerHTML.replace(/tabOn/g, 'tabOff'); if (cname == 'sc') { vX += '
' + name + '
'; } else { if ($('nnn')) { $('nnn').className = 'tabOff'; } vX += '
' + name + '
'; } } $('cRow').innerHTML = vX; } } function opCheck(x, y) { var i, z = 0, options = JSON.parse(localStorage.options); for (i = 0; i < options.length; i++) { if (x == options[i][5] || y == options[i][4] || y == options[i][3]) { return 1; } } return 0; } //cats // 0-$id, 1-$l1, 2-$l2, 3-$note_l1, 4-$note_l2, 5-$ad_l1, 6-$ad_l2, 7-0, 8-$star_l1, 9-$star_l2, 10-$mid, 11-$cid //ops //0-id 1-en, 2-es 3-cid 4-sid 5-pid 6-grp 7-price 8-ox // product // 0-id 1-en, 2-es 3-eblurb 4-sblurb 5-cat 6-0 7-price 8-image 9-show_star, 10-plate_e 11-plate_s, 12-soc, 13-sos, 14-sxc, 15-sxs //ops = getOps(pid, cat, soc, sos, sxc, sxs, i, 'O'); function getOps(x, y, soc, sos, sxc, sxs, q, zadd) { var ist, i, j, oj, p$, name, oprice, oname, type, tGrp, opz, item, tType, typeCk, ckd, cls, align, oid, z = -1, grpCk = '', iOpt = [], options = JSON.parse(localStorage.options), op0 = ''; cats = JSON.parse(localStorage.cats); for (i = 0; i < cats.length; i++) { if (cats[i][0] == y && cats[i][11] > 0) { z = cats[i][11]; // y is sub - otherwise y is cat -- if z == -1 y is cat break; } } tType = options[0][8]; for (j = 0; j < options.length; j++) { oj = options[j]; // y is cat -- z is sub -- x is product // x == options[j][5] || if ( x == options[j][5] || y == options[j][3] || options[j][3] == 1001 && y != 1 && y != 15 && y != 14 && y != 12 && y != 10 && y != 115 && y != 13 && y != 54 && y != 94 && y != 112 || //options[j][3] == 1 //|| y == options[j][4] && (oj[8] == 0 && z > 0 && sos == 1) || y == options[j][3] && (oj[8] == 1 && z < 0 && sxc == 1) || y == options[j][4] && (oj[8] == 1 && z > 0 && sxs == 1) || z == options[j][3] && ((oj[8] == 0 && soc == 1) || (oj[8] == 1 && sxc == 1)) ) { tGrp = oj[6] + '.' + oj[3] + '.' + oj[4] + '.' + oj[5] + '.' + x; // $ogrp $ocid $ocid $osid $opid // array($id, $l1, $l2, $ocid, $osid, $opid, $ogrp, $price, $ox); //0-id 1-en, 2-es 3-cid 4-sid 5-pid 6-grp 7-price 8-ox ckd = ''; if ((tGrp != grpCk) || tType != oj[8]) { if (grpCk != '') { op0 += '
'; } if (oj[8] == 0) { ckd = 'checked'; } grpCk = tGrp; // tType = oj[8]; } if (oj[8] == 0) { type = 'radio'; } else { type = 'checkbox'; } name = grpCk; p$ = ''; oprice = ''; if (oj[7] > 0) { p$ = '$'; oprice = oj[7]; } oname = oj[ln].replace("//", ""); // op0 += '---' + x + '---'; // oid = 'op0' + j + x; op0 += ' '; // op0 += '' + oname + ' ' + p$ + oprice + ' '; if (op0 != '') { op0 = '
' + op0 + '
'; } return op0; } function hideLineP() { document.querySelectorAll(".linep").forEach(function (item) { item.className = 'disN'; }); document.querySelectorAll(".addlp").forEach(function (item) { item.className = 'disN'; }); document.querySelectorAll(".boxp").forEach(function (item) { item.className = ''; }); } function showLineP(x) { hideLineP(); $('linep' + x).className = 'linep'; $('addp' + x).className = 'addlp'; $('boxp' + x).className = 'boxp'; } function loadInfo(x, y) { $('econtent').className = 'disN'; $('staffedit').className = 'blueLink ml20'; $('editinfo').className = 'greyLink'; if (x != '') { loadPhoto(x); } if (y > 0) { $('eplate').className = 'aL p10'; } } function showPhoto(x) { var img = new Image(), foto = $('foto'); img.className = 'foto'; foto.className = 'fotoWrap'; foto.innerHTML = svgLoad(); img.onload = function () { foto.innerHTML = ''; foto.appendChild(img); } img.src = 'https://storage.googleapis.com/img-dirtymenu/' + x; foto.addEventListener("click", function () { closeFoto(x); }); } function showCC() { var img = new Image(), scc = $('scc'); // img.className = 'foto'; scc.className = 'mt20'; scc.innerHTML = svgLoad(); img.onload = function () { scc.innerHTML = ''; scc.appendChild(img); } img.src = 'https://storage.googleapis.com/img-dirtymenu/cc.png'; } function showEdit(x) { $('econtent').className = ''; $('ephoto').className = 'disN'; $('eplate').className = 'disN'; $('staffedit').className = 'greyLink ml20'; if (x > 0) { $('editinfo').className = 'blueLink'; } } function addValueM(x, y) { var i, pid, update, iid, z, qty, pr, ino, // tOrder, // tItem, // lqty = $('lqty' + x).innerHTMLH, dataL = $('line' + x), ops = $('opsE' + x).getElementsByClassName('ops'), total = Number(dataL.dataset.oprice), opsN = []; for (i = 0; i < ops.length; i++) { if (ops[i].checked == true) { if (ops[i].value > 0) { if (y == 15) { total += Number(ops[i].value); } else { total = Number(ops[i].value); } } opsN.push(ops[i].id.substr(3)); } } $('price' + x).innerHTML = ' $' + total; dataL.dataset.price = total; dataL.dataset.ops = opsN; console.log(total); // showSnack('snackG', 'updated', 1000); strO(); } function addValueO(x, y) { //x=line number y = cat CHECK-Y, CHECK d-1 for multiple rows of options var i, pid, update, iid, ino, total, tOrder = orders[ono], tItem = tOrder[x], oprice = tItem['oprice'], ops = $('div1').getElementsByClassName('ops'), opsN = []; console.log(ops); for (i = 0; i < ops.length; i++) { if (ops[i].checked == true) { // if (ops[i].value > 0) { if (y == 15) { total = Number(oprice); total += Number(ops[i].value); // console.log('15'); } else { total = Number(ops[i].value); console.log(i); console.log(ops[i].value); } // } opsN.push(ops[i].id.substring(ops[i].id.indexOf('-') + 1)); } } console.log(total); tItem['price'] = total; tItem['ops'] = opsN; $('price' + x).innerHTML = ' $' + total; updateItem(x, 'ops'); updateItem(x, 'price'); showSnack('snackG', 'updated', 1000); strO(); } //function addValueO(x) { // var i, ops, pid, update, iid, z, //opsA, // tOrder = orders[ono], // tItem = tOrder[x], // total = Number(tItem['oprice']), // iid = tItem['iid'], // ops = $('opsEz' + x).getElementsByClassName('opt'), // opsN = []; // if (ops != '') { // for (i = 0; i < ops.length; i++) { // if (ops[i].checked == true) { // total += Number(ops[i].value); // opsN.push(ops[i].id.substr(3)); // } // } // tItem['price'] = total; // // tItem['ops'] = opsN; // $('price' + x).innerHTML = ' $' + total; // } // // if (iid > 0) { // updateItem(x, 'price'); // updateItem(x, 'ops'); // } // showSnack('snackG', 'updated', 1000); // strO(); //} function unSub(ino) { var tOrder = orders[ono], tMeta = tOrder[0], tItem = tOrder[ino], status = tItem['status'];; if (tMeta['status'] == 3) { tItem['status'] = 2; } else { tItem['status'] = 1; } // updateItem(ino, 'status'); strO(); showSnack('snackG', 'not canceled', 1000); showItems(); } //function unSub(ino) { // var tOrder = orders[ono], // tItem = tOrder[ino], // ostatus = $('edititem' + ino).getAttribute('data-status'); // // $('product' + ino).className = 'fll'; // // $('ladd0' + ino).className = 'ladd0'; // tItem['status'] = ostatus; // if (tItem['iid'] > 0) { // updateItem(ino, 'status'); // } // strO(); // showSnack('snackG', 'not canceled', 1000); // showItems(); //} function addOne(x) { var n, i; tOrder = orders[ono]; sessionStorage.setItem('addone', JSON.stringify(tOrder[x])); n = JSON.parse(sessionStorage.getItem('addone')); n['status'] = 0; n['iid'] = 0; tOrder.splice(1, 0, n); sessionStorage.setItem('dupe', 1); showSnack('snackG', 'added', 1000); sessionStorage.setItem('addone', x); strO(); showItems(0); scrollTo(0, 0); } function showDetailsM(i) { var d = $('details' + i); if (d.className == 'ldetails0') { $('details' + i).className = 'ldetails1'; $('blurb' + i).className = 'blurb'; $('plate' + i).className = 'plating'; $('noteE' + i).className = 'disN'; $('opsE' + i).className = 'disN'; } else { $('details' + i).className = 'ldetails0'; $('blurb' + i).className = 'disN'; $('plate' + i).className = 'disN'; $('opsE' + i).removeAttribute('class'); $('noteE' + i).className = 'aC'; } } function showDetailsC(i) { var d = $('details' + i).className; document.querySelectorAll('.blurb').forEach(function (item) { item.className = 'disN'; }); document.querySelectorAll('.plate').forEach(function (item) { item.className = 'disN'; }); document.querySelectorAll('.ldetails1').forEach(function (item) { item.className = 'ldetails0'; }); if (d == 'ldetails0') { $('details' + i).className = 'ldetails1'; $('blurb' + i).className = 'blurb'; $('plate' + i).className = 'plating'; } else { $('details' + i).className = 'ldetails0'; } } // document.querySelectorAll('.ldetails1').forEach(function (item) { // item.className = 'ldetails0'; // }); function showDetailsO(i) { var d = $('details' + i), opsE = $('opsE' + i), eTD = opsE.getElementsByTagName("td")[0]; if (d.className == 'ldetails0') { $('details' + i).className = 'ldetails1'; $('blurb' + i).className = 'blurb'; $('plate' + i).className = 'plating'; $('noteE' + i).className = 'disN'; opsE.className = 'disN'; } else { $('details' + i).className = 'ldetails0'; $('blurb' + i).className = 'disN'; $('plate' + i).className = 'disN'; $('noteE' + i).className = 'sC'; eTD.innerHTML == '' ? '' : opsE.removeAttribute('class'); // $('opsE' + i).className = 'opsE'; } } function addItem(pid, line) { var i, y, k, oi, oid, opid, newItems, nqt, n, lqty, note, price, oprice, ops, status, opA, op0, date = 0, product = getProduct(pid), item = product[1], food = product[16], tOrder = orders[ono], tMeta = tOrder[0]; tMeta['status'] = 1; // addValueM(line); note = $('note' + line) ? $('note' + line).innerHTML : ''; price = $('line' + line).getAttribute('data-price'); oprice = $('line' + line).getAttribute('data-oprice'); lqty = $('lqty' + line).innerHTML; ops = $('line' + line).getAttribute('data-ops'); if (ops != '') { ops = ops.split(','); } else { opA = $('opsE' + line).getElementsByClassName('ops'); if (opA.length > 0) { op0 = opA[0].id; ops = [Number(op0.substr(3))]; // ops = $('edititem' + line).getAttribute('data-0'); // console.log(ops); // console.log(ops[0]); // console.log(op0); // console.log(op00); // alert("ops!"); } } lqty = isNaN(lqty) ? 1 : Number(lqty) + 1; $('lqty' + line).innerHTML = lqty; n = { iid: 0, pid: pid, oid: tMeta['oid'], status: staff, wstat: 0, date: 0, item: item, qty: 1, price: price, oprice: oprice, ops: ops, note: note.trim(), food: food, update: [], deleted: 0 }; tOrder.splice(1, 0, n); showSnack('snackG', 'added', 1000); strO(); } function closeSnack() { $('snackbar').className = 'disN'; } function showSnack(style, snack, time) { var x = $('snackbar'); clearTimeout(snacktime); x.className = style; x.innerHTML = snack; if (time > 0) { snacktime = setTimeout(function () { x.className = 'disN'; }, time); } } //function showSnack(id, snack, time) { // time = time || 1000; // var x = document.getElementById(id); // x.className = "show"; // x.innerHTML = snack; // clearTimeout(snacktime); // snacktime = setTimeout(function () { // x.className = x.className.replace("show", ""); // }, time); //} function hrM(z) { var d = new Date(z); var h2 = d.getHours(); if (h2 < 10) h2 = '0' + h2; var m2 = d.getMinutes(); if (m2 < 10) m2 = '0' + m2; var hr = h2 + ':' + m2; return hr; } function dM(z) { var d = new Date(z); var dy = d.getDate(); if (dy < 10) dy = '0' + dy; var mo; if (ln == '1') mo = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; else mo = ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic']; var day = dy + ' ' + mo[d.getMonth()]; return day; } function dMY(z) { var d = new Date(z); var dy = d.getDate(); if (dy < 10) dy = '0' + dy; var mo; if (ln == '1') mo = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; else mo = ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic']; var day = dy + ' ' + mo[d.getMonth()] + ', ' + d.getFullYear(); return day; } function dHM(x) { // var y = (x) ? x.substr(x.indexOf(' '), 6) : 0, // z = y.replace(':', '-'); return (x) ? x.substr(x.indexOf(' '), 6) : 0; // minutes // return z; } function dateMin(z) { var today = new Date(), order_date = new Date(z), Ms = (today.getTime() - order_date.getTime()), Mns = Math.round(Ms / (1000 * 60)); // Mns = Mns < 1 ? '' : Mns; return Mns; // minutes } function safeText(val) { val = val.replace(/>/gi, ">"); val = val.replace(/"/gi, """); val = val.replace(/'/gi, "'"); val = val.replace(/
'; //} function svgNE() { return '
'; } function setFind() { $('svF').setAttribute("class", "disN"); $('a2z').className = 'abcO'; $('a2z').focus(); } function svgFind() { return ''; } function svgSel() { return ''; } function svgLoad() { return ''; } function svgXX() { return '' }; function svgAdd() { return ''; } function rateShow() { return '$1 = ' + dollar + ' MX'; } //function settings() { // sessionStorage.setItem('pedit', Math.abs(usr.uid)); // goTab(-3); //} function f0Num(num) { return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,') } function f2Num(num) { return '$' + num.toFixed(2).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,') } function setUsr() { usr = localStorage.getItem('usr'); if (usr) { usr = JSON.parse(localStorage.getItem('usr')); } else { usr = { uid: 0, name: "", email: "", till: 0, peoplemax: 0, ordermax: 0, productmax: 0, tablemax: 0, officemax: 0, optionmax: 0, extramax: 0, catmax: 0, submax: 0, msg_no: 0, staff: 0, lang: 1, code: 0 } localStorage.setItem('usr', JSON.stringify(usr)); } uid = usr.uid; ln = usr.lang; l = getLang(ln); } setUsr(); //window.addEventListener('load', setUsr); // for (var i = 0; i < l.length; i++) {f // }