# visual-slider/trunk/admin/assets/js/code.js

Visual Slider, version trunk. 248 lines.

- Page: https://pluginprobe.com/plugins/visual-slider/trunk/code/admin/assets/js/code.js
- Raw: https://pluginprobe.com/plugins/visual-slider/trunk/raw/admin/assets/js/code.js
- Modified: 2026-06-08T20:28:54+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/visual-slider/trunk/code/admin/assets/js/code.js#L10-L20`.

```javascript
(function($, undefined) {
    'use strict';
	    function isset(variable) {
        if (variable === "undefined") {
            return '';
        } else if (variable === undefined) {
            return '';
        } else if (variable === null) {
            return '';
        } else if (variable === 0) {
            return 0;
        } else if (variable === '0') {
            return '0';
        } else {
            return variable;
        }

    }
	/*************************************************************************************************************************************************************************
	--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
																		vs_settingEmptyAndZero
        --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	**************************************************************************************************************************************************************************/
	function vs_settingEmptyAndZero(obj) {
		for (var key in obj) {
			if (obj[key] === null || obj[key] === undefined || obj[key] === 'undefined' || obj[key] === '') {
				delete obj[key];
			} else if ($.type(obj[key]) === 'object') {
				vs_settingEmptyAndZero(obj[key]);
					var sum = Object.values(obj[key]).reduce(function(acc, val) {
					return acc + val;
				}, 0);
 				if (sum === 0) {
					delete obj[key];
				}
			}
		}
		return obj;
	}
	$.fn.vs_settingEmptyAndZero =  function(obj) { 
		for (var key in obj) {
			if (obj[key] === null || obj[key] === undefined || obj[key] === 'undefined' || obj[key] === '') {
				delete obj[key];
			} else if ($.type(obj[key]) === 'object') {
				vs_settingEmptyAndZero(obj[key]);
					var sum = Object.values(obj[key]).reduce(function(acc, val) {
					return acc + val;
				}, 0);
 				if (sum === 0) {
					delete obj[key];
				}
			}
		}
		return obj;
 
  	};

	/*************************************************************************************************************************************************************************
	--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
																			 UrlCode
	--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	**************************************************************************************************************************************************************************/
 	function vs_urlencode(inputString='') {
		if (inputString && typeof inputString !== 'object') {
			try {
				return btoa(encodeURIComponent(inputString));
			} catch (e) {
				 return '';
			}
		} else {
			return '';
		}
	}
	/*************************************************************************************************************************************************************************
	--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
																			 vs_urldecode
	--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	**************************************************************************************************************************************************************************/
	function vs_urldecode(inputString = '') {
		 if (typeof inputString !== 'object' && inputString.length > 0) {
			try {
				let decodedString = atob(inputString); 
				return decodeURIComponent(decodedString.replace(/\+/g, '%20'));  
			} catch (e) {
				return '';  
			}
		} else {
			return '';
		}
	} 
	/*************************************************************************************************************************************************************************
	--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
																			Data Decode
 	--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	**************************************************************************************************************************************************************************/	 
	function vs_data_encode(option, code) {
		function vs_encodeRecursive(obj, depth, parentIndex) {
			var output = '';
			var r = 0;
			for (var key in obj) {
				if (obj.hasOwnProperty(key)) {
					var value = obj[key];
 					var index = '';
					if (parentIndex !== 0) {
						index = parentIndex + '_';
					}
					if (value !== null && typeof value === 'object') {
						r++;
						output += '[' + code + '_' + index + r + ' key="' + key + '"]';
						output += vs_encodeRecursive(value, depth + 1, index + +r);
						output += '[/' + code + '_' + index + r + ']';
		
					} else {
						r++;
						var index = '';
						if (parentIndex !== 0) {
							index = parentIndex + '_';
						}
						output += '[' + code + '_' + index + r + ' key="' + key + '"]';
 							output += vs_urlencode(value);
 						output += '[/' + code + '_' + index + r + ']';
					}
				}
			}
		
			return output;
		}
		
		return vs_encodeRecursive(option, 0, 0);
	}
		
	/*************************************************************************************************************************************************************************
	--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
																	vs_serializecode
	--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	**************************************************************************************************************************************************************************/	
	function vs_serializecode(input='', code='dt') {
		var regex = new RegExp('\\[(' + code + '_\\d+)(_\\d+)?(?: (key)="([^"]*)")?\\](.+?(?=\\[\/\\1\\2?\\]))?', 'g');
		var matches = input.matchAll(regex);
		var shortcodes = {};

		for (const match of matches) {
			if (match[1] && match[1] !== '') {
				// store child data in parent's content array
				shortcodes[match[1]] = {
					'name': match[1] + (match[2] || ''),
					'key': (match[4] && match[4] !== '') ? match[4] : '',
					'value': (match[5] && match[5] !== '') ? match[5] : ''
				};
			}
		}
	
		if (Object.keys(shortcodes).length === 0) {
			return input;
		}
	
		return shortcodes;
	}
	/*************************************************************************************************************************************************************************
	--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
																		vs_data_decode
	--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	**************************************************************************************************************************************************************************/	
	function vs_data_decode(data, code) {
		var obj = vs_serializecode(data, code);
		var a = {};

		if (typeof obj === 'object' && Object.keys(obj).length > 0) {
		        $.each(obj, function (index, value) {
		            a[value['key']] = vs_data_decode_array(value);

		        });
		} else {
		 
				a = vs_urldecode(obj);
			 
		}
		return a;

	} 
	/*************************************************************************************************************************************************************************
	--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
																		vs_data_decode Array
	--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	**************************************************************************************************************************************************************************/	

	function vs_data_decode_array(v) {
		var a = {};
		var o_2 = vs_serializecode(v['value'], v['name']);
		if (typeof o_2 === 'object' && Object.keys(o_2).length > 0) {

			$.each(o_2, function (index, v_2) {
				a[v_2['key']] = vs_data_decode_array(v_2);
			});
			
		} else {
		   a = vs_urldecode(v['value']);
		}
		return a;
	} 
		
	 /*************************************************************************************************************************************************************************
	--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
																		 encode
	--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	**************************************************************************************************************************************************************************/	
	$.fn.vs_encode = function(data,code) {
 		return vs_data_encode(vs_settingEmptyAndZero(data),code );
 	}; 
			 
	/*************************************************************************************************************************************************************************
	--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
																		 decode
	--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	**************************************************************************************************************************************************************************/	
	$.fn.vs_decode = function( data,code) {
 		return vs_data_decode( data,code);
	 };
	/*************************************************************************************************************************************************************************
	--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
																		 Get Value From Objects
	--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	**************************************************************************************************************************************************************************/	
	$.fn.vs_getValueFromObject=function(obj, str) {
   	 const regex = /([^\[\]]+)|\[([^\[\]]+)\]/g;
		let match;
		let keys = [];
		while ((match = regex.exec(str)) !== null) {
			if (match[1]) {
				keys.push(match[1]);
			} else if (match[2]) {
				keys.push(match[2]);
			}
		}
		let current = obj;
		for (let i = 0; i < keys.length; i++) {
			if ( current[keys[i]] !== undefined) {
				current = current[keys[i]];
			} else {
				return '';  
			}
		}
	
		return current;
	}
 
	 
})(jQuery);
```
