<commit_before><?php
/**
 * @package ZT Contact Pro module for Joomla!
 * @author http://www.zootemplate.com
 * @copyright (C) 2015- ZooTemplate.Com
 * @license PHP files are GNU/GPL
 * */
defined('JPATH_BASE') or die();
jimport('joomla.html.html');
jimport('joomla.form.formfield');
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');

class JFormFieldTypecaptcha extends JFormFieldList
{

    protected $type = 'typecaptcha';

    public function getOptions()
    {
        if (version_compare(JVERSION, '3.0', 'ge'))
        {
            if (!defined('CONTACT_JVERSION'))
                define('CONTACT_JVERSION', '30');
        }

        //Get value of layout style from database
        $db = JFactory::getDBO();
        $cId = JRequest::getVar('cid', '');
        if ($cId != '')
            $cId = $cId[0];
        if ($cId == '')
        {
            $cId = JRequest::getVar('id');
        }
        $query = $db->getQuery(true);
        $query->select('m.params')
                ->from('#__modules AS m')
                ->where('m.id=' . $cId);
        $db->setQuery($query);
        $module = $db->loadObject();
        $params = new JRegistry();
        $params->loadString($module->params);
        $layoutStyle = $params->get('typecaptcha', 'recaptcha');
        //End get value of layout style
        $options = array();
        $val = "captcha";
        $text = "Captcha";
        $options[] = JHTML::_('select.option', $val, JText::_($text));
        $val = "recaptcha";
        $text = "Recaptcha";
        $options[] = JHTML::_('select.option', $val, JText::_($text));
        ?>

        <script type="text/javascript">
            jQuery(window).on('load', function () {
        <?php
        if (CONTACT_JVERSION == 30)
        {
            ?>
                    var Recaptcha = jQuery('#jform_params_recapcha').parent().parent();
                    for (i = 0; i <= 2; i++) {
                        Recaptcha.addClass('recaptcha');
                        Recaptcha = Recaptcha.next();
                    }
                    var Captcha = jQuery('jform_params_captcha').parent().parent();
                    for (i = 0; i <= 8; i++) {
                        Captcha.addClass('captcha');
                        Captcha = Captcha.next();
                    }
        <?php } ?>
                var zt_recaptcha = jQuery('.recaptcha');
                var zt_captcha = jQuery('.captcha');
                var layout = "<?php echo $layoutStyle; ?>";
                var selectStyle = function (style) {
                    switch (style) {
                        case "recaptcha":
                            zt_recaptcha.each(function (item) {
                                jQuery(item).css('display', '');
                            });
                            zt_captcha.each(function (item) {
                                jQuery(item).css('display', 'none');
                            });
                            break;
                        case "captcha":
                            zt_recaptcha.each(function (item) {
                                jQuery(item).css('display', 'none');
                            });
                            zt_captcha.each(function (item) {
                                jQuery(item).css('display', '');
                            });
                            break;
                    }
                    ;
                }
                selectStyle(layout);
        <?php
        if (CONTACT_JVERSION == 30)
        {
            ?>
                    jQuery('#jform_params_typecaptcha').change('change', function () {
                        selectStyle(this.value);
                    });
        <?php }
        ?>
            });
        </script>
        <?php
        return $options;
    }

}
?>
<commit_msg>^ Improve captchar type select<commit_after><?php
/**
 * @package ZT Contact Pro module for Joomla!
 * @author http://www.zootemplate.com
 * @copyright (C) 2015- ZooTemplate.Com
 * @license PHP files are GNU/GPL
 * */
defined('JPATH_BASE') or die();
jimport('joomla.html.html');
jimport('joomla.form.formfield');
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');

class JFormFieldTypecaptcha extends JFormFieldList
{

    protected $type = 'typecaptcha';

    public function getOptions()
    {
        if (version_compare(JVERSION, '3.0', 'ge'))
        {
            if (!defined('CONTACT_JVERSION'))
                define('CONTACT_JVERSION', '30');
        }

        //Get value of layout style from database
        $db = JFactory::getDBO();
        $cId = JRequest::getVar('cid', '');
        if ($cId != '')
            $cId = $cId[0];
        if ($cId == '')
        {
            $cId = JRequest::getVar('id');
        }
        $query = $db->getQuery(true);
        $query->select('m.params')
                ->from('#__modules AS m')
                ->where('m.id=' . $cId);
        $db->setQuery($query);
        $module = $db->loadObject();
        $params = new JRegistry();
        $params->loadString($module->params);
        $layoutStyle = $params->get('typecaptcha', 'recaptcha');
        //End get value of layout style
        $options = array();
        $val = "captcha";
        $text = "Captcha";
        $options[] = JHTML::_('select.option', $val, JText::_($text));
        $val = "recaptcha";
        $text = "Recaptcha";
        $options[] = JHTML::_('select.option', $val, JText::_($text));
        ?>
        <script type="text/javascript">
            jQuery(document).ready(function(){
                var $fields = jQuery('#jform_params_recapcha').closest('#attrib-captcha').find('.control-group');
                $fields.each(function(){
                    var index = jQuery(this).index();
                    if(index > 1 && index < 5){
                        jQuery(this).addClass('zt-contact-recaptcha');
                    }
                    if(index > 4){
                        jQuery(this).addClass('zt-contact-mathcaptcha');
                    }
                });
                jQuery('#jform_params_typecaptcha').chosen().change(function(){
                    if(jQuery(this).val() === 'recaptcha'){
                        jQuery('.zt-contact-recaptcha').show('slow');
                        jQuery('.zt-contact-mathcaptcha').hide('slow');
                    }
                    else{
                        jQuery('.zt-contact-recaptcha').hide('slow');
                        jQuery('.zt-contact-mathcaptcha').show('slow');
                    }
                });
                if(jQuery('#jform_params_typecaptcha').val() === 'recaptcha'){
                    jQuery('.zt-contact-recaptcha').show('slow');
                    jQuery('.zt-contact-mathcaptcha').hide('slow');
                }
                else{
                    jQuery('.zt-contact-recaptcha').hide('slow');
                    jQuery('.zt-contact-mathcaptcha').show('slow');
                }
            });
        </script>
        <?php
        return $options;
    }

}
?>

{'fraction_non_alphanumeric': 0.1579466929911155, 'fraction_numerical': 0.004089691157805669, 'mean_word_length': 1.440467997247075, 'pattern_counts': {'":': 2, '<': 19, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1844213', 'n_tokens_mistral': 2029, 'n_tokens_neox': 1915, 'n_words': 334}