'; return loadJsMustache($, 'producbox', prd, { '__pru__': 'https://tilaamo.net/tuote/{ { slug } }' }, 1); }; const constrpg = (pagintop2) => { data = constr_pgInp; pagin.total = Math.ceil(data.count / pagin.size); let c1 = data.products, c2 = [], c3 = []; c1 = c1.map(e => productBox(e)); for (let i = 0; i < c1.length; i++) { if (i % 2 === 0) c2[c2.length] = []; if (i % 3 === 0) c3[c3.length] = []; c2[parseInt(i / 2)][i % 2] = c1[i]; c3[parseInt(i / 3)][i % 3] = c1[i]; } if (c2.length > 0) { if (c2[c2.length - 1].length === 1) c2[c2.length - 1][1] = ''; if (c3[c3.length - 1].length === 1) c3[c3.length - 1][1] = ''; if (c3[c3.length - 1].length === 2) c3[c3.length - 1][2] = ''; } $('#tblc1').html(c1.map(e => `
`).join('')); $('#tblc2').html(c2.map((e, i) => `${e.map((e2,j) => `
${e2}
`).join('')}
`).join('')); $('#tblc3').html(c3.map((e, i) => `${e.map((e2,j) => `
${e2}
`).join('')}
`).join('')); /** tarvittaessaan kuvan otsikon korkeudet tasalleen */ [2, 3].forEach(nro => { const ids = []; $(`#tblc${nro} .pbtitle`).each(function() { const n = $(this).parent().parent().parent().parent().attr('id').split('_')[1]; if (ids.indexOf(n) === -1) ids.push(n); }); ids.forEach(id => { let mxh = 0; $(`[id^="box${nro}_${id}_"]`).each(function() { mxh = Math.max(mxh, $(`#${this.id} .pbtitle`).height()); }); $(`[id^="box${nro}_${id}_"] .pbtitle`).height(mxh); }); }); /** Kuvien korkeus samaksi kun leeys */ $('.imgbox').each(function() { if ($(this).width() != $(this).height()) $(this).height($(this).width()); }); if (pagintop2 && paginTop) { $('html, body').animate({ scrollTop: $("#plist_top").offset().top - 150 }, 500); } }; let resizeCt = true; const myResize = function() { if (resizeCt) setTimeout(() => { constrpg(); resizeCt = true; }, 1000); resizeCt = false; }; window.addEventListener('resize', myResize); const displayPage = () => { paginTop = false; const cat_ids = '92,58,80,47,56,31,3,63,30,65,4,73,89,90,50,112,72,2,111,7,5,6,13,14,15,16,42,1,114,118,115,119,116,79'; const cat_id = '0'; if (parseInt('') === 1) pagin.filter.isnew = 1; if (parseInt('') === 1) pagin.filter.isoffer = 1; if (parseInt('') === 1) pagin.filter.isclearance = 1; ajax({ url: 'product/cnt', data: { cat_ids: cat_ids, cat_id: cat_id, filter: pagin.filter }, callback: function(c) { pagin.total = Math.ceil(c.count / pagin.size); if (typeof pagin.fst !== 'undefined') $('.sync-pagination').twbsPagination('destroy'); let sPg = url.searchParams.get('page'); if (!(sPg && /^[1-9][0-9]*$/.test(sPg))) sPg = 1; const obj = { totalPages: pagin.total > 0 ? pagin.total : 1, visiblePages: '5', startPage: Number(sPg), onPageClick: function(evt, page) { ajax({ url: 'product/list', data: { page: page, size: pagin.size, cat_ids: cat_ids, cat_id: cat_id, filter: pagin.filter, sort: pagin.sort }, callback: c => { let gt = {}; gt['page'] = page; gt['size'] = pagin.size; gt['sort'] = pagin.sort; for (f in pagin.filter) gt[`fil-${f}`] = pagin.filter[f]; gt = '?' + Object.keys(gt).map(k => `${k}=${gt[k]}`).join('&'); window.history.replaceState({}, null, window.location.href.split('?')[0] + gt); constr_pgInp = charDecode(c); constrpg(true); paginTop = true; pagin.fst = true; } }); } }; $('.sync-pagination').twbsPagination(obj); } }); }; const updateSizes1 = () => { const iw = $('#page-container').innerWidth(); $('.text11').css('font', "bold " + parseInt(iw / 45.0) + "px arial,serif"); $('.text12').css('font', "bold " + parseInt(iw / 65.0) + "px arial,serif"); $('.tabttl').css('font', parseInt(iw / 35.0) + "px arial,serif"); $('.text2').css('font', parseInt(iw / 65.0) + "px arial,serif"); $('.prtab div').css('font', parseInt(iw / 65.0) + "px arial,serif"); const pdg = parseInt(iw / 80.0); $('.prtab div').css('padding', pdg + 'px'); $('.prtabcontent').css('padding', '0px ' + pdg + 'px'); }; const updateSlider = () => { $('[id^="imtd_"]').each(function() { $('#imtdd_' + this.id.split('_')[1]).height($(this).height()); }); }; const search = (v, e) => { if (typeof e === 'undefined' || parseInt(e.which || e.keyCode) === 13) { pagin.filter.search = v; displayPage(); } }; if (parseInt('1') === 1) { const sl = charDecode(JSON.parse('[{"id":102,"slug":"tervetuloa-tilaamoon","title":"TERVETULOA TILAAMOON","descr":"<p>Tilaamo tarjoaa omaa tuotantoamme cindy vaatteet mummoille ja pullukoille sek&;auml; k&;auml;sinneulotut villasukat. T&;auml;m&;auml; on varttu.net sivuston tilausj&;auml;rjestelm&;auml;.<\/p><p>Siirry selailemaan tuotteita ryhmitt&;auml;in p&;auml;&;auml;valikon TUOTTEET linkin kautta.<\/p><p>Kun olet vahvistanut tilauksesi, saat s&;auml;hk&;ouml;postissa ilmoituksen tilauksen vastaanottamisesta.<\/p><p>Jos tuntuu, ett&;auml; tilaaminen ei onnistu tai emme ota yhteytt&;auml; vuorokauden kuluessa, soita Cindylle 040 542 8483, kaikkina viikonp&;auml;ivin&;auml;.<\/p>","isoffer":0,"isnew":0,"isclearance":0,"iscoming":0,"img":"1653146195836966.jpeg","instock":7,"uniq":0,"displst":0,"shwinfpg":1,"isserv":0,"delivtime":0,"days":0,"price":0,"active":"active","k":"0","daysdt":"08.04.2025","ftr":"Minimi toimitusaika 0 työpäivää, eli noin 08.04.2025","tabs":[]}]')); loadJsMustache($, 'fplnks', sl); sl.forEach(e => { e.price = e.price ? formatPrice(e.price) : ''; e.tabb = e.tabs.length > 0; if (parseInt(e.isnew) === 1) e.clImg1 = ``; else if (parseInt(e.isoffer) === 1) e.clImg1 = ``; else if (parseInt(e.isclearance) === 1) e.clImg1 = ``; else e.clImg1 = ''; e.iscomingt = parseInt(e.iscoming) === 1 ? 'Tulossa' : ''; }); loadJsMustache($, 'fstprodcarousel', sl, { '__pru__': 'https://tilaamo.net/tuote/{ { slug } }' }); for (let i = 0; i < sl.length; i++) { $('#img1_' + sl[i].k).attr('src', 'https://tilaamo.net/img/tuotekuvat/mid/' + sl[i].img); if (sl[i].tabs.length > 0) { $(`div[id^="tabsl_${sl[i].id}_"]`).on('click', function(e) { const [pid, n] = this.id.split('_'); $(`div[id^="tabs_${pid}_"]`).hide(); $(`div[id^="tabsl_${pid}_"]`).removeClass('active'); $(`#tabs_${pid}_${n}`).show(); $(this).addClass('active'); }).first().trigger('click'); } } } updateSizes1(); updateSizes1(); updateSizes1(); window.addEventListener("resize", function() { updateSizes1(); }); window.addEventListener("orientationchange", function() { updateSizes1(); }); $("#carousel-slider").on('slid.bs.carousel', function() { updateSlider(); }); updateSlider(); $('.carousel').carousel({ interval: 2500 }); $('#sort1, #sort2, #size1, #size2').change(function() { const [k, n] = [this.id.slice(0, -1), parseInt(this.id.slice(-1)) === 1 ? 2 : 1]; pagin[k] = $(this).val(); displayPage(); $('#' + k + n).val($(this).val()); }); $('#sort1,#sort2').val(pagin.sort); $('#size1,#size2').val(pagin.size); $('#search1,#search2').keyup(function(e) { $('#' + this.id.slice(0, -1) + (parseInt(this.id.slice(-1)) === 1 ? 2 : 1)).val($(this).val()); search($(this).val(), e); }); $('#search1btn, #search2btn').on('click', function() { search($('#' + this.id.slice(0, -3)).val()); }); displayPage(); }))(jQuery);