|
|
function gdMakeArticleActive(newId, noEvent) { |
|
|
|
|
|
const gdCurrentArticleId = |
|
|
document.querySelector(".gdactivearticle")?.attributes.id?.value; |
|
|
|
|
|
|
|
|
if (gdCurrentArticleId !== "gdfrom-" + newId) { |
|
|
|
|
|
document |
|
|
.querySelector(".gdactivearticle") |
|
|
?.classList.remove("gdactivearticle"); |
|
|
|
|
|
|
|
|
const newFormId = "gdfrom-" + newId; |
|
|
const newArticle = document.querySelector(`#${newFormId}`); |
|
|
|
|
|
|
|
|
newArticle?.classList.add("gdactivearticle"); |
|
|
|
|
|
|
|
|
if ( |
|
|
!noEvent && |
|
|
typeof articleview.onJsActiveArticleChanged !== "undefined" |
|
|
) { |
|
|
articleview.onJsActiveArticleChanged(newFormId); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
var overIframeId = null; |
|
|
|
|
|
function gdSelectArticle(id) { |
|
|
var selection = window.getSelection(); |
|
|
var range = document.createRange(); |
|
|
range.selectNodeContents(document.getElementById("gdfrom-" + id)); |
|
|
selection.removeAllRanges(); |
|
|
selection.addRange(range); |
|
|
} |
|
|
|
|
|
function processIframeMouseOut() { |
|
|
overIframeId = null; |
|
|
top.focus(); |
|
|
} |
|
|
|
|
|
function processIframeMouseOver(newId) { |
|
|
overIframeId = newId; |
|
|
} |
|
|
|
|
|
function processIframeClick() { |
|
|
if (overIframeId != null) { |
|
|
overIframeId = overIframeId.replace("gdexpandframe-", ""); |
|
|
gdMakeArticleActive(overIframeId); |
|
|
} |
|
|
} |
|
|
|
|
|
function init() { |
|
|
window.addEventListener("blur", processIframeClick, false); |
|
|
} |
|
|
window.addEventListener("load", init, false); |
|
|
|
|
|
function gdExpandOptPart(expanderId, optionalId) { |
|
|
const d1 = document.getElementById(expanderId); |
|
|
const isExpanded = d1.alt === "[+]"; |
|
|
|
|
|
d1.alt = isExpanded ? "[-]" : "[+]"; |
|
|
d1.src = isExpanded |
|
|
? "qrc:///icons/collapse_opt.svg" |
|
|
: "qrc:///icons/expand_opt.svg"; |
|
|
|
|
|
document |
|
|
.getElementById(optionalId) |
|
|
?.querySelectorAll(".dsl_opt") |
|
|
.forEach((d2) => { |
|
|
d2.style.display = isExpanded ? "inline" : "none"; |
|
|
}); |
|
|
} |
|
|
|
|
|
function emitClickedEvent(link) { |
|
|
try { |
|
|
if ("string" != typeof link) { |
|
|
return; |
|
|
} |
|
|
articleview.linkClickedInHtml(link); |
|
|
} catch (error) { |
|
|
console.error(error); |
|
|
} |
|
|
} |
|
|
|
|
|
function gdExpandArticle(id) { |
|
|
emitClickedEvent(); |
|
|
|
|
|
const articleContent = document.getElementById("gdarticlefrom-" + id); |
|
|
const expandIcon = document.getElementById("expandicon-" + id); |
|
|
const articleElement = document.getElementById("gdfrom-" + id); |
|
|
const dictNameElement = document.getElementById("gddictname-" + id); |
|
|
|
|
|
if (!articleContent || !expandIcon || !articleElement || !dictNameElement) { |
|
|
console.warn("One or more required elements not found for id:", id); |
|
|
return; |
|
|
} |
|
|
|
|
|
const isExpanded = articleContent.style.display === "block"; |
|
|
|
|
|
if (isExpanded) { |
|
|
articleContent.style.display = "none"; |
|
|
expandIcon.className = "gdexpandicon"; |
|
|
articleElement.classList.add("gdcollapsedarticle"); |
|
|
|
|
|
dictNameElement.style.cursor = "pointer"; |
|
|
dictNameElement.title = ""; |
|
|
|
|
|
articleview.collapseInHtml(id, true); |
|
|
} else { |
|
|
articleContent.style.display = "block"; |
|
|
expandIcon.className = "gdcollapseicon"; |
|
|
articleElement.classList.remove("gdcollapsedarticle"); |
|
|
|
|
|
dictNameElement.style.cursor = "default"; |
|
|
dictNameElement.title = ""; |
|
|
|
|
|
articleview.collapseInHtml(id, false); |
|
|
} |
|
|
} |
|
|
|
|
|
function gdCheckArticlesNumber() { |
|
|
const dictNameElements = document.getElementsByClassName("gddictname"); |
|
|
|
|
|
if (dictNameElements.length === 1) { |
|
|
const dictNameElement = dictNameElements[0]; |
|
|
const articleId = dictNameElement.id.replace("gddictname-", ""); |
|
|
const articleElement = document.getElementById("gdfrom-" + articleId); |
|
|
|
|
|
if ( |
|
|
articleElement && |
|
|
articleElement.className.includes("gdcollapsedarticle") |
|
|
) { |
|
|
gdExpandArticle(articleId); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
function gdAttachEventHandlers() { |
|
|
|
|
|
const gdArticles = document.querySelectorAll(".gdarticle"); |
|
|
|
|
|
|
|
|
gdArticles.forEach(function (article) { |
|
|
article.addEventListener("click", gdHandleArticleEvent); |
|
|
article.addEventListener("contextmenu", gdHandleArticleEvent); |
|
|
}); |
|
|
|
|
|
document.body.addEventListener("click", function (event) { |
|
|
|
|
|
const dictNameElement = event.target.closest(".gddictname"); |
|
|
|
|
|
if (dictNameElement) { |
|
|
|
|
|
const articleId = dictNameElement |
|
|
.closest(".gdarticle") |
|
|
?.getAttribute("data-gd-id"); |
|
|
|
|
|
gdExpandArticle(articleId); |
|
|
|
|
|
event.stopPropagation(); |
|
|
} |
|
|
}); |
|
|
|
|
|
function gdHandleArticleEvent(event) { |
|
|
|
|
|
const articleId = event.target |
|
|
.closest(".gdarticle") |
|
|
?.getAttribute("data-gd-id"); |
|
|
gdMakeArticleActive(articleId, false); |
|
|
} |
|
|
|
|
|
handleIframeEvents(); |
|
|
} |
|
|
|
|
|
function handleIframeEvents() { |
|
|
const iframes = document.querySelectorAll("iframe[data-gd-id]"); |
|
|
|
|
|
iframes.forEach((iframe) => { |
|
|
const gdId = iframe.getAttribute("data-gd-id"); |
|
|
|
|
|
iframe.addEventListener("mouseover", function () { |
|
|
processIframeMouseOver("gdexpandframe-" + gdId); |
|
|
}); |
|
|
|
|
|
iframe.addEventListener("mouseout", function () { |
|
|
processIframeMouseOut(); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
if ( |
|
|
document.readyState === "complete" || |
|
|
document.readyState === "interactive" |
|
|
) { |
|
|
gdAttachEventHandlers(); |
|
|
} else { |
|
|
document.addEventListener("DOMContentLoaded", gdAttachEventHandlers); |
|
|
} |
|
|
|