https://kauppa.healthylife.fi/wp-content/plugins/woocommerce-currency-switcher/js/front.js?ver=2.3.0
1"use strict"; 2var woocs_loading_first_time = true;//simply flag var 3var woocs_sumbit_currency_changing = true;//just a flag variable for drop-down redraws when prices redraws by AJAX 4 5jQuery(function ($) { 6 7 jQuery.fn.life = function (types, data, fn) { 8 jQuery(this.context).on(types, this.selector, data, fn); 9 return this; 10 }; 11 12 woocs_array_of_get = jQuery.parseJSON(woocs_array_of_get); 13 14 //wp-content\plugins\woocommerce\assets\js\frontend\cart.js 15 if (Object.keys(woocs_array_of_get).length !== 0) { 16 if ('currency' in woocs_array_of_get) { 17 //console.log('here'); 18 //this code nessesary for correct redrawing of the shipping methods while currency changes on the cart page 19 $('body.woocommerce-cart .shop_table.cart').closest('form').find('input[name="update_cart"]').prop('disabled', false); 20 $('body.woocommerce-cart .shop_table.cart').closest('form').find('input[name="update_cart"]').trigger('click'); 21 } 22 } 23 24 //keeps data of $_GET array 25 26 if (Object.keys(woocs_array_of_get).length == 0) { 27 woocs_array_of_get = {}; 28 } 29 30 //*** 31 woocs_array_no_cents = jQuery.parseJSON(woocs_array_no_cents); 32 33 //*** 34 35 //emptying cart widget after checkout 36 if (!parseInt(woocs_get_cookie('woocommerce_items_in_cart'), 10)) { 37 $('.widget_shopping_cart_content').empty(); 38 $(document.body).trigger('wc_fragment_refresh'); 39 } 40 41 if (woocs_array_of_get.currency != undefined || woocs_array_of_get.removed_item != undefined || woocs_array_of_get.key != undefined) 42 { 43 woocs_refresh_mini_cart(555); 44 } 45 //intercept adding to cart event to redraw mini-cart widget 46 jQuery(document).on("adding_to_cart", function () { 47 woocs_refresh_mini_cart(999); 48 }); 49 50 //to make price popup mobile friendly 51 jQuery('.woocs_price_info').life('click', function () { 52 return false; 53 }); 54 55 //+++++++++++++++++++++++++++++++++++++++++++++++ 56 //console.log(woocs_drop_down_view); 57 if (woocs_drop_down_view == 'chosen' || woocs_drop_down_view == 'chosen_dark') { 58 try { 59 if (jQuery("select.woocommerce-currency-switcher").length) { 60 jQuery("select.woocommerce-currency-switcher").chosen({ 61 disable_search_threshold: 10 62 }); 63 64 jQuery.each(jQuery('.woocommerce-currency-switcher-form .chosen-container'), function (index, obj) { 65 jQuery(obj).css({'width': jQuery(this).prev('select').data('width')}); 66 }); 67 } 68 } catch (e) { 69 console.log(e); 70 } 71 } 72 73 74 75 if (woocs_drop_down_view == 'ddslick') { 76 try { 77 jQuery.each(jQuery('select.woocommerce-currency-switcher'), function (index, obj) { 78 var width = jQuery(obj).data('width'); 79 var flag_position = jQuery(obj).data('flag-position'); 80 jQuery(obj).ddslick({ 81 //data: ddData, 82 width: width, 83 imagePosition: flag_position, 84 selectText: "Select currency", 85 //background:'#ff0000', 86 onSelected: function (data) { 87 if (!woocs_loading_first_time) 88 { 89 var form = jQuery(data.selectedItem).closest('form.woocommerce-currency-switcher-form'); 90 jQuery(form).find('input[name="woocommerce-currency-switcher"]').eq(0).val(data.selectedData.value); 91 92 if (Object.keys(woocs_array_of_get).length == 0) { 93 //jQuery(form).submit(); 94 woocs_redirect(data.selectedData.value); 95 } else { 96 woocs_redirect(data.selectedData.value); 97 } 98 99 100 } 101 } 102 }); 103 }); 104 105 } catch (e) { 106 console.log(e); 107 } 108 } 109 110 woocs_loading_first_time = false; 111 112 113 if (woocs_drop_down_view == 'wselect' && woocs_is_mobile != 1) { 114 try { 115 //https://github.com/websanova/wSelect#wselectjs 116 jQuery('select.woocommerce-currency-switcher').wSelect({ 117 size: 7 118 }); 119 } catch (e) { 120 console.log(e); 121 } 122 } 123 124 //for flags view instead of drop-down 125 jQuery('.woocs_flag_view_item').on("click", function () { 126 if (woocs_sumbit_currency_changing) { 127 if (jQuery(this).hasClass('woocs_flag_view_item_current')) { 128 return false; 129 } 130 //*** 131 132 if (Object.keys(woocs_array_of_get).length == 0) { 133 window.location = window.location.href + '?currency=' + jQuery(this).data('currency'); 134 } else { 135 136 woocs_redirect(jQuery(this).data('currency')); 137 138 } 139 } 140 141 return false; 142 });
143 144 //for converter 145 if (jQuery('.woocs_converter_shortcode').length) { 146 jQuery('.woocs_converter_shortcode_button').on("click", function () { 147 var amount = jQuery(this).parent('.woocs_converter_shortcode').find('.woocs_converter_shortcode_amount').eq(0).val(); 148 var from = jQuery(this).parent('.woocs_converter_shortcode').find('.woocs_converter_shortcode_from').eq(0).val(); 149 var to = jQuery(this).parent('.woocs_converter_shortcode').find('.woocs_converter_shortcode_to').eq(0).val(); 150 var precision = jQuery(this).parent('.woocs_converter_shortcode').find('.woocs_converter_shortcode_precision').eq(0).val(); 151 var results_obj = jQuery(this).parent('.woocs_converter_shortcode').find('.woocs_converter_shortcode_results').eq(0); 152 jQuery(results_obj).val(woocs_lang_loading + ' ...'); 153 var data = { 154 action: "woocs_convert_currency", 155 amount: amount, 156 from: from, 157 to: to, 158 precision: precision 159 }; 160 161 jQuery.post(woocs_ajaxurl, data, function (value) { 162 jQuery(results_obj).val(value); 163 }); 164 165 return false; 166 167 }); 168 } 169 170 //for rates 171 if (jQuery('.woocs_rates_shortcode').length) { 172 jQuery('.woocs_rates_current_currency').life('change', function () { 173 var _this = this; 174 var data = { 175 action: "woocs_rates_current_currency", 176 current_currency: jQuery(this).val(), 177 precision: jQuery(this).data('precision'), 178 exclude: jQuery(this).data('exclude') 179 }; 180 181 jQuery.post(woocs_ajaxurl, data, function (html) { 182 jQuery(_this).parent('.woocs_rates_shortcode').html(html); 183 }); 184 185 return false; 186 187 }); 188 } 189 190 //if we using js price update while the site is cached 191 if (typeof woocs_shop_is_cached !== 'undefined') { 192 if (woocs_shop_is_cached) { 193 194 woocs_sumbit_currency_changing = false; 195 if (typeof woocs_array_of_get.currency === 'undefined') { 196 197 if (jQuery('body').hasClass('single')) { 198 jQuery('.woocs_price_info').remove(); 199 } 200 201 //*** 202 var products_ids = []; 203 jQuery.each(jQuery('.woocs_price_code'), function (index, item) { 204 products_ids.push(jQuery(item).data('product-id')); 205 }); 206 207 //if no prices on the page - do nothing 208 if (products_ids.length === 0) { 209 woocs_sumbit_currency_changing = true; 210 return; 211 } 212 213 var data = { 214 action: "woocs_get_products_price_html", 215 products_ids: products_ids 216 }; 217 jQuery.post(woocs_ajaxurl, data, function (data) { 218 219 data = jQuery.parseJSON(data); 220 221 if (!jQuery.isEmptyObject(data)) { 222 jQuery('.woocs_price_info').remove(); 223 jQuery.each(jQuery('.woocs_price_code'), function (index, item) { 224 225 if (data.ids[jQuery(item).data('product-id')] != undefined) { 226 jQuery(item).replaceWith(data.ids[jQuery(item).data('product-id')]); 227 } 228 229 }); 230 //*** 231 jQuery('.woocommerce-currency-switcher').val(data.current_currency); 232 //*** 233 if (woocs_drop_down_view == 'chosen' || woocs_drop_down_view == 'chosen_dark') { 234 try { 235 if (jQuery("select.woocommerce-currency-switcher").length) { 236 jQuery("select.woocommerce-currency-switcher").chosen({ 237 disable_search_threshold: 10 238 }); 239 jQuery('select.woocommerce-currency-switcher').trigger("chosen:updated"); 240 } 241 } catch (e) { 242 console.log(e); 243 } 244 } 245 //*** 246 if (woocs_drop_down_view == 'ddslick') { 247 try { 248 jQuery('select.woocommerce-currency-switcher').ddslick('select', {index: data.current_currency, disableTrigger: true}); 249 } catch (e) { 250 console.log(e); 251 } 252 } 253 //*** 254 if (woocs_drop_down_view == 'wselect' && woocs_is_mobile != 1) { 255 //https://github.com/websanova/wSelect 256 try { 257 jQuery('select.woocommerce-currency-switcher').val(data.current_currency).change(); 258 } catch (e) { 259 console.log(e); 260 } 261 } 262 //*** 263 /* auto switcher*/ 264 265 var auto_switcher = jQuery('.woocs_auto_switcher'); 266 if (auto_switcher.length > 0) { 267 woocs_auto_switcher_redraw(data.current_currency, auto_switcher); 268 } 269 woocs_sumbit_currency_changing = true; 270 271 //*** 272 //for another woocs switchers styles 273 document.dispatchEvent(new CustomEvent('after_woocs_get_products_price_html', {detail: { 274 current_currency: data.current_currency 275 }})); 276 } 277 278 }); 279 280 } else { 281 woocs_sumbit_currency_changing = true; 282 } 283 } 284 } 285 286 //*** 287 //removing price info on single page near variation prices 288 setTimeout(function () {
289 //jQuery('body.single-product .woocommerce-variation-price').find('.woocs_price_info').remove(); 290 }, 300); 291 //*** 292 293 294}); 295 296 297function woocs_redirect(currency) { 298 if (!woocs_sumbit_currency_changing) { 299 return; 300 } 301 302 //*** 303 var l = window.location.href; 304 l = l.replace('#', ''); 305 306 //for #id navigation l = l.replace(/(#.+$)/gi, ''); 307 308 l = l.split('?'); 309 l = l[0]; 310 var string_of_get = '?'; 311 woocs_array_of_get.currency = currency; 312 313 /* 314 l = l.replace(/(\?currency=[a-zA-Z]+)/g, '?'); 315 l = l.replace(/(¤cy=[a-zA-Z]+)/g, ''); 316 */ 317 318 if (woocs_special_ajax_mode) { 319 string_of_get = ""; 320 321 var data = { 322 action: "woocs_set_currency_ajax", 323 currency: currency 324 }; 325 326 jQuery.post(woocs_ajaxurl, data, function (value) { 327 location.reload(); 328 }); 329 330 } else { 331 if (Object.keys(woocs_array_of_get).length > 0) { 332 jQuery.each(woocs_array_of_get, function (index, value) { 333 string_of_get = string_of_get + "&" + index + "=" + value; 334 }); 335 //string_of_get+=decodeURIComponent(jQuery.param(woocs_array_of_get)); 336 } 337 window.location = l + string_of_get; 338 } 339 340 341} 342 343function woocs_refresh_mini_cart(delay) { 344 /** Cart Handling */ 345 setTimeout(function () { 346 try { 347 //for refreshing mini cart 348 $fragment_refresh = { 349 url: wc_cart_fragments_params.ajax_url, 350 type: 'POST', 351 data: {action: 'woocommerce_get_refreshed_fragments', woocs_woocommerce_before_mini_cart: 'mini_cart_refreshing'}, 352 success: function (data) { 353 if (data && data.fragments) { 354 355 jQuery.each(data.fragments, function (key, value) { 356 jQuery(key).replaceWith(value); 357 }); 358 359 try { 360 if ($supports_html5_storage) { 361 sessionStorage.setItem(wc_cart_fragments_params.fragment_name, JSON.stringify(data.fragments)); 362 sessionStorage.setItem('wc_cart_hash', data.cart_hash); 363 } 364 } catch (e) { 365 366 } 367 368 jQuery('body').trigger('wc_fragments_refreshed'); 369 } 370 } 371 }; 372 373 jQuery.ajax($fragment_refresh); 374 375 376 /* Cart hiding */ 377 try { 378 //if (jQuery.cookie('woocommerce_items_in_cart') > 0) 379 if (woocs_get_cookie('woocommerce_items_in_cart') > 0) 380 { 381 jQuery('.hide_cart_widget_if_empty').closest('.widget_shopping_cart').show(); 382 } else { 383 jQuery('.hide_cart_widget_if_empty').closest('.widget_shopping_cart').hide(); 384 } 385 } catch (e) { 386 //*** 387 } 388 389 390 jQuery('body').bind('adding_to_cart', function () { 391 jQuery('.hide_cart_widget_if_empty').closest('.widget_shopping_cart').show(); 392 }); 393 394 } catch (e) { 395 //*** 396 } 397 398 }, delay); 399 400} 401 402function woocs_get_cookie(name) { 403 var matches = document.cookie.match(new RegExp( 404 "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" 405 )); 406 return matches ? decodeURIComponent(matches[1]) : undefined; 407} 408 409/*auto switcher*/ 410 411jQuery(function () { 412 jQuery('.woocs_auto_switcher_link').on("click", function () { 413 woocs_redirect(jQuery(this).data('currency')); 414 return false; 415 }); 416}); 417 418function woocs_auto_switcher_redraw(curr_curr, switcher) { 419 var view = switcher.data('view'); 420 switch (view) { 421 case 'classic_blocks': 422 switcher.find('a').removeClass('woocs_curr_curr'); 423 switcher.find('a[data-currency="' + curr_curr + '"]').addClass('woocs_curr_curr'); 424 break; 425 case 'roll_blocks': 426 switcher.find('a').removeClass('woocs_curr_curr'); 427 switcher.find('li').removeClass('woocs_auto_bg_woocs_curr_curr'); 428 var current_link = switcher.find('a[data-currency="' + curr_curr + '"]'); 429 current_link.addClass('woocs_curr_curr'); 430 current_link.parents('li').addClass('woocs_auto_bg_woocs_curr_curr'); 431 break; 432 case 'round_select': 433 switcher.find('a').removeClass('woocs_curr_curr'); 434 var current_link = switcher.find('a[data-currency="' + curr_curr + '"]'); 435 current_link.addClass('woocs_curr_curr'); 436 jQuery('.woocs_current_text').html(current_link.find('.woocs_base_text').html()); 437 break; 438 default: 439 break; 440 } 441 442} 443 444function woocs_remove_link_param(key, sourceURL) { 445 var rtn = sourceURL.split("?")[0], 446 param, 447 params_arr = [], 448 queryString = (sourceURL.indexOf("?") !== -1) ? sourceURL.split("?")[1] : ""; 449 if (queryString !== "") { 450 params_arr = queryString.split("&"); 451 for (var i = params_arr.length - 1; i >= 0; i -= 1) { 452 param = params_arr[i].split("=")[0]; 453 if (param === key) { 454 params_arr.splice(i, 1); 455 } 456 } 457 rtn = rtn + "?" + params_arr.join("&"); 458 } 459 return rtn; 460} 461
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.