"use strict";
//function helper_captions_begin() {
// var box = null;
// var titleTxt = null;
// //addCaptionEventListeners();
// box = document.getElementById("helper_caption_box"); //if box already exists, remove it.
// if (box !== null) {
// box.parentNode.removeChild(box);
// }
// box = make_caption_box(); //make captions box
// document.body.insertBefore(box, document.body.firstChild);
// //hide_caption_box();
// document.body.addEventListener("mouseout", function (event) {
// box = document.getElementById("helper_caption_box");
// if (box !== null) {
// if ((event.clientY) > -6 && (Math.abs(event.clientY - 6) + Math.abs(box.offsetHeight)) < parseFloat(top.innerHeight).toFixed(0)) {
// box.style.top = parseFloat(event.clientY - 6).toFixed(0).toString() + "px";
// }
// if ((event.clientX) > -16 && (Math.abs(event.clientX - 16) + Math.abs(box.offsetWidth)) < parseFloat(top.innerWidth).toFixed(0)) {
// box.style.left = parseFloat(event.clientX - 16).toFixed(0).toString() + "px";
// }
// }
// titleTxt = event.target.getAttribute("data-title");
// if (titleTxt !== null) {
// document.getElementById("helper_caption_box").style.opacity = 1.0;
// box.innerText = titleTxt; //event.target.getAttribute("data-title");
// //global_caption_box_timer = setInterval(fadeCaptionBox(box.id), 1);
// //box.style.opacity = 0.3;
// }
// else if (titleTxt === null) {
// //box.innerText = null;
// document.getElementById("helper_caption_box").style.opacity = 0.0;
// }
// //event.stopImmediatePropagation();
// //event.stopPropagation();
// //event.preventDefault();
// });
//}
/*
function fadeCaptionBox(elem_id) {
var elem = null;
elem = document.getElementById(elem_id);
if (elem !== null) {
//alert(elem.style.opacity);
if (parseFloat(elem.style.opacity) > 0 && parseFloat(elem.style.opacity) <= 1.0) {
elem.style.opacity = parseFloat(elem.style.opacity) - 0.01;
}
else {
elem.style.opacity = 0;
clearInterval(global_caption_box_timer);
global_caption_box_timer = null;
}
}
}
*/
//################# for helper captions functions ######################
/*
*
* IMPORTANT: Some helper caption functions also exist in file create_window_[X].js
*
*/
//################# end note for helper captions functions #############
function add_caption(elem, title, desc) {
if (elem !== null) {
elem.setAttribute("data-title", title.toString());
elem.setAttribute("data-desc", desc.toString());
set_caption(elem);
}
return elem;
}
function make_caption_box() {
var box = null;
if (document.getElementById("helper_caption_box") !== null) {
box = document.getElementById("helper_caption_box");
//box.parentNode.removeChild(box);
} else {
box = document.createElement("div");
box.setAttribute("id", "helper_caption_box");
box.style.borderStyle = "solid";
box.style.borderWidth = "0.5px";
//box.style.borderColor = "#339";
box.style.borderColor = "#222";
box.style.borderRadius = "3px";
box.style.boxShadow = "2px 2px 7px #222";
box.style.backgroundColor = "#e9e9e9";
box.style.color = "rgb(51,51,51)";
box.style.position = "absolute";
box.style.padding = "4px";
box.style.paddingLeft = "5px";
box.style.paddingRight = "5px";
box.style.margin = "25px";
box.style.zIndex = 100000001110;
//alert(box.style.zIndex);
box.style.height = "auto";
box.style.width = "auto";
box.style.minWidth = "150px";
box.style.opacity = 0;
box.style.fontFamily = "Microsoft Sans Serif, Arial, Sans-Serif, Verdana";
box.style.fontSize = "10pt";
box.style.fontWeight = 500;
box.style.whiteSpace = "nowrap";
box.style.lineHeight = "130%";
box.style.borderStyle = "solid";
box.style.borderColor = "rgb(51,51,51)";
//box.style.borderWidth = "1px";
//box.style.wordBreak = "keep-all";
box.style.letterSpacing = "0.03em";
box.style.userSelect = "none";
//2024-04-22:
//by default, set the display property to "none" so
//that the helper captions box does not display
//an empty box.
box.style.display = "none";
//alert(box.style.display);
//box.setAttribute("data-title", "Helper Caption Box");
//box.innerHTML = "";
//box.innerText = event.target.getAttribute("data-title");
//2023-11-20:
//Changed the captions box to be stored inside its own DOM container
//object.
//If the DOM helper captions container does not exist, create it,
//and place container into the DOM as a child node of the body.
//This fixes a bug which causes the helper captions to never display.
//(display: none; opacity: 0;)
//Previously, the helper captions box was stored inside the
//"chromosphere_objects_container" *object which is a DOM object that
//is not visible. It is permanently set to displayed as 'none', and its opacity is 0.
//This prevents any child nodes (i.e. the helper captions box) from being visible.
//
//*or stored inside the body object if the "chromosphere_objects_container" does not exist
append_to_helper_captions_container(box);
//set the CSS X, Y, animation for helper captions box
//see file at transformations/transformations.js
most_customizable_config_elem_for_animation(box.id, "top, left", "0.4", "0.01");
//most_customizable_config_elem_for_animation(elem_id, css_property, duration, delay)
//return box;
}
}
function set_caption(elem) {
elem.addEventListener("mousemove", function (event) {
//2024-04-20:
//if the title and description values are string objects, and
//have a length greater than 0, then continue. otherwise,
//the captions box would display as empty.
if (typeof elem.getAttribute("data-title") === "string" && elem.getAttribute("data-title").length > 0) {
//continue
}
else {
return; //exit function
}
if (typeof elem.getAttribute("data-desc") === "string" && elem.getAttribute("data-desc").length > 0) {
//continue
}
else {
return; //exit function
}
move_caption_box(this, event);
}, false);
elem.addEventListener("mousedown", function () {
var box = document.getElementById("helper_caption_box");
if (box !== null) {
cancel_delay_fade_in_timer(); //cancel the timer that delays time and shows caption box. We do not need to display the caption box at this point
box.style.opacity = 0.0;
box.style.display = "none";
box.parentNode.removeChild(box);
}
event.stopPropagation();
event.preventDefault();
return;
}, false);
elem.addEventListener("mouseout", function () {
var box = document.getElementById("helper_caption_box");
if (box !== null) {
cancel_delay_fade_in_timer(); //cancel the timer that delays time and shows caption box. We do not need to display the caption box at this point
box.style.opacity = 0.0;
box.style.display = "none";
box.parentNode.removeChild(box);
}
event.stopPropagation();
event.preventDefault();
return;
}, false);
return elem;
}
function move_caption_box(elem, event) {
var pixel_ratio = null;
var box = document.getElementById("helper_caption_box");
var box_top = null;
var box_left = null;
var inverse_px_ratio = null;
var px_ratio_diff = null;
var title = null;
var desc = null;
//alert(event.target.id);
pixel_ratio = parseFloat(get_pixel_ratio());
inverse_px_ratio = get_inverse_pixel_ratio(pixel_ratio);
//px_ratio_diff = subtract_pixel_ratio_from_1(inverse_px_ratio);
//alert(px_ratio_diff);
//2023-06-23: check to see if either description or title are null.
//if either is null, don't show helper captions
title = elem.getAttribute("data-title");
desc = elem.getAttribute("data-desc");
//2024-04-17:
//if the title and description values are string objects, and
//have a length greater than 0, then continue. otherwise,
//the captions box would display as empty.
if (typeof title === "string" && title.length > 0) {
//continue
}
else {
return; //exit function
}
if (typeof desc === "string" && desc.length > 0) {
//continue
}
else {
return; //exit function
}
if (title !== null && desc !== null) {
if (box !== null) {
box.style.display = "block";
cancel_delay_fade_in_timer(); //cancels any pending timers that may be active in fading in the helper captions box
delay_fade_in_captions_box(); //delays time and fades-in the helper captions box
//alert(inverse_px_ratio);
if (inverse_px_ratio === 0.8) {
//alert(inverse_px_ratio);
box_top = (event.clientY / inverse_px_ratio);
box_left = (event.clientX / inverse_px_ratio);
}
else {
box_top = (event.clientY * inverse_px_ratio);
box_left = (event.clientX * inverse_px_ratio);
}
box.style.top = (box_top - 9) + "px";
box.style.left = (box_left - 18) + "px";
//box.style.top = (parseFloat(event.clientY * pixel_ratio) + 10) + "px";
//box.style.left = (parseFloat(event.clientX * pixel_ratio) + 21) + "px";
box.innerHTML = "