2016-03-12 14:24:18 +01:00
|
|
|
/* Builtin script also includes html_dir.script */
|
2016-03-15 17:02:07 +01:00
|
|
|
{{#display_chapter}}
|
2016-03-15 18:13:56 +01:00
|
|
|
function showChapter(chap, noreset){
|
2016-03-15 14:07:37 +01:00
|
|
|
if (!displayAll) {
|
2016-03-15 13:18:14 +01:00
|
|
|
var chapters = document.getElementsByClassName("chapter");
|
|
|
|
for (i = 0; i < chapters.length; i++) {
|
2016-03-15 18:13:56 +01:00
|
|
|
if (i == chap) {
|
2016-03-15 14:07:37 +01:00
|
|
|
chapters[i].style.display = "block";
|
2016-03-15 18:13:56 +01:00
|
|
|
} else {
|
2016-03-15 14:07:37 +01:00
|
|
|
chapters[i].style.display = "none";
|
|
|
|
}
|
2016-03-12 14:40:06 +01:00
|
|
|
}
|
2016-03-15 13:18:14 +01:00
|
|
|
var controls = document.getElementsByClassName("chapterControls");
|
|
|
|
for (i = 0; i < controls.length; i++){
|
2016-03-15 18:13:56 +01:00
|
|
|
if (i >= chap * 2-1 && i <= chap * 2) {
|
2016-03-15 14:07:37 +01:00
|
|
|
controls[i].style.display = "block";
|
2016-03-15 18:13:56 +01:00
|
|
|
} else {
|
2016-03-15 14:07:37 +01:00
|
|
|
controls[i].style.display = "none";
|
|
|
|
}
|
2016-03-12 14:40:06 +01:00
|
|
|
}
|
2016-03-15 13:18:14 +01:00
|
|
|
if (!noreset) {
|
2016-03-15 14:07:37 +01:00
|
|
|
window.location.hash = "#chapter-"+chap;
|
2016-03-15 13:18:14 +01:00
|
|
|
}
|
2016-03-15 18:13:56 +01:00
|
|
|
} else {
|
2016-03-12 14:40:06 +01:00
|
|
|
window.location.hash = "#chapter-"+chap;
|
2016-03-15 13:18:14 +01:00
|
|
|
}
|
2016-03-15 14:07:37 +01:00
|
|
|
}
|
|
|
|
|
2016-03-15 18:13:56 +01:00
|
|
|
function getChapter(elem) {
|
|
|
|
if (elem.className == "chapter") {
|
|
|
|
return parseInt(elem.id.substr("chapter-".length));
|
|
|
|
} else {
|
|
|
|
return getChapter(elem.parentElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function switchAll() {
|
2016-03-15 14:07:37 +01:00
|
|
|
if (!displayAll){
|
2016-03-15 13:18:14 +01:00
|
|
|
displayAll = true;
|
|
|
|
var chapters = document.getElementsByClassName("chapter");
|
|
|
|
for (i = 0; i < chapters.length; i++) {
|
2016-03-15 14:07:37 +01:00
|
|
|
chapters[i].style.display = "block";
|
2016-03-15 13:18:14 +01:00
|
|
|
}
|
|
|
|
var controls = document.getElementsByClassName("chapterControls");
|
|
|
|
for (i = 0; i < controls.length; i++){
|
2016-03-15 14:07:37 +01:00
|
|
|
controls[i].style.display = "none";
|
2016-03-15 13:18:14 +01:00
|
|
|
}
|
2016-03-15 14:07:37 +01:00
|
|
|
displayAllSwitcher = document.getElementById("book-button");
|
|
|
|
displayAllSwitcher.src="{{{pages_svg}}}";
|
2016-04-02 13:58:36 +02:00
|
|
|
displayAllSwitcher.alt="{{{loc_display_one}}}";
|
|
|
|
displayAllSwitcher.title="{{{loc_display_one}}}";
|
2016-03-15 14:07:37 +01:00
|
|
|
}else{
|
2016-03-15 13:18:14 +01:00
|
|
|
displayAll = false;
|
|
|
|
showChapter(0);
|
2016-03-15 14:07:37 +01:00
|
|
|
displayAllSwitcher = document.getElementById("book-button");
|
|
|
|
displayAllSwitcher.src="{{{book_svg}}}";
|
2016-04-02 13:58:36 +02:00
|
|
|
displayAllSwitcher.alt="{{{loc_display_all}}}";
|
|
|
|
displayAllSwitcher.title="{{{loc_display_all}}}";
|
2016-03-12 14:40:06 +01:00
|
|
|
}
|
2016-03-15 14:07:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
window.onload = function(){
|
|
|
|
displayAll = false;
|
2016-03-15 18:13:56 +01:00
|
|
|
var hash = document.location.hash;
|
|
|
|
if (!hash) {
|
|
|
|
showChapter(0, true);
|
|
|
|
} else {
|
|
|
|
var element = document.getElementById(hash.substr(1));
|
|
|
|
var chap = getChapter(element);
|
|
|
|
showChapter(chap, true);
|
|
|
|
}
|
2016-03-15 14:07:37 +01:00
|
|
|
};
|
2016-03-15 18:13:56 +01:00
|
|
|
{{/display_chapter}}
|