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 rem_prepo(input).replace(/[\(\)]/g, "").replace(/[’]/ig, "-").replace(/[ď]/ig, "d").replace(/[ěé]/ig, "e").replace(/[óöô]/ig, "o").replace(/[ůúü]/ig, "u").replace(/[í]/ig, "i").replace(/[äá]/ig, "a").replace(/[Ł]/ig, "l")
// .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")
}
//20170323
// odstran predlozky
function rem_prepo(input) {
return input.replace(/delľ/i,"").replace(/d’/i,"").replace(/^z /i,"")
}
// 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("