var counter = 0;
function init(){
//I don't know why but init runs twice, so this prevents the second run
if (counter > 0) {
return;
} else {
counter++;
}
//alert("init " + counter);
// addToolTipsToNotes();
document.getElementById('pbToggle').onclick = function(){
if(document.getElementById('pbToggle').checked){
addPageBreaks();
}else{
clearPageBreaks();
}
};
//alert("init step 1");
document.getElementById('allNoteToggle').onclick = function(){
if(document.getElementById('allNoteToggle').checked){
addAllNotes();
}else{
clearAllNotes();
}
};
// alert("init step 2");
document.getElementById('geoNoteToggle').onclick = function(){
if(document.getElementById('geoNoteToggle').checked){
addGeoNotes();
}else{
clearGeoNotes();
}
};
// alert("init step 3");
document.getElementById('histNoteToggle').onclick = function(){
if(document.getElementById('histNoteToggle').checked){
addHistNotes();
}else{
clearHistNotes();
}
};
// alert("init step 4");
document.getElementById('bioNoteToggle').onclick = function(){
if(document.getElementById('bioNoteToggle').checked){
addBioNotes();
}else{
clearBioNotes();
}
};
// alert("init step 5");
document.getElementById('lexNoteToggle').onclick = function(){
if(document.getElementById('lexNoteToggle').checked){
addLexNotes();
}else{
clearLexNotes();
}
};
// alert("init step 6");
document.getElementById('geneticNoteToggle').onclick = function(){
if(document.getElementById('geneticNoteToggle').checked){
addGeneticNotes();
}else{
clearGeneticNotes();
}
};
// alert("init step 7");
document.getElementById('generalNoteToggle').onclick = function(){
if(document.getElementById('generalNoteToggle').checked){
addGeneralNotes();
}else{
clearGeneralNotes();
}
};
// alert("init step 8");
document.getElementById('transNoteToggle').onclick = function(){
if(document.getElementById('transNoteToggle').checked){
addTransNotes();
}else{
clearTransNotes();
}
};
// alert("init step 9");
//delete this:
//CM adding 2020-11-04. I am cloning from above.
/*
document.getElementById('noteToggle').onclick = function(){
if(document.getElementById('noteToggle').checked){
addNotes();
}else{
clearNotes();
}
};
*/
//var bodyContents = document.getElementsByTagName("body").innerHTML;
//console.log(spanList);
//alert(bodyContents);
//alert("body contents" + document.getElementsByTagName("text").innerHTML);
//alert("end of init");
}
/* see https://www.w3schools.com/jquery/html_append.asp, https://api.jquery.com/append/ */
/* I did it with xslt instead
function addToolTipsToNotes(){
//this works
// $("note[subtype=\'genetic\']").prepend("Prepended text");
// $("note[subtype=\'genetic\']").append("Appended text");
//these two lines work, but not when I move closing span tag to end of second, and all text displays instead of being hidden, like CSS isn't acting on it''
// $("note[subtype=\'genetic\']").prepend("Hover for note type ");
// $("note[subtype=\'genetic\']").append("Tooltip text");
//this is what it should look like, but seems to be causing an error that makes rest of js not run
// $("note[subtype=\'genetic\']").prepend("");
// $("note[subtype=\'genetic\']").append("Genetic note");
//this doesn't work'
// $("note[subtype=\'genetic\']").css("class","tooltip");
// $("note[subtype=\'genetic\']").append("Tooltip text");
}
*/
function clearPageBreaks(){
$("pb").css("display","none");
$(".-teibp-pb").css("display","none");
}
function addPageBreaks(){
$("pb").css("display","block");
$(".-teibp-pb").css("display","block");
}
function addAllNotes(){
//all all except authorial (on by default)
addGeoNotes();
addHistNotes();
addBioNotes();
addLexNotes();
addGeneticNotes();
addGeneralNotes();
document.getElementById('geoNoteToggle').checked = true;
document.getElementById('histNoteToggle').checked = true;
document.getElementById('bioNoteToggle').checked = true;
document.getElementById('lexNoteToggle').checked = true;
document.getElementById('geneticNoteToggle').checked = true;
document.getElementById('generalNoteToggle').checked = true;
showReadingViewNotesList();
// alert("add all notes");
}
//turns notes on or off depending on view selected
function setNotes(){
switch(view) {
case "edition":
addAllNotes();
break;
case "edition_markup":
clearAllNotes();
break;
case "edition_semantic":
clearAllNotes();
break;
case "transcription":
addAllNotes();
break;
}
}
function clearAllNotes(){
//clear all except authorial (should always be on)
clearGeoNotes();
clearHistNotes();
clearBioNotes();
clearLexNotes();
clearGeneticNotes();
clearGeneralNotes();
document.getElementById('geoNoteToggle').checked = false;
document.getElementById('histNoteToggle').checked = false;
document.getElementById('bioNoteToggle').checked = false;
document.getElementById('lexNoteToggle').checked = false;
document.getElementById('geneticNoteToggle').checked = false;
document.getElementById('generalNoteToggle').checked = false;
clearReadingViewNotesList();
document.getElementById('allNoteToggle').checked = false;
//clear the transcription notes, too, or they still show up when you switch back to reading view
clearTransNotes();
//and clear this toggle, since switching the text view now clears all notes
document.getElementById('transNoteToggle').checked = false;
// alert("clear all notes");
}
function showReadingViewNotesList(){
$("div[n=\'readingVersionNoteList\']").css({"display": "inline-block", "background": "white", "border": "1px solid #aaaaaa", "padding": ".3em"});
$(".-teibp-div[n=\'readingVersionNoteList\']").css({"display": "inline-block", "background": "white", "border": "1px solid #aaaaaa", "padding": ".3em"});
}
function clearReadingViewNotesList(){
$("div[n=\'readingVersionNoteList\']").css("display","none");
$(".-teibp-div[n=\'readingVersionNoteList\']").css("display","none");
}
function addGeoNotes(){
$("note[subtype=\'geographical\']").css("display","block");
$(".-teibp-note[subtype=\'geographical\']").css("display","block");
// $("tei-note[subtype=\'geographical\']").css("display","block");
// $(".-teibp-tei-note[subtype=\'geographical\']").css("display","block");
// alert("add geo notes");
}
function clearGeoNotes(){
$("note[subtype=\'geographical\']").css("display","none");
$(".-teibp-note[subtype=\'geographical\']").css("display","none");
// $("tei-note[subtype=\'geographical\']").css("display","none");
// $(".-teibp-tei-note[subtype=\'geographical\']").css("display","none");
// alert("clear geo notes");
}
function addHistNotes(){
$("note[subtype=\'historical\']").css("display","block");
$(".-teibp-note[subtype=\'historical\']").css("display","block");
}
function clearHistNotes(){
$("note[subtype=\'historical\']").css("display","none");
$(".-teibp-note[subtype=\'historical\']").css("display","none");
}
function addBioNotes(){
$("note[subtype=\'biographical\']").css("display","block");
$(".-teibp-note[subtype=\'biographical\']").css("display","block");
}
function clearBioNotes(){
$("note[subtype=\'biographical\']").css("display","none");
$(".-teibp-note[subtype=\'biographical\']").css("display","none");
}
function addLexNotes(){
$("note[subtype=\'lexical\']").css("display","block");
$(".-teibp-note[subtype=\'lexical\']").css("display","block");
}
function clearLexNotes(){
$("note[subtype=\'lexical\']").css("display","none");
$(".-teibp-note[subtype=\'lexical\']").css("display","none");
}
function addGeneticNotes(){
$("note[subtype=\'genetic\']").css("display","block");
$(".-teibp-note[subtype=\'genetic\']").css("display","block");
// $("span[type=\'genetic\']").css("display","block");
// $(".-teibp-span[type=\'genetic\']").css("display","block");
// alert("genetic added");
}
function clearGeneticNotes(){
$("note[subtype=\'genetic\']").css("display","none");
$(".-teibp-note[subtype=\'genetic\']").css("display","none");
// $("span[type=\'genetic\']").css("display","none");
// $(".-teibp-span[type=\'genetic\']").css("display","none");
// alert("genetic cleared");
}
function addGeneralNotes(){
$("note[subtype=\'general\']").css("display","block");
$(".-teibp-note[subtype=\'general\']").css("display","block");
}
function clearGeneralNotes(){
$("note[subtype=\'general\']").css("display","none");
$(".-teibp-note[subtype=\'general\']").css("display","none");
}
function addTransNotes(){
$("note[type=\'transcription\']").css("display","block");
$(".-teibp-note[type=\'transcription\']").css("display","block");
}
function clearTransNotes(){
$("note[type=\'transcription\']").css("display","none");
$(".-teibp-note[type=\'transcription\']").css("display","none");
}
function addAuthorNotes(){
$("note[type=\'authorial\']").css("display","block");
$(".-teibp-note[type=\'authorial\']").css("display","block");
}
function clearAuthorNotes(){
$("note[type=\'authorial\']").css("display","none");
$(".-teibp-note[type=\'authorial\']").css("display","none");
}
function addContextualNotes(){
$("note[type=\'contextual\']").css("display","block");
$(".-teibp-note[type=\'contextual\']").css("display","block");
}
function clearContextualNotes(){
$("note[type=\'contextual\']").css("display","none");
$(".-teibp-note[type=\'contextual\']").css("display","none");
}
//make toolbox draggable, based on https://www.w3schools.com/howto/howto_js_draggable.asp
/*
dragElement(document.getElementById("teibpToolbox"));
function dragElement(elmnt) {
var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
if (document.getElementById(elmnt.id + "header")) {
// if present, the header is where you move the DIV from:
document.getElementById(elmnt.id + "header").onmousedown = dragMouseDown;
} else {
// otherwise, move the DIV from anywhere inside the DIV:
elmnt.onmousedown = dragMouseDown;
}
function dragMouseDown(e) {
e = e || window.event;
e.preventDefault();
// get the mouse cursor position at startup:
pos3 = e.clientX;
pos4 = e.clientY;
document.onmouseup = closeDragElement;
// call a function whenever the cursor moves:
document.onmousemove = elementDrag;
}
function elementDrag(e) {
e = e || window.event;
e.preventDefault();
// calculate the new cursor position:
pos1 = pos3 - e.clientX;
pos2 = pos4 - e.clientY;
pos3 = e.clientX;
pos4 = e.clientY;
// set the element's new position:
elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
}
function closeDragElement() {
// stop moving when mouse button is released:
document.onmouseup = null;
document.onmousemove = null;
}
}
*/
//make toolbox draggable end
//If W3C event model used, prefer that. Window events are fallbacks
if(document.addEventListener){
//W3C event model used
document.addEventListener("DOMContentLoaded", init, false);
window.addEventListener("load", init, false);
} else if(document.attachEvent){
//IE event model used
document.attachEvent( "onreadystatechange", init);
window.attachEvent( "onload", init);
}
function switchThemes(theme) {
document.getElementById('maincss').href=theme.options[theme.selectedIndex].value;
}
function showFacs(num, url, id) {
facsWindow = window.open ("about:blank")
facsWindow.document.write("")
facsWindow.document.write("
")
facsWindow.document.write("TEI Boilerplate Facsimile Viewer")
facsWindow.document.write($('#maincss')[0].outerHTML)
facsWindow.document.write($('#customcss')[0].outerHTML)
facsWindow.document.write("")
if ($('#teibp-tagusage-css').length) {
facsWindow.document.write($('#teibp-tagusage-css')[0].outerHTML)
}
if ($('#teibp-rendition-css').length) {
facsWindow.document.write($('#teibp-rendition-css')[0].outerHTML)
}
facsWindow.document.write("")
facsWindow.document.write("")
facsWindow.document.write("")
facsWindow.document.write("")
facsWindow.document.write("")
facsWindow.document.write("")
facsWindow.document.write("")
facsWindow.document.write("")
facsWindow.document.write($("teiHeader")[0].outerHTML)
//facsWindow.document.write("" + $("teiHeader")[0].html() + "")
//facsWindow.document.write($('').append($('teiHeader').clone()).html();)
//facsWindow.document.write($("teiHeader")[0].outerHTML)
facsWindow.document.write("")
facsWindow.document.write("
")
$(".-teibp-thumbnail").each(function() {
facsWindow.document.write("
")
})
facsWindow.document.write("
")
facsWindow.document.write("
")
facsWindow.document.write($("footer")[0].outerHTML)
facsWindow.document.write("")
facsWindow.document.write("")
facsWindow.document.close()
}