// gEl('aladeclasa').classList.add('geta');
// gEl('aladeclasa').classList.remove('geta');
//mobile
function gEl(id){
return document.getElementById(id);
}
function gElClass(clasa){
return document.getElementsByClassName(clasa);
}
let burger = gEl('hamburger')
if(burger)
burger.addEventListener('click', function() {
if(this.classList.contains('close')){
closeMenu(this)
}else{
openMenu(this)
}
});
function openMenu(t){
t.classList.add('close');
gEl('nav').classList.add('navVisible');
gEl('body').classList.add('hideOverflow');
}
function closeMenu(t){
t.classList.remove('close');
gEl('nav').classList.remove('navVisible');
gEl('body').classList.remove('hideOverflow');
if(!t.classList.contains('close')){
gEl('nav').classList.remove('navsubmenu');
Array.from(gElClass('subMenu')).forEach(elem => elem.style.display = "none");
Array.from(gElClass('subnavs')).forEach(elem => elem.style.display = "block");
Array.from(gElClass('aparent')).forEach(elem => elem.style.display = "");
}
}
function closeMinicart(event){
if(event.target.id == 'overlay'){
if(gEl('cartBox').classList.contains('cartShow')){
closeCart();}
if(gEl('tabelMarimi')){
if(gEl('tabelMarimi').style.display=='block'){
gEl('tabelMarimi').style.display='none';
gEl('body').classList.remove('hideOverflow');
gEl('overlay').classList.remove('overlayed');
}
}
}
}
let ocart = gEl('openCart')
if(ocart)
ocart.addEventListener('click', function() {
refreshCart();
gEl('cartBox').classList.add('cartShow');
gEl('body').classList.add('hideOverflow');
gEl('overlay').classList.add('overlayed');
});
let ccart = gEl('closeCart');
if(ccart)
ccart.addEventListener('click', function() {
gEl('cartBox').classList.remove('cartShow');
gEl('body').classList.remove('hideOverflow');
gEl('overlay').classList.remove('overlayed');
});
Array.from(gElClass('aparent')).forEach(elem => {
if(window.innerWidth < 1080){
elem.addEventListener('click', function(e) {
e.stopPropagation();
e.preventDefault();
displaySubMenu(this);
});
}
})
Array.from(gElClass('backMenu')).forEach(elem => {
if(window.innerWidth < 1080){
elem.addEventListener('click', function(e) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
restoreSubMenu(this);
});
}
})
function restoreSubMenu(t){
let sbc = t.attributes['data-subchild'].value;
gEl('auleu-'+sbc).style.display = 'flex';
Array.from(gElClass('subnavs')).forEach(subs=>{
// let sbid = subs.attributes['data-subchilds'].value;
//if(sbc != sbid){
subs.style.display = 'block';
//}
});
gEl('subSubNav'+sbc).style.display = 'none';
gEl('nav').classList.remove('navsubmenu');
}
function displaySubMenu(t){
let sbc = t.attributes['data-subchilds'].value;
let prnt = t.attributes['data-parent'].value;
gEl('auleu-'+sbc).style.display = 'none';
Array.from(gElClass('subnavs')).forEach(subs=>{
let sbid = subs.attributes['data-subchilds'].value;
let prr = subs.dataset['parent'];
if(sbc != sbid && prr == prnt){
subs.style.display= 'none';
}
});
gEl('subSubNav'+sbc).style.display = 'block';
gEl('nav').classList.add('navsubmenu');
}
//all
gEl('closeParent').addEventListener('click', function() {
this.parentElement.classList.remove("slideTop");
gEl('overlay').classList.remove('overlayed');
gEl('body').classList.remove('hideOverflow');
});
let srcelem = gEl('openSearch')
if(srcelem)
srcelem.addEventListener('click', function() {
localCall("getPopulars", '', msg => {
let html = '';
Object.values(msg).forEach(elemop => {
html += '
\
\
\
\
\
\
\
\
\
\
'+elemop.price+' lei \
';
});
let popul = document.getElementById('popularsList');
if(popul) popul.innerHTML = html;
}, fail => {
});
gEl('searchBox').classList.add('slideTop');
gEl('body').classList.add('hideOverflow');
gEl('cartBox').classList.remove('cartShow');
setTimeout(() => gEl('cauta').focus(),500);
});
function clearMainFor(){
Array.from(document.getElementsByClassName('genderS')).forEach(selector => selector.parentNode.classList.remove('selected'));
}
Array.from(document.getElementsByClassName('genderS')).forEach(selector =>{
selector.addEventListener('click', function(event){
let whm = this.attributes['data-switch'].value;
if(window.innerWidth < 1080){
event.preventDefault();
gEl('nav').classList.remove('navsubmenu');
Array.from(gElClass('mainMenu')).forEach(msub=> msub.style.display = 'none');
let showM = gElClass(whm);
if(showM)
Array.from(showM).forEach(vsm => vsm.style.display = "block");
}
clearMainFor();
this.parentNode.classList.add('selected');
setCookie('pentru', whm.toLowerCase(), 60);
let bgg = document.getElementById('gender');
if(bgg){
bgg.classList.remove('barbatiActiv');
bgg.classList.remove('femeiActiv');
bgg.classList.remove('copiiActiv');
bgg.classList.add((whm.toLowerCase())+'Activ');
}
// window.location.reload();
});
});
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i 1?"e":"");
let minicart = gEl('cartContent');
if(!minicart){
minicart = gEl('continutCos');
if(minicart)
displayProductSummary(msg);
return;
}
if(minicart){
minicart.innerHTML = '';
let gotProducts = false;
if(Object.keys(msg.items).length == 0){
minicart.innerHTML = '';
}else{
htmlToContent = '';
gotProducts = Object.entries(msg.items).sort((a, b) => parseInt(a[0]) < parseInt(b[0]) ? 1 : (parseInt(a[0]) > parseInt(b[0]) ? -1 : 0) );
gotProducts.forEach(([pId,product])=>{
var sizes='';
if (product.size){var sizes='
Mărime: '+product.size+'';}
htmlToContent += '
\

\
\
- '+product.name+'
'+sizes+' - ';
if(product.indisponibil){
htmlToContent += '
- Produsul nu se mai găsește în stoc!
';
}else{
htmlToContent +='Cantitate: '+product.quantity+'';
}
let pname =product.name.replace(/'/, '');
pname = pname.replace("'","");
htmlToContent += '- Elimina
\
';
if(product.discountvalue > 0){
htmlToContent += ''+parseFloat(product.price * product.quantity).toFixed(2)+' lei';
htmlToContent += ''+parseFloat(product.priceD * product.quantity).toFixed(2)+' lei';
htmlToContent += '-'+parseFloat(product.discountvalue * product.quantity).toFixed(2)+' lei';
}else{
if(parseFloat(product.priceS) > parseFloat(product.price)){
htmlToContent += ''+parseFloat(product.price * product.quantity).toFixed(2)+' lei';
htmlToContent += ''+parseFloat(product.priceS * product.quantity).toFixed(2)+' lei';
}
else{htmlToContent += ''+parseFloat(product.price * product.quantity).toFixed(2)+' lei';}
}
htmlToContent += '
';
});
htmlToContent += '
';
minicart.innerHTML = htmlToContent;
let cartBottom = gEl('bottomCart');
if(cartBottom){
cartBottom.innerHTML = '';
let voucherString = '';
Object.entries(msg.vouchers).forEach(([vId,voucher]) => {
voucherString += 'Voucher: '+voucher.cod+'-'+(voucher.evalue).toFixed(2)+' Lei
';
});
deliveryCost = "Gratuită";
if(parseInt(msg.deliveryitems[1].value)>0){deliveryCost = msg.deliveryitems[1].value+" Lei";}
cartBottom.innerHTML += voucherString;
cartBottom.innerHTML += 'Livrare '+deliveryCost+'
Total '+parseFloat(msg.totalPrice).toFixed(2)+' Lei
';
cartBottom.innerHTML += 'Finalizare comandaVezi coșul\
';
}}
freeShipping = 200;
if(msg.totalPrice < freeShipping){
bar = msg.totalPrice / freeShipping * 100;
//$('#miniCart').append('Primeste transport gratuit'+msg.totalPrice+' lei '+freeShipping+' lei
');
}else{
// $('#miniCart').append('Felicitari! Transportul pentru aceasta comanda este gratuit.
');}
// $('#miniCart').append('Vezi cosulFinalizare comanda');
// $('#cartItems').html(msg.totalQuantity);
//$('.removeProduct').off('click');
//$('.removeProduct').on('click', removeFromCart);
}
//$('.showUnder').click(function(){
// $(this).toggleClass('minus');
// $(this).next().slideToggle(300);
//});
try{
let upselitems= document.getElementById('cartUpsell');
if(upselitems){
if(!Object.values(JSON.parse(getCookie('suggoff'))).length){
getSuggestions(gotProducts);
}
}
}catch{
console.log('error in cookie');
}
}
//minicart.style.display = 'block';
}
function getSuggestions(ids){
let skipfam = ids.map(elem => 'skipfam[]='+elem[1].familyId).join('&');
let colors =[];
let brands =[];
let sizes =[];
let upselld = document.getElementById('cartUpsell');
let upselitems= document.getElementById('upsellItems');
if(upselitems){
upselitems.innerHTML = '';
upselld.display = 'none';
localCall("getSuggestions",skipfam , displaySuggestions, fail=>console.log('no suggestions'), "GET");
}
}
function displaySuggestions(response){
let upselitems= document.getElementById('upsellItems');
if(upselitems){
Object.values(response).forEach(prod => {
let updiv = document.createElement('div');
updiv.classList.add('upsellItem');
updiv.innerHTML = '\
\
\
\
\
'+prod.name+'\
'+prod.price+' lei \
';
upselitems.appendChild(updiv);
});
let upselld = document.getElementById('cartUpsell');
if(upselld) upselld.style.display = '';
}
}
function putSecondPict(msg){
Object.values(msg.items).forEach(pict => {
let elemP = gEl('pictf-'+pict.id);
if(elemP){
let np = document.createElement('picture');
np.classList.add('image2');
let pna= pict.name.split('.');
pna.pop();
const basename = pna.join('.');
np.innerHTML = '\
';
elemP.prepend(np);
}
});
Array.from(gElClass('productImage')).forEach(elem => {
if(elem.children.length == 1){
let dpn = elem.children[0].cloneNode(true);
dpn.classList.remove('image1');
dpn.classList.add('image2');
elem.append(dpn);
}
});
}
function getSecondPicture(){
let aFids = Array.from(gElClass('productImage')).map(elem => {
if(typeof elem.attributes['data-fid'] !== 'undefined') return elem.dataset['fid'] ;
return 0;
}).filter(elem=> elem != 0);
if(aFids.length)
localCall('getSecondPicture', aFids.map(elem => 'fid[]='+elem).join('&'), putSecondPict, msg=>console.log('no second pict') ) ;
}
function getProductsVariations(){
let aFids = Array.from(gElClass('productDisplay')).map(elem => {
if(typeof elem.attributes['data-fid'] !== 'undefined') return elem.attributes['data-fid'].value ;
return 0;
}).filter(elem=> elem != 0);
localCall('getProductsVariations', aFids.map(elem => 'id[]='+elem).join('&'), showProductVariations, msg=>console.log('no second pict') ) ;
}
function getProductsVariations_black(){
let aFids = Array.from(gElClass('productDisplay')).map(elem => {
if(typeof elem.attributes['data-fid'] !== 'undefined') return elem.attributes['data-fid'].value ;
return 0;
}).filter(elem=> elem != 0);
localCall('getProductsVariations', aFids.map(elem => 'id[]='+elem).join('&')+"&black=1", showProductVariations_black, msg=>console.log('no second pict') ) ;
}
function getUniversalSizeOn(){
let usqp = new URLSearchParams(window.location.search);
return usqp.getAll('x[]');
}
function showProductVariations(msg){
let usOn = getUniversalSizeOn();
Array.from(gElClass('productDisplay')).forEach(elem => {
if(typeof elem.attributes['data-fid'] == 'undefined') return false;
const fid = elem.attributes['data-fid'].value ;
if(typeof msg.items[fid] === 'undefined') return false;
const slug = elem.attributes['data-path'].value.split('?')[0] ;
let gotSizes = Object.values(msg.items[fid]).map(sid => (
{ id:sid.id
,uSizeId: sid.uSizeId
, name: ((typeof attrValNames[sid.sizeId] !== 'undefined')?attrValNames[sid.sizeId].value:' ' )
, showOrder: ((typeof attrValNames[sid.sizeId] !== 'undefined')?attrValNames[sid.sizeId].showOrder:'0') }
)).sort(
(a, b) => a.showOrder != '0' ? (parseInt(a.showOrder) < parseInt(b.showOrder) ? -1 : parseInt(a.showOrder) > parseInt(b.showOrder) ? 1 : 0) : (a.name.toLowerCase() < b.name.toLowerCase() ? -1 : (a.name.toLowerCase() > b.name.toLowerCase() ? 1 : 0) )
);
let extraElem = 0;
if(usOn.length){
let tmp = gotSizes.filter(size => usOn.includes(size.uSizeId));
if(tmp){
extraElem = gotSizes.length - tmp.length;
gotSizes = tmp;
}
}else{
if(gotSizes.length > 3 ){
extraElem = gotSizes.length-3;
gotSizes = gotSizes.slice(0,3);
}
}
let output = gotSizes.map(sid => ''+sid.name+'');
if(extraElem){
output.push('+'+extraElem+'');
}
elem.querySelector('.famsizes').innerHTML = output.join('');
});
}
function showProductVariations_black(msg){
Array.from(gElClass('productDisplay')).forEach(elem => {
if(typeof elem.attributes['data-fid'] == 'undefined') return false;
const fid = elem.attributes['data-fid'].value ;
if(typeof msg.items[fid] === 'undefined') return false;
const slug = elem.attributes['data-path'].value.split('?')[0] ;
let gotSizes = Object.values(msg.items[fid]).map(sid => ({id:sid.id
, name: ((typeof attrValNames[sid.sizeId] !== 'undefined')?attrValNames[sid.sizeId].value:'FARA' )
, showOrder: ((typeof attrValNames[sid.sizeId] !== 'undefined')?attrValNames[sid.sizeId].showOrder:'0') }
)).sort(
(a, b) => a.showOrder != '0' ? (parseInt(a.showOrder) < parseInt(b.showOrder) ? -1 : parseInt(a.showOrder) > parseInt(b.showOrder) ? 1 : 0) : (a.name.toLowerCase() < b.name.toLowerCase() ? -1 : (a.name.toLowerCase() > b.name.toLowerCase() ? 1 : 0) )
);
let extraElem = 0;
if(gotSizes.length > 3 ){
extraElem = gotSizes.length-3;
gotSizes = gotSizes.slice(0,3);
}
let output = gotSizes.map(sid => ''+sid.name+'');
if(extraElem){
output.push('+'+extraElem+'');
}
elem.querySelector('.famsizes').innerHTML = output.join('');
});
return;
Array.from(gElClass('productDisplay')).forEach(elem => {
if(typeof elem.attributes['data-fid'] == 'undefined') return false;
const fid = elem.attributes['data-fid'].value ;
if(typeof msg.items[fid] === 'undefined') return false;
const slug = elem.attributes['data-path'].value ;
let output = Object.values(msg.items[fid]).map(sid => ({id:sid.id, name: (typeof attrValNames[sid.sizeId] !== 'undefined')?attrValNames[sid.sizeId].value:'FARA' })).sort((a, b) => a.name.toLowerCase() < b.name.toLowerCase() ? -1 : (a.name.toLowerCase() > b.name.toLowerCase() ? 1 : 0) ).map(sid => ''+sid.name+'');
elem.querySelector('.famsizes').innerHTML = output.join('');
});
}
var HtmlEntities = function() {};
HtmlEntities.map = {
"'": "'",
"<": "<",
">": ">",
" ": " ",
"¡": "¡",
"¢": "¢",
"£": "£",
"¤": "¤",
"¥": "¥",
"¦": "¦",
"§": "§",
"¨": "¨",
"©": "©",
"ª": "ª",
"«": "«",
"¬": "¬",
"®": "®",
"¯": "¯",
"°": "°",
"±": "±",
"²": "²",
"³": "³",
"´": "´",
"µ": "µ",
"¶": "¶",
"·": "·",
"¸": "¸",
"¹": "¹",
"º": "º",
"»": "»",
"¼": "¼",
"½": "½",
"¾": "¾",
"¿": "¿",
"À": "À",
"Á": "Á",
"Â": "Â",
"Ã": "Ã",
"Ä": "Ä",
"Å": "Å",
"Æ": "Æ",
"Ç": "Ç",
"È": "È",
"É": "É",
"Ê": "Ê",
"Ë": "Ë",
"Ì": "Ì",
"Í": "Í",
"Î": "Î",
"Ï": "Ï",
"Ð": "Ð",
"Ñ": "Ñ",
"Ò": "Ò",
"Ó": "Ó",
"Ô": "Ô",
"Õ": "Õ",
"Ö": "Ö",
"×": "×",
"Ø": "Ø",
"Ù": "Ù",
"Ú": "Ú",
"Û": "Û",
"Ü": "Ü",
"Ý": "Ý",
"Þ": "Þ",
"ß": "ß",
"à": "à",
"á": "á",
"â": "â",
"ã": "ã",
"ä": "ä",
"å": "å",
"æ": "æ",
"ç": "ç",
"è": "è",
"é": "é",
"ê": "ê",
"ë": "ë",
"ì": "ì",
"í": "í",
"î": "î",
"ï": "ï",
"ð": "ð",
"ñ": "ñ",
"ò": "ò",
"ó": "ó",
"ô": "ô",
"õ": "õ",
"ö": "ö",
"÷": "÷",
"ø": "ø",
"ù": "ù",
"ú": "ú",
"û": "û",
"ü": "ü",
"ý": "ý",
"þ": "þ",
"ÿ": "ÿ",
"Œ": "Œ",
"œ": "œ",
"Š": "Š",
"š": "š",
"Ÿ": "Ÿ",
"ƒ": "ƒ",
"ˆ": "ˆ",
"˜": "˜",
"Α": "Α",
"Β": "Β",
"Γ": "Γ",
"Δ": "Δ",
"Ε": "Ε",
"Ζ": "Ζ",
"Η": "Η",
"Θ": "Θ",
"Ι": "Ι",
"Κ": "Κ",
"Λ": "Λ",
"Μ": "Μ",
"Ν": "Ν",
"Ξ": "Ξ",
"Ο": "Ο",
"Π": "Π",
"Ρ": "Ρ",
"Σ": "Σ",
"Τ": "Τ",
"Υ": "Υ",
"Φ": "Φ",
"Χ": "Χ",
"Ψ": "Ψ",
"Ω": "Ω",
"α": "α",
"β": "β",
"γ": "γ",
"δ": "δ",
"ε": "ε",
"ζ": "ζ",
"η": "η",
"θ": "θ",
"ι": "ι",
"κ": "κ",
"λ": "λ",
"μ": "μ",
"ν": "ν",
"ξ": "ξ",
"ο": "ο",
"π": "π",
"ρ": "ρ",
"ς": "ς",
"σ": "σ",
"τ": "τ",
"υ": "υ",
"φ": "φ",
"χ": "χ",
"ψ": "ψ",
"ω": "ω",
"ϑ": "ϑ",
"ϒ": "&Upsih;",
"ϖ": "ϖ",
"–": "–",
"—": "—",
"‘": "‘",
"’": "’",
"‚": "‚",
"“": "“",
"”": "”",
"„": "„",
"†": "†",
"‡": "‡",
"•": "•",
"…": "…",
"‰": "‰",
"′": "′",
"″": "″",
"‹": "‹",
"›": "›",
"‾": "‾",
"⁄": "⁄",
"€": "€",
"ℑ": "ℑ",
"℘": "℘",
"ℜ": "ℜ",
"™": "™",
"ℵ": "ℵ",
"←": "←",
"↑": "↑",
"→": "→",
"↓": "↓",
"↔": "↔",
"↵": "↵",
"⇐": "⇐",
"⇑": "&UArr;",
"⇒": "⇒",
"⇓": "⇓",
"⇔": "⇔",
"∀": "∀",
"∂": "∂",
"∃": "∃",
"∅": "∅",
"∇": "∇",
"∈": "∈",
"∉": "∉",
"∋": "∋",
"∏": "∏",
"∑": "∑",
"−": "−",
"∗": "∗",
"√": "√",
"∝": "∝",
"∞": "∞",
"∠": "∠",
"∧": "∧",
"∨": "∨",
"∩": "∩",
"∪": "∪",
"∫": "∫",
"∴": "∴",
"∼": "∼",
"≅": "≅",
"≈": "≈",
"≠": "≠",
"≡": "≡",
"≤": "≤",
"≥": "≥",
"⊂": "⊂",
"⊃": "⊃",
"⊄": "⊄",
"⊆": "⊆",
"⊇": "⊇",
"⊕": "⊕",
"⊗": "⊗",
"⊥": "⊥",
"⋅": "⋅",
"⌈": "⌈",
"⌉": "⌉",
"⌊": "⌊",
"⌋": "⌋",
"⟨": "〈",
"⟩": "〉",
"◊": "◊",
"♠": "♠",
"♣": "♣",
"♥": "♥",
"♦": "♦"
};
HtmlEntities.decode = function(string) {
var entityMap = HtmlEntities.map;
for (var key in entityMap) {
var entity = entityMap[key];
var regex = new RegExp(entity, 'g');
string = string.replace(regex, key);
}
string = string.replace(/"/g, '"');
string = string.replace(/&/g, '&');
return string;
}
HtmlEntities.encode = function(string) {
var entityMap = HtmlEntities.map;
string = string.replace(/&/g, '&');
string = string.replace(/"/g, '"');
for (var key in entityMap) {
var entity = entityMap[key];
var regex = new RegExp(key, 'g');
string = string.replace(regex, entity);
}
return string;
}
function popupSubscribeNewsletter(){
let formElement = document.forms['popupSubscribe'];
let formData = new FormData(formElement);
if(formElement.checkValidity()){
localCall("subscribeNewsletter",formData, msg => {
let suc = gEl('popupnewsSuccess');
let fail = gEl('popupnewsWarning');
if(msg.insert > 0 ){
setCookie('inscris', "1", 15);
if(fail) fail.style.display = 'none';
if(suc) suc.style.display = '';
}else{
if(fail) fail.style.display = '';
if(suc) suc.style.display = 'none';
}
}, msg => {console.log(msg); }, 'POST');
}else{
formElement.reportValidity();
}
}
function subscribeNewsletter(){
let formElement = document.forms['subscribe'];
let formData = new FormData(formElement);
if(formElement.checkValidity()){
localCall("subscribeNewsletter",formData, msg => {
let suc = gEl('newsSuccess');
let fail = gEl('newsWarning');
if(msg.insert > 0 ){
if(fail) fail.style.display = 'none';
if(suc) suc.style.display = '';
}else{
if(fail) fail.style.display = '';
if(suc) suc.style.display = 'none';
}
}, msg => {console.log(msg); }, 'POST');
}else{
formElement.reportValidity();
}
}
function displaySearchResults(msg){
let sug = document.getElementById('sugestii');
if(!sug) return false;
sug.innerHTML = '';
sugg = '';
Object.values(msg.items).forEach(item => {
sugg += '
'+item.price+' lei';
});
sug.innerHTML += 'Produse sugerate';
sug.innerHTML +='';
}
var debounceSearch = false;
function searchForProduct(){
if(debounceSearch) clearTimeout(debounceSearch);
debounceSearch = setTimeout(()=>{
if(this.value.length > 3){
localCall('search', 'seek='+this.value, displaySearchResults, msg=>{console.log(msg)});
}
}, 300);
}
function getEventPath(e) {
var path = [];
var currentElem = e.target;
while (currentElem) {
path.push(currentElem);
currentElem = currentElem.parentElement;
}
if (path.indexOf(window) === -1 && path.indexOf(document) === -1)
path.push(document);
if (path.indexOf(window) === -1)
path.push(window);
return path;
}
function checkAddtoWishlist(e){
let are = getEventPath(e).filter(elem => typeof elem.classList !=='undefined' && (elem.classList.contains('addToFavorite') || elem.classList.contains('toWishlist')));
if(are.length){
let wish = are.pop();
if(typeof wish.attributes['data-productid'] !== 'undefined'){
let famid = wish.attributes['data-productid'].value;
let familyId = wish.dataset['fid'];
localCall('addToWishlist', {fid:famid}, msg => {
if(msg.status == 1){
wish.classList.add('wished');
(rtbhEvents = window.rtbhEvents || []).push(
{
eventType: 'wishlist',
offerId: (familyId).toString()
},
{
eventType: 'uid',
id: getCookie('idVisit')
});
}else{
wish.classList.remove('wished');
let infav = document.getElementById('wishitem-'+msg.fid);
if(infav) infav.remove();
}
let wiscounte = document.getElementById('wishcount')
if(wiscounte){
wiscounte.innerHTML = Object.keys(JSON.parse(getCookie('wish'))).length;
}
}, msg=>{console.log(msg)}, "POST");
}
}
}
function accountUser(fbresponse){
localCall('login', fbresponse, success=>{
location.href = 'contul-meu';
}, failF = false, mode= 'POST')
}
function finalAccountUser(fbresponse){
localCall('login', fbresponse, success=>{
location.href = 'finalizare-comanda';
}, failF = false, mode= 'POST')
}
function parseJwt (token) {
var base64Url = token.split('.')[1];
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
var jsonPayload = decodeURIComponent(window.atob(base64).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
return JSON.parse(jsonPayload);
}
function submitContact(e) {
if( !document.getElementById("contact-form").checkValidity()){
document.getElementById("contact-form").reportValidity();
return;
}
document.getElementById('tokenulcontact').value = e;
document.getElementById("contact-form").submit();
}
function getSimilarProducts(ids = []){
if(!ids.length) return;
localCall("getSimilarProducts", ids.map(id => 'ids[]='+id).join('&'), msg => {
if(typeof displaySimilarProductsDis !== 'undefined')
displaySimilarProductsDis(msg);
}, emsg=>{
console.log(emsg);
})
}