HEX
Server: Apache
System: Linux web2213.uni5.net 5.4.282-1.el8.elrepo.x86_64 #1 SMP Mon Aug 19 18:33:22 EDT 2024 x86_64
User: clinicamaciel (596848)
PHP: 7.3.33
Disabled: apache_child_terminate,c99_buff_prepare,c99_sess_put,dl,eval,exec,leak,link,myshellexec,openlog,passthru,pclose,pcntl_exec,php_check_syntax,php_strip_whitespace,popen,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,symlink,system,socket_listen,socket_create_listen,putenv
Upload Files
File: /home/clinicamaciel/www/wp-content/plugins/trx_addons/cpt/sport/sport.admin.js
/* global jQuery:false */
/* global TRX_ADDONS_STORAGE:false */

jQuery(document).ready(function() {
	"use strict";
	
	// Add 'sport' to the 'Add New' link's URL in the competitions
	if (jQuery('body').hasClass('post-type-cpt_competitions')) {
		var sport = jQuery('select#cpt_competitions_sports').length == 1 ? jQuery('select#cpt_competitions_sports > option:selected').val() : jQuery('input#cpt_competitions_sports').val();
		var add_new = jQuery('a.page-title-action');
		if (add_new.length > 0) {
			var href = jQuery('a.page-title-action').attr('href');
			jQuery('a.page-title-action').attr('href', trx_addons_add_to_url(href, {'cpt_competitions_sports': sport}));
		}

	// Add 'competition' to the 'Add New' link's URL  in the rounds and players
	} else if (jQuery('body').hasClass('post-type-cpt_rounds') || jQuery('body').hasClass('post-type-cpt_players')) {
		var competition = jQuery('select#competition').length == 1 ? jQuery('select#competition > option:selected').val() : jQuery('input#competition').val();
		var add_new = jQuery('a.page-title-action');
		if (add_new.length > 0) {
			var href = jQuery('a.page-title-action').attr('href');
			jQuery('a.page-title-action').attr('href', trx_addons_add_to_url(href, {'competition': competition}));
		}

	// Add 'competition' and 'round' to the 'Add New' link's URL in the matches
	} else if (jQuery('body').hasClass('post-type-cpt_matches')) {
		var competition = jQuery('select#competition').length == 1 ? jQuery('select#competition > option:selected').val() : jQuery('input#competition').val();
		var cur_round = jQuery('select#round').length == 1 ? jQuery('select#round > option:selected').val() : jQuery('input#round').val();
		var add_new = jQuery('a.page-title-action');
		if (add_new.length > 0) {
			var href = jQuery('a.page-title-action').attr('href');
			jQuery('a.page-title-action').attr('href', trx_addons_add_to_url(href, {'competition': competition, 'round': cur_round}));
		}
		
	}
	
	// Field "Sport" changed - refresh competitions and rounds
	//--------------------------------------------------------
	jQuery('body').on('change', 'select.sport', function () {
		"use strict";
		var fld = jQuery(this);
		var comp_fld = fld.parents('.vc_edit-form-tab').find('select.competition');
		if (comp_fld.length > 0) {
			var comp_lbl = comp_fld.parent().prev();
			trx_addons_refresh_list('competitions', fld.val(), comp_fld, comp_lbl);
		}
	});
	jQuery('body').on('change', 'select.competition', function () {
		"use strict";
		var fld = jQuery(this);
		var round_fld = fld.parents('.vc_edit-form-tab').find('select.round');
		if (round_fld.length > 0) {
			var round_lbl = round_fld.parent().prev();
			trx_addons_refresh_list('rounds', fld.val(), round_fld, round_lbl);
		}
	});
	
});