1'use strict'; 2 3(function ($) { 4 5 if (typeof pfinder_sett === 'string') { 6 let pf_sett = atob(pfinder_sett); //doc: 11 7 pfinder_sett = JSON.parse(pf_sett); 8 } 9 10 $('.pf_jsdataidx').each(function (i, obj) { 11 let jsdataidx = $(this).data('jsdataidx'); 12 let pffrom = $(this).data('from'); 13 let pf_data = window['pfinder_data' + jsdataidx]; 14 pf_data = atob(pf_data); //doc: 11 15 pf_data = JSON.parse(pf_data); 16 let pf_links = pf_data.pf_links; 17 let pf_onpage = pf_data.pf_onpage; 18 let display_cnt = pf_data.display_cnt; 19 var pf_displayprice = pfinder_sett.pf_displayprice; 20 // 21 if (Object.keys(pf_links).length > 0 && (pffrom == 'shtcode' || (pffrom != 'shtcode' && pf_onpage == 'yes') || 22 (pffrom != 'shtcode' && pf_onpage == 'no' && pf_displayprice != 'nodisplay' && display_cnt > 0))) { 23 24 var pf_displaysort = pfinder_sett.pf_displaysort; 25 var pf_template = pfinder_sett.pf_template; 26 if (pffrom != 'shtcode') pf_displayprice = 'nodisplay'; 27 var pf_sortArr = []; 28 window['pf_nonstock' + jsdataidx] = []; 29 let str_pf_links = JSON.stringify(pf_links).replace(/\\/g, ''); 30 let json = { api_nonce: pfinder_sett.api_nonce, from: 'productpage', pid: pf_data.pid, arr_links: str_pf_links }; 31 32 $.ajax({ 33 type: 'POST', 34 url: pfinder_sett.api_url + 'pfinder_reader', 35 data: json, 36 beforeSend: function (xhr) { 37 xhr.setRequestHeader('X-WP-Nonce', pfinder_sett.api_nonce); //doc: 47 38 }, 39 success: function (response) { 40 response = atob(response.data); //doc: 11 41 const js_arr = JSON.parse('[' + JSON.parse(response) + ']'); 42 js_arr.forEach(function (jsItem) {
43 Object.entries(pf_links).forEach(([pf_idx, value]) => { 44 let obj = JSON.parse(value); 45 let lnkkey = obj.lnkkey 46 let lnkurl = obj.lnkurl 47 let lnkmode = obj.lnkmode 48 let lnkidx = obj.lnkidx 49 const stridx = lnkidx + jsItem.lnkkey + jsdataidx; 50 // 51 if (lnkkey == jsItem.lnkkey && lnkidx == jsItem.lnkidx) { 52 const faPrice = jsItem.fa_price; 53 const arrfapric = faPrice.split('##'); 54 let lnkval = arrfapric[0], lnkvariable = '', lnkprice = '', lnkoldprice = ''; 55 if (arrfapric.length == 2) lnkprice = arrfapric[1]; //doc: 212 56 else { 57 lnkvariable = arrfapric[1]; 58 lnkprice = arrfapric[2]; 59 } 60 let spn = '', strtitle = ''; 61 if (pf_template == 'no') { 62 strtitle = lnkval + ': ' + lnkprice; 63 if (lnkvariable != '') strtitle = lnkval + ' ' + lnkvariable + ': ' + lnkprice; 64 spn = '#spn_' + stridx; 65 } else { 66 spn = '#divpf_' + stridx; 67 strtitle = $(spn).html(); 68 // 69 lnkprice = lnkprice.replace(/<\/?strike>/g, ''); 70 if (!lnkprice.includes('ک٠ترÛÙ')) { //doc: 214 71 const arrPrice = lnkprice.split(' '); 72 if (arrPrice.length == 2) { 73 lnkoldprice = arrPrice[0]; 74 lnkprice = arrPrice[1]; 75 } 76 } 77 strtitle = strtitle.replace('{shop_name}', lnkval) 78 .replace('{variable}', lnkvariable) 79 .replace('{price}', lnkprice) 80 .replace('{old_price}', lnkoldprice); 81 } 82 $(spn).html(strtitle); 83 pf_sortArr.push({ lnkkey: lnkidx + jsItem.lnkkey, price: jsItem.price }); 84 } 85 if (lnkkey == jsItem.lnkkey && lnkidx == jsItem.lnkidx && lnkmode == 1) { 86 if (pf_displayprice == 'display') $('#divpf_' + stridx).css('display', 'flex'); 87 } 88 89 }); 90 }); 91 92 if (pfinder_sett.pf_shownonst == 'yes') {
93 Object.entries(pf_links).forEach(([pf_idx, value]) => { 94 let obj = JSON.parse(value); 95 let lnkkey = obj.lnkkey 96 let lnkvalue = obj.lnkvalue 97 let lnkurl = obj.lnkurl 98 let lnkidx = obj.lnkidx 99 let lnkmode = obj.lnkmode 100 let isexist = 0; 101 const stridx = lnkidx + lnkkey + jsdataidx; 102 // 103 pf_sortArr.forEach(function (srtItem) { 104 if (srtItem.lnkkey == lnkidx + lnkkey) isexist = 1; 105 }); 106 if (isexist == 0) { 107 let spn = '', strtitle = ''; 108 if (pf_template == 'no') { 109 spn = '#spn_' + stridx; 110 strtitle = lnkvalue + ': ' + pfinder_sett.pf_nonstock; 111 } else { 112 spn = '#divpf_' + stridx; 113 strtitle = $(spn).html(); 114 strtitle = strtitle.replace('{shop_name}', lnkvalue) 115 .replace('{variable}', '') 116 .replace('{price}', pfinder_sett.pf_nonstock) 117 .replace('{old_price}', ''); 118 } 119 $(spn).html(strtitle); 120 if (lnkmode == 1) { 121 window['pf_nonstock' + jsdataidx].push(stridx); 122 if (pf_displayprice == 'display') $('#divpf_' + stridx).css('display', 'flex'); 123 } 124 } 125 }); 126 } 127 if (pf_displayprice == 'display' && display_cnt > 0) { 128 if (pf_displaysort == 'asc') { 129 pf_sortArr.sort(function (x, y) { 130 return y.price - x.price; 131 }); 132 } else { 133 pf_sortArr.sort(function (x, y) { 134 return x.price - y.price; 135 }); 136 } 137 pf_sortArr.forEach(function (pf_sort) { 138 pf_display_sorting(pf_sort.lnkkey, jsdataidx); 139 }); 140 $('#pfinder_main_caption' + jsdataidx).html(pfinder_sett.pf_caption); 141 $('#pfinder_main_dv_temp' + jsdataidx).attr('style', ''); 142 $('#pfinder_main_dv' + jsdataidx).attr('style', ''); 143 } 144 if (pf_displayprice == 'displayif') pf_applay_displayif(js_arr, pf_data.pPrice, jsdataidx); 145 } 146 }); 147 } 148 }); 149 150 $('.pf_jsdataidx2').each(function (i, obj) { 151 let jsdataidx = $(this).data('jsdataidx'); 152 let pf_data = window['pfinder_data' + jsdataidx]; 153 pf_data = atob(pf_data); //doc: 11 154 pf_data = JSON.parse(pf_data); 155 let pf_links = pf_data.pf_links; 156 // 157 if (Object.keys(pf_links).length > 0) { 158 let str_pf_links = JSON.stringify(pf_links).replace(/\\/g, ''); 159 let json = { api_nonce: pf_data.api_nonce, from: 'shortcode', pid: pf_data.pid, arr_links: str_pf_links }; 160 $.ajax({ 161 type: 'POST', 162 url: pfinder_sett.api_url + 'pfinder_reader', 163 data: json, 164 beforeSend: function (xhr) { 165 xhr.setRequestHeader('X-WP-Nonce', pfinder_sett.api_nonce); //doc: 47 166 }, 167 success: function (response) { 168 $('#pf_shortcode_price' + jsdataidx).html(response.data); 169 } 170 }); 171 } 172 }); 173 174 function pf_display_sorting(elemkey, jsdataidx) { 175 let main = document.getElementById('pfinder_main_dv' + jsdataidx); 176 [].map.call(main.children, Object).sort(function (a, b) { 177 if (a.id == 'divpf_' + elemkey + jsdataidx) return -1; 178 }).forEach(function (elem) { 179 main.appendChild(elem); 180 }); 181 } 182 183 function pf_applay_displayif(js_arr, pPrice, jsdataidx) { 184 let dv_disp = 0; 185 js_arr.forEach(function (jsItem) { 186 let price = jsItem.price; 187 if (Number(pPrice) <= Number(price) && price != '-1') {
188 Object.entries(pf_links).forEach(([pf_idx, value]) => { 189 let obj = JSON.parse(value); 190 let lnkkey = obj.lnkkey 191 let lnkmode = obj.lnkmode 192 let lnkidx = obj.lnkidx 193 // 194 if (lnkkey == jsItem.lnkkey && lnkidx == jsItem.lnkidx && lnkmode == 1) { 195 $('#divpf_' + lnkidx + jsItem.lnkkey + jsdataidx).css('display', 'flex'); 196 dv_disp++; 197 } 198 }); 199 } 200 }); 201 if (pfinder_sett.pf_shownonst == 'yes') { 202 window['pf_nonstock' + jsdataidx].forEach(function (nItem) { 203 $('#divpf_' + nItem).css('display', 'flex'); 204 }); 205 } 206 207 if (dv_disp > 0) { 208 if (pf_displaysort == 'asc') { 209 pf_sortArr.sort(function (x, y) { 210 return y.price - x.price; 211 }); 212 } else { 213 pf_sortArr.sort(function (x, y) { 214 return x.price - y.price; 215 }); 216 } 217 pf_sortArr.forEach(function (pf_sort) { 218 pf_display_sorting(pf_sort.lnkkey, jsdataidx) 219 }); 220 $('#pfinder_main_caption' + jsdataidx).html(pfinder_sett.pf_caption); 221 $('#pfinder_main_dv_temp' + jsdataidx).attr('style', ''); 222 $('#pfinder_main_dv' + jsdataidx).attr('style', ''); 223 } 224 } 225 226 let pf_btn = document.getElementsByClassName("pfinder_product_btn"); 227 for (let i = 0; i < pf_btn.length; i++) { 228 pf_btn[i].addEventListener('mouseover', pf_mouseover); 229 pf_btn[i].addEventListener('mouseout', pf_mouseout); 230 } 231 232 function pf_mouseover(event) { 233 let elemId = event.target.id; 234 $('#' + elemId).css("background-color", pfinder_sett.vewcolors[3]); 235 $('#' + elemId).css("border-color", pfinder_sett.vewcolors[1]); 236 $('#' + elemId).css("color", pfinder_sett.vewcolors[5]); 237 } 238 239 function pf_mouseout(event) { 240 let elemId = event.target.id; 241 $('#' + elemId).css("background-color", pfinder_sett.vewcolors[2]); 242 $('#' + elemId).css("border-color", pfinder_sett.vewcolors[0]); 243 $('#' + elemId).css("color", pfinder_sett.vewcolors[4]); 244 } 245 246})(jQuery); 247
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.