var historie = new Array() // pole s spoupností 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ů // konstruktor objektu pojmu function Pojem() { this.title = ""; // název this.subtitle = "" // podtitul this.description = ""; // obsah pojmu this.refs = new Array(); // příbuzné pojmy } //inicializace aplikace function init() { actualTerm= 0; for (var i = 0; i < term.length; i++) {// načtení pojmů var termin = new Pojem() termin.title = term[i][0]; termin.subtitle = term[i][1] termin.description = term[i][2] termin.refs = term[i][3]; terminy.push(termin); } // terminy.sort(sortByTitle); showTerm(0) showList(""); } // 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"; } } // přechod na předcházející pojem v historii function goPrev() { if (historie_actual > 0) { showTerm(historie[--historie_actual],false) setActualHistory(historie_actual) } } // přechod na následující pojem v historii function goNext() { if (historie_actual < historie.length-1 ) { showTerm(historie[++historie_actual], false) setActualHistory(historie_actual) } } // 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] setHTML("desc_title", pojem.title); setHTML("desc_subtitle", pojem.subtitle); setHTML("termdescription", wikify(pojem.description)); setHTML("refs", createRelated(index)); actualTerm = index } // rozsekání řetězce na jednotlivé řádky function delinearize(retez) { var radky = retez.split(lineDelimiter) return radky.join("\n"); } // zobvrazení pojmu s daným názvem function showTermNamed(jmeno) { jmeno = jmeno.toLowerCase() var termExists = false; for (var i = 0; i< terminy.length; i++) { if (terminy[i].title.toLowerCase() == jmeno) { showTerm(i); termExists = true; actualTerm = i break; } } if (!termExists) { alert("Termín není v databázi."); } } // převedení pojmu z wiki-sekvence na HTML pro zobrazení pojmu function wikify(retez) { var pozice = 0; var vystup = ""; var radky = retez.split(lineDelimiter) for (var i =0; i< radky.length; i++) { //alert("Radek " + i + ": " + radky[i]) if (radky[i] == "") continue; vystup += "
"
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
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]
vystup +="") { vystup += " class='imgRight'" }
if (casti.length == 3) {
vystup += " alt=\"" + casti[2] + "\" title=\"" + casti[2] + "\""
}
vystup += " \/>"
j += obrazek.length +3;
continue;
}
if (radky[i].charAt(j) == "[" && radky[i].charAt(j+1) == "[" ) {
//alert("odkaz")
var zbytek = radky[i].substring(j+2);
var odkaz = zbytek.substring(0, zbytek.indexOf("]]"))
var casti = odkaz.split("|");
if (casti.length == 2) {
vystup += "" + casti[0] + ""
}
if (casti.length == 1) {
vystup += "" + casti[0] + ""
}
j += odkaz.length +3;
continue;
}
if (radky[i].charAt(j) == "/" && radky[i].charAt(j+1) == "/" ) {
if (zasobnik.isLast("em")) {
zasobnik.pop();
vystup += ""
}
else {
zasobnik.push("em");
vystup += "";
}
j += 1;
continue;
}
if (radky[i].charAt(j) == "*" && radky[i].charAt(j+1) == "*" ) {
if (zasobnik.isLast("strong")) {
zasobnik.pop();
vystup += ""
}
else {
zasobnik.push("strong");
vystup += "";
}
j += 1;
continue;
}
vystup += radky[i].charAt(j)
}
vystup += "