PageSourceSearch

https://us.althea.kr/cdn/shop/t/26/assets/sc-pb-app.min.js?v=14539175268944030951620196445

js althea.kr collected 2026-10-03 21:19:51 UTC 31,570 bytes, 769 lines download raw bytes

1/*Added by opu*/
2
3var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(r){var t,e,o,a,h,n,c,d="",C=0;for(r=Base64._utf8_encode(r);C<r.length;)a=(t=r.charCodeAt(C++))>>2,h=(3&t)<<4|(e=r.charCodeAt(C++))>>4,n=(15&e)<<2|(o=r.charCodeAt(C++))>>6,c=63&o,isNaN(e)?n=c=64:isNaN(o)&&(c=64),d=d+this._keyStr.charAt(a)+this._keyStr.charAt(h)+this._keyStr.charAt(n)+this._keyStr.charAt(c);return d},decode:function(r){var t,e,o,a,h,n,c="",d=0;for(r=r.replace(/[^A-Za-z0-9\+\/\=]/g,"");d<r.length;)t=this._keyStr.indexOf(r.charAt(d++))<<2|(a=this._keyStr.indexOf(r.charAt(d++)))>>4,e=(15&a)<<4|(h=this._keyStr.indexOf(r.charAt(d++)))>>2,o=(3&h)<<6|(n=this._keyStr.indexOf(r.charAt(d++))),c+=String.fromCharCode(t),64!=h&&(c+=String.fromCharCode(e)),64!=n&&(c+=String.fromCharCode(o));return c=Base64._utf8_decode(c)},_utf8_encode:function(r){r=r.replace(/\r\n/g,"\n");for(var t="",e=0;e<r.length;e++){var o=r.charCodeAt(e);o<128?t+=String.fromCharCode(o):o>127&&o<2048?(t+=String.fromCharCode(o>>6|192),t+=String.fromCharCode(63&o|128)):(t+=String.fromCharCode(o>>12|224),t+=String.fromCharCode(o>>6&63|128),t+=String.fromCharCode(63&o|128))}return t},_utf8_decode:function(r){for(var t="",e=0,o=c1=c2=0;e<r.length;)(o=r.charCodeAt(e))<128?(t+=String.fromCharCode(o),e++):o>191&&o<224?(c2=r.charCodeAt(e+1),t+=String.fromCharCode((31&o)<<6|63&c2),e+=2):(c2=r.charCodeAt(e+1),c3=r.charCodeAt(e+2),t+=String.fromCharCode((15&o)<<12|(63&c2)<<6|63&c3),e+=3);return t}};
4
5/*Important Notice: call this function "load_sc_pb_apps()" if u have any ajax pagination or anything.... */
6
7var _pb_install_type = 'auto'; // auto or manual
8
9var _pb_collection_page_img_selector = ''; // product page image selector
10var _pb_collection_page_img_holder_selector = '';
11var _pb_product_page_img_selector = ''; // product page image selector
12
13/***************************************************************************************************/
14
15
16function sc_pb_app_process(scjQuery){
17		
18    /*SCPB.xProcess = function(data){
19    	console.log(data);
20    }*/
21    
22  	SCPB.get_page_products=function(callback){
23          var char_limit=1700;
24          var search_queries=[];
25          var handles=[];
26          var str_handles='';
27          var sc_ws_collection_products={
28              total_products:0,
29              products:[],
30              products_by_handle:{},
31              products_by_id:{}
32          };
33          scjQuery('a[href*="/products/"]').each(function(idx){
34              var url=scjQuery(this).attr('href');
35              var handle=SCPB.get_product_handle(url);
36              //var handle=url.replace('/products/','');
37
38              if(handles.indexOf(handle)==-1){
39                  handles.push(handle);
40              }
41          });
42
43          var counter=0;
44          for(i=0;i<handles.length;i++){
45              var handle=handles[i];
46
47              counter+=handle.length+14;
48              if(counter >= char_limit){
49                  search_queries.push(str_handles);
50                  counter=0;
51                  str_handles='';
52              }
53              if(str_handles.length > 0){
54                str_handles += " OR ";
55              }                
56              str_handles += "handle:\"" + handle + "\"";
57          }
58          search_queries.push(str_handles);
59
60
61          var q_done_count=0;
62          var i=0;
63          for(i=0;i<search_queries.length;i++){
64              scjQuery.ajax({
65                url : '/search?type=product&view=sc-pb-front-25052016&q='+search_queries[i],
66                processData : false,
67                contentType : false,
68                //dataType : 'json',
69                success : function(product_data, textStatus, jqXHR){
70                    
71                  	product_data=JSON.parse(product_data);
72                    var products=product_data.Items;
73					//console.log(products);
74                    for(j=0;j<products.length;j++){
75                        sc_ws_collection_products.products.push(products[j]);
76                        sc_ws_collection_products.products_by_handle[products[j].handle]=products[j];
77                        sc_ws_collection_products.products_by_id[products[j].id]=products[j];
78                    }
79                    sc_ws_collection_products.total_products+=product_data.TotalProduct;
80                    q_done_count+=1;
81
82                    if(q_done_count==search_queries.length){
83                        callback(sc_ws_collection_products);
84                    }
85
86                }
87            });
88          }
89
90
91      };
92  
93      SCPB.get_product_handle=function(url){
94          url=url.trim();
95          if(url.endsWith('/')){
96              url=url.substr(0,(url.length-1));
97          }
98          var handle=url.substr(url.lastIndexOf("/")+1);
99          return handle;
100      };
101  
102  
103  		SCPB.ObjectLength = function( object ) {
104            var length = 0;
105            for( var key in object ) {
106                if( object.hasOwnProperty(key) ) {
107                    ++length;
108                }
109            }
110            return length;
111        };
112  		//ops action before fire event
113        SCPB.pb_add_collection_page_auto_selector = function() {
114        	if(meta.page.pageType == 'collection' && _pb_install_type == 'manual'){
115              //var _pb_a_tag_objects = scjQuery('a[href*="/products/"]').has('img');
116              //var _pb_a_tag_objects = scjQuery('a[href*="/products/"]').has('img['+_pb_img_src+'*="/products/"]');
117              var _pb_a_tag_objects = scjQuery(_pb_collection_page_img_selector);
118              if(_pb_a_tag_objects.length > 0){
119                for(i=0;i<_pb_a_tag_objects.length;i++){
120                  //if(scjQuery(_pb_a_tag_objects[i]).length > 0 && scjQuery(_pb_a_tag_objects[i]).filter('[href*="/products/"]').length > 0){
121                  if(scjQuery(_pb_a_tag_objects[i]).length > 0){
122                      scjQuery(_pb_a_tag_objects[i]).addClass('sc-pb-element');
123                      //scjQuery(_pb_a_tag_objects[i]).parents().find('a').addClass('sc-pb-element');
124                  }
125                }
126              }
127            }
128        }
129        SCPB.pb_add_product_page_auto_selector = function() {
130        	if(meta.page.pageType == 'product' && _pb_install_type == 'manual'){
131              if(_pb_product_page_img_selector != ''){
132              	scjQuery(_pb_product_page_img_selector).addClass('sc-pb-element');
133              } else {
134                var _pb_product_img_object = scjQuery('img[src*="/products/"][src*="/cdn.shopify.com/s/files/"]').filter('[src*=".jpg"],[src*=".jpeg"],[src*=".png"]');
135                if(_pb_product_img_object.length > 0){
136                  for(i=0;i<_pb_product_img_object.length;i++){
137                    if(scjQuery(_pb_product_img_object[i]).length > 0){
138                        scjQuery(_pb_product_img_object[i]).addClass('sc-pb-element');
139                    }
140                  }
141                }
142              }
143            }
144        }
145        //opu patch
146        if(_pb_install_type=='manual'){
147        	SCPB.pb_add_collection_page_auto_selector();
148          	SCPB.pb_add_product_page_auto_selector();
149        }
150  		//////////////////////////////////////////////////////////////////////////////////////////////
151  
152  		var APP_BASE_URL = '/apps/product-badge';
153		var MSG_TYPE_NOTICE = 'notice';
154        var __scassets__object = __scpdt__assets__object.split('scpdt.css');
155      	var __scpdt_assets__url = __scassets__object[0];
156  		//console.log(__scpdt_assets__url);
157		//
158		search_result = function(result){
159          
160          		SCPB.productListShopify = {};
161				//
162				scjQuery.each(result.products, function(i, product){
163						console.log(product.handle);
164                  		SCPB.productListShopify[product.handle] = product
165				});
166          		
167				for(var handle in SCPB.imgElements){
168						//
169						var imgElement = SCPB.imgElements[handle];
170						var img = scjQuery("img", imgElement);
171                  		var imgParent = img.parents(":not(a)").first();
172                  		if(_pb_install_type=='manual' && _pb_collection_page_img_holder_selector != ''){
173                          img = scjQuery(imgElement).parent().find(_pb_collection_page_img_holder_selector);
174                          imgParent = img.parent();
175                        }
176						
177                  		imgParent.addClass("sc-badge-main");
178						img.before("<div class=\"sc-badge-container sc-badge-collection\">");
179						objElement = scjQuery(imgElement);
180						scjQuery('.sc-badge-collection', imgParent).css({
181								"width" : objElement.width(),
182								"height" : objElement.height(),
183								"margin-left" : SCPB.getBadgeMarginW(objElement),
184								"margin-right" : SCPB.getBadgeMarginW(objElement),
185								"margin-top" : SCPB.getBadgeMarginH(objElement),
186								"margin-bottom" : SCPB.getBadgeMarginH(objElement),
187								"padding" : SCPB.getBadgePadding(objElement),
188						});
189						//console.log(imgElement);
190                  		var product = SCPB.productListShopify[handle];
191						SCPB.activeVariant = product.variants[0];
192						SCPB.showBadgeForProduct(product, imgElement)
193				}
194		};
195		//
196		SCPB.getVariantId = function(){
197				var variantId = false;
198				if(typeof Shopify == "object" && typeof Shopify.urlParam == "function")
199						variantId = Shopify.urlParam("variant");
200				var index = typeof product_select_index === "number" ? product_select_index : 0;
201				if(!variantId){
202						if(scjQuery("form[action='/cart/add'] select[name='id'] option:selected").length){
203								variantId = scjQuery("form[action='/cart/add'] select[name='id'] option:selected")[index].value;
204						}else{
205								if(scjQuery("form[action='/cart/add'] input[name='id']").length){
206										variantId = scjQuery("form[action='/cart/add'] input[name='id']")[index].value;
207										console.log('v', variantId);
208								}
209						}
210
211				}
212				return variantId;
213
214				
215		}
216
217		SCPB.validateBadgeConditions = function(condition, product){
218
219				var match = true;
220				var sc_log = true;
221				//
222				if(sc_log)console.log('validation-start');
223				if(condition.on_sale == 'yes'){
224						if(match){
225								if(!SCPB.activeVariant.hasOwnProperty("compare_at_price") || SCPB.activeVariant.compare_at_price == null){
226										match = false;
227								}else{
228										match = false;
229										var discount_price = SCPB.activeVariant.compare_at_price - SCPB.activeVariant.price;
230										if(parseFloat(condition.min_discount_amount)){
231												if(discount_price >= ( parseFloat(condition.min_discount_amount) * 100 )){
232														match = true;
233												}
234										}
235										if(parseFloat(condition.min_discount_percentage)){
236												if(( ( discount_price / SCPB.activeVariant.compare_at_price ) * 100 ) >= parseFloat(condition.min_discount_percentage)){
237														match = true;
238												}
239										}
240								}
241						}
242				}else if(condition.on_sale == 'no'){
243				}
244				if(!match && sc_log)console.log('on_sale');
245				if(condition.new == 'yes'){
246						if(condition.from_time || condition.to_time){
247								if(match){
248										if(condition.from_time.trim() != ""){
249												if(Date.parse(parsePublishedDate(product.published_at)) < Date.parse(condition.from_time)){
250														match = false
251												}
252										}
253										if(condition.to_time.trim() != "" && match){
254												if(Date.parse(parsePublishedDate(product.published_at)) > Date.parse(condition.to_time)){
255														match = false
256												}
257										}
258								}
259						}
260						
261						if(parseInt(condition.last_days) &&
262								( match && ( condition.from_time.trim() == "" && condition.to_time.trim() == "" ) )
263								|| ( !match && ( condition.from_time.trim() != "" || condition.to_time.trim() != "" ) )
264								){
265								var till_last_days = new Date(product.published_at);
266								var today = new Date();
267								till_last_days.setDate(till_last_days.getDate() + parseInt(condition.last_days));
268								if(till_last_days < today){
269										match = false;
270								}else if(!match)match = true;
271						}
272						
273				}else if(condition.new == 'no' && match){
274						if(condition.from_time || condition.to_time){
275								if(match){
276										if(condition.from_time.trim() != ""){
277												if(Date.parse(parsePublishedDate(product.published_at)) >= Date.parse(condition.from_time)){
278														match = false
279												}
280										}
281										if(condition.to_time.trim() != "" && match){
282												if(Date.parse(parsePublishedDate(product.published_at)) <= Date.parse(condition.to_time)){
283														match = false
284												}
285										}
286								}
287						}
288						
289						if(parseInt(condition.last_days) &&
290								( match && ( condition.from_time.trim() == "" && condition.to_time.trim() == "" ) )
291								|| ( !match && ( condition.from_time.trim() != "" || condition.to_time.trim() != "" ) )
292								){
293								var till_last_days = new Date(product.published_at);
294								var today = Date.now();
295								till_last_days.setDate(till_last_days.getDate() + parseInt(condition.last_days));
296								if(till_last_days >= today){
297										match = false;
298								}else if(!match)match = true;
299						}
300						
301				}
302
303				if(!match && sc_log)console.log('new');
304
305				if(condition.collections && match){
306						match = false;
307						var cids = condition.collections.split(",");
308						for(var i = 0; i < product.collections.length; i++){
309								var cid = product.collections[i];
310								if(scjQuery.inArray(cid + "", cids) >= 0){
311										match = true;
312										break
313								}
314						}
315				}
316
317				if(!match && sc_log)console.log('collection');
318
319				if(condition.stock == 'avail'){
320						if(match){
321								match = false;
322								for(var i = 0; i < product.variants.length; i++){
323										var variant = product.variants[i];
324										if(variant.inventory_quantity > 0 || !variant.hasOwnProperty('inventory_management')){
325												match = true;
326												break
327										}
328								}
329						}
330				}else if(condition.stock == 'not_avail'){
331						if(match){
332								for(var i = 0; i < product.variants.length; i++){
333										var variant = product.variants[i];
334										if(variant.inventory_quantity > 0 || !variant.hasOwnProperty('inventory_management')){
335												match = false;
336												break
337										}
338								}
339						}
340				}else if(condition.stock == 'low_stock'){
341						if(match){
342								match = false;
343								//
344								min_qty = condition.stock_min_qty ? parseInt(condition.stock_min_qty) : 1;
345								if(min_qty && min_qty <= 0)
346										min_qty = 1;
347								//
348								for(var i = 0; i < product.variants.length; i++){
349										var variant = product.variants[i];
350										if(variant.inventory_quantity > 0 && variant.inventory_quantity <= min_qty && variant.hasOwnProperty('inventory_management')){
351												match = true;
352												break
353										}
354								}
355						}
356				}
357
358				if(!match && sc_log)console.log('stock');
359
360				if(condition.hasOwnProperty('from_price') || condition.hasOwnProperty('to_price')){
361						if(match){
362								if(condition.hasOwnProperty('from_price') && condition.from_price != ""){
363										if(SCPB.activeVariant.price < ( parseFloat(condition.from_price) * 100 )){
364												match = false
365										}
366								}
367								if(condition.hasOwnProperty('to_price') && condition.to_price != "" && match){
368										if(match == true && SCPB.activeVariant.price > ( parseFloat(condition.to_price) * 100 )){
369												match = false
370										}
371								}
372						}
373				}
374
375				if(!match && sc_log)console.log('from_price - to_price: ');
376
377				if(condition.v_option == 'ex_sel_variant'){
378						if(match){
379								var vids = condition.variant_list.split(",");
380								if(scjQuery.inArray(SCPB.activeVariant.id + "", vids) != -1){
381										match = false;
382								}
383
384						}
385				}else if(condition.v_option == 'sel_variant_only' && match){
386						match = false;
387						var vids = condition.variant_list.split(",");
388						if(scjQuery.inArray(SCPB.activeVariant.id + "", vids) != -1){
389								match = true;
390						}
391				}
392				if(!match && sc_log)console.log('V_option');
393				if(sc_log)console.log('validation-end: ', match);
394				return match;
395		}
396
397		SCPB.showBadge = function(product, element, badgeID, imgPosition, imgText, imgURL, badgeWidth, badgeHeight, inPX, text_styles, badge_styles){
398
399				//
400				var badgeElm;
401				if(element)
402						badgeElm = scjQuery(".sc-badge-container .sc-badge-img[data-sc-badge-id='" + badgeID + "']", element);
403				else
404						badgeElm = scjQuery(".sc-badge-container .sc-badge-img[data-sc-badge-id='" + badgeID + "']");
405				//
406          		if(badgeElm.length > 0){
407						badgeElm.first().show()
408				}else{
409                  		var newNode = '<div data-sc-badge-id="' + badgeID + '" class="sc-badge-img ' + imgPosition + '" style="background-size: cover; background-image: url('
410								+ "'" + __scpdt_assets__url + imgURL + "'" + '); width: ' + ( badgeWidth ? badgeWidth : 30 ) + ( inPX == "true" ? 'px' : '%' ) + '; height: ' + ( badgeHeight ? badgeHeight : 30 )
411								+ ( inPX == 'true' ? 'px' : '%' ) + ';' + badge_styles + ' ">';
412						if(imgText){
413								var text = imgText;
414								if(text.indexOf("##SAVE_PERCENTAGE##") >= 0){
415										var save_percent = 0;
416										if(SCPB.activeVariant.hasOwnProperty('compare_at_price') && SCPB.activeVariant.price < SCPB.activeVariant.compare_at_price){
417												save_percent = ( SCPB.activeVariant.compare_at_price - SCPB.activeVariant.price ) / SCPB.activeVariant.compare_at_price * 100;
418												save_percent = Math.round(save_percent * 100) / 100;
419										}
420										text = text.replace('##SAVE_PERCENTAGE##', save_percent);
421								}
422								if(text.indexOf("##SAVE_AMOUNT##") >= 0){
423										var save_amount = 0;
424										if(SCPB.activeVariant.hasOwnProperty('compare_at_price') && SCPB.activeVariant.price < SCPB.activeVariant.compare_at_price){
425												save_amount = ( SCPB.activeVariant.compare_at_price - SCPB.activeVariant.price ) / 100;
426										}
427										var save_amount_with_currency = sc_pb_money_format.replace("{{amount}}", save_amount);
428										text = text.replace('##SAVE_AMOUNT##', save_amount_with_currency)
429								}
430								if(text.indexOf("##PRODUCT_PRICE##") >= 0){
431										var price_with_currency = sc_pb_money_format.replace("{{amount}}", ( SCPB.activeVariant.price / 100 ));
432										text = text.replace('##PRODUCT_PRICE##', price_with_currency)
433								}
434								if(text.indexOf("##NEW_DAYS##") >= 0){
435										var date_difference = ( Date.parse(product.published_at) - new Date() ) / 86400000;
436										text = text.replace('##NEW_DAYS##', date_difference)
437								}
438								if(text.indexOf("##PRODUCT_SKU##") >= 0){
439										if(SCPB.activeVariant.hasOwnProperty('sku')){
440												if(SCPB.activeVariant.sku != ""){
441														text = text.replace('##PRODUCT_SKU##', SCPB.activeVariant.sku)
442												}
443										}else{
444												text = "";
445										}
446								}
447								if(text.indexOf("##PRODUCT_QUANTITY##") >= 0){
448										if(SCPB.activeVariant.hasOwnProperty('inventory_quantity') && SCPB.activeVariant.hasOwnProperty('inventory_management')){
449												if(SCPB.activeVariant.inventory_quantity > 0 && SCPB.activeVariant.inventory_management){
450														text = text.replace('##PRODUCT_QUANTITY##', SCPB.activeVariant.inventory_quantity)
451												}
452										}else{
453												text = "";
454										}
455								}
456								var textStyle = text_styles;
457								//
458								newNode += '<span class="sc-badge-content" style="' + ( textStyle ? textStyle : '' ) + '">
458' + text + '</span>'
459						}
460						newNode += '</div>';
461
462						//console.log(element);
463                  		
464                  		if(SCPB.page == "product")
465								scjQuery('.sc-badge-container').append(newNode)
466						else
467                          	if(_pb_install_type == 'manual' && _pb_collection_page_img_holder_selector != ''){
468                          		scjQuery(element).parent().find(".sc-badge-container").append(newNode);
469                            } else {
470                          		scjQuery('.sc-badge-container', element).append(newNode)
471                            }
472				}
473		};
474
475		SCPB.showBadgeForProduct = function(product, element){
476				var matched = false;
477				var arrBadges = SCPB.badges;
478				for(var id in arrBadges){
479						var badge = arrBadges[id];
480						var condition = badge.logics;
481						//
482						if(matched){
483								break;
484						}
485						// 
486						matched = badge.enabled === "1" ? SCPB.validateBadgeConditions(condition, product) : false;
487						if(!matched){
488								continue;
489						}
490						//
491						if(SCPB.page == "product"){
492								SCPB.showBadge(product, element, badge.id, badge.product.imgOptions.position, badge.product.imgOptions.text, badge.product.imgOptions.url
493										, badge.product.imgOptions.badge_width, badge.product.imgOptions.badge_height, badge.product.imgOptions.in_px, badge.product.imgOptions.text_styles, badge.product.imgOptions.badge_styles);
494						}else{
495                          		SCPB.showBadge(product, element, badge.id, badge.collection.imgOptions.position, badge.collection.imgOptions.text, badge.collection.imgOptions.url
496										, badge.collection.imgOptions.badge_width, badge.collection.imgOptions.badge_height, badge.collection.imgOptions.in_px, badge.collection.imgOptions.text_styles, badge.collection.imgOptions.badge_styles);
497						}
498				}
499				return null
500		};
501
502		function getImageLinkList(){
503				if(scjQuery('.sc-pb-element').length > 0){
504						var elements = scjQuery('.sc-pb-element');
505				}else{
506						var elements = scjQuery('a[href*="/products/"]:not(form a[href*="/products/"]):not(.related-products a[href*="/products/"])').has('img[src*="/products/"], img[src*="/no-image"]');
507				}
508
509				
510          		//console.log(elements);
511          		var arrElements = {};
512				elements.each(function(index, element){
513						var splits = scjQuery(element).attr('href').split('/');
514						var handle = splits[splits.length - 1].split('?')[0];
515						arrElements[handle] = element
516				});
517          		//console.log(arrElements);
518          		return arrElements;
519		}
520
521		function getImageLinkFromProductPage(){
522          		if(scjQuery('.sc-pb-element').length > 0){
523						var images = scjQuery('.sc-pb-element');
524				}else{
525						var images = scjQuery('img[src*="/products/"][src*="/cdn.shopify.com/s/files/"]').filter('[src*=".jpg"],[src*=".jpeg"],[src*=".png"]');
526				}
527
528				var maxWidth = 0;
529				var mainImage;
530				images.each(function(index, image){
531						var currentWidth = image.width;
532						if(currentWidth > maxWidth){
533								maxWidth = currentWidth;
534								mainImage = image
535						}
536				});
537				return mainImage;
538		}
539
540		
541
542		function parsePublishedDate(published_date){ // added by tawhid
543				var published_date = new Date(published_date);
544				var year = published_date.getFullYear();
545				var month = published_date.getMonth() + 1;
546				var date = published_date.getDate();
547				return  month + "/" + date + "/" + year;
548		}
549
550		SCPB.getBadgeMarginW = function(elem, strCssRule){
551				var bordT = elem.outerWidth() - elem.innerWidth();
552				var paddT = elem.innerWidth() - elem.width();
553				var margT = elem.outerWidth(true) - elem.outerWidth();
554				return margT / 2
555		};
556
557		SCPB.getBadgeMarginH = function(elem, strCssRule){
558				var bordT = elem.outerHeight() - elem.innerHeight();
559				var paddT = elem.innerHeight() - elem.height();
560				var margT = elem.outerHeight(true) - elem.outerHeight();
561				return margT / 2
562		};
563
564		SCPB.getBadgePadding = function(elem, strCssRule){
565				var bordT = elem.outerWidth() - elem.innerWidth();
566				var paddT = elem.innerWidth() - elem.width();
567				var margT = elem.outerWidth(true) - elem.outerWidth();
568				return paddT
569		};
570
571		SCPB.bindBadges = function(){
572				if(SCPB.page === 'product'){
573						scjQuery('.sc-badge-container .sc-badge-img').hide();
574						//
575						var image = getImageLinkFromProductPage();
576						var imgObj = scjQuery(image);
577						//
578						var imageParent = imgObj.parents(":not(a)").first();
579						imageParent.addClass("sc-badge-main");
580						if(imgObj){
581								imgObj.before("<div class=\"sc-badge-container\">");
582								scjQuery('.sc-badge-container').css({
583										"width" : imgObj.width(),
584										"height" : imgObj.height(),
585										"margin-left" : SCPB.getBadgeMarginW(imgObj),
586										"margin-right" : SCPB.getBadgeMarginW(imgObj),
587										"margin-top" : SCPB.getBadgeMarginH(imgObj),
588										"margin-bottom" : SCPB.getBadgeMarginH(imgObj),
589										"padding" : SCPB.getBadgePadding(imgObj),
590								});
591								//
592								var variant = null;
593								var variantId = SCPB.getVariantId();
594								if(variantId){
595										var product = SCPB.product;
596										for(var i = 0; i < product.variants.length; i++){
597												if(variantId == product.variants[i].id){
598														variant = product.variants[i];
599														break;
600												}
601										}
602								}else
603										variant = SCPB.product.variants[0];
604								//
605								SCPB.activeVariant = variant;
606								//
607								if(variant != null){
608										SCPB.showBadgeForProduct(product, image);
609								}
610						}
611				}else{
612						
613                  		
614                  
615                  		SCPB.imgElements = getImageLinkList();
616						//
617						/*var searchKeyword = "";
618						for(var handle in SCPB.imgElements){
619								if(searchKeyword.length > 0)
620										searchKeyword += " OR ";
621								searchKeyword += "handle:\"" + handle + "\""
622						}*/
623						//
624						var SC_AppBaseURL = "/apps/product-badge/";
625						var SC_AppScriptPath = SC_AppBaseURL + 'scripts/';
626						var SC_App_Front_Path = SC_AppBaseURL + 'app-front/';
627						//
628						
629						//scjQuery.getScript('/search?q=' + searchKeyword + '&view=sc-pb-front-25052016');
630                  		SCPB.get_page_products(search_result);
631				}
632		};
633		SCPB.page = SCPB.page.split('.')[0];
634		if(scjQuery.inArray(SCPB.page, ['index', 'collection', 'product']) >= 0){
635      
636          //if (typeof (Storage) !== "undefined") {
637            
638        	/*if (sessionStorage.sc_pb_badges) {
639              	console.log('add badge from session');
640              	SCPB.badges = JSON.parse(sessionStorage.sc_pb_badges);
641              	SCPB.bindBadges();
642              	var _badge_custom_css = JSON.parse(sessionStorage.sc_pb_settings);
643              	scjQuery('body').append("<style>" + _badge_custom_css.custom_css + "</style>");
644            } else {*/
645            
646            if (typeof _sc_pb_json_data !== 'undefined') {
647            	console.log('add badge from liquid');
648              	var b_data = JSON.parse(Base64.decode(_sc_pb_json_data));
649                //sessionStorage.setItem("sc_pb_badges", JSON.stringify(b_data.badges));
650                SCPB.badges = b_data.badges;
651                SCPB.bindBadges();
652
653                //sessionStorage.setItem("sc_pb_settings", JSON.stringify(b_data.settings));
654                if(b_data.settings.custom_css != ''){
655                    scjQuery('body').append("<style>" + b_data.settings.custom_css + "</style>");
656                }
657            } else {
658                scjQuery.ajax({
659                  type: 'GET',
660                  url: "/apps/product-badge/app-front/app-front/get_all_badges",
661                  dataType: 'json',
662                  async: false,
663                  success: function (data, textStatus, jqXHR) {
664                    if (data.type == MSG_TYPE_NOTICE) {
665                      var b_data = JSON.parse(data.text);
666                      //sessionStorage.setItem("sc_pb_badges", JSON.stringify(b_data.badges));
667                      console.log('add badge from ajax');
668                      SCPB.badges = b_data.badges;
669                      SCPB.bindBadges();
670                      //sessionStorage.setItem("sc_pb_settings",JSON.stringify(b_data.settings));
671                      if(b_data.settings.custom_css != ''){
672                        scjQuery('body').append("<style>" + b_data.settings.custom_css + "</style>");
673                      }
674                    }
675                  }
676                });
677            }
678        
679        
680        
681        /*scjQuery.ajax({
682          type: 'GET',
683          url: "/apps/product-badge/app-front/app-front/get_all_badges",
684          dataType: 'json',
685          async: false,
686          success: function (data, textStatus, jqXHR) {
687            if (data.type == MSG_TYPE_NOTICE) {
688              //
689			  var b_data = JSON.parse(data.text);
690			  //
691			  sessionStorage.setItem("sc_pb_badges", JSON.stringify(b_data.badges));
692              console.log('add badge from ajax');
693              SCPB.badges = b_data.badges;
694              SCPB.bindBadges();
695			  
696			  
697			  sessionStorage.setItem("sc_pb_settings",JSON.stringify(b_data.settings));
698              //console.log('add settings from ajax');
699              //data = JSON.parse(data.text);
700              if(b_data.settings.custom_css != ''){
701			  	scjQuery('body').append("<style>" + b_data.settings.custom_css + "</style>");
702			  }
703            }
704          }
705        });*/
706      //}
707
708      /*if (sessionStorage.sc_pb_settings) {
709        var settings = JSON.parse(sessionStorage.sc_pb_settings);
710        console.log('add settings from session');
711        scjQuery('body').append("<style>" + settings.custom_css + "</style>");
712      } else {
713        scjQuery.ajax({
714          type: 'GET',
715          url: "/apps/product-badge/app-front/app-front/get_settings",
716          dataType: 'json',
717          async: false,
718          success: function (data, textStatus, jqXHR) {
719            if (data.type == MSG_TYPE_NOTICE) {
720              sessionStorage.setItem("sc_pb_settings",data.text);
721              console.log('add settings from ajax');
722              data = JSON.parse(data.text);
723              scjQuery('body').append("<style>" + data.custom_css + "</style>");
724            }
725          }
726        });
727      }*/
728      
729    //} else {
730      /*scjQuery.ajax({
731        type: 'GET',
732        url: "/apps/product-badge/app-front/app-front/get_all_badges",
733        dataType: 'json',
734        async: false,
735        success: function (data, textStatus, jqXHR) {
736          if (data.type == MSG_TYPE_NOTICE) {
737            var _pb_object = JSON.parse(data.text)
738			SCPB.badges = JSON.parse(_pb_object.badges);
739            SCPB.bindBadges();
740          }
741        }
742      });*/
743
744      /*scjQuery.ajax({
745        type: 'GET',
746        url: "/apps/product-badge/app-front/app-front/get_settings",
747        dataType: 'json',
748        async: false,
749        success: function (data, textStatus, jqXHR) {
750          if (data.type == MSG_TYPE_NOTICE) {
751            data = JSON.parse(data.text);
752            scjQuery('body').append("<style>" + data.custom_css + "</style>");
753          }
754        }
755      });*/
756
757    //}
758		}
759		//
760		SCPB.update_variant = function(variant){
761				
762				SCPB.activeVariant = variant;
763				scjQuery('.sc-badge-container').empty();
764				var image = getImageLinkFromProductPage();
765				SCPB.showBadgeForProduct(SCPB.product, image);
766		}
767
768      
769}

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.