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){
addAllContextualNotes();
}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();
}
};
//need to clear these so they don't show up in initial display of default Reading View
clearSemanticTooltips();
clearIntermediateTooltips();
//clearPageBreaks();
clearAllNotes();
// 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");
document.getElementById('pbToggle').checked = false;
}
function addPageBreaks(){
$("pb").css("display","block");
$(".-teibp-pb").css("display","block");
}
// (trans notes added separately)
function addAllContextualNotes(){
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;
document.getElementById('allNoteToggle').checked = true;
//20220610
//showReadingViewNotesList();
$("span[type=\'wrapperForContextualTooltip\']").css("display", "block");
$("span[type=\'wrapperForContextualGeneticTooltip\']").css("display", "block");
// alert("add all notes");
}
//turns notes and tooltips on or off depending on view selected; should be renamed "setViewDefaults" or similar
function setNotes(view){
//alert(view);
switch(view) {
case "../css/edition.css":
//alert("edition");
//addAllContextualNotes();
clearAllNotes();
clearSemanticTooltips();
clearIntermediateTooltips();
clearTransNotes();
break;
case "../css/edition_markup.css":
//alert("edition_markup");
clearAllNotes();
clearSemanticTooltips();
addIntermediateTooltips();
break;
case "../css/edition_semantic.css":
//alert("edition_semantic");
clearAllNotes();
clearIntermediateTooltips();
addSemanticTooltips();
break;
case "../css/transcription.css":
//alert("transcription");
//clearAllNotes();
clearAllContextualNotes();
clearSemanticTooltips();
clearIntermediateTooltips();
addTransNotes();
break;
}
}
function clearSemanticTooltips() {
var semanticArray = $("span[type=\'inlineWrapperForSemanticTooltip\']");
let count = $("span[type=\'inlineWrapperForSemanticTooltip\']").length;
for (let i = 0; i < count; i++) {
semanticArray[i].className = "none";
}
$("seg[type=\'semanticTooltipText\']").css("display", "none");
}
function addSemanticTooltips() {
var semanticArray = $("span[type=\'inlineWrapperForSemanticTooltip\']");
let count = $("span[type=\'inlineWrapperForSemanticTooltip\']").length;
for (let i = 0; i < count; i++) {
semanticArray[i].className = "tooltip";
}
$("seg[type=\'semanticTooltipText\']").css("display", "inline");
}
function clearIntermediateTooltips() {
var intermediateArray = $("span[type=\'inlineWrapperForIntermediateTooltip\']");
let count = $("span[type=\'inlineWrapperForIntermediateTooltip\']").length;
for (let i = 0; i < count; i++) {
intermediateArray[i].className = "none";
}
$("seg[type=\'intermediateTooltipText\']").css("display", "none");
}
function addIntermediateTooltips() {
var intermediateArray = $("span[type=\'inlineWrapperForIntermediateTooltip\']");
let count = $("span[type=\'inlineWrapperForIntermediateTooltip\']").length;
for (let i = 0; i < count; i++) {
intermediateArray[i].className = "tooltip";
}
$("seg[type=\'intermediateTooltipText\']").css("display", "inline");
}
function clearAllNotes(){
//clear all except authorial (should always be on)
clearAllContextualNotes();
//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 clearAllContextualNotes() {
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;
//20220610
//clearReadingViewNotesList();
document.getElementById('allNoteToggle').checked = false;
//take out the enclosing spans also, or they still cause line breaks in Inter, Sem, and Trans View
//$("span[type=\'wrapperForContextualTooltip\']").css("display", "none");
$("span[type=\'wrapperForContextualGeographicalTooltip\']").css("display", "none");
$("span[type=\'wrapperForContextualHistoricalTooltip\']").css("display", "none");
$("span[type=\'wrapperForContextualBiographicalTooltip\']").css("display", "none");
$("span[type=\'wrapperForContextualLexicalTooltip\']").css("display", "none");
$("span[type=\'wrapperForContextualGeneticTooltip\']").css("display", "none");
$("span[type=\'wrapperForContextualGeneralTooltip\']").css("display", "none");
}
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");
$("span[type=\'wrapperForContextualGeographicalTooltip\']").css("display", "block");
}
function clearGeoNotes(){
// $("note[subtype=\'geographical\']").css("display","none");
// $(".-teibp-note[subtype=\'geographical\']").css("display","none");
$("span[type=\'wrapperForContextualGeographicalTooltip\']").css("display", "none");
//20220610
document.getElementById('allNoteToggle').checked = false;
}
function addHistNotes(){
// $("note[subtype=\'historical\']").css("display","block");
// $(".-teibp-note[subtype=\'historical\']").css("display","block");
$("span[type=\'wrapperForContextualHistoricalTooltip\']").css("display", "block");
}
function clearHistNotes(){
// $("note[subtype=\'historical\']").css("display","none");
// $(".-teibp-note[subtype=\'historical\']").css("display","none");
$("span[type=\'wrapperForContextualHistoricalTooltip\']").css("display", "none");
//20220610
document.getElementById('allNoteToggle').checked = false;
}
function addBioNotes(){
// $("note[subtype=\'biographical\']").css("display","block");
// $(".-teibp-note[subtype=\'biographical\']").css("display","block");
$("span[type=\'wrapperForContextualBiographicalTooltip\']").css("display", "block");
}
function clearBioNotes(){
// $("note[subtype=\'biographical\']").css("display","none");
// $(".-teibp-note[subtype=\'biographical\']").css("display","none");
$("span[type=\'wrapperForContextualBiographicalTooltip\']").css("display", "none");
//20220610
document.getElementById('allNoteToggle').checked = false;
}
function addLexNotes(){
// $("note[subtype=\'lexical\']").css("display","block");
// $(".-teibp-note[subtype=\'lexical\']").css("display","block");
$("span[type=\'wrapperForContextualLexicalTooltip\']").css("display", "block");
}
function clearLexNotes(){
// $("note[subtype=\'lexical\']").css("display","none");
// $(".-teibp-note[subtype=\'lexical\']").css("display","none");
$("span[type=\'wrapperForContextualLexicalTooltip\']").css("display", "none");
//20220610
document.getElementById('allNoteToggle').checked = false;
}
function addGeneticNotes(){
$("span[type=\'wrapperForContextualGeneticTooltip\']").css("display", "block");
/* this is not working. comment out previous line before testing */
/* $("span[type=\'wrapperForContextualGeneticTooltip\']").fadeIn(); */
}
function clearGeneticNotes(){
$("span[type=\'wrapperForContextualGeneticTooltip\']").css("display", "none");
/* this sort of works -- doesn't fade, but there is a delay before it abruptly disappears. comment out previous line before testing */
/* $("span[type=\'wrapperForContextualGeneticTooltip\']").fadeOut(); */
//20220610
document.getElementById('allNoteToggle').checked = false;
}
function addGeneralNotes(){
// $("note[subtype=\'general\']").css("display","block");
// $(".-teibp-note[subtype=\'general\']").css("display","block");
$("span[type=\'wrapperForContextualGeneralTooltip\']").css("display", "block");
}
function clearGeneralNotes(){
// $("note[subtype=\'general\']").css("display","none");
// $(".-teibp-note[subtype=\'general\']").css("display","none");
$("span[type=\'wrapperForContextualGeneralTooltip\']").css("display", "none");
//20220610
document.getElementById('allNoteToggle').checked = false;
}
function addTransNotes(){
// $("note[type=\'transcription\']").css("display","block");
// $(".-teibp-note[type=\'transcription\']").css("display","block");
$("span[type=\'wrapperForTranscriptionTooltip\']").css("display", "block");
document.getElementById('transNoteToggle').checked = true;
}
function clearTransNotes(){
// $("note[type=\'transcription\']").css("display","none");
// $(".-teibp-note[type=\'transcription\']").css("display","none");
$("span[type=\'wrapperForTranscriptionTooltip\']").css("display", "none");
}
/* right now I think these aren't called -- they're on all the time? */
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");
}
/* these two are now obsolete -- I'm using Spans above to do this for individual types */
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("