/** odeslání XMLHttp poadavku
* @param function obsluha funkce zajiující obsluhu pøi zmìnì stavu poadavku, dostane parametr s XMLHttp objektem @param string method GET|POST|...
* @param string url URL poadavku
* @param string [content] tìlo zprávy
* @param array [headers] pole pøedaných hlavièek ve tvaru { 'hlavièka': 'obsah' }
* @return bool true v pøípadì úspìchu, false jinak
*
* @deprecated DON'T USE ANY MORE!!!
* @todo DELETE
*/
function send_xmlhttprequest(obsluha, method, url, content, headers) {
var xmlhttp = (window.XMLHttpRequest ? new XMLHttpRequest : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false));
if (!xmlhttp) { return false; }
xmlhttp.open(method, url);
xmlhttp.onreadystate = function() { obsluha(xmlhttp); };
if (headers) {
for (var key in headers) {
xmlhttp.setRequestHeader(key, headers[key]);
}
}
xmlhttp.send(content);
return true;
}
function hide(checker, element_id)
{
var element = document.getElementById(element_id);
if(checker.checked)
element.style.display = 'none';
else
element.style.display = 'block';
}
// pri zmacknuti klavesy ENTER se provede potvrzeni formulare, hlavni submit okno musi mit ID="submit"
/*
if (document.layers)
document.captureEvents(event.keydown);
document.onkeydown =
function (evt) {
var keyCode = evt ? (evt.which ? evt.which : evt.keyCode) : event.keyCode;
if(keyCode == 13) { // ENTER
if(document.getElementById('submit')) {
document.getElementById('submit').click();
} else if(document.getElementById('save')) {
document.getElementById('save').click();
}
}
}
if (document.layers)
document.captureEvents(Event.FOCUS | Event.BLUR);
var focussedElement = false;
document.onfocus =
function (evt) {
if (focussedElement)
focussedElement.focussed = false;
focussedElement = evt.target ? evt.target : event.srcElement;
focussedElement.focussed = true;
window.status = 'focus on: ' + (focussedElement.id ? focussedElement.id : focussedElement.name ? focussedElement.name : focussedElement);
}
document.onblur =
function (evt) {
if (focussedElement)
focussedElement.focussed = false;
focussedElement = null;
}
*/
// minimalizuje/maximalizuje okno
function minmax(id) {
if(document.getElementById(id + 'c').style.display == 'none') {
document.getElementById(id + 'c').style.display = 'block';
} else {
document.getElementById(id + 'c').style.display = 'none';
}
}
// otevre kalendar
function open_calendar(prefix, params, field, type) {
window.open("/shared/calendar/?" + params, "calendar", "width=340,height=230");
dateField = document.getElementById(field);
dateType = type;
}
// otevre kalendar
function open_advanced_calendar(prefix, params, field, type, script) {
open_calendar(prefix, params, field, type);
dateScript = script;
}
// zvysi datum o zadany pocet dnu
function inc_date_day(field, inc_days) {
var my_date = document.getElementById(field).value;
pom = my_date.split(' ');
my_date = pom[0];
date = inc_day(my_date, inc_days);
if(pom[1])
date += ' ' + pom[1];
document.getElementById(field).value = date;
}
// snizi datum o zadany pocet dnu
function dec_date_day(field, dec_days) {
var my_date = document.getElementById(field).value;
pom = my_date.split(' ');
my_date = pom[0];
date = dec_day(my_date, dec_days);
if(pom[1])
date += ' ' + pom[1];
document.getElementById(field).value = date;
}
// opravdu smazat zaznam?
function confirm_del(text) {
if(text == '')
text = 'Skutečně odstranit záznam?';
return confirm(text);
}
var nodiac =
{
'á':'a', 'Á':'a',
'č':'c', 'Č':'c',
'ď':'d', 'Ď':'d',
'é':'e', 'É':'e',
'ě':'e', 'Ě':'e',
'í':'i', 'Í':'i',
'ň':'n', 'Ň':'n',
'ó':'o', 'Ó':'o',
'ř':'r', 'Ř':'r',
'š':'s', 'Š':'s',
'ť':'t', 'Ť':'t',
'ú':'u', 'Ú':'u',
'ů':'u', 'Ů':'u',
'ý':'y', 'Ý':'y',
'ž':'z', 'Ž':'z',
'ü':'ue','Ü':'ue',
'ä':'a', 'Ä':'a',
'ë':'e', 'Ë':'e',
'ö':'o', 'Ö':'o',
'ï':'i', 'Ï':'i',
'ÿ':'y', 'Ÿ':'y',
'ł':'l', 'Ł':'l',
'ĺ':'l', 'Ĺ':'l',
'ć':'c', 'Ć':'c'
};
/** Vytvoření přátelského URL
* @param string s řetězec, ze kterého se má vytvořit URL
* @return string řetězec obsahující pouze čísla, znaky bez diakritiky, podtržítko a pomlčku
* @copyright Jakub Vrána, http://php.vrana.cz
*/
function make_url(s)
{
s = s.toLowerCase();
var s2 = '';
for (var i=0; i < s.length; i++)
{
s2 += (typeof nodiac[s.charAt(i)] != 'undefined' ? nodiac[s.charAt(i)] : s.charAt(i));
}
return s2.replace(/[^a-z0-9_]+/g, '-').replace(/^-|-$/g, '');
}
function set_url(s, id)
{
document.getElementById(id).value = make_url(s);
}
function clocks(lang)
{
var my_date = new Date();
var element = document.getElementById('acttime');
var acttime = element.innerHTML;
var time = acttime.split('.');
my_date.setHours(Number(time[0]), Number(time[1]), (Number(time[2]) + 1), 0);
if(my_date.getSeconds() < 10)
var seconds = '0' + my_date.getSeconds();
else
var seconds = my_date.getSeconds();
if(lang == 'en')
{
element.innerHTML = my_date.getHours()+':'+my_date.getMinutes()+':'+seconds;
}
else
{
element.innerHTML = my_date.getHours()+'.'+my_date.getMinutes()+'.'+seconds;
}
}
function start_clock(lang)
{
clocks(lang);
setTimeout("start_clock('"+lang+"')", 1000);
}
// knihovna datovych funkci {{{
function get_year(date)
{
var tmp = date.split('.');
if(tmp[2])
return tmp[2];
else
{
var tmp = new Date();
return tmp.getFullYear();
}
}
function get_month(date)
{
var tmp = date.split('.');
if(tmp[1])
return tmp[1];
else
{
var tmp = new Date();
return tmp.getMonth() + 1;
}
}
function get_day(date)
{
var tmp = date.split('.');
if(tmp[0])
return tmp[0];
else
{
var tmp = new Date();
return tmp.getDate();
}
}
function inc_day(date, days_to_inc)
{
var timestamp = get_timestamp(date);
var tmp = new Date(timestamp);
tmp.setDate(tmp.getDate() + Number(days_to_inc));
var tmpDate = tmp.getDate().toString();
var tmpMonth = (1+tmp.getMonth()).toString();
if (tmpDate.length == 1)
tmpDate = '0'+tmpDate;
if (tmpMonth.length == 1)
tmpMonth = '0'+tmpMonth;
//return tmp.getDate() + '.' + (tmp.getMonth() + 1) + '.' + tmp.getFullYear();
return tmpDate+'.'+tmpMonth+'.'+tmp.getFullYear().toString();
}
function get_timestamp(date)
{
var year = get_year(date);
var month = get_month(date);
var day = get_day(date);
return Date.parse(year + '/' + month + '/' + day);
}
function dec_day(date, days_to_dec)
{
return inc_day(date, '-' + days_to_dec);
}
// }}}
var ie = navigator.userAgent.match(/MSIE/) ? true : false;
var pattBrowser = new RegExp(/MSIE (\d+)\.\d+/gi);
var ieVersion = new Number(0);
if (navigator.userAgent.match(pattBrowser)) {
ieVersion = new Number(RegExp.$1);
}
// function getElement() {{{
/**
* Get object of element by ID.
*
* @param string $element ID name of requested element.
* @return object Returns element's object.
*/
function getElement(e)
{
return document.getElementById(e);
}
// }}}
// function getElementPosition() {{{
/**
* Get element position.
*
* @param object $obj DOM object of parent element.
* @param object Returns array with element position.
*/
function getElementPosition(obj)
{
var curleft = 0;
var curtop = 0;
if (obj.offsetParent)
{
curleft = obj.offsetLeft;
curtop = obj.offsetTop;
while (obj = obj.offsetParent)
{
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
}
}
return {curleft:curleft, curtop:curtop};
}
// }}}
var parElem;
// AJAX {{{
var xhr;
// function create_xhr() {{{
/**
* Creation XHR object.
*
* @return object
*/
function create_xhr()
{
try
{
// Firefox, Opera 8.0+, Safari
xhr = new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xhr = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Váš prohlížeč nepodporuje AJAX.");
return false;
}
}
}
}
// }}}
// function show_xhr_error() {{{
/**
* Show error message, if XHR fail.
*
* @retrun void
*/
function show_xhr_error()
{
alert('Chyba objektu XMLHttpRequest'+"\n"+'Kód chyby: '+xhr.status+"\n"+'Chybová zpráva: '+xhr.text);
}
// }}}
// function get_help() {{{
/**
* Get helps for malfunction.
*
* @param object $element Parant elemen, for get helps position.
* @param integer $id Malfunction ID.
*/
function get_help(element, id)
{
parElem = element;
create_xhr();
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4)
{
if (xhr.status == 200)
{
destroy_help();
var div = document.createElement('div');
div.id="help-text";
div.innerHTML = xhr.responseText;
parPos = getElementPosition(parElem);
var pos_left = (parPos.curleft/2)+parElem.offsetWidth;
var pos_top = parPos.curtop+25;
if(navigator.userAgent.indexOf("MSIE") != -1)
div.style.setAttribute('cssText', 'left:'+pos_left+'px;top:'+pos_top+'px;', 0);
else
div.setAttribute('style', 'left:'+pos_left+'px;top:'+pos_top+'px;');
document.body.appendChild(div);
}
else
show_xhr_error();
}
};
xhr.open('GET', '/res/ajax/help.php?id='+id, true);
xhr.send(null);
}
/**
* Process AJAX funciton for getting malfunction help.
*
* @return void
*/
function destroy_help()
{
var help = getElement('help-text');
if (help != undefined)
document.body.removeChild(help);
}
// }}}
// filter_tournament() {{{
/**
* Search in tournament names from Trefik.
*
* @param string search What you find.
* @return void
*/
var filter_search;
function filter_tournament()
{
var search = getElement('filterName').value;
var prize = getElement('filterPrize').value;
var filOper = getElement('filterOperator');
var annual = new Number(cJsLib.$('Annual').options[cJsLib.$('Annual').selectedIndex].value);
var plMan = cJsLib.$('PlayerTypeMan').checked == true ? 1 : 0;
var plWoman = cJsLib.$('PlayerTypeWoman').checked == true ? 1 : 0;
var notPaired = cJsLib.$('NotPaired').checked == true ? 1 : 0;
var filOper = filOper.options[filOper.selectedIndex].value;
var cLoad = true;
if ((search == 0 && prize == '' && filOper == '' && annual == '')
|| (search == 0 && filOper == '' && annual == '')
)
{
cLoad = confirm('Zobrazení výsledků bez zadaného filtru může trvat dlouho. Pokračovat?');
}
if (cLoad) {
filter_search = search;
create_xhr();
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var xml = xhr.responseXML;
var tournaments = xml.getElementsByTagName('tournament');
if (typeof tournaments != 'undefined' && typeof tournaments == 'object') {
var available = getElement('tournamentAvailable');
var registered = getElement('tournamentRegistered');
var new_available = document.createElement('select');
new_available.setAttribute('id', 'tournamentAvailable');
new_available.setAttribute('name', 'tournament_available[]');
new_available.setAttribute('multiple', 'multiple');
new_available.setAttribute('size', '10');
if (tournaments.length > 0) {
for (var i = 0; i < tournaments.length; i++) {
if (tournaments[i].hasChildNodes()) {
var id = getTextContent(tournaments[i].getElementsByTagName('id')[0]);
var annual = getTextContent(tournaments[i].getElementsByTagName('annual')[0]);
var name = getTextContent(tournaments[i].getElementsByTagName('name')[0]);
var player_type = getTextContent(tournaments[i].getElementsByTagName('player_type')[0]);
var tour_type = getTextContent(tournaments[i].getElementsByTagName('tournament_type')[0]);
var phase_type = getTextContent(tournaments[i].getElementsByTagName('phase_type')[0]);
var prize = getTextContent(tournaments[i].getElementsByTagName('prize')[0]);
var paired = getTextContent(tournaments[i].getElementsByTagName('paired')[0]);
var new_option = genDOMOption(name + ' [' + (annual != '' ? annual + ', ' : '') + player_type + ', ' + tour_type + ', ' + phase_type + ', ' + prize + ' ...... ' + paired + ']', id);
new_available.appendChild(new_option);
}
}
}
else
{
var new_option = genDOMOption();
new_available.appendChild(new_option);
alert('Nenalezeny žádné položky.');
}
var pNode = available.parentNode;
pNode.replaceChild(new_available, available);
}
}
else
show_xhr_error();
};
}
xhr.open('GET', '/res/ajax/tournament-filter.php?search='+search+'&prize='+prize+'&annual='+annual+'&man='+plMan+'&woman='+plWoman+'&operator='+filOper+'¬_paired='+notPaired);
xhr.send(null);
}
// else {
// alert('Musíte vyplnit nějaký údaj - Název nebo Dotaci.');
// }
};
// }}}
var clicked_element;
/**
* Change status of banned system user.
*
* @param {Object} element DOM object.
* @param {String} id ID of configuration function (in DB).
* @return {Void} Returns void
*/
function changeBannedSystemUser(element, id)
{
clicked_element = element;
create_xhr();
xhr.onreadystatechange = function()
{
if (xhr.readyState == 0 || xhr.readyState == 4) {
if (xhr.status == 200) {
var itemStatus = xhr.responseXML.getElementsByTagName("item");
itemStatus = itemStatus.item(0).firstChild.data;
setCls(clicked_element, "active stat"+(itemStatus == "n" ? "off" : "on"));
} else {
show_xhr_error();
}
}
};
xhr.open("GET", "/res/ajax/change-banned-user.php?id="+id);
xhr.send(null);
};
/**
* Change status of active configuration function.
*
* @param {Object} element DOM object.
* @param {String} id ID of configuration function (in DB).
* @return {Void} Returns void
*/
function changeActiveConfigurationFunction(element, id)
{
clicked_element = element;
create_xhr();
xhr.onreadystatechange = function()
{
if (xhr.readyState == 0 || xhr.readyState == 4) {
if (xhr.status == 200) {
var itemStatus = xhr.responseXML.getElementsByTagName("item");
itemStatus = itemStatus.item(0).firstChild.data;
setCls(clicked_element, "active stat"+(itemStatus == "n" ? "off" : "on"));
} else {
show_xhr_error();
}
}
};
xhr.open("GET", "/res/ajax/change-active-configuration-function.php?id="+id);
xhr.send(null);
};
/**
* Change status of active configuration data type.
*
* @param {Object} element DOM object.
* @param {String} id ID of configuration data type (in DB).
* @return {Void} Returns void
*/
function changeActiveConfigurationDataTypeItem(element, id)
{
clicked_element = element;
create_xhr();
xhr.onreadystatechange = function()
{
if (xhr.readyState == 0 || xhr.readyState == 4) {
if (xhr.status == 200) {
var itemStatus = xhr.responseXML.getElementsByTagName("item");
itemStatus = itemStatus.item(0).firstChild.data;
setCls(clicked_element, "active stat"+(itemStatus == "n" ? "off" : "on"));
} else {
show_xhr_error();
}
}
};
xhr.open("GET", "/res/ajax/change-active-configuration-datatype.php?id="+id);
xhr.send(null);
};
/**
* Change status of active configuration item.
*
* @param {Object} element DOM object.
* @param {String} id ID of configuration group (in DB).
* @return {Void} Returns void
*/
function changeActiveConfigurationItem(element, id)
{
clicked_element = element;
create_xhr();
xhr.onreadystatechange = function()
{
if (xhr.readyState == 0 || xhr.readyState == 4) {
if (xhr.status == 200) {
var itemStatus = xhr.responseXML.getElementsByTagName("item");
itemStatus = itemStatus.item(0).firstChild.data;
setCls(clicked_element, "active stat"+(itemStatus == "n" ? "off" : "on"));
} else {
show_xhr_error();
}
}
};
xhr.open("GET", "/res/ajax/change-active-configuration-item.php?id="+id);
xhr.send(null);
};
/**
* Change status of active configuration group.
*
* @param {Object} element DOM object.
* @param {String} id ID of configuration group (in DB).
* @return {Void} Returns void
*/
function changeActiveConfigurationGroup(element, id)
{
clicked_element = element;
create_xhr();
xhr.onreadystatechange = function()
{
if (xhr.readyState == 0 || xhr.readyState == 4) {
if (xhr.status == 200) {
var itemStatus = xhr.responseXML.getElementsByTagName("item");
itemStatus = itemStatus.item(0).firstChild.data;
setCls(clicked_element, "active stat"+(itemStatus == "n" ? "off" : "on"));
} else {
show_xhr_error();
}
}
};
xhr.open("GET", "/res/ajax/change-active-configuration-group.php?id="+id);
xhr.send(null);
};
/**
* Change status of active country.
*
* @param {Object} element DOM object.
* @param {String} id ID of country (in DB).
* @return {Void} Returns void
*/
function change_active_country(element, id)
{
clicked_element = element;
create_xhr();
xhr.onreadystatechange = function()
{
if (xhr.readyState == 0 || xhr.readyState == 4) {
if (xhr.status == 200) {
var itemStatus = xhr.responseXML.getElementsByTagName("item");
itemStatus = itemStatus.item(0).firstChild.data;
setCls(clicked_element, "active stat"+(itemStatus == "n" ? "off" : "on"));
} else {
show_xhr_error();
}
}
};
xhr.open("GET", "/res/ajax/change-active-country.php?id="+id);
xhr.send(null);
};
/**
* Change status of active competition.
*
* @param {Object} element DOM object.
* @param {String} id ID of tournament (in DB).
* @return {Void} Returns void
*/
function change_active_competition(element, id)
{
clicked_element = element;
create_xhr();
xhr.onreadystatechange = function()
{
if (xhr.readyState == 0 || xhr.readyState == 4) {
if (xhr.status == 200) {
var itemStatus = xhr.responseXML.getElementsByTagName("item");
itemStatus = itemStatus.item(0).firstChild.data;
setCls(clicked_element, "active stat"+(itemStatus == "n" ? "off" : "on"));
} else {
show_xhr_error();
}
}
};
xhr.open("GET", "/res/ajax/change-active-competition.php?id="+id);
xhr.send(null);
};
/**
* Change status of major tournament.
*
* @param object $element DOM object.
* @param string $id ID of tournament (in DB).
* @return void Returns void
*/
function changeFuturesTournament(element, id)
{
clicked_element = element;
create_xhr();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var itemStatus = xhr.responseXML.getElementsByTagName("item");
var status = itemStatus.item(0).firstChild.data;
var attr = clicked_element.attributes;
for(var i = attr.length-1; i >= 0; i--) {
if(attr[i].name == "CLASS" || attr[i].name == "class") {
if(status == "y") {
clicked_element.attributes[i].value = "active staton";
} else {
clicked_element.attributes[i].value = "active statoff";
}
break;
}
}
} else {
show_xhr_error();
}
}
}
xhr.open('GET', '/res/ajax/change-futures-tournament.php?id=' + id);
xhr.send(null);
}
/**
* Change status of major tournament.
*
* @param object $element DOM object.
* @param string $id ID of tournament (in DB).
* @return void Returns void
*/
function changeMajorTournament(element, id)
{
clicked_element = element;
create_xhr();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var itemStatus = xhr.responseXML.getElementsByTagName("item");
var status = itemStatus.item(0).firstChild.data;
var attr = clicked_element.attributes;
for(var i = attr.length-1; i >= 0; i--) {
if(attr[i].name == "CLASS" || attr[i].name == "class") {
if(status == "y") {
clicked_element.attributes[i].value = "active staton";
} else {
clicked_element.attributes[i].value = "active statoff";
}
break;
}
}
} else {
show_xhr_error();
}
}
}
xhr.open('GET', '/res/ajax/change-major-tournament.php?id=' + id);
xhr.send(null);
}
function changeExhibitionTournament(element, id)
{
clicked_element = element;
create_xhr();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var itemStatus = xhr.responseXML.getElementsByTagName("item");
var status = itemStatus.item(0).firstChild.data;
var attr = clicked_element.attributes;
for(var i = attr.length-1; i >= 0; i--) {
if(attr[i].name == "CLASS" || attr[i].name == "class") {
if(status == "y") {
clicked_element.attributes[i].value = "active staton";
} else {
clicked_element.attributes[i].value = "active statoff";
}
break;
}
}
} else {
show_xhr_error();
}
}
}
xhr.open('GET', '/res/ajax/change-exhibition-tournament.php?id=' + id);
xhr.send(null);
}
/**
* Change status of active tournament.
*
* @param object $element DOM object.
* @param string $id ID of tournament (in DB).
* @return void Returns void
*/
function change_act_tour(element, id)
{
clicked_element = element;
create_xhr();
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4)
{
if (xhr.status == 200)
{
var itemStatus = xhr.responseXML.getElementsByTagName("item");
var status = itemStatus.item(0).firstChild.data;
var attr = clicked_element.attributes;
for(var i = attr.length-1; i >= 0; i--)
{
if(attr[i].name == "CLASS" || attr[i].name == "class")
{
if(status == "y")
clicked_element.attributes[i].value = "active staton";
else
clicked_element.attributes[i].value = "active statoff";
break;
}
}
}
else
show_xhr_error();
}
}
xhr.open('GET', '/res/ajax/change-active-tournament.php?id='+id);
xhr.send(null);
}
// function change_act_bookmaker() {{{
/**
* Change status of active tournament.
*
* @param object $element DOM object.
* @param string $id ID of tournament (in DB).
* @return void Returns void
*/
function change_act_bookmaker(element, id)
{
clicked_element = element;
create_xhr();
xhr.open('GET', '/res/ajax/change-active-tournament.php?id='+id, true);
xhr.onreadystatechange = function()
{
if (xhr.readyState == 0 || xhr.readyState == 4)
{
if (xhr.status == 200)
{
var itemStatus = xhr.responseXML.getElementsByTagName("item");
var status = itemStatus.item(0).firstChild.data;
var attr = clicked_element.attributes;
for(var i = attr.length-1; i >= 0; i--)
{
if(attr[i].name == "CLASS" || attr[i].name == "class")
{
if(status == "y")
clicked_element.attributes[i].value = "active staton";
else
clicked_element.attributes[i].value = "active statoff";
break;
}
}
}
else
show_xhr_error();
}
};
xhr.send(null);
}
// }}}
function lockMatch(element, id)
{
clicked_element = element;
create_xhr();
xhr.onreadystatechange = function()
{
if (xhr.readyState == 0 || xhr.readyState == 4) {
if (xhr.status == 200) {
var itemStatus = xhr.responseXML.getElementsByTagName("item");
itemStatus = itemStatus.item(0).firstChild.data;
setCls(clicked_element, "active stat"+(itemStatus == "n" ? "off" : "on"));
} else {
show_xhr_error();
}
}
};
xhr.open('GET', '/res/ajax/lock-match.php?id=' + id);
xhr.send(null);
};
// function find_player() {{{
/**
* Find player and generate suggest with names for adding players into article.
*
* @param string $whatSearch What search.
* @return void Returns void.
*/
function find_player(whatSearch)
{
if (whatSearch.length >= 2)
{
create_xhr();
xhr.onreadystatechange = function()
{
if (xhr.readyStatus == 0 || xhr.readyState == 4)
{
if (xhr.status == 200)
{
// first try destroy previous container
if (getElement('searchedPlayer') != null)
destroyElem('searchedPlayer');
var container = document.createElement('div');
var dContainer = document.createElement('div');
var closer = document.createElement('div');
var a = document.createElement('a');
container.setAttribute('id', 'searchedPlayer');
setCls(closer, 'closer');
setOnClick(a, "destroyElem('searchedPlayer');");
a.appendChild(document.createTextNode('X'));
closer.appendChild(a);
container.appendChild(closer);
dContainer.setAttribute('id', 'data');
if (xhr.responseXML.getElementsByTagName('players').item(0) == null
|| xhr.responseXML.getElementsByTagName('empty').item(0) != null)
{
dContainer.appendChild(document.createTextNode('Žádní hráči neodpovídají kritériu.'));
}
else
{
var players = xhr.responseXML.getElementsByTagName('player');
for (var i = 0; i < players.length; i++)
{
var id = players[i].getElementsByTagName('id').item(0);
var surname = players[i].getElementsByTagName('surname').item(0);
var firstname = players[i].getElementsByTagName('firstname').item(0);
var args = new Array();
args['href'] = (id.firstChild ? id.firstChild.nodeValue : '');
args['text'] = (surname.firstChild ? surname.firstChild.nodeValue : '')+(firstname.firstChild ? ' '+firstname.firstChild.nodeValue : '');
args['onclick'] = 'addPlayerToArticle(this);return false;';
dContainer.appendChild(createALink(args));
}
}
container.appendChild(dContainer);
var pos = getElementPosition(getElement('FindPlayerBut'));
container.style.top = pos.curtop+'px';
container.style.left = pos.curleft+10+getElement('FindPlayerBut').offsetWidth+'px';
document.body.appendChild(container);
}
else
show_xhr_error();
}
}
xhr.open('GET', '/res/ajax/find-player.php?what='+whatSearch);
xhr.send(null);
} else {
alert('Minimální délka pro hledání jsou 2 znaky.');
}
}
// }}}
function findPlayerMatch(elemID, idPick, autoReload)
{
var whatSearch = getElement(elemID).value;
if (whatSearch.length >= 2)
{
var tipID = getElement(elemID).getAttribute('id');
tipID = tipID.substr(tipID.indexOf('-')+1);
create_xhr();
xhr.onreadystatechange = function()
{
if (xhr.readyState == 0 || xhr.readyState == 4)
{
if (xhr.status == 200)
{
// first try destroy previous container
if (getElement('findedMatches') != null)
destroyElem('findedMatches');
var container = document.createElement('div');
var dContainer = document.createElement('div');
var closer = document.createElement('div');
var a = document.createElement('a');
container.setAttribute('id', 'findedMatches');
setCls(closer, 'closer');
setOnClick(a, "destroyElem('findedMatches');");
a.appendChild(document.createTextNode('X'));
closer.appendChild(a);
container.appendChild(closer);
dContainer.setAttribute('id', 'data');
if (xhr.responseXML.getElementsByTagName('response').item(0) == null
|| xhr.responseXML.getElementsByTagName('empty').item(0) != null)
{
dContainer.appendChild(document.createTextNode('Žádné zápasy odpovídají kritériu.'));
} else {
var players = xhr.responseXML.getElementsByTagName('row');
for (var i = 0; i < players.length; i++) {
var id = players[i].getElementsByTagName('id').item(0);
var nMatch = players[i].getElementsByTagName('match').item(0);
var args = new Array();
args['href'] = '';
args['id'] = 'nm-'+(id.firstChild ? id.firstChild.nodeValue : '');
args['text'] = nMatch.firstChild ? nMatch.firstChild.nodeValue : '';
args['onclick'] = 'selectGame('+(id.firstChild ? id.firstChild.nodeValue : '')+', '+idPick+', '+autoReload+');return false;';
dContainer.appendChild(createALink(args));
}
}
container.appendChild(dContainer);
var pos = getElementPosition(getElement('FindMatch-1'));
container.style.top = pos.curtop+'px';
container.style.left = pos.curleft+10+getElement('FindMatch-1').offsetWidth+'px';
document.body.appendChild(container);
}
else
show_xhr_error();
}
}
xhr.open('GET', '/res/ajax/find-player-match.php?what='+whatSearch);
xhr.send(null);
} else {
alert('Minimální délka pro hledání jsou 2 znaky.');
}
};
// function createALink() {{{
/**
* Create URL link for adding player into article.
*
* @param array $args Array with parameters.
*
Possible values are:
*