HEX
Server: Apache/2.4.65 (Debian)
System: Linux wordpress-7cb4c6b6f6-mtmmf 5.15.0-131-generic #141-Ubuntu SMP Fri Jan 10 21:18:28 UTC 2025 x86_64
User: www-data (33)
PHP: 8.3.27
Disabled: NONE
Upload Files
File: //var/www/html/wp-content/plugins/yith-woocommerce-compare/assets/js/src/includes/common.js
/* global jQuery */

'use strict';

const
	addQueryArgs = ( args, url ) => {
		const urlObj = new URL( url || window.location.href ),
			searchParams = urlObj.searchParams;

		Object.entries( args ).map( ( [ key, value ] ) => searchParams.set( key, value ) );

		return urlObj.toString();
	},
	block = ( $item ) => {
		if ( 'undefined' === typeof jQuery.fn.block ) {
			return;
		}

		$item
			.addClass( 'js-blocked' )
			.block({
				message: null,
				overlayCSS: {
					background: '#fff url(' + yith_woocompare.loader + ') no-repeat center',
					backgroundSize: '20px 20px',
					opacity: 0.6
				}
			});
	},
	unblock = ( $item ) => {
		if ( 'undefined' === typeof jQuery.fn.unblock ) {
			return;
		}

		$item
			.removeClass( 'js-blocked' )
			.unblock();
	},
	getCookie = ( cookieName ) => {
		const cookies = document.cookie
			.split( ';' )
			.reduce( ( a, i ) => {
				const [ key, value ] = i.trim().split('=');
				a[ key ] = value;
				return a;
			}, {} );

		return cookies?.[ cookieName ];
	};

export {
	addQueryArgs,
	getCookie,
	block,
	unblock
};