AlaK4X
Linux lhjmq-records 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64



Your IP : 3.147.86.30


Current Path : /var/www/lhjmq-records.qc.ca/public_html/xsl/records/generator/js/
Upload File :
Current File : /var/www/lhjmq-records.qc.ca/public_html/xsl/records/generator/js/functions.php

<?php
//INIT FUNCTION CALLS

var xml_path = "xml/"
var xsl_path = "xsl/"
var pop_type = "0"
var ligue_last = ""
var equipe_last = ""
var franchise_last = ""

window.onload = function()
{
	var moz = (typeof document.implementation.createDocument != 'undefined');
	var ie =  (typeof window.ActiveXObject != 'undefined');


	//load_and_transform method :
	//load_and_transform([xml file name and path], [xsl file name and path], [div name for content display], [not required:node name for default sorting, ascending])
	load_and_transform(xml_path + 'main_tool_selectors.xml', xsl_path + 'main_tool_selectors.xsl', 'main_level_tool', null, {record_type: 'V'});
	load_and_transform(xml_path + 'main_tool_selectors.xml', xsl_path + 'saisons.xsl', 'main_seasons', null, {season_in: '0', season_out: '3000'});
	load_and_transform(xml_path + 'main_tool_selectors.xml', xsl_path + 'second_tool_selectors.xsl', 'second_level_tool');
	load_and_transform(xml_path + 'records.xml', xsl_path + 'records.xsl', 'main_records');
	load_and_transform(xml_path + 'most_pop_records.xml', xsl_path + 'most_pop_records.xsl', 'most_pop_records', null, {pop_type: '0'});
}



//-->
function sortTypeDispatcher(field_name, div_name)
{
	if(eval('typeof sort_type_' + field_name + '_' + div_name + ' != \'undefined\''))
	{
		if(eval("previous_field_" + div_name + "_name") != (field_name + '_' + div_name))
			eval('sort_type_' + field_name + '_' + div_name + ' = \'ascending\'')
		else if(eval('sort_type_' + field_name + '_' + div_name + ' == \'ascending\''))
			eval('sort_type_' + field_name + '_' + div_name + ' = \'descending\'')
		else
			eval('sort_type_' + field_name + '_' + div_name + ' = \'ascending\'')
	}
	else
		eval('sort_type_' + field_name + '_' + div_name + ' = \'ascending\'')

	eval("previous_field_" + div_name + "_name = field_name + '_' + div_name");

	return eval('sort_type_' + field_name + '_' + div_name);
}



//-->
function XmlTransform_ie(xt_xml, xt_xsl, xt_sort_field, xt_sort_order_type, param)
{
	// Chargement XML
	var xmldoc = new ActiveXObject("MSXML2.DOMDocument")
	xmldoc.async = false;
	xmldoc.resolveExternals = true;
	xmldoc.validateOnParse = true;
	xmldoc.load(xt_xml + "?" + new Date().getTime()); // //alert(xmlfile);

	if (xmldoc.parseError.errorCode != 0)
	{
		error = xmldoc.parseError;
		//alert('Error parsing XML file:\n' + error.reason + '[' + error.url + ': line ' + error.line + ', col ' + error.linepos + ']');
	}

	// Chargement XSL
	var xsldoc = new ActiveXObject("MSXML2.FreeThreadedDOMDocument" );
	xsldoc.async = false;
	xsldoc.resolveExternals = true;
	xsldoc.validateOnParse = true;
	xsldoc.load(xt_xsl + "?" + new Date().getTime()); // //alert(xmlfile);
	if (xsldoc.parseError.errorCode != 0)
	{
		error = xsldoc.parseError;
		//alert('Error parsing XSL file:\n' + error.reason + '[' + error.url + ': line ' + error.line + ', col ' + error.linepos + ']');
	}

	// Propri�t� de transformation
	xsldoc.setProperty('SelectionLanguage','XPath')
	xsldoc.setProperty('SelectionNamespaces','xmlns:xsl="http://www.w3.org/1999/XSL/Transform"')
	var xtemplate = new ActiveXObject("MSXML2.XSLTemplate" );
	xtemplate.stylesheet = xsldoc;
	xprocessor = xtemplate.createProcessor();
	xprocessor.input = xmldoc;


	if(param)
	{
		for(var label in param)
		{
			xprocessor.addParameter(label, param[label]);
		}
	}
	//-->CONDITION FOR SORTING ONLY
	if (xt_sort_field != null)
	{
		if(typeof xt_sort_order_type != 'undefined')
		{
			xprocessor.addParameter("sort", xt_sort_field);
			xprocessor.addParameter("sort_order_type", xt_sort_order_type);
		}
	}
	//<--CONDITION FOR SORTING ONLY

	// Transformation
	xprocessor.transform();
	output = xprocessor.output; //alert(xml2htm);

	return output;
}



//-->
function XmlTransform_moz(xt_xml, xt_xsl, sort_field, sort_order_type, param)
{
	var processor;
	var xslt;
	var xmlDoc;

	xslt = document.implementation.createDocument("", "", null);
	xslt.async = false;
	xslt.load(xt_xsl + "?" + new Date().getTime());

	xmlDoc = document.implementation.createDocument("", "", null);
	xmlDoc.async = false;
	xmlDoc.load(xt_xml + "?" + new Date().getTime());

	var processor = new XSLTProcessor();
	processor.importStylesheet(xslt);

	//-->CONDITION FOR SORTING ONLY
	if (sort_field != null)
	{
		if(typeof sort_order_type != 'undefined')
		{
			processor.setParameter(null, "sort_order_type", sort_order_type);
			processor.setParameter(null, "sort", sort_field);
		}
	}
	//<--CONDITION FOR SORTING ONLY

	if(param)
	{
		for(var label in param)
		{
			processor.setParameter(null, label, param[label]);
		}
	}

	var XmlDom = processor.transformToDocument(xmlDoc)

	var serializer = new XMLSerializer();
	var output = serializer.serializeToString(XmlDom.documentElement);

	return output;
}



//-->
function load_and_transform(XMLData, xslFile, div_name, sort_field, param)
{
	var output = '';
	var sort_order_type = '';

	sort_order_type = sortTypeDispatcher(sort_field, div_name)

	var moz = (typeof document.implementation.createDocument != 'undefined');
	var ie =  (typeof window.ActiveXObject != 'undefined');

	if (moz)
	{
		if (param)
		{
			var output = XmlTransform_moz(XMLData, xslFile, null, null, param)
		}
		//----->CONDITION FOR SORTING ONLY
		else if (sort_field != null)
		{
			if(typeof sort_order_type != 'undefined')
			{
				var output = XmlTransform_moz(XMLData, xslFile, sort_field, sort_order_type)
			}
		}
		else
		//----->CONDITION FOR SORTING ONLY
			var output = XmlTransform_moz(XMLData, xslFile)
	}
	else if (ie)
	{

		if(param)
		{
			var output = XmlTransform_ie(XMLData, xslFile, null, null, param)
		}
		//----->CONDITION FOR SORTING ONLY
		else if(sort_field && sort_order_type)
		{
			var output = XmlTransform_ie(XMLData, xslFile, sort_field, sort_order_type)
		}
		else
	//----->CONDITION FOR SORTING ONLY

		var output = XmlTransform_ie(XMLData, xslFile)
	}

	document.getElementById(div_name).innerHTML = output;
}



//-->
function get_season_by_selection(obj)
{
	years = obj.split("|")
	yr_in = years[1]
	yr_out = years[2]

	if(yr_in && yr_out)
		load_and_transform(xml_path + "main_tool_selectors.xml", xsl_path + "saisons.xsl", "main_seasons", null, {season_in: yr_in, season_out: yr_out, visible_state: get_season_visibility_state()})
}



//-->
function get_type_level_and_id(str, xsl_level_file, div_name, mode)
{
	if(mode)
	{
		//document.getElementById("section01").value = "-1"
		//document.getElementById("section02").value = "-1"
		//document.getElementById("section03").value = "-1"
		//document.getElementById("section04").value = "-1"
		//document.getElementById("section05").value = "-1"

		//document.getElementById("select_reg").checked = false
		//document.getElementById("select_elim").checked = false
		//document.getElementById("select_both").checked = false
		//document.getElementById("select_dom").checked = false
		//document.getElementById("select_away").checked = false
		//document.getElementById("select_dom_away").checked = false

		document.getElementById("ligue_selector").style.display = "none";
		//document.getElementById("ligue_selector").selectedIndex = 0;

		document.getElementById("equipe_selector").style.display = "none";
		//document.getElementById("equipe_selector").selectedIndex = 0;

		document.getElementById("franchise_selector").style.display = "none";
		//document.getElementById("franchise_selector").selectedIndex = 0;

		//load_and_transform(xml_path + "main_tool_selectors.xml", xsl_path + "saisons.xsl", "main_seasons", null, {season_in: '0', season_out: '3000', visible_state: get_season_visibility_state()})

		if(mode.length > 0)
			mode.style.display = "block";
	}

	final_str = str.split("|")
	load_and_transform(xml_path + 'main_tool_selectors.xml', xsl_path + xsl_level_file, div_name, null, {level_name: final_str[1], level_name_id: final_str[2]})
}



//-->
function get_section_letter(obj, letter, group)
{
	if(obj.id == "section00")
	{
		if(group == "0")
		{
			value = document.getElementById("ligue_selector").value
			document.getElementById("season_selector").selectedIndex = ligue_last
		}
		else if(group == "1")
		{
			value = document.getElementById("equipe_selector").value
			document.getElementById("season_selector").selectedIndex = equipe_last
		}
		else if(group == "2")
		{
			value = document.getElementById("franchise_selector").value
			document.getElementById("season_selector").selectedIndex = franchise_last
		}

		this_final_letter = value.split("|")
		document.getElementById("section01").value = this_final_letter[0]


		if(document.getElementById("season_selector").style.display == 'block')
		{
			value = document.getElementById("season_selector").value
			this_final_letter = value.split("|")
			document.getElementById("section02").value = this_final_letter
		}
	}
	else if(obj.id == "section01")
	{
		if(document.getElementById("season_selector").style.display == 'block')
		{
			value = document.getElementById("season_selector").value
			this_final_letter = value.split("|")
			document.getElementById("section02").value = this_final_letter
		}
	}

	final_letter = letter.split("|")
	obj.value = final_letter[0]

	if(document.getElementById("ligue_selector").style.display == 'block' && document.getElementById("season_selector").style.display == 'block')
	{
		ligue_last = document.getElementById("season_selector").selectedIndex
	}

	if(document.getElementById("equipe_selector").style.display == 'block' && document.getElementById("season_selector").style.display == 'block')
	{
		equipe_last = document.getElementById("season_selector").selectedIndex
	}

	if(document.getElementById("franchise_selector").style.display == 'block' && document.getElementById("season_selector").style.display == 'block')
	{
		franchise_last = document.getElementById("season_selector").selectedIndex
	}

}



//-->
function get_record(xml)
{
	load_and_transform(xml_path + xml, xsl_path + 'records.xsl', 'main_records');
	load_and_transform(xml_path + 'most_pop_records.xml', xsl_path + 'most_pop_records.xsl', 'most_pop_records', null, {pop_type: pop_type});
}



//-->
function get_pop_record(type)
{
	pop_type = type
	load_and_transform(xml_path + 'most_pop_records.xml', xsl_path + 'most_pop_records.xsl', 'most_pop_records', null, {pop_type: type});
}



//-->
function show_hide_season_section(obj)
{
	if(obj.id == "select_saison")
		document.getElementById("season_selector").style.display = "block";
	else
		document.getElementById("season_selector").style.display = "none";
}



//-->
function get_season_visibility_state()
{
	season_selector_obj = document.getElementById("season_selector")

	if(season_selector_obj.style.display == "none")
		season_visibility = 'off'
	else
		season_visibility = 'on'

	return season_visibility;

}
?>