PageSourceSearch

https://www.trollmall.com/users/flaaronning2_mystore_no/templates/custom_javascript.js?v=1791523030

js trollmall.com collected 2026-10-09 05:17:33 UTC 17,430 bytes, 389 lines download raw bytes

1      
2
3
4var modalLanguages = {
5          Norge:['https://www.trollmall.com/pages/flaaronningcom', 'NOK', 'norway.png'],
6          EU:['https://www.trollmall.com', 'EUR', 'eu.png'],
7          Sweden:['https://www.trollmall.com', 'SEK', 'sweden.png'],
8          Other:['https://www.trollmall.com', 'USD', 'globe.png'],
9      }
10
11jQuery(document).ready( function($){
12	// Disable dropdown / megamenu
13  var navLinks = document.querySelectorAll('.list-inline > li');
14
15    function redirection() {
16      document.getElementById('addShadeBg').style.display = 'none';
17      this.querySelector('.menu-hover').click();
18    }
19
20    navLinks.forEach(navLink => {
21      navLink.addEventListener('click', redirection);
22    })
23  //Currecny Modal
24    if (window.location.href.indexOf("sandbox=1") > -1 || true) {
25    // Add Language Modal
26     var img_path = '/users/flaaronning2_mystore_no/Image/';
27
28      var englishPopup =
29          '<div class="modal fade" data-backdrop="static" data-keyboard="false" id="engCountryModal" tabindex="-1" role="dialog" aria-labelledby="engCountryModalTitle" aria-hidden="true"> \
30            <div class="modal-dialog modal-dialog-centered" role="document"> \
31              <div class="modal-content" style="padding: 10px;"> \
32                <div class="modal-header row" style="text-align: center; border-bottom: none;"> \
33                  <h5 class="modal-title col-12">Welcome to Trollmall</h5> \
34                  <p>Select region</p> \
35                </div> \
36                <div class="modal-body row plr20" style="font-size: 1rem; list-style: none; justify-content: center;"> \
37                  <ul class="col-4 modal__content" style="list-style: none; text-align: left; margin: 0;"></ul> \ \
38                </div> \
39                <div class="modal-footer" style="text-align: left; list-style: none; padding-top: 0; padding-bottom: 0;"> \
40                </div> \
41              </div> \
42            </div> \
43          </div>';
44
45
46      var modalContent = ''
47	
48      
49      Object.keys(modalLanguages).map(key => {
50        var usedPathname = (window.location.pathname === "/" ? '' : window.location.pathname);
51		var newBaseUrl = modalLanguages[key][0] + usedPathname;
52		var urlParams = window.location.search.replace('?', '&');
53		//modalContent += `<li class="key"><a href="${modalLanguages[key][0]}/?currency=${modalLanguages[key][1]}" data-country-name="${key}"><img src=${img_path}${modalLanguages[key][2]}> ${key}</a></li></a></li>`;
54		modalContent += `<li class="key"><a href="${newBaseUrl}/?currency=${modalLanguages[key][1]}
54${urlParams}" data-country-name="${key}"><img src=${img_path}${modalLanguages[key][2]}> ${key}</a></li></a></li>`;
55      });
56    
57
58    $('body').append(englishPopup);
59    $('.modal__content').append(modalContent);    
60    
61    function dontShow(country) {
62      modalSetCookie("CountryModalClosed", "true");
63      modalSetCookie("CountryModalVal", country, 5);
64    }
65    
66      $(document).on('click', '#engCountryModal .modal-body li a', function(e){
67          cm_link = $(this).attr('href');
68          cm_country = $(this).data('country-name');
69
70          e.preventDefault();
71          dontShow(cm_country);
72          setTimeout(function(){
73              window.location = cm_link + '&country=' + cm_country;
74          }, 500);
75          return false;
76   
77     });
78    
79	console.log("test code");
80      modalSetCookie("MCPopupClosed", "yes", 1000);
81      if (modalGetCookie("CountryModalClosed") != "true"){
82			console.log("test code 1");
83		  $('#engCountryModal').show();
84          $('#engCountryModal').addClass('in');
85          $('#engCountryModal').addClass('show');
86      }
87    
88
89
90  } // End of sandbox
91  
92  
93  
94  $(".europeBanners-index-row-two").insertAfter(".europeBanners-index-row-three:last");
95  if (location.href.indexOf('/products/') !== -1){
96    if (product.customer_group != '' && product.customer_group != '0'){
97
98      if ( product.tags.pakke !== undefined){
99        var html = '';
100        html += '<a href="#" class="decreaseQty">-</a>';
101          html += '<input id="qtyInput" type="text" min="' + product.tags.pakke + '" name="quantity" size="3" value="' + product.tags.pakke + '" step="' + product.tags.pakke + '" style="margin-bottom: 10px;">';
102        html += '<a href="#" class="increaseQty">+</a>';
103        $('.product_quantity').html(html);
104
105                                            var min = parseInt( $('#qtyInput').attr('min') );
106                                            var interval = parseInt( $('#qtyInput').attr('step') );
107                                    
108                                            $('.increaseQty').unbind('click');
109                                            $('.decreaseQty').unbind('click');
110
111                                            $('.increaseQty').click( function(e){
112                                        e.preventDefault();
113                                        var value = parseInt( $('#qtyInput').val());
114                                        
115                                        $('#qtyInput').val( value + interval );
116                                      });
117                                    
118                                      $('.decreaseQty').click( function(e){
119                                        e.preventDefault();
120                                        var value = parseInt( $('#qtyInput').val());
121                                        if(value - interval >= min ){
122                                                $('#qtyInput').val( value - interval );
123                                        } else {
124                                          // Do nothing
125                                        }
126                                      });
127                                            $('#qtyInput').focus( function(e){
128                                        e.preventDefault();
129                                        $(this).attr('disabled','disabled');
130                                      });
131                                            $('#qtyInput').blur( function(e){
132                                        e.preventDefault();
133                                        $(this).removeAttr('disabled');
134                                      });
135      }
136    }
137  }
138
139  if (customer_group != '' && customer_group != '0'){
140    if (location.href.indexOf('/cart') !== -1){
141      $('.cart-table.table tbody tr').each( function(){
142        var step = $(this).data('pakke');
143
144        if (step !== undefined && step != ''){
145          $(this).find('input').attr({ 'min': 0, 'step': step, 'style': "width:180px;" });
146          $(this).find('input').focusout( function(e){
147
148            var value = $(this).val();
149            var step = $(this).attr('step');
150            if (value % step != 0){
151              value = value - (value % step);
152
153              $(this).val(value);
154            }
155          });          
156        }
157      });
158    }
159  }
160	
161	$('.product-tabs .nav-tabs a').filter( function () {
162		return $(this).text() == 'Produsent' 
163	}).text('Designer')
164	
165
166  if (customer_group != '' && customer_group != '0'){
167
168    // 
169    $('.flex-products .product-box, .flex-stretch-products .product-box').each( function(i){
170      var html = '';
171      var quantity = $(this).data('pakke');
172
173      if (quantity !== undefined && quantity != '')
174        html += '<input type="hidden" name="quantity" value="'+ quantity +'">';
175
176      $(this).find('form').append(html);
177    });
178
179    // 
180    $('.checkout-cart > .cart_content .cart-product-wrapper .product').each( function(i){
181      var quantity = $(this).data('pakke');
182
183      if (quantity !== undefined && quantity != ''){
184        $(this).find('.quantity_changer').data('step', quantity);
185      }
186
187    });
188
189
190    jQuery(document).ready( function($){
191
192      setTimeout( function(){
193            $('.quantity_changer > a').undelegate('click');
194            $('.quantity_changer > a').unbind('click');
195            $('.quantity_changer > a').undelegate();
196$('body').undelegate('.quantity_changer > a', 'click');
197            $('body').delegate('.quantity_changer > a', 'click', function(e){
198                e.preventDefault();
199                var modifier = $(this).data('modify');
200                var id = $(this).parent().attr('data_id');
201                var quantity = parseInt($(this).parent().data('quantity'));
202
203                var step = parseInt($(this).closest('.product').attr('data-pakke'));
204                //console.log("STEP" + step);
205                //console.log("Quantity" + quantity);
206                if(modifier == 'increase'){
207                  var diff = quantity+step;
208                    $.post('ajax.php?ajaxfunc=update_cart_mobile&id='+id+'&qty='+diff, function(data) {
209              //open_drawer();
210                // Load the shopping cart widget content
211                              if (current_lang_code != 'no') {
212                                lang_prefix = '/' + current_lang_code;
213                              } else {
214                                lang_prefix = '';
215                              }
216
217                            $('.checkout-cart .cart_content').load(lang_prefix + ' .checkout-cart .cart_content > *' , function(dat){
218                              rebind_cart();
219                            });
220                            $('#mobile_cart .cart_content').load(lang_prefix + ' #mobile_cart .cart_content > *' , function(dat){
221                              rebind_cart();
222                            });
223                            $('.search-main.cart-menu.plr10.text-center .quantity_top_num_wrapper').load(lang_prefix + ' .search-main.cart-menu.plr10.text-center .quantity_top_num_wrapper > *', function(dat){
224                        updateMobileCartQuantity();
225                                });
226
227                        if (settings.advancedPopupOnPurchase == true){
228                            $('#shoppingcartp .left_part').load(lang_prefix + ' #shoppingcartp .left_part > *' , function(dat){
229                              rebind_cart();
230                            });
231                        }
232
233                    });
234                } else if (modifier == 'decrease'){
235                  var diff = quantity - step;
236                  if (diff < 0) diff = 0;
237
238                       $.post('ajax.php?ajaxfunc=update_cart_mobile&id='+id+'&qty='+diff, function(data) {
239                           //open_drawer();
240                           // Load the shopping cart widget content
241                              if (current_lang_code != 'no') {
242                                lang_prefix = '/' + current_lang_code;
243                              } else {
244                                lang_prefix = '';
245                              }
246
247                  $('.checkout-cart .cart_content').load(lang_prefix + ' .checkout-cart .cart_content > *' , function(dat){
248                    rebind_cart();
249                  });
250                  $('#mobile_cart .cart_content').load(lang_prefix + ' #mobile_cart .cart_content > *' , function(dat){
251                    rebind_cart();
252                  });
253                            $('.search-main.cart-menu.plr10.text-center .quantity_top_num_wrapper').load(lang_prefix + ' .search-main.cart-menu.plr10.text-center .quantity_top_num_wrapper > *', function(dat){
254                        updateMobileCartQuantity();
255                                });
256
257                        if (settings.advancedPopupOnPurchase == true){
258                            $('#shoppingcartp .left_part').load(lang_prefix + ' #shoppingcartp .left_part > *' , function(dat){
259                              rebind_cart();
260                            });
261                        }
262
263                    });
264                }
265            });
266        }, 1200);
267      });
268
269  }
270
271});
272
273
274// Shop the Look
275$(document).ready( function($){
276	$('.stl_package .stl_product').each( function(i){
277      
278      	if ($(this).data('tag-pakke') !== undefined && $(this).data('tag-pakke') > 0 ){
279          var tag_value = $(this).data('tag-pakke');
280          var that = $(this);
281          var input = $(this).find('input[name="quantity"]').detach();
282          input.addClass('stl_qty');
283          
284          var html = '';
285          if (customer_group != '' && customer_group != '0'){
286            html = '<a href="#" class="decreaseQty">-</a>';
287          	$(this).find('.stl_action-panel > .col-md-6').eq(0).append(html);
288          }
289          
290          $(this).find('.stl_action-panel > .col-md-6').eq(0).append(input);
291          $(this).find('input.stl_qty').attr('type', 'text');
292          
293          if (customer_group != '' && customer_group != '0'){
294        	html = '<a href="#" class="increaseQty">+</a>';
295            $(this).find('.stl_action-panel > .col-md-6').eq(0).append(html);
296
297            $(this).find('input.stl_qty').attr('min', tag_value);
298            $(this).find('input.stl_qty').attr('step', tag_value);
299            $(this).find('input.stl_qty').val(tag_value);
300            $(this).find('.stl_action-panel > .col-md-6').eq(0).addClass('product_quantity');
301            
302                                                        $('.increaseQty').unbind('click');
303                                            $('.decreaseQty').unbind('click');
304
305            
306                                       $('.increaseQty').click( function(e){
307                                        e.preventDefault();
308                                         var current_value =  $(this).parent().find('input.stl_qty').val();
309                                         console.log(current_value);
310                                         console.log(tag_value);
311                                         $(this).parent().find('input.stl_qty').val( parseInt(current_value) + parseInt(tag_value) );
312                                      });
313                                    
314                                      $('.decreaseQty').click( function(e){
315                                        e.preventDefault();
316                                        	var current_value =  $(this).parent().find('input.stl_qty').val();
317                                        console.log(current_value - tag_value >= tag_value);
318                                        if(current_value - tag_value >= tag_value ){
319                                           $(this).parent().find('input.stl_qty').val( parseInt(current_value) -  parseInt(tag_value) );
320                                        } else {
321                                          // Do nothing
322                                        }
323                                      });
324                                       $(this).find('input.stl_qty').focus( function(e){
325                                        e.preventDefault();
326                                        $(this).attr('disabled','disabled');
327                                      });
328                                       $(this).find('input.stl_qty').blur( function(e){
329                                        e.preventDefault();
330                                        $(this).removeAttr('disabled');
331                                      });
332
333            
334          }
335          
336        }
337    });
338  
339	if ($('a[data-target="overlay-account"] .menu__text').text().indexOf('My Account')!==-1){
340      $('a[data-target="overlay-account"] .menu__text').text('Account');
341    }
342});
343
344
345    function modalSetCookie(cname, cvalue, exdays) {
346      var d = new Date();
347      d.setTime(d.getTime() + (exdays*24*60*60*1000));
348      var expires = "expires="+ d.toUTCString();
349      document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
350    }
351    
352    function modalGetCookie(cname) {
353        var name = cname + "=";
354        var ca = document.cookie.split(';');
355        for(var i = 0; i <ca.length; i++) {
356            var c = ca[i];
357            while (c.charAt(0) == ' ') {
358                c = c.substring(1);
359            }
360            if (c.indexOf(name) == 0) {
361                return c.substring(name.length, c.length);
362            }
363        }
364    }
365
366	if (modalGetCookie('CountryModalVal')!==undefined && modalGetCookie('CountryModalVal')!=''){
367      var htmlImage = modalLanguages[modalGetCookie('CountryModalVal')][2];
368      var htmlTitle = modalLanguages[modalGetCookie('CountryModalVal')][1];
369          
370      var flagHtml = '<div class="mega-icons" id="flag-open">';
371            flagHtml += '<a href="#" data-backdrop="static" data-keyboard="false" class="topmenu-buttons flx flex-column align-items-center plr15">';
372              flagHtml += '<img src="/users/kokosweden_mystore_no/images_design/flags/'+ htmlImage +'" style="width: 32px;">';
373              flagHtml += '<span class="mega-icons-txt">'+ htmlTitle +'</span>';
374            flagHtml += '</a>';
375          flagHtml += '</div>';
376      $('.flx.__header_icons_wrapper').prepend(flagHtml);
377      
378      $('#flag-open').click( function(e){
379        e.preventDefault();
380        
381        $('#engCountryModal').show();
382        $('#engCountryModal').addClass('in');
383        $('#engCountryModal').addClass('show');
384      })
385    }
386
387
388
389	

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.