<commit_before><?php
 /*
 * Project:		eqdkpPLUS Libraries: myHTML
 * License:		Creative Commons - Attribution-Noncommercial-Share Alike 3.0 Unported
 * Link:		http://creativecommons.org/licenses/by-nc-sa/3.0/
 * -----------------------------------------------------------------------
 * Began:		2008
 * Date:		$Date$
 * -----------------------------------------------------------------------
 * @author		$Author$
 * @copyright	2006-2011 EQdkp-Plus Developer Team
 * @link		http://eqdkp-plus.com
 * @package		libraries:myHTML
 * @version		$Rev$
 * 
 * $Id$
 */

if ( !defined('EQDKP_INC') ){
	header('HTTP/1.0 404 Not Found');exit;
}

if (!class_exists("html")) {
	class html extends gen_class {
		public static $shortcuts = array('user', 'jquery', 'pm', 'in', 'game', 'time', 'editor'=>'tinyMCE', 'crypt'=>'encrypt', 'tpl');
		
		private $blnDepJS = false;

		/**
		* Generate Widget
		* 
		* @param $options	Options for the fields
		*/	
		public function widget($options = array()){
			//backward compatibility
			$type = (isset($options['fieldtype'])) ? $options['fieldtype'] : ((isset($options['type'])) ? $options['type'] : '');
			if(!isset($options['value'])) {
				if(isset($options['default'])) $options['value'] = $options['default'];
				elseif($type == 'int') $options['value'] = '0';
			}
			$options['javascript']	= (isset($options['javascript'])) ? $options['javascript'] : '';
			
			//dependencies
			if (isset($options['dependency'])){
				if (!$this->blnDepJS){
					
					$this->tpl->add_js(
						'function dep_check_value(name, target, value){
							if ($("#"+target).val() == value){
								$("input[name="+name+"],textarea[name="+name+"],select[name="+name+"]").removeAttr("disabled");
							} else {
								$("input[name="+name+"],textarea[name="+name+"],select[name="+name+"]").attr("disabled", "disabled");
							}
						}
						
						function dep_check_cb(name, target){
							if ($("#"+target).attr("checked") == "checked"){
								$("input[name="+name+"],textarea[name="+name+"],select[name="+name+"]").removeAttr("disabled");
							} else {
								$("input[name="+name+"],textarea[name="+name+"],select[name="+name+"]").attr("disabled", "disabled");
							}
						}
						
						'	
					, 'docready');
										
					$this->blnDepJS = true;
				}
			
			
				if (is_array($options['dependency'])){
					//It's a dropdown
					$this->tpl->add_js('
					$(document).on("change", "#'.$options['dependency'][0].'", function () {
							dep_check_value("'.$options['name'].'", "'.$options['dependency'][0].'", "'.$options['dependency'][1].'");
						});	
						dep_check_value("'.$options['name'].'", "'.$options['dependency'][0].'", "'.$options['dependency'][1].'");
					', 'docready');
					
					
				} else {
					//It's a checkbox
					$this->tpl->add_js('$(document).on("change", "#'.$options['dependency'].'", function () {
							dep_check_cb("'.$options['name'].'", "'.$options['dependency'].'");
						});		
						dep_check_cb("'.$options['name'].'", "'.$options['dependency'].'");
					', 'docready');
				}
			}
			
			//clean id<commit_msg>- fixed an issue with jquery 1.9.x Hint: attr("disabled","disabled") is now prop("disabled",true), to disable the prop use false ;)<commit_after><?php
 /*
 * Project:		eqdkpPLUS Libraries: myHTML
 * License:		Creative Commons - Attribution-Noncommercial-Share Alike 3.0 Unported
 * Link:		http://creativecommons.org/licenses/by-nc-sa/3.0/
 * -----------------------------------------------------------------------
 * Began:		2008
 * Date:		$Date$
 * -----------------------------------------------------------------------
 * @author		$Author$
 * @copyright	2006-2011 EQdkp-Plus Developer Team
 * @link		http://eqdkp-plus.com
 * @package		libraries:myHTML
 * @version		$Rev$
 * 
 * $Id$
 */

if ( !defined('EQDKP_INC') ){
	header('HTTP/1.0 404 Not Found');exit;
}

if (!class_exists("html")) {
	class html extends gen_class {
		public static $shortcuts = array('user', 'jquery', 'pm', 'in', 'game', 'time', 'editor'=>'tinyMCE', 'crypt'=>'encrypt', 'tpl');
		
		private $blnDepJS = false;

		/**
		* Generate Widget
		* 
		* @param $options	Options for the fields
		*/	
		public function widget($options = array()){
			//backward compatibility
			$type = (isset($options['fieldtype'])) ? $options['fieldtype'] : ((isset($options['type'])) ? $options['type'] : '');
			if(!isset($options['value'])) {
				if(isset($options['default'])) $options['value'] = $options['default'];
				elseif($type == 'int') $options['value'] = '0';
			}
			$options['javascript']	= (isset($options['javascript'])) ? $options['javascript'] : '';
			
			//dependencies
			if (isset($options['dependency'])){
				if (!$this->blnDepJS){
					
					$this->tpl->add_js('
						function dep_check_value(name, target, value){
							if ($("#"+target).val() == value){
								$("input[name="+name+"],textarea[name="+name+"],select[name="+name+"]").prop("disabled", false);
							} else {
								$("input[name="+name+"],textarea[name="+name+"],select[name="+name+"]").prop("disabled", true);
							}
						}

						function dep_check_cb(name, target){
							if ($("#"+target).is(":checked")){
								$("input[name="+name+"],textarea[name="+name+"],select[name="+name+"]").prop("disabled", false);
							} else {
								$("input[name="+name+"],textarea[name="+name+"],select[name="+name+"]").prop("disabled", true);
							}
						}
						
					', 'docready');
					$this->blnDepJS = true;
				}
			
			
				if (is_array($options['dependency'])){
					//It's a dropdown
					$this->tpl->add_js('
					$(document).on("change", "#'.$options['dependency'][0].'", function () {
							dep_check_value("'.$options['name'].'", "'.$options['dependency'][0].'", "'.$options['dependency'][1].'");
						});	
						dep_check_value("'.$options['name'].'", "'.$options['dependency'][0].'", "'.$options['dependency'][1].'");
					', 'docready');
					
					
				} else {
					//It's a checkbox
					$this->tpl->add_js('$(document).on("change", "#'.$options['dependency'].'", function () {
							dep_check_cb("'.$options['name'].'", "'.$options['dependency'].'");
						});		
						dep_check_cb("'.$options['name'].'", "'.$options['dependency'].'");
					', 'docready');
				}
			}
			
			//clean id
{'fraction_non_alphanumeric': 0.2831546952487602, 'fraction_numerical': 0.008958566629339306, 'mean_word_length': 2.9099437148217637, 'pattern_counts': {'":': 1, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5282142', 'n_tokens_mistral': 2524, 'n_tokens_neox': 2014, 'n_words': 316}