var historie = new Array()// pole s posloupností procházených pojmů - historie var max_historie = 10; // limit historie var historie_actual = -1; // ukazatel aktuální pojmu při procházení hstorie var terminy = new Array(); // pole s pojmy var lineDelimiter = "$"// oddělovač řádků var initialized = false; // promenna urcujici, zda jiz byl seznam pojmu nacten // 20150831 var sortString = " -0123456789aábcčdďeěéfghhiíjklmnňoópqrřsštťuúůüvwxyýzž"; // IE hack - resi nepritomnost funkce indexOf u Array if (!Array.prototype.indexOf) { Array.prototype.indexOf = function(obj, start) { for (var i = (start || 0), j = this.length; i < j; i++) { if (this[i] === obj) { return i; } } return -1; } } // konstruktor objektu pojmu function Pojem() { this.title = ""; // název this.subtitle = "" // podtitul } // nacteni seznamu pojmu do iframu function loadTermsList() { document.getElementById("termsListLoader").src = "terms/terms.txt"; } // odstraneni tagu
 ze vstupniho textu vcetne styloveho parametru v Google Chrome
function removeTagPre(text) {
	text = text.substr(5);
	if(text.toLowerCase().substr(0, 17) == 'style="word-wrap:') {
		text = text.substr(54);
	}
	if(text.toLowerCase().substr(text.length - 6) == "") {
		text = text.substring(0, text.length - 6);
	}
	return text;
}

//inicializace aplikace
function init() {
	var termsList = document.getElementById("termsListLoader").contentWindow.document.body.innerHTML;
	var operaMajorVersion = navigator.userAgent.substr(-5, 2);
	var operaMinorVersion = navigator.userAgent.substr(-2);
	//alert(operaMajorVersion + "   > " + operaMinorVersion);
	var k = navigator.userAgent.indexOf("MSIE");
	var l = navigator.userAgent.substr(k + 5);
	var m = l.indexOf(".");
	var ieMajorVersion = l.substr(0, m);

	if(termsList != "" && !initialized) {
		if(navigator.appName != "Opera" || operaMajorVersion <= "11" || (operaMajorVersion == "10" && operaMinorVersion < 52) || confirm("Používáte slovníkem nepodporovanou verzi prohlížeče Opera " + operaMajorVersion + "." + operaMinorVersion + ". Načítání slovníku může zabrat i několik minut, během kterých nemusí prohlížeč reagovat. Doporučujeme použít jiný prohlížeč. Za způsobené problémy se omlouváme.\n\nChcete i přesto pokračovat?\n\n\nThe dictionary does not support web browser Opera " + operaMajorVersion + "." + operaMinorVersion + ". Loading the dictionary may take several minutes, during which the browser may not respond. In this case, using a different browser is recommended. For the inconvenience we apologize.\n\nDo you want to continue anyway?")) {
			actualTerm = -1;
			termsList = removeTagPre(termsList);
			if(navigator.appName == "Netscape" || (navigator.appName == "Microsoft Internet Explorer" && ieMajorVersion >= 9)) {
				var termsArray = termsList.split(String.fromCharCode(10));
			} else {
				if (operaMajorVersion == "11" && operaMinorVersion >= 61) {
					var termsArray = termsList.split(String.fromCharCode(10));	
				} else {
					var termsArray = termsList.split(String.fromCharCode(13, 10));
				}
				if (termsArray.length == 1) {
					termsArray = termsList.split(String.fromCharCode(10));
				}
			}

			for(var i = 0; i < termsArray.length; i++) {// načtení pojmů
				if(termsArray[i] != "") {
					var termin = new Pojem()
					termin.title = termsArray[i].split("#")[0];
					termin.subtitle = termsArray[i].split("#")[1];
					terminy.push(termin);
				}
			}

            // 20150803
			terminy.sort(sorterCze);

			var variables = location.search;
			if(variables.indexOf('?pojem=') == 0) {
				var trm = variables.substr(7);
				trm = decodeURIComponent(trm);				
				trm = trm.split('+').join(' ');
                trm = trm.replace(/@@@/g,"+");
//                console.log(trm);
				showTermNamed(trm);
			} else {   			   
				showTerm(0, true);
			}

			showList("");
			var index = historie[0];
			selectListItem(terminy[index].title);
			initialized = true;
		}
	}
}

// 20150803
// radici funkce - nebere v potaz nepovolene znaky
function sortByTitle(a, b) {
    a = sanitize(a.title).toLowerCase();
    b = sanitize(b.title).toLowerCase();
    if (a > b) {
        return 1;
    }
    if (a < b) {
        return -1;
    }
    return 0;   
}

//20150831
function sorterCze(a, b) {
    a = sanitize(a.title).toLowerCase();
    b = sanitize(b.title).toLowerCase();
        
        var bi = 0;
        var aindex = 0;
        var bindex = 0;
        
        for (var ai = 0; ai < a.length; ai++) {
            
            // DODELAT pokud b.length == bi return !!!!
            if (b.length == bi) {
                return 1;
            }
            
            if (a[ai] == "c" && a.length >= ai + 1 && a[ai +1] == "h") {
                if (b[bi] == "c" && b.length >= bi + 1 && b[bi +1] == "h") {
            		ai++;
            		bi += 2;
            		continue;
            	}
                aindex = 25;
                bindex = sortString.indexOf(b[bi]);
//                if (bindex == -1) return -1;
                return aindex > bindex ? 1 : -1;
            }
            
            if (b[bi] == "c" && b.length >= bi + 1 && b[bi +1] == "h") {
                if (a[ai] == "c" && a.length >= ai + 1 && a[ai +1] == "h") {
            		ai++;
            		bi += 2;
            		continue;
            	}
                aindex = sortString.indexOf(a[ai]);;
                bindex = 25
//                if (aindex == -1) return 1;
                return aindex > bindex ? 1 : -1;
            }
            
            if (a[ai] == b[bi]) {
                bi++;
                continue;
            }
            
            if (sortString.indexOf(a[ai]) > sortString.indexOf(b[bi])) return 1;
            if (sortString.indexOf(a[ai]) < sortString.indexOf(b[bi])) return -1;
        }
        return 0;
}

// 20150803
// odstran neporovnatelne znaky
function sanitize(input) {
    return input.replace(/[\(\)]/g, "").replace(/[’]/ig, "-").replace(/[ď]/ig, "d").replace(/[ěé]/ig, "e").replace(/[ó]/ig, "o").replace(/[ůúü]/ig, "u")
//        .replace(/[á]/ig, "a").replace(/[č]/ig, "c").replace(/[ď]/ig, "d").replace(/[ěé]/ig, "e").replace(/[í]/ig, "i").replace(/[ó]/ig, "o").replace(/[ř]/ig, "r").replace(/[š]/ig, "s").replace(/[ť]/ig, "t").replace(/[ůúü]/ig, "u").replace(/[ý]/ig, "y").replace(/[ž]/ig, "z");
    
    //.replace(/ď/ig, "d").replace(/[éě]/ig, "e").replace(/[úůü]/ig, "u")
}

// uložení pojmu do hisorie
function putToHistory(index) {
	if(historie.length == max_historie) {
		historie.shift();
	}
	historie.push(index);
	setActualHistory(historie.length - 1);
}

// nastavení aktuálního pojmu v historii
function setActualHistory(index) {
	historie_actual = index;
	var history_prev = document.getElementById("history_prev");
	var history_next = document.getElementById("history_next");
	if(index == 0) {// zablokovani predchoziho talcitka
		history_prev.src = "design/l_inactive.png"
	}
	if(index > 0) {
		history_prev.src = "design/l_active.png"
	}
	if(index == historie.length - 1) {//zabokovani dalsiho tlacitka
		history_next.src = "design/r_inactive.png";
	}
	if(index < historie.length - 1 && historie.length > 1) {//odblokovani dalsiho tlacitka
		history_next.src = "design/r_active.png";
	}

	var lastTerms = new StringBuffer();
	var termName = "";
	var termIndex = "0";
	var prefix = "";
	var suffix = "";
	lastTerms.append("");
	setHTML("last_terms", lastTerms.toString());
}

// přechod na předcházející pojem v historii
function goPrev() {
	if(historie_actual > 0) {
		var index = historie[--historie_actual];
		showTerm(index, false);
		selectListItem(terminy[index].title);
		setActualHistory(historie_actual);
	}
}

// přechod na následující pojem v historii
function goNext() {
	if(historie_actual < historie.length - 1) {
		var index = historie[++historie_actual];
		showTerm(index, false);
		selectListItem(terminy[index].title);
		setActualHistory(historie_actual);
	}
}

// zobrazení/skrytí seznamu posledně zobrazených pojmů
function viewTerms(lang) {
if (lang == 1) {  
  // for english version
  if (document.getElementById("last_terms").style.display == 'block') {
    document.getElementById("last_terms").style.display = 'none';
    document.getElementById("view_terms_btn").innerHTML = 'View terms';  
  } else {
    document.getElementById("last_terms").style.display = 'block';
    document.getElementById("view_terms_btn").innerHTML = 'Hide terms';
  }
} else {
  if (document.getElementById("last_terms").style.display == 'block') {
    document.getElementById("last_terms").style.display = 'none';
    document.getElementById("view_terms_btn").innerHTML = 'Zobrazit pojmy';  
  } else {
    document.getElementById("last_terms").style.display = 'block';
    document.getElementById("view_terms_btn").innerHTML = 'Skrýt pojmy';
  }
}	
}

// funkce vraci nazev souboru obsahujici dany pojem
function getFileNameFromTitle(title) {
	var diacritics = ['á', 'à', 'ă', 'ä', 'â', 'ą', 'å', 'ā', 'æ', 'ã', 'ß', 'č', 'ć', 'ç', 'ď', 'đ', 'é', 'ě', 'è', 'ë', 'ę', 'ê', 'í', 'ì', 'ï', 'î', 'ī', 'ľ', 'ł', 'ň', 'ń', 'ñ', 'ó', 'ò', 'ŏ', 'ö', 'ő', 'ô', 'ō', 'õ', 'ø', 'ř', 'ŕ', 'š', 'ś', 'ş', 'ť', 'ţ', 'ú', 'ů', 'ù', 'ü', 'ű', 'ŭ', 'ǔ', 'ū', 'ý', 'ŷ', 'ž', ' ', ' ', '–', '.', ':', ',', '!', '/', '&', '*', '…', '(', ')', '[', ']', '„', '“', '”', '’', '‘', '‚', '?', '+'];
	var chars = ['a225', 'a224', 'a259', 'a228', 'a226', 'a261', 'a229', 'a257', 'a230', 'a227', 'b223', 'c269', 'c263', 'c231', 'd271', 'd273', 'e233', 'e283', 'e232', 'e235', 'e281', 'e234', 'i237', 'i236', 'i239', 'i238', 'i299', 'l318', 'l322', 'n328', 'n324', 'n241', 'o243', 'o242', 'o335', 'o246', 'o337', 'o244', 'o333', 'o245', 'o248', 'r345', 'r341', 's353', 's347', 's351', 't357', 't355', 'u250', 'u367', 'u249', 'u252', 'u369', 'u365', 'u468', 'u363', 'y253', 'y375', 'z382', '_', '_', '-8211', '-046', '-058', '-044', '-033', '-047', '-038', '-042', '-8230', '-040', '-041', '-091', '-093', '-8222', '-8220', '-8221', '-8217', '-8216', '-8218', 'ot', 'pl'];
	title = title.toLowerCase();
	for(var i = 0; i < diacritics.length; i++) {
		title = title.split(diacritics[i]).join(chars[i]);
		// vyreseno takto, protoze u replaceAll nefunguji tyto znaky: *,(,),[
	}
	if(title.indexOf("-038amp;") > 0) {
		return title.replace("-038amp;", "-038");
	}
	return title; //.replace(/\+/g, "_"); // replace + with IS _
}

// po nacteni obsahu iframu zobrazi obsah pojmu
function showDescription() {
	var description = document.getElementById("termLoader").contentWindow.document.body.innerHTML;
	description = removeTagPre(description);
	setHTML("termdescription", wikify(description));
	document.getElementById("termdescription").style.color = "#333";
}

//nahradi rezervovane znacky (pouzito az ve funkci wikify)
function replaceReserved(description) {
	description = description.replaceAll("/tt", "");
	description = description.replaceAll("/tt", "");
	description = description.replaceAll("//t", "// t");
	description = description.replaceAll("/t", "");
	description = description.replaceAll("/aa", "");
	description = description.replaceAll("//au", "//_au");
	description = description.replaceAll("/au", "/_au");
	description = description.replaceAll("/ap", "/_ap");
  description = description.replaceAll("</a", "--a");	                                                                  
	description = description.replaceAll("/a", "");	
  description = description.replaceAll("--a", "Literatura:");
	description = description.replaceAll("#", "
"); description = description.replaceAll("&", "&"); description = description.replaceAll("&_42;", "*"); //* description = description.replaceAll("&_36;", "$"); //$ description = description.replaceAll("<span", ""); description = description.replaceAll("<", "<"); description = description.replaceAll(">", ">"); description = description.replaceAll("</span>", "
"); return description; } // zobrazení index-tého pojmu toHistory - ukazatel, jestli se má uložit do historie (true/false) function showTerm(index, toHistory) { if(toHistory) putToHistory(index); showNode("info"); var pojem = terminy[index]; var capital = ""; setHTML("termdescription", "

Pojem se načítá…

"); document.getElementById("termdescription").style.color = "gray"; var fileName = getFileNameFromTitle(pojem.title); if(pojem.title.charAt(0).toLowerCase() != pojem.title.charAt(0)) { capital = "_velke"; } //document.getElementById("termLoader").src = "terms/" + fileName.charAt(0) + "/" + fileName + capital + ".txt"; document.getElementById("termLoader").contentWindow.location.replace("terms/" + fileName.charAt(0) + "/" + fileName + capital + ".txt"); setHTML("desc_title", pojem.title); pojem.subtitle = pojem.subtitle.replaceAll("&", "&"); pojem.subtitle = pojem.subtitle.replaceAll("<span", "'); pojem.subtitle = pojem.subtitle.replaceAll("</span>", ""); setHTML("desc_subtitle", pojem.subtitle); actualTerm = index; } // rozsekání řetězce na jednotlivé řádky function delinearize(retez) { var radky = retez.split(lineDelimiter) return radky.join("\n"); } // vybere položku seznamu s daným názvem function selectListItem(jmeno) { var seznam = document.getElementById("seznam"); if(seznam != null) { var itemId = -1; for(var i = 0; i < seznam.length; i++) { if(seznam.options[i].text == jmeno) { itemId = i; break; } } seznam.selectedIndex = itemId; } } // zobrazení pojmu s daným názvem function showTermNamed(jmeno) { var termExists = false; jmeno = jmeno.replaceAll(" ", " "); // nahrazení pevné mezery (#160) normální mezerou jmeno = jmeno.replaceAll("&", "&"); for(var j = 0; j < 2; j++) { if(j == 1 && !termExists) { var letter = jmeno.charAt(0); if(letter == letter.toLowerCase()) { letter = letter.toUpperCase(); } else { letter = letter.toLowerCase(); } jmeno = letter + jmeno.substr(1); } if(!termExists) { for(var i = 0; i < terminy.length; i++) { if(terminy[i].title == jmeno) { showTerm(i, true); selectListItem(jmeno); termExists = true; actualTerm = i; break; } } } } if(!termExists) { alert("Termín není v databázi."); if(actualTerm == -1) { showTerm(0, true); } } } // JavaScript StringBuffer umožňující spojování řetězců mnohem rychleji než // operátor "+", znatelné především v IE function StringBuffer() { this.buffer = []; } StringBuffer.prototype.append = function append(string) { this.buffer.push(string); return this; }; StringBuffer.prototype.toString = function toString() { return this.buffer.join(""); }; StringBuffer.prototype.length = function length() { return this.buffer.length; }; StringBuffer.prototype.clear = function clear() { this.buffer = []; }; //provereni a prevedeni rezervovaneho textu na HTML a vyprazdneni sub-bufferu function checkSubBuf(subBuf, buf) { if (subBuf.length() > 0) { console.log("1", subBuf.toString()); //TODO comment out console.log("2", replaceReserved(subBuf.toString())); //TODO comment out buf.append(replaceReserved(subBuf.toString())); subBuf.clear(); } } // převedení pojmu z wiki-sekvence na HTML pro zobrazení pojmu function wikify(retez) { var pozice = 0; var buf = new StringBuffer(); //pridano 20140811 var subBuf = new StringBuffer(); //alert(subBuf.length()); var radky = retez.split(lineDelimiter) for(var i = 0; i < radky.length; i++) { //alert("Radek " + i + ": " + radky[i]) if(radky[i] == "") continue; buf.append("

"); var zasobnik = new Array() //var odkazovy = new Regexp for(var j = 0; j < radky[i].length; j++) { if(radky[i].charAt(j) == "{" && ("i<>".indexOf(radky[i].charAt(j + 1)) > -1 )) {//pozor, obrazek //pridano 20140811 checkSubBuf(subBuf, buf); var zbytek = radky[i].substring(j + 1); var obrazek = zbytek.substring(0, zbytek.indexOf("}}")) var alignment = (obrazek.charAt(0) == "i") ? "" : obrazek.charAt(0); var casti = obrazek.split("{"); casti[1] = (casti[1].indexOf("}") > -1 ) ? casti[1].substring(0, casti[1].length - 1) : casti[1] buf.append("") { buf.append(" class='imgRight'") } if(casti.length == 3) { buf.append(" class=" + casti[2]); } buf.append(" \/>"); j += obrazek.length + 3; continue; } if(radky[i].charAt(j) == "{" && radky[i].charAt(j + 1) == "{") { //pridano 20140811 checkSubBuf(subBuf, buf); //alert("odkaz") var zbytek = radky[i].substring(j + 2); var odkaz = zbytek.substring(0, zbytek.indexOf("}}")) var casti = odkaz.split("|"); if(casti.length == 2) { buf.append("" + casti[0] + ""); } if(casti.length == 1) { buf.append("" + casti[0] + ""); } j += odkaz.length + 3; continue; } if(radky[i].charAt(j) == "/" && radky[i].charAt(j + 1) == "/") { //pridano 20140811 checkSubBuf(subBuf, buf); if(zasobnik.isLast("em")) { zasobnik.pop(); buf.append(""); } else { zasobnik.push("em"); buf.append(""); } j += 1; continue; } if(radky[i].charAt(j) == "*" && radky[i].charAt(j + 1) == "*") { //pridano 20140811 checkSubBuf(subBuf, buf); if(zasobnik.isLast("strong")) { zasobnik.pop(); buf.append(""); } else { zasobnik.push("strong"); buf.append(""); } j += 1; continue; } //pridano/upraveno 20140811 // zakomentovano 20160129 - spatne zobrazeni   // if (zasobnik.isLast("em") || zasobnik.isLast("strong")) { // buf.append(radky[i].charAt(j)); // } else { // subBuf.append(radky[i].charAt(j)); // } // pridano 20160129 kvuli   predchozi pridavalo rovnou k buf a neprovadelo nahrazeni & subBuf.append(radky[i].charAt(j)); } //pridano 20140811 checkSubBuf(subBuf, buf); buf.append("

"); } return buf.toString(); } function getValue(nodeId) { return document.getElementById(nodeId).value } function setHTML(nodeId, retez) { document.getElementById(nodeId).innerHTML = retez; } pictures = new Array() actualPicture = 0 // zobrazení seznamu vyhledaných pojmů function showList(filter) { setHTML("list_content", createList(filter)); } // zobrazení seznamu všech pojmů function showAll() { document.getElementById("word_begin").value = "podle začátku"; document.getElementById("word_begin").className = "inputClass"; document.getElementById("searched_title").value = "v názvech pojmů"; document.getElementById("searched_title").className = "inputClass"; //setHTML("seznamPojmu", "Seznam pojmů"); showList(""); } // vytvoření seznamu pojmů, které začínají řetězcem filter a obsahují řetězec filter2 function createList(filter) { var filter2 = getValue("searched_title"); filter = filter.toLowerCase(); filter2 = filter2.toLowerCase(); var buf = new StringBuffer(); buf.append(""); return buf.toString(); } function loopOverTermsWithErrors(buf, filter, filter2) { var counter = 0; for(var i = 0; i < terminy.length; i++) { if((filter == "" || terminy[i].title.toLowerCase().indexOf(filter) == 0 || filter == "podle začátku") && (filter2 == "" || terminy[i].title.toLowerCase().indexOf(filter2) > -1 || filter2 == "v názvech pojmů")) { buf.append("\n"); counter++; } } // pokud nenalezeno hledej preklep if (counter == 0) { //alert("counter == 0"); var counterErr = 0; //buf.append(""); var filterMatch = new StringBuffer(); var regFilter; var pattern; var outArray = new Array(); var outArrayIndex = new Array(); var outArray2 = new Array(); var outArrayIndex2 = new Array(); for (var i = 0; i < terminy.length; i++) { // prohledej vsechyn terminy //alert(terminy[i].title); // search "?" if (filter != "" && filter != "podle začátku") { // podle zacatku "?" for (var j = 0; j < filter.length; j++) { filterMatch.append("^"); filterMatch.append(filter.substring(0,j+1)); filterMatch.append("?"); filterMatch.append(filter.substring(j+1)); regFilter = filterMatch.toString(); //alert(regFilter); pattern = new RegExp(regFilter, "i"); if (pattern.test(terminy[i].title)) { //alert("match::" + regFilter+" :: "+terminy[i].title); if (outArray.indexOf(terminy[i]) == -1) { outArray.push(terminy[i]); outArrayIndex.push(i); //counterErr++; } } filterMatch.clear(); } for (var j = 0; j < filter.length + 1; j++) { // podle zacatku "." filterMatch.append("^"); filterMatch.append(filter.substring(0,j)); filterMatch.append("."); filterMatch.append(filter.substring(j)); regFilter = filterMatch.toString(); //alert(regFilter); pattern = new RegExp(regFilter, "i"); if (pattern.test(terminy[i].title)) { //alert("match::" + regFilter+" :: "+terminy[i].title); if (outArray.indexOf(terminy[i]) == -1) { outArray.push(terminy[i]); outArrayIndex.push(i); //counterErr++; } } filterMatch.clear(); } } // search "." if (filter2 != "" && filter2 != "v názvech pojmů") { // podle obsahu pojmu "?" for (var j = 0; j < filter2.length; j++) { //filterMatch.append("^"); filterMatch.append(filter2.substring(0,j+1)); filterMatch.append("?"); filterMatch.append(filter2.substring(j+1)); regFilter = filterMatch.toString(); //alert(regFilter); pattern = new RegExp(regFilter, "i"); if (pattern.test(terminy[i].title)) { //alert("match::" + regFilter+" :: "+terminy[i].title); if (outArray2.indexOf(terminy[i]) == -1) { outArray2.push(terminy[i]); outArrayIndex2.push(i); //counterErr++; } } filterMatch.clear(); } for (var j = 0; j < filter2.length + 1; j++) { // podle obsahu pojmu "." //filterMatch.append("^"); filterMatch.append(filter2.substring(0,j)); filterMatch.append("."); filterMatch.append(filter2.substring(j)); regFilter = filterMatch.toString(); //alert(regFilter); pattern = new RegExp(regFilter, "i"); if (pattern.test(terminy[i].title)) { //alert("match::" + regFilter+" :: "+terminy[i].title); if (outArray2.indexOf(terminy[i]) == -1) { outArray2.push(terminy[i]); outArrayIndex2.push(i); //counterErr++; } } filterMatch.clear(); } } } var outArray3 = new Array(); // vysledne hledani var outArrayIndex3 = new Array(); if (filter == "" || filter == "podle začátku") { // pokud hledame jen podle filter2 outArray3 = outArray2; outArrayIndex3 = outArrayIndex2; counterErr = outArray3.length; } if (filter2 == "" || filter2 == "v názvech pojmů") { // pokud hledame jen podle filter outArray3 = outArray; outArrayIndex3 = outArrayIndex; counterErr = outArray3.length; } if (filter != "" && filter != "podle začátku" && filter2 != "" && filter2 != "v názvech pojmů") { // pokud hledame podle obou filtru for (var i = 0; i < outArray.length; i++) { if (outArray2.indexOf(outArray[i]) != -1) { outArray3.push(outArray[i]); outArrayIndex3.push(outArrayIndex[i]); counterErr++; } } } //alert(counterErr); if (counterErr == 0) { setHTML("seznamInfo", "Nenalezen žádný pojem"); show("seznamInfo"); } else { setHTML("seznamInfo", "Měli jste na mysli?"); show("seznamInfo"); for (var i = 0; i < outArray3.length; i++) { buf.append("\n"); } } } else { //setHTML("seznamPojmu", "Seznam pojmů"); hide("seznamInfo"); } } // hledání v názvech pojmů function searchTitles() { setHTML("list_content", createList(getValue("word_begin"))); } // uzávorkování řetězce function quote(retez) { return "\"" + retez + "\""; } // zobrazení uzlu s id="nodeId" function showNode(nodeId) { document.getElementById(nodeId).style.visibility = "visible" } // zjištění, zda retez je poslední prvek pole Array.prototype.isLast = function(retez) { if(this.length == 0) return false; else { if(this[this.length - 1] == retez) return true; else return false; } } // nahrazenmí všech výskytů podřetězce stare řetězcem nove String.prototype.replaceAll = function(stare, nove) { var nahrada = new RegExp(stare, "g") return this.replace(nahrada, nove) } // pri kliknuti na input se odstrani zasedly defaultni text nebo se oznaci function onFocus(id) { var obj = document.getElementById(id); if ((obj.value == "podle začátku") || (obj.value == "v názvech pojmů") ) { /*obj.value = " ";*/ obj.value = ""; } else { obj.select(); //obj.setSelectionRange(0, obj.value.length); } } // pri ztrate fokusu se text v pripade, ze neni vyplneny vyplni defautlnim textem text function onBlur(id, text) { var obj = document.getElementById(id); if (obj.value == "") { obj.value = text; obj.className = "inputClass"; //document.getElementById(id + "_button").style.display = "none"; } else { obj.className = "inputFill"; } } function enterPress(e) { e = e || window.event; if (e.keyCode == 13) { searchTitles(); } } function show(nodeId) { document.getElementById(nodeId).style.display = "block"; } function hide(nodeId) { document.getElementById(nodeId).style.display = "none"; }