var editors = [ ["Ondřej Zendulka", 167123, "zendulka@med.muni.cz" ], ["Jan Juřica", 14537, "jurica@med.muni.cz"], ["Leoš Landa", 70449, "landa@med.muni.cz"], ["Alena Máchalová", 59956, "amachal@med.muni.cz"], ["Gabriela Dovrtělová", 416809, "dovrtel@med.muni.cz"], ["Hana Kostková", 235124, "hkostkova@med.muni.cz"], ["Jana Merhautová", 222905, "jmerhaut@med.muni.cz"], ["Kristýna Nosková", 342767, "noskova@med.muni.cz"] ] var i18n = { cs: { casuistry: "Případová studie", part_title: "Část", next_part: "Pokračovat na další část kazuistiky", answer: "Odpověď", answer_show: "Zobrazit odpověď", answer_hide: "Skrýt odpověď", cath: "Kategorie", orig_papers: "Zobrazit původní práce", orig_papers_title: "Původní práce", questions: "Otázky k zamyšlení", keyword_search_title: "Kazuistiky s klíčovým slovem", fulltext_search_title: "Kazuistiky obsahující frázi", send_mail: "Poslat zprávu autorům", mail_subject: "Moje postřehy ke kazuistice" }, en: { casuistry: "Case report", part_title: "Part", next_part: "Continue to the next part", answer: "Answer", answer_show: "Show the answer", answer_hide: "Hide the answer", cath: "Cathegory", orig_papers: "Show original papers", orig_papers_title: "Original papers", questions: "Questions", keyword_search_title: "Case reports containing keyword", fulltext_search_title: "Case reports containing phrase", send_mail: "Send mail to the authors", mail_subject: "My comments to case report" } } if (this["actLang"] == undefined) { var meta = document.querySelector("html[lang]"); if (!meta) { this["actLang"] = "cs" } else { this["actLang"] = meta.getAttribute("lang"); } } var baseurl = this.location.href; function initApp() { if (items.length > 0) { initCathegories() } var searchField = document.getElementById("search"); searchField.addEventListener("keyup", searchPhrase); searchField.value = ""; document.getElementById("search_fulltext").checked = true; collectKeywords(); var chapter = -1; var actItem = -1; var actPhrase = "", actKeyword = ""; if (baseurl.indexOf("?") > -1) { var end = baseurl.substring(baseurl.indexOf("?")+1); var attrs = end.match(/[^\&]+=[^\&]+/g); if (attrs) { for (var i = 0; i < attrs.length; i++) { var attr = attrs[i]; var name = attr.substring(0,attr.indexOf("=")); var val = attr.substring(attr.indexOf("=")+1); if (name == "cathegory") { chapter = parseInt(val); } if (name == "item") { actItem = parseInt(val); } if (name == "phrase") { actPhrase = val; } if (name == "keyword") { actKeyword = val; } } } baseurl = baseurl.substring(0, baseurl.indexOf("?")) } if (chapter != -1) { showCathegory(chapter); if (prep > 0) { showCathItem(actItem); } } } var sections = ["toc", "display"]; var actual = { cat: -1, item: -1, phrase: "", keyword: null }; var sourcesLoaded = 0; function addLoadedSource() { sourcesLoaded += 1; if (sourcesLoaded == 3) { collectKeywords(); } } function initCathegories() { for (var i = 0; i < items.length; i++) { var item = items[i] item.index = i; if (!chapters[item.cathegory].items) { chapters[item.cathegory].items = [] } chapters[item.cathegory].items.push(item); } collectKeywords(); } /**************** UI ****************/ function showSection(sid) { var section = document.querySelector("." + sid + ", #" + sid); if (!section) return; if (section) { section.classList.remove("hidden"); } } function hideSection(sid) { var section = document.querySelector("." + sid + ", #" + sid); if (!section) return; if (!section.classList.contains("hidden")) { section.classList.add("hidden"); } } function showCathegory(index) { if (index === actual.cat) { return; } hideSection("keywordLists"); var tabs = document.querySelectorAll(".mainmatter a"); if (actual.cat > -1 && tabs[actual.cat]) { tabs[actual.cat].classList.remove("actual"); } actual.cat = index; actual.item = -1; var actCat = chapters[index]; if (tabs[actual.cat]) { tabs[actual.cat].classList.add("actual"); } document.querySelector(".toc h2").innerHTML = actCat.title; var resList = []; for (var i = 0; i< actCat.items.length; i++) { resList.push(items[actCat.items[i]]); } history.pushState({}, "", baseurl + "?cathegory=" + index); showResultList(i18n[actLang].cath + ": " + actCat.title, resList) //actCat.items } function clearCathegories() { if (actual.cat != -1) { var link = document.querySelectorAll(".mainmatter a")[actual.cat]; link.classList.remove("actual"); actual.cat = -1; } } function showResultList(title, list) { showSection("toc"); hideSection("display"); actual.selected = null; document.querySelector(".toc h2").innerHTML = title; var clist = document.querySelector(".cases"); clist.innerHTML = ""; for (var i = 0; i < list.length; i++) { var li = clist.appendChild(document.createElement("li")); var item = list[i]; var fig = li.appendChild(document.createElement("figure")); fig.className = "case"; fig.setAttribute("data-index", item.index); fig.addEventListener("click", showResultItem); var img = fig.appendChild(document.createElement("img")) img.setAttribute("alt", i18n[actLang].casuistry ); img.src= "design/document.svg"; var fc = fig.appendChild(document.createElement("figcaption")); fc.innerHTML = item.title; //"CS " + (i+1); } } function initQuestions() { var qs = document.querySelectorAll(".question"); var togglers = document.querySelectorAll(".answer-toggler"); for (var i = 0; i < togglers.length; i++) { togglers[i].addEventListener("click", toggleAnswer); } } function toggleAnswer(evt) { var btn = evt.currentTarget; var answer = btn.parentNode.parentNode.querySelector(".answer"); if (!answer) return; if (answer.style.display && answer.style.display == "block") { btn.title = i18n[actLang].answer_show; answer.style.display = "none"; } else { btn.title = i18n[actLang].answer_hide; answer.style.display = "block"; } } var actCase = 0; var actPart = 0; var questionsOnEnd = true; var questionCount = 0; var romans = [ "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"]; function showItem(evt) { if (typeof evt == "number") { actual.item = evt; } else { var cs = evt.currentTarget; if (actual.item > -1) { //alert(actual.item) document.querySelectorAll(".cases figure")[actual.item].classList.remove("actual"); } actual.item = parseInt(cs.getAttribute("data-index")); cs.classList.add("actual"); } showSection("display"); actPart = 0; questionsOnEnd = true; questionCount = 0; var index1 = chapters[actual.cat].items[actual.item].index; case1 = items[index1]; var base = document.querySelector(".display"); base.innerHTML = ""; var ctitle = base.appendChild(document.createElement("h2")); ctitle.innerHTML = case1.title; var p = base.appendChild(document.createElement("div")); p.className = "toolbar"; if (case1.parts.length > 1) { var input = p.appendChild(document.createElement("input")); input.type = "button"; input.className = "continuer"; input.value = i18n[actLang].next_part; input.addEventListener("click", showNextPart); } showPart(0, "d"); } function showResultItem(evt) { var target = evt.currentTarget; var cs = evt.currentTarget; if (actual.selected) { actual.selected.classList.remove("actual"); } actual.selected = target; actual.selected.classList.add("actual"); cs.classList.add("actual"); //var index = parseInt(cs.getAttribute("data-index"),10); var ititle = cs.querySelector("figcaption").innerHTML; showItemByTitle(ititle); } function showItemByTitle(ititle) { actual.item = null; for (var i = 0; i < items.length; i++) { if (items[i].title == ititle) { actual.item = items[i]; break; } } if (!actual.item) { console.log("Polozka s id " + ititle + " nenalezena"); return; } showSection("display"); actPart = 0; questionsOnEnd = true; questionCount = 0; case1 = actual.item; var base = document.querySelector(".display"); base.innerHTML = ""; var ctitle = base.appendChild(document.createElement("h2")); ctitle.innerHTML = case1.title; var p = base.appendChild(document.createElement("div")); p.className = "toolbar"; if (case1.parts.length > 1) { var input = p.appendChild(document.createElement("input")); input.type = "button"; input.className = "continuer"; input.value = i18n[actLang].next_part; input.addEventListener("click", showNextPart); } showPart(0, "d"); } function showPart(index, decide) { var base = document.querySelector(".display"); actPart = index; var item = actual.item; part1 = item.parts[actPart]; var part = base.insertBefore(document.createElement("div"), base.lastChild); part.className = "part"; part.setAttribute("data-index", index); ctitle = part.appendChild(document.createElement("h3")); ctitle.innerHTML = i18n[actLang].part_title + " " + romans[index]; var story = part.appendChild(document.createElement("div")); story.className = "story"; var text = part1.text; if (text.charAt(0) != "<") { text = "

" + polishText(text) + "

"; } story.innerHTML = addNbsp(text); showActQuestions(); if (actPart == item.parts.length -1) { //posledni cast kazuisitky if (item.biblio && item.biblio.length > 0) { var continuer = document.querySelector(".continuer"); continuer.value = i18n[actLang].orig_papers; //continuer } } } function showActQuestions(evt) { var part1 = actual.item.parts[actPart]; var part = document.querySelectorAll(".part")[actPart]; if (!part) return; if (!part1.qs || part1.qs.length == 0) { return; } var qs = part.appendChild(document.createElement("div")); qs.className = "questions"; var qtitle = qs.appendChild(document.createElement("h4")); qtitle.innerHTML = i18n[actLang].questions; for (var i = 0; i < part1.qs.length; i++) { questionCount++; var q1 = part1.qs[i]; qs.appendChild(getQuestionCode(q1, questionCount )); } questionsOnEnd = false; } function getQuestionCode(question, qindex) { var q = document.createElement("div"); q.className = "question"; var task = q.appendChild(document.createElement("div")); task.className = "task"; task.innerHTML = (qindex) + ". " + addNbsp(question.task); if (question.answer) { var toggler = task.appendChild(document.createElement("input")); toggler.type = "image"; toggler.className = "answer-toggler"; toggler.src = "design/key_solid.png"; toggler.setAttribute("alt", i18n[actLang].answer); toggler.setAttribute("title", i18n[actLang].answer_show); toggler.addEventListener("click", toggleAnswer); var answer = q.appendChild(document.createElement("div")); answer.className = "answer"; answer.innerHTML = addNbsp(question.answer); } return q; } function showNextPart(evt) { var item = actual.item; if (actPart == item.parts.length -1) { showBiblios(); return; } if (actPart +1 < item.parts.length) { showPart(actPart +1, "n"); } else { var continuer = document.querySelector(".continuer"); if (item.biblio && item.biblio.length > 0) { continuer.value = i18n[actLang].orig_papers; } else { document.querySelector(".toolbar").style.display = "none"; } } } var postbox = null; var postContainer = null; var postTrigger = null; function showBiblios() { document.querySelector(".toolbar").style.display = "none"; var base = document.querySelector(".display"); var biblio = base.appendChild(document.createElement("div")); biblio.className = "biblio"; var btitle = biblio.appendChild(document.createElement("h3")); btitle.innerHTML = i18n[actLang].orig_papers_title; var blist = biblio.appendChild(document.createElement("ol")); for (var i = 0; i < case1.biblio.length; i++) { var bli = blist.appendChild(document.createElement("li")); bitem = case1.biblio[i]; var btext = "

" + bitem.author + ". " + bitem.title + ". " + bitem.journal + ". " + bitem.volume + ".

" + bitem.url + "

"; btext = btext.replace(/\.\./g, "."); bli.innerHTML = case1.biblio[i]; } var mail = base.appendChild(document.createElement("section")); mail.className = "mail"; var mp = mail.appendChild(document.createElement("p")); var plink = mp.appendChild(document.createElement("a")); var item = actual.item; var komu = ""; for (var i =0; i < item.editors.length; i++) { var aindex = item.editors.charAt(i); if (i > 0) { komu += "," } komu += editors[aindex][2]; } var subj = i18n[actLang].mail_subject + " " + item.title; plink.href = "mailto:" + komu + "?subject=" + encodeURIComponent(subj); plink.innerHTML = i18n[actLang].send_mail; mp.appendChild(document.createTextNode(": " + komu)) /* postTrigger = mail.appendChild(document.createElement("input")); postTrigger.type = "button"; postTrigger.value = i18n[actLang].send_mail; postTrigger.addEventListener("click", openPostClient); postContainer = mail.appendChild(document.createElement("div")); postContainer.className = ""; postContainer.id = "postbox-container"; postbox = postContainer.appendChild(document.createElement("object")); postbox.setAttribute("width", "550"); postbox.setAttribute("height", "380"); postbox.setAttribute("type", "text/html"); postbox.setAttribute("class", "mailer"); postbox.addEventListener("load", postAfterload); */ } // function postAfterload(evt) { var obj = evt.currentTarget; var url = obj.getAttribute("data"); console.log("Nacteno " + url); var doc = postbox.contentDocument; var search = doc.location.search; if (search.indexOf("?new_mail") == 0) { console.log("Otevreno okno s postou"); hideNodes(doc, ["#hlavicka", "#mailtblmenu", "#menu", "#paticka", "#FAQico", "#DSearch", "hr", "b", ".simplemail", "#addRiadok", "#cc", "#bcc", "#postpone_button" ]); var rows = doc.querySelectorAll(".newMail tr"); for (var i =0; i < rows.length; i++) { var row = rows[i], inner = row.innerHTML, hide = false; if (inner.indexOf("to-list") > -1) { hide = true }; if (inner.indexOf("cc-list") > -1) { hide = true }; if (inner.indexOf("bcc-list") > -1) { hide = true }; if (inner.indexOf("reply-to-list") > -1) { hide = true }; if (inner.indexOf("adresar-list") > -1) { hide = true }; if (inner.indexOf("not-found") > -1) { hide = true }; if (inner.indexOf("lookup-adr") > -1) { hide = true }; if (inner.indexOf("attach-info") > -1) { hide = true }; if (inner.indexOf("sent_folder") > -1) { hide = true }; if (inner.indexOf("save_address") > -1) { hide = true }; if (hide) { row.style.display = "none"; } } if (rows && rows.length > 16) { // rows[0].style.display = "none"; /* rows[10].style.display = "none"; rows[11].style.display = "none"; rows[12].style.display = "none"; rows[14].style.display = "none"; rows[16].style.display = "none"; rows[17].style.display = "none"; */ } doc.getElementById("obalka").style.borderTop = "0px none"; doc.getElementById("o2").style.minWidth = "0"; var apl = doc.getElementById("aplikace"); apl.style.marginLeft = 0; for (var i = 0; i < apl.childNodes.length; i++) { var child = apl.childNodes[i]; if (child.nodeType == 3) { child.nodeValue = ""; } if (child.nodeType == 1) { if (child.nodeName == "FORM") {break} else { child.style.display = "none"; } } } var item = actual.item; var komu = doc.getElementById("toIn"); komu.value = ""; for (var i =0; i < item.editors.length; i++) { var aindex = item.editors.charAt(i); if (i > 0) { komu.value += " , " } komu.value += editors[aindex][2]; } komu.setAttribute("cols", 40); komu.style.width = "400px"; komu.setAttribute("rows", 1); var subj = i18n[actLang].mail_subject + " " + item.title; plink.href = "mailto:" + komu + "?" + subj; plink.innerHTML = "" } else { closePostClient(); } /* if (search.indexOf("?ajax") == 0) { //zruseni odeslani mailu closePostClient(); return; } if (search.indexOf("?folder") == 0) { // uspesne odeslani mailu closePostClient(); return; } */ } function openPostClient() { postbox.setAttribute("data", "https://is.muni.cz/auth/mail/?new_mail=1") postContainer.style.display = "block"; postTrigger.style.display = "none" ; } function closePostClient() { postContainer.style.display = "none"; postTrigger.style.display = "inline-block" ; } function hideNodes(doc, rules) { for (var i = 0; i < rules.length; i++) { var node = doc.querySelector(rules[i]); if (node) { node.style.display = "none"; } } } function listAllQuestions() { var case1 = actual.item; var parts = document.querySelectorAll(".part"); var lastPart = parts[parts.length-1]; var qs = lastPart.appendChild(document.createElement("div")); qs.className = "questions"; var qtitle = qs.appendChild(document.createElement("h4")); qtitle.innerHTML = i18n[actLang].questions; for (var i = 0; i < case1.parts.length; i++) { for (var j = 0; j < case1.parts[i].qs.length; j++) { questionCount++; var q1 = case1.parts[i].qs[j]; qs.appendChild(getQuestionCode(q1, questionCount )); } } } function polishText(text) { return addNbsp(text); } function addNbsp(text) { var out = text.replace(/\s([ksvziouKSVZA])\s/, " $1 "); out = out.replace(/([\s;,\.])([ksvziou])\s/gi, "$1$2 "); out = out.replace(/\[\[([^\]]+)\]\]/g, "obrazek"); return out } /**** klicova slova **********/ function Keyword(word, index) { this.word = word; this.refs = [ index ]; } function keywordSorter(k1, k2) { return k1.word.localeCompare(k2.word); } function compressKeywords(list) { if (list.length == 0) return []; var newList = []; newList.push(list[0]); var lastItem = newList[0]; for (var i = 1; i < list.length; i++) { var item = list[i]; if (!item) continue; if (item.word == lastItem.word) { // && item.orig == lastItem.orig lastItem.refs.push(item.refs[0]); } else { newList.push(item); var last = newList.length-1; item.index = last; lastItem = newList[last]; } } return newList; } var keywords = [] function collectKeywords() { var kws = []; for (var i = 0; i < items.length; i++) { var item = items[i]; for (var k = 0; k < item.keywords.length; k++) { var kw = item.keywords[k]; kws.push(new Keyword(kw, i)); } } kws.sort(keywordSorter); kws = compressKeywords(kws); keywords = kws; //listFoundKeywords(keywords) console.log("klicovych slov: " + keywords.length) } function searchKeywords(phrase) { var list = []; for (var i = 0, len = keywords.length; i < len; i++) { if (keywords[i].word.search(new RegExp(phrase, "i")) > -1) { keywords[i].index = i; list.push(keywords[i]); } } listFoundKeywords(list); } function listFoundKeywords(list) { showSection("keywordLists"); hideSection("toc"); var out = document.createDocumentFragment(); var ol = out.appendChild(document.createElement("ol")) ol.classname = "kwlist" for (var i = 0; i ]+>/g, ""); if (cont.search(phrase) > -1) { isFound = true; //break; } for (var k = 0; k < part.qs.length; k++) { var question = part.qs[k]; if (!question || !question.task || !question.answer) { continue; } var cont = question.task.toLowerCase().replace(/<[^>]+>/g, "") + question.answer.toLowerCase().replace(/<[^>]+>/g, ""); if (cont.search(phrase) > -1) { isFound = true; //break; } } } if (isFound) { list.push(item); } } showResultList( i18n[actLang].fulltext_search_title + ": " + phrase, list); } function searchPhrase(evt) { var phrase = document.getElementById("search").value.trim().toLowerCase(); if (phrase.length < 3) return; hideSection("display"); hideSection("keywordLists"); clearCathegories(); if (document.getElementById("search_keywords").checked) { searchKeywords(phrase); } else { searchFulltext(phrase); } } window.addEventListener("load", initApp)