PageSourceSearch

https://www.somfy.nl/RichPages/js/rp.js?1790326431194

js somfy.nl collected 2026-09-28 05:45:23 UTC 7,352 bytes, 197 lines download raw bytes

1(function ($) {
2    "use strict";
3    var ecommerceService = {
4        init: function() {
5        },
6        loadProducts: function() {
7            var _ecommerceService = this;
8            var _price = 0;
9
10            var references = $(".product_item").find("a").map(function() {
11                return $(this).data("ref");
12            }).get().join(',');
13			//console.log("productRefs",references);
14        }
15    },
16    manageLocalStorage = {
17    	init: function() {
18    	},
19    	displayLastVisitedProduct: function(){
20	    	if (storageAvailable('localStorage') && $("#lastProductVisited").length) {
21	    		let sfyProductRefArray = localStorage.getItem('sfyProductReferences') ? JSON.parse(localStorage.getItem('sfyProductReferences')) : [];
22				//remove current product
23				if(typeof sfy_product_reference !== 'undefined' && sfyProductRefArray.includes(sfy_product_reference)) {
24					const indexCurrentProduct = sfyProductRefArray.indexOf(sfy_product_reference);
25					if (indexCurrentProduct > -1) { 
26						sfyProductRefArray.splice(indexCurrentProduct, 1);
27					}
28				}
29	    		//do ajax call to display slider of last visited products
30	    		if (sfyProductRefArray.length > 0){
31	    			console.log("sfyProductRefArray",sfyProductRefArray);
32	    			//console.log("sfyProductRefArrayjoin",sfyProductRefArray.join(','));
33	    			//limit  length to 10 
34	    			if (sfyProductRefArray.length >= 10){
35	    				sfyProductRefArray = sfyProductRefArray.slice(-10);
36	    				console.log("sfyProductRefArray_10",sfyProductRefArray);
37	    			}
38	    			var ajaxDisplayLastProducts = $.ajax({
39	                    url: pageAjaxURL + '?plugin=RichPages&action=lastProductVisited',
40	                    type: "POST",
41	                    data: {
42	    					references: sfyProductRefArray.join(',')
43	                    },
44	                    dataType: "html",
45	                    success: function( data ) { 
46							$("#lastProductVisited").removeClass("d-none");
47	                    	$("#lastProductVisited .product_slider").append(data);
48
49							$('#lastProductVisited .product').on('click', function (e) {
50								// add event tagcommander
51								try {
52									tc_product_event_click($('.product-title', this));
53								} catch (error) {
54									console.log(error);
55								}
56							});
57
58							if (typeof loadPricesForVisibleProducts === "function") {
59								loadPricesForVisibleProducts(true);
60							}
61
62							if(typeof displayWishlistIconsThumbnails === "function") {
63								displayWishlistIconsThumbnails();
64							}
65
66							// not required on V6
67	                        try {
68	                        	var items = $('#lastProductVisited .product_slider .product_item');
69	                            /* reinit tagCo events for block click*/
70	                        	if(items.length > 0 && typeof unbind_block_click === "function"  && typeof block_click === "function"){
71	                        		unbind_block_click();
72	                        		block_click();
73	                        	}
74	                        	if(items.length > 1) {
75	                                var autoplay = false;
76	                                jQuery('#lastProductVisited .product_slider').data('instance').init();
77	                             	$('#lastProductVisited .list_products').slick('slickPause');
78	                             	$('#lastProductVisited [data-toggle="tooltip"]').tooltip();
79	                        	}
80	                        	
81	                        } catch(e) {
82	                        	console.log("error while loading last product visited", e);
83	                        }
84	                        
85	                    }
86	                });
87	    		}
88	    	}
89    	},
90    	addReferenceToLastVisitedProduct: function(){
91    		if (storageAvailable('localStorage')) {
92    			let sfyProductRefArray = localStorage.getItem('sfyProductReferences') ? JSON.parse(localStorage.getItem('sfyProductReferences')) : [];
93    			// TODO get the product reference from URL ? 
94    			//var newref = getParameterByName('ref');
95    			if(typeof sfy_product_reference !== 'undefined' && sfy_product_reference !== null) {
96    				if (sfyProductRefArray.length >= 10) {
97	    				sfyProductRefArray = sfyProductRefArray.slice(-10);
98	    			}
99        			sfyProductRefArray.push(sfy_product_reference);
100        			localStorage.setItem('sfyProductReferences', JSON.stringify(uniqueArray(sfyProductRefArray)));
101    			}
102
103    		}
104    	}
105    }
106    $(document).ready(function () {
107        ecommerceService.init();        
108        manageLocalStorage.init();
109        manageLocalStorage.addReferenceToLastVisitedProduct();
110        manageLocalStorage.displayLastVisitedProduct();
111        ecommerceService.loadProducts();
112
113        $('.conversionGuideList').trigger('change');
114
115        $('.conversionGuideList').on('change', function(){
116            if($('#conversionGuideList_1').val() != '' && $('#conversionGuideList_2').val() != ''){
117                $('#ConversionGuideProductsSlider').hide();
118                $('#ConversionGuideLoader').show();
119
120                var codeGuide = $('#nl-form').data('guide');
121                var codeList1 = $('#conversionGuideList_1').val();
122                var codeList2 = $('#conversionGuideList_2').val();
123
124                getConversionGuideProducts(codeGuide, codeList1, codeList2);
125            }
126        });
127    });
128})(jQuery);
129
130
131function storageAvailable(type) {
132	try {
133		var storage = window[type],
134		x = '__storage_test__';
135		storage.setItem(x, x);
136		storage.removeItem(x);
137		return true;
138	}
139	catch(e) {
140		return e instanceof DOMException && (
141			// everything except Firefox
142			e.code === 22 ||
143			// Firefox
144			e.code === 1014 ||
145			// test name field too, because code might not be present
146			// everything except Firefox
147			e.name === 'QuotaExceededError' ||
148			// Firefox
149			e.name === 'NS_ERROR_DOM_QUOTA_REACHED') &&
150			// acknowledge QuotaExceededError only if there's something already stored
151			storage.length !== 0;
152	}
153}
154
155function getParameterByName(name, url) {
156	if (!url) url = window.location.href;
157	name = name.replace(/[\[\]]/g, "\\$&");
158	var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
159	results = regex.exec(url);
160	if (!results) return null;
161	if (!results[2]) return '';
162	return decodeURIComponent(results[2].replace(/\+/g, " "));
163}
164
165function uniqueArray(arr) {
166	var a = [];
167	for (var i=0, l=arr.length; i<l; i++)
168		if (a.indexOf(arr[i]) === -1 && arr[i] !== '')
169			a.push(arr[i]);
170	return a;
171}
172
173function getConversionGuideProducts(codeGuide, codeList1, codeList2){
174    $.ajax({
175        url: pageAjaxURL + '?plugin=RichPages&action=conversionGuideProducts',
176        type: "POST",
177        data: {
178            codeGuide:codeGuide,
179            codeList1:codeList1,
180            codeList2:codeList2
181        },
182        dataType: "html",
183        success: function( data ) {
184            try {
185
186                $('#ConversionGuideProductsSlider').html(data);
187
188                $('#ConversionGuideLoader').hide();
189                $('#ConversionGuideProductsSlider').show();
190
191            } catch(e) {
192                console.log("error while loading last product visited", e);
193            }
194
195        }
196    });
197}

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.