Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/app/code/Ecombricks/Common/view/frontend/web/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/app/code/Ecombricks/Common/view/frontend/web/js/jquery-serialize-json.js
/**
 * Copyright © eComBricks. All rights reserved.
 * See LICENSE.txt for license details.
 */
define([
    'jquery'
], function ($) {
    'use strict';
    
    $.fn.serializeJson = function() {
        
        var json = {};
        var keyCounters = {};
        
        this.isInteger = function (value) {
            return value === parseInt(value, 10);
        };
        
        this.parseKey = function (key) {
            return key.match(/[a-zA-Z0-9_]+|(?=\[\])/g);
        };
        
        this.isArrayKey = function (key) {
            return key.match(/^$/);
        };
        
        this.isObjectKey = function (key) {
            return key.match(/^[a-zA-Z0-9_]+$/);
        };
        
        this.getCurrentKeyIndex = function (key) {
            if (keyCounters[key] === undefined) {
                keyCounters[key] = 0;
            }
            return keyCounters[key]++;
        };
        
        this.createKeyValue = function (key, value) {
            var target = this.isInteger(key) ? [] : {};
            target[key] = value;
            return target;
        };
        
        $.each($(this).serializeArray(), (function (parameterIndex, parameter) {
            var currentKey = parameter.name;
            var keys = this.parseKey(currentKey);
            var value = parameter.value;
            for (var keyIndex = keys.length - 1; keyIndex >= 0; keyIndex--) {
                var key = keys[keyIndex];
                currentKey = currentKey.replace(new RegExp("\\[" + key + "\\]$"), '');
                if (this.isArrayKey(key)) {
                    value = this.createKeyValue(this.getCurrentKeyIndex(currentKey), value);
                } else if (this.isObjectKey(key)) {
                    value = this.createKeyValue(key, value);
                }
            }
            json = $.extend(true, json, value);
        }).bind(this));
        return json;
    }
    
});

Spamworldpro Mini