Server : Apache
System : Linux iZ2vcgyutqttsd1p850kl8Z 3.10.0-1160.92.1.el7.x86_64 #1 SMP Tue Jun 20 11:48:01 UTC 2023 x86_64
User : www ( 1000)
PHP Version : 5.6.40
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
Directory :  /www/wwwroot/saimikebio.com/ecshopjcw/js/
Upload File :
Current Directory [ Writeable ] Root Directory [ Writeable ]


Current File : /www/wwwroot/saimikebio.com/ecshopjcw/js/selectbox.js
var SelectBox = Class.create();
SelectBox.prototype = {
    initialize:function (src, dst)
    {
        this.dst_options = new Array();
        this.src_obj = document.getElementById(src);
        this.dst_obj = document.getElementById(dst);
        this.copy_method = (typeof (arguments[2]) != 'undefined')?true:false;
    },
    addItem:function ()
    {
        var all = (typeof (arguments[0]) != 'undefined')?arguments[0]:false;
        var src_options = this.fetch_options(this.src_obj, all);
        if (src_options.length > 0)
        {
            this.copy_options(this.dst_obj, src_options);
        }
    },
    delItem:function ()
    {
        var all = (typeof (arguments[0]) != 'undefined')?arguments[0]:false;
        var dst_options = this.fetch_options(this.dst_obj, all);
        if (dst_options.length > 0)
        {
            this.del_options(this.dst_obj, dst_options);
        }
    },
    moveItem:function (direction)
    {
        var dst_options = this.fetch_options(this.dst_obj);
        var insert_position = new Object;
        if (direction == 'up')
        {
            if (dst_options[0] === this.dst_obj.options[0])
            {
                return;
            }
            insert_position = dst_options[0].previousSibling;
        }
        else
        {
            if (dst_options[dst_options.length-1] === this.dst_obj.options[this.dst_obj.options.length-1])
            {
                return;
            }
            insert_position = dst_options[dst_options.length-1].nextSibling.nextSibling;
        }
        this.move_options(this.dst_obj, insert_position, dst_options);
    },
    fetch_options:function (o)
    {
        var sel_options = [];
        var c = 0;
        var all = (typeof (arguments[1]) != 'undefined')?arguments[1]:false;
        for (var i=0,l=o.options.length; i<l; i++)
        {
            if (all === false)
            {
                if (o.options[i].selected)
                {
                    sel_options[c++] = o.options[i];
                }
            }
            else
            {
                sel_options[c++] = o.options[i];
            }
        }
        return sel_options;
    },
    del_options:function (o, arr)
    {
        for (var i=0,l=arr.length; i<l; i++)
        {
            if (this.copy_method === false)
            {
                o.removeChild(arr[i]);
            }
            else
            {
                this.src_obj.appendChild(arr[i]);
            }
            
            this.dst_options = this.delete_array(arr[i].value, this.dst_options);
        }
    },
    copy_options:function (o, arr)
    {
        for (var i=0,l=arr.length; i<l; i++)
        {
            if (!this.in_array(arr[i].value, this.dst_options))
            {
                if (this.copy_method === false)
                {
                    new_opt = this.clone_option(arr[i]);
                }
                else
                {
                    new_opt = arr[i];
                }
                o.appendChild(new_opt);
                this.dst_options[this.dst_options.length] = arr[i].value;
            }
        }
    },
    move_options:function (o, p, arr)
    {
        for (var i=0,l=arr.length; i<l; i++)
        {
            o.insertBefore(arr[i], p);
        }
    },
    clone_option:function (o)
    {
        var new_opt = document.createElement('OPTION');
        new_opt.value = o.value;
        new_opt.innerHTML = o.innerHTML;
        return new_opt;
    },
    in_array:function (elem, array)
    {
        var re = new RegExp('\\\|' + elem + '\\\|');
        return re.test('|' + array.join('|') + '|');
    },
    delete_array:function (elem, array)
    {
        var re = new RegExp( elem + '\\\|');
        var _str = (array.join('|') + '|').replace(re, '');
        return _str.split('|');
    }
}