NexusLeads Webshell
NexusLeads


Server : LiteSpeed
System : Linux server 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64
User : alsaif ( 1057)
PHP Version : 7.4.33
Disable Function : show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/alsaif/domains/alsaif.group/private_html/media/regularlabs/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/alsaif/domains/alsaif.group/private_html/media/regularlabs/js/form.js
/**
 * @package         Regular Labs Library
 * @version         23.9.3039
 * 
 * @author          Peter van Westen <info@regularlabs.com>
 * @link            https://regularlabs.com
 * @copyright       Copyright © 2023 Regular Labs All Rights Reserved
 * @license         GNU General Public License version 2 or later
 */

"use strict";

if (typeof window.RegularLabsForm === 'undefined'
    || typeof RegularLabsForm.version === 'undefined'
    || RegularLabsForm.version < '23.9.3039') {

    (function($) {
        window.RegularLabsForm = {
            version: '23.9.3039',

            getValue: function(name, escape) {
                let $field = $(`[name="${name}"]`);

                if ( ! $field.length) {
                    $field = $(`[name="${name}[]"]`);
                }

                if ( ! $field.length) {
                    return;
                }

                const type = $field[0].type;

                switch (type) {
                    case 'radio':
                        $field = $(`[name="${name}"]:checked`);
                        break;

                    case 'checkbox':
                        return this.getValuesFromList($(`[name="${name}[]"]:checked`), escape);

                    case 'select':
                    case 'select-one':
                    case 'select-multiple':
                        return this.getValuesFromList($field.find('option:checked'), escape);
                }

                return this.prepareValue($field.val(), escape);
            },

            getValuesFromList: function($elements, escape) {
                const self = this;

                const values = [];

                $elements.each(function() {
                    values.push(self.prepareValue($(this).val(), escape));
                });

                return values;
            },

            prepareValue: function(value, escape) {
                if ( ! isNaN(value) && value.indexOf('.') < 0) {
                    return parseInt(value);
                }

                if (escape) {
                    value = value.replace(/"/g, '\\"');
                }

                return value.trim();
            },

            toTextValue: function(str) {
                return str.toString().replace(/^[\s-]*/, '').trim();
            },

            toSimpleValue: function(str) {
                return str.toString().toLowerCase().replace(/[^0-9a-z]/g, '').trim();
            },

            // preg_quote: function(str) {
            //     return str.toString().replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!<>\|\:])/g, '\\$1');
            // },

            // escape: function(str) {
            //     return str.toString().replace(/([\"])/g, '\\$1');
            // },

            setRadio: function(id, value) {
                value = value ? 1 : 0;

                const selector = `input#jform_${id}${value},input#jform_params_${id}${value},input#advancedparams_${id}${value}`;

                document.getElements(selector).each(function(el) {
                    el.click();
                });
            },

            initCheckAlls: function(id, classname) {
                $(`#${id}`).attr('checked', this.allChecked(classname));
                $(`input.${classname}`).click(function() {
                    $(`#${id}`).attr('checked', this.allChecked(classname));
                });
            },

            allChecked: function(classname) {
                return $(`input.${classname}:checkbox:not(:checked)`).length < 1;
            },

            checkAll: function(checkbox, classname) {
                const allchecked = this.allChecked(classname);
                $(checkbox).attr('checked', ! allchecked);
                $(`input.${classname}`).attr('checked', ! allchecked);
            },

            // getEditorSelection: function(editorID) {
            //     const editorTextarea = document.getElementById(editorID);
            //
            //     if (!editorTextarea) {
            //         return '';
            //     }
            //
            //     const editorFrame = editorTextarea.parentNode.querySelector('iframe');
            //
            //     if (!editorFrame) {
            //         return '';
            //     }
            //
            //     const contentWindow = editorFrame.contentWindow;
            //
            //     if (typeof contentWindow.getSelection !== 'undefined') {
            //         const sel = contentWindow.getSelection();
            //
            //         if (sel.rangeCount) {
            //             const container = contentWindow.document.createElement("div");
            //             const len       = sel.rangeCount;
            //             for (let i = 0; i < len; ++i) {
            //                 container.appendChild(sel.getRangeAt(i).cloneContents());
            //             }
            //
            //             return container.innerHTML;
            //         }
            //
            //         return '';
            //     }
            //
            //     if (typeof contentWindow.document.selection !== 'undefined') {
            //         if (contentWindow.document.selection.type == "Text") {
            //             return contentWindow.document.selection.createRange().htmlText;
            //         }
            //     }
            //
            //     return '';
            // },

            toggleSelectListSelection: function(id) {
                const el = document.getElement(`#${id}`);
                if (el && el.options) {
                    for (let i = 0; i < el.options.length; i++) {
                        if ( ! el.options[i].disabled) {
                            el.options[i].selected = ! el.options[i].selected;
                        }
                    }
                }
            },

            prependTextarea: function(id, content, separator) {
                const textarea      = $(`#${id}`);
                let originalContent = textarea.val().trim();

                if (originalContent && separator) {
                    separator       = separator == 'none' ? '' : `\n\n${separator}`;
                    originalContent = `${separator}\n\n${originalContent}`;
                }

                textarea.val(`${content}${originalContent}`);
                this.moveCursorInTextareaTo(id, content.length);
            },

            moveCursorInTextareaTo: function(id, position) {
                const textarea = document.getElementById(id);

                if (textarea.setSelectionRange) {
                    textarea.focus();
                    textarea.setSelectionRange(position, position);
                    textarea.scrollTop = 0;
                    return;
                }

                if (textarea.createTextRange) {
                    var range = textarea.createTextRange();
                    range.moveStart('character', position);
                    range.select();
                    textarea.scrollTop = 0;
                }
            },

            setToggleTitleClass: function(input, value) {
                const el = $(input).parent().parent().parent().parent();

                el.removeClass('alert-success').removeClass('alert-error');
                if (value === 2) {
                    el.addClass('alert-error');
                } else if (value) {
                    el.addClass('alert-success');
                }
            }
        };

        $(document).ready(function() {
            removeEmptyControlGroups();
            addShowOnTriggers();

            function removeEmptyControlGroups() {
                // remove all empty control groups
                $('div.control-group > div.control-label label').each(function(i, el) {
                    if ($(el).html().trim() == '') {
                        $(el).remove();
                    }
                });
                $('div.control-group > div.control-label,div.control-group > div.controls').each(function(i, el) {
                    if ($(el).html().trim() == '') {
                        $(el).remove();
                    }
                });
                $('div.control-group').each(function(i, el) {
                    if ($(el).html().trim() == '') {
                        $(el).remove();
                    }
                });
                $('div.control-group > div.hide').each(function(i, el) {
                    $(el).parent().css('margin', 0);
                });
            }

            /**
             * Adds keyup triggers to fields to trigger show/hide of showon fields
             */
            function addShowOnTriggers() {
                const fieldIDs = [];

                $('[data-showon]').each(function() {
                    const $target  = $(this);
                    const jsonData = $target.data('showon') || [];

                    // Collect an all referenced elements
                    for (let i = 0, len = jsonData.length; i < len; i++) {
                        fieldIDs.push(`[name="${jsonData[i]['field']}"]`);
                        fieldIDs.push(`[name="${jsonData[i]['field']}[]"]`);
                    }
                });

                // Trigger the change event on keyup
                $(fieldIDs.join(',')).on('input', function() {
                    $(this).change();
                });
            }
        });
    })(jQuery);
}

NexusLeads