gwpNo = {313: "3", 314: "1", 315: "1", 316: "1", 317: "1", 318: "1", 319: "1", 320: "1", 321: "1", 322: "1", 323: "1", 324: "1", 325: "2", 326: "1", 327: "1", 328: "1", 329: "1", 330: "2", 349: "1", 350: "1", 351: "1", 352: "1", 353: "1", 354: "1", 355: "1", 357: "1", 356: "1", 376: "3", 379: "2", 380: "1", 381: "1", 367: "3", 368: "3", 369: "7", 385: "2", 370: "3", 371: "3", 372: "3", 373: "3", 374: "3", 377: "4", 378: "2", 387: "1", 388: "1", 389: "1", 390: "1", 391: "1", 392: "1", 393: "1", 394: "1", 395: "1", 396: "1", 397: "1", 398: "1", 399: "1", 400: "1", 401: "1", 402: "1", 403: "1", 404: "1", 405: "1", 406: "1", 407: "1", 408: "1", 409: "1", 410: "1", 414: "1", 415: "1", 416: "1", 417: "1", 418: "1", 419: "1", 420: "1", 421: "1", 422: "1", 423: "1", 424: "1", 425: "1", 426: "1", 427: "1", 428: "1", 429: "2", 430: "2", 431: "2", 432: "3", 433: "3", 434: "3", 81: "1", 82: "1", 441: "3", 442: "2", 443: "2", 461: "1", 462: "1", 485: "1", 486: "1", 524: "1", 525: "1", 526: "1", 527: "1", 528: "1", 529: "1", 530: "1", 531: "1", 532: "1", };var opt_list = [56,59,60,61,62,63,64,65,66,67,68,69,71,72,73,74,78,80,84,98,99,100]; gwpMulti = {56: "57", };gwpMultiCnt = {56: "58", }; var more_txt = [], less_txt = [], optTmp = [], isStock = 0; var sid = '203'; var url = 'https://gwp.brweb.pl/i/203/'; var selcolor = '#8dbe23'; var imgLimit = '1000'; var moreLabel = '+'; var lessLabel = '-'; var showMLcnt = 1; var prevMopen = ''; function showPrev(e) { if (window.innerWidth < 700) return null; var id = e.id; var aId = id.split('__'); var prev_div = document.getElementById('gwp_div_preview_'+aId[0].replace('option_','')); prev_div.style.display = 'block'; prev_div.innerHTML = ''; } function hidePrev(e) { if (window.innerWidth < 700) return null; var id = e.id; var aId = id.split('__'); var prev_div = document.getElementById('gwp_div_preview_'+aId[0].replace('option_','')); prev_div.style.display = 'none'; prev_div.innerHTML = ''; } function showPrevMobile(e) { var id = e.id; var aId = id.split('__'); var prev_id = 'gwp_div_preview_'+aId[0].replace('option_',''); var prev_div = document.getElementById(prev_id); if (prevMopen != '' && prevMopen != prev_div) document.getElementById(prevMopen).style.display = 'none'; prev_div.style.display = 'block'; prev_div.innerHTML = ''; prev_div.style.position = 'absolute'; prev_div.style.left = '0px'; prev_div.style.bottom = '20px'; prev_div.style.margin = '0px 10px'; prev_div.style.width = 'calc(100% - 20px)'; prevMopen = prev_id; } function hidePrevMobile(e) { var id = e.id; var aId = id.split('__'); var prev_id = 'gwp_div_preview_'+aId[0].replace('option_',''); var prev_div = document.getElementById(prev_id); prev_div.style.display = 'none'; prev_div.innerHTML = ''; } function hideDiv() { document.getElementById(prevMopen).style.display = 'none'; } function selectClick(e,m) { if (m == 1) { return selectClickMulti(e); } var id = e.id; var aId = id.split('__'); var optId = aId[0].replace('option_',''); if (document.getElementById(aId[0]).value != aId[1] || document.getElementById(aId[0]).length == 1) { if (window.innerWidth < 700) showPrevMobile(e); document.getElementById(aId[0]).value = aId[1]; if (document.getElementById('gwp_div_title_'+optId)) document.getElementById('gwp_div_title_'+optId).innerHTML = e.title; } else { if (window.innerWidth < 700) hidePrevMobile(e); document.getElementById(aId[0]).selectedIndex = '0'; if (document.getElementById('gwp_div_title_'+optId)) document.getElementById('gwp_div_title_'+optId).innerHTML = ''; id = ''; } document.getElementById(aId[0]).dispatchEvent(new Event('change')); var c = document.getElementsByClassName('c_' + aId[0]); for( var i = 0; i < c.length; i++){ c[i].parentElement.style.border = '1px solid transparent'; document.getElementById('tick_'+c[i].id).style.display = 'none'; if ( c[i].id == id ) { c[i].parentElement.style.border = '1px solid ' + selcolor; document.getElementById('tick_'+c[i].id).style.display = 'block'; } } } function selectClickMulti(e) { var id = e.id; var aId = id.split('__'); var optId = aId[0].replace('option_',''); if (document.getElementById(aId[0]).value != aId[1] || document.getElementById(aId[0]).length == 1) { if (window.innerWidth < 700) showPrevMobile(e); } else { if (window.innerWidth < 700) hidePrevMobile(e); id = ''; } document.getElementById(aId[0]).dispatchEvent(new Event('change')); if (optId in gwpMulti && document.getElementById('option_'+gwpMulti[optId])) { var savedText = document.getElementById('option_'+gwpMulti[optId]).value; var aList = savedText.split(', '); var oOpt = []; var oRemoved = 0; var oi = 0; for( var i = 0; i < aList.length; i++){ var aOpt = aList[i].split(': '); if (aOpt[0] != '' && e.title != aOpt[0]) { oOpt[oi] = {'name': aOpt[0]}; var ci = oi; oi++; } if (e.title == aOpt[0]) { oRemoved = 1; } } if (oRemoved == 0 && e.title != '') { oOpt[oi] = {'name': e.title}; } var c = document.getElementsByClassName('c_' + aId[0]); for( var i = 0; i < c.length; i++){ c[i].parentElement.style.border = '1px solid transparent'; document.getElementById('tick_'+c[i].id).style.display = 'none'; } var newText = ''; for( var oi = 0; oi < oOpt.length; oi++){ newText = newText + (oi > 0 ? ', ' : '') + oOpt[oi]['name']; for( var i = 0; i < c.length; i++){ if ( c[i].title == oOpt[oi]['name'] ) { c[i].parentElement.style.border = '1px solid ' + selcolor; document.getElementById('tick_'+c[i].id).style.display = 'block'; } } } var mCnt = document.getElementById('option_'+gwpMultiCnt[optId]); document.getElementById('option_'+gwpMulti[optId]).value = newText; var newTextInfo = ''; if (oOpt.length == 0) { newTextInfo = 'Wybierz do ' + (mCnt.length-1) + ' arkuszy naklejek.'; } else if (oOpt.length == 1) { newTextInfo = 'Wybrano 1 arkusz naklejek.'; } else if (oOpt.length < 5 || oOpt.length == 22 || oOpt.length == 23 || oOpt.length == 24 || oOpt.length == 32 || oOpt.length == 33 || oOpt.length == 34 || oOpt.length == 42 || oOpt.length == 43 || oOpt.length == 44) { newTextInfo = 'Wybrano ' + oOpt.length + ' arkusze naklejek.'; } else { newTextInfo = 'Wybrano ' + oOpt.length + ' arkuszy naklejek.'; } document.getElementById('gwp_div_multi_'+gwpMulti[optId]).innerHTML = newTextInfo; for(c = 0; c < mCnt.length; c++) { if (mCnt[c].innerHTML == oOpt.length) { mCnt.value = mCnt[c].value; mCnt.dispatchEvent(new Event('change')); } } if (oOpt.length == 0) { mCnt.value = ''; mCnt.dispatchEvent(new Event('change')); } } } function radioClick(e) { var id = e.id; if (window.innerWidth < 700) showPrevMobile(e); var aId = id.split('__'); var optId = aId[0].replace('option_',''); document.getElementById(aId[0]+'_'+aId[1]).click(); if (document.getElementById('gwp_div_title_'+optId)) document.getElementById('gwp_div_title_'+optId).innerHTML = e.title; var c = document.getElementsByClassName('c_' + aId[0]); for( var i = 0; i < c.length; i++){ c[i].parentElement.style.border = '1px solid transparent'; document.getElementById('tick_'+c[i].id).style.display = 'none'; if ( c[i].id == id ) { c[i].parentElement.style.border = '1px solid ' + selcolor; document.getElementById('tick_'+c[i].id).style.display = 'block'; } } } function gwpMore(oid) { var h = document.getElementsByClassName('gwpHidden'+oid); var type = more_txt[oid] == document.getElementById('gwp_more'+oid).innerHTML ? 'block' : 'none'; for( var i = 0; i < h.length; i++){ h[i].style.display = type; } document.getElementById('gwp_more'+oid).innerHTML = type == 'block' ? less_txt[oid] : more_txt[oid] ; } function showGWP() { opt_list.forEach(function(opt_id) { var s = document.getElementById('option_'+opt_id); if (s && (!optTmp[opt_id] || optTmp[opt_id] != s.innerHTML)) { s.style.display = 'none'; optTmp[opt_id] = s.innerHTML; var sColors = ''; if (s.parentElement.className.indexOf('option_truestock ') != -1 && isStock == 0) { isStock = 1; const intervalGWP = setInterval(function() { showGWP(); }, 500); } sColors += '
'; sColors += '
'; var c = s.getElementsByTagName('option'); var imgNo = 0; var optCnt = c.length - 1; more_txt[opt_id] = moreLabel + (showMLcnt == 1 ? (optCnt - imgLimit + 1) : ''); less_txt[opt_id] = lessLabel + (showMLcnt == 1 ? (optCnt - imgLimit + 1) : ''); for( var j = 0; j< c.length; j++){ if (c[j].value != '' && c[j].value != 'wybierz' && c[j].value != 'choose' && c[j].value != 'wählen') { imgNo++; sColors += '
imgLimit || (imgNo == imgLimit && imgNo != optCnt)) ? ' class="gwpHidden'+opt_id+' gwp-opt" ' : 'class="gwp-opt"') + '>
'; } } if (optCnt > imgLimit) { sColors += '
' + more_txt[opt_id] + '
'; } sColors += '
'; if (document.getElementById('gwp_div_'+opt_id)) { div = document.getElementById('gwp_div_'+opt_id); div.innerHTML = sColors; s.parentElement.appendChild(div); } else { const div = document.createElement('div'); div.innerHTML = sColors; div.id = 'gwp_div_'+opt_id; div.className = 'gwp-div'; div.style = 'position:relative;'; s.parentElement.appendChild(div); if (opt_id in gwpMulti) { var mCnt = document.getElementById('option_'+gwpMultiCnt[opt_id]); const div = document.createElement('div'); div.innerHTML = 'Wybierz do ' + (mCnt.length-1) + ' arkuszy naklejek.'; div.id = 'gwp_div_multi_'+gwpMulti[opt_id]; div.style = 'position:relative;padding-top:5px;font-size: 1rem;'; div.className = 'gwp-div-multi'; s.parentElement.appendChild(div); document.getElementById('option_'+gwpMulti[opt_id]).parentElement.parentElement.parentElement.parentElement.style.display = 'none'; document.getElementById('option_'+gwpMultiCnt[opt_id]).parentElement.parentElement.parentElement.style.display = 'none'; var im_buttons = document.getElementsByClassName('im_new_select'); setTimeout(function() { im_buttons[0].style.display = 'none'; im_buttons[1].style.display = 'none'; im_buttons[2].style.display = 'none'; im_buttons[3].style.display = 'none'; im_buttons[4].style.display = 'none'; }, 300); setTimeout(function() { im_buttons[0].style.display = 'none'; im_buttons[1].style.display = 'none'; im_buttons[2].style.display = 'none'; im_buttons[3].style.display = 'none'; im_buttons[4].style.display = 'none'; }, 500); } } } var sr = document.getElementsByName('option_'+opt_id); if (sr && sr.length > 0 && (!optTmp[opt_id] || optTmp[opt_id] != s.innerHTML)) { optTmp[opt_id] = sr[0].parentElement.parentElement.innerHTML; var sColors = ''; var imgNo = 0; var optCnt = sr.length; for( var ri = 0; ri < sr.length; ri++){ if (sr[ri].parentElement.className == 'radio-wrap none') { optCnt--; } } more_txt[opt_id] = moreLabel + (showMLcnt == 1 ? (optCnt - imgLimit + 1) : ''); less_txt[opt_id] = lessLabel + (showMLcnt == 1 ? (optCnt - imgLimit + 1) : ''); var rlabels = sr[0].parentElement.parentElement.getElementsByTagName('label'); var rDict = new Array(); for( var rli = 0; rli < rlabels.length; rli++){ if (rlabels[1].innerHTML != '' || !rlabels[rli]) rDict[rlabels[rli].getAttribute('for')] = rlabels[rli].innerHTML; } sColors += '
'; sColors += '
'; for( var ri = 0; ri < sr.length; ri++){ if (sr[ri].parentElement.className != 'radio-wrap none') { imgNo++; sColors += '
imgLimit || (imgNo == imgLimit && imgNo != optCnt)) ? ' class="gwpHidden'+opt_id+' gwp-opt" ' : 'class="gwp-opt"') + '>
'; } } if (optCnt > imgLimit) { sColors += '
' + more_txt[opt_id] + '
'; } sColors += '
'; if (document.getElementById('gwp_div_'+opt_id)) { div = document.getElementById('gwp_div_'+opt_id); div.innerHTML = sColors; s.parentElement.appendChild(div); } else { const div = document.createElement('div'); div.innerHTML = sColors; div.id = 'gwp_div_'+opt_id; div.style = 'position:relative;'; div.className = 'gwp-div'; sr[0].parentElement.parentElement.parentElement.appendChild(div); sr[0].parentElement.parentElement.style.height = '0px'; sr[0].parentElement.parentElement.style.visibility = 'hidden'; } } }); } showGWP();