403Webshell
Server IP : 38.190.208.107  /  Your IP : 216.73.216.76
Web Server : nginx/1.28.1
System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64
User : www ( 1000)
PHP Version : 8.2.28
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /www/wwwroot/wp.2/wp-content/themes/blocksy/static/js/options/helpers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/wwwroot/wp.2/wp-content/themes/blocksy/static/js/options/helpers/get-value-from-input.js
import { isString, isObject, isNumber, isBoolean } from './primitive-types'

export const getFirstLevelOptions = (options, hasInnerOptions = true) => {
	const { __CT_KEYS_ORDER__, ...rest } = options

	return Object.keys(rest).reduce((currentOptions, currentOptionId) => {
		if (!options[currentOptionId].type) {
			return {
				...currentOptions,
				...getFirstLevelOptions(
					options[currentOptionId],
					hasInnerOptions
				),
			}
		}

		if (options[currentOptionId].options) {
			return {
				...currentOptions,
				...getFirstLevelOptions(
					options[currentOptionId].options,
					hasInnerOptions
				),
			}
		}

		if (options[currentOptionId]['inner-options'] && hasInnerOptions) {
			return {
				...currentOptions,
				[currentOptionId]: options[currentOptionId],
				...getFirstLevelOptions(
					options[currentOptionId]['inner-options'],
					hasInnerOptions
				),
			}
		}

		return {
			...currentOptions,
			[currentOptionId]: options[currentOptionId],
		}
	}, {})
}

export const flattenOptions = (options) =>
	Object.keys(options).reduce(
		(result, currentId) => ({
			...result,

			...(options[currentId].type
				? { [currentId]: options[currentId] }
				: currentId === '__CT_KEYS_ORDER__'
				? { [currentId]: options[currentId] }
				: flattenOptions(options[currentId])),
		}),
		{}
	)

export const getValueFromInput = (
	options,
	values,
	valueGetter = null,
	hasInnerOptions = true
) => {
	let firstLevelOptions = getFirstLevelOptions(options, hasInnerOptions)

	return {
		...values,
		...Object.keys(firstLevelOptions).reduce(
			(currentValues, currentOptionId) => {
				let actualValue = null

				if (Object.keys(values).indexOf(currentOptionId) > -1) {
					if (
						isString(values[currentOptionId]) ||
						isNumber(values[currentOptionId]) ||
						isBoolean(values[currentOptionId])
					) {
						actualValue = values[currentOptionId]
					}

					if (
						isObject(values[currentOptionId]) &&
						!Array.isArray(values[currentOptionId])
					) {
						// Dont touch responsive values and dont spread all keys
						// together.
						actualValue = {
							// ...(firstLevelOptions[currentOptionId].value || {}),
							...values[currentOptionId],
						}
					}

					if (Array.isArray(values[currentOptionId])) {
						actualValue = values[currentOptionId]
							? values[currentOptionId]
							: [
									...(firstLevelOptions[currentOptionId]
										.value || []),
									// ...values[currentOptionId],
							  ]
					}
				} else if (valueGetter) {
					return {
						...currentValues,
						...valueGetter(
							currentOptionId,
							firstLevelOptions[currentOptionId]
						),
					}
				} else {
					if (
						Object.keys(firstLevelOptions[currentOptionId]).indexOf(
							'value'
						) > -1
					) {
						actualValue = firstLevelOptions[currentOptionId].value
					} else {
						actualValue = ''
					}
				}

				return {
					...currentValues,
					[currentOptionId]: actualValue,
				}
			},
			{}
		),
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit