function seizureErrorDialog(maxRow) {
ggbApplet.evalCommand("errorText=\"error log here.\"");
var logTextName = "errorText";
const target = document.getElementsByTagName("main")[0];
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
console.log(mutation);
if (mutation.addedNodes[0]) {
if (mutation.addedNodes[0].className == "dialogComponent errorDialog") {
console.log(mutation.addedNodes[0]);
var errText = mutation.addedNodes[0].getElementsByClassName("mainPanel")[0].textContent;
var outputText = "[GeoGebra - エラー]" + errText;
console.log(outputText);
var currentLog = ggbApplet.getValueString(logTextName);
if (maxRow && currentLog.split("\n").length >= maxRow) {
var tempArr = currentLog.split("\n");
tempArr.shift();
currentLog = tempArr.join("\n");
}
ggbApplet.setTextValue(logTextName, currentLog + "\n" + outputText);
mutation.addedNodes[0].getElementsByClassName("dialogContainedButton")[0].click();
}
}
});
});
const config = {
childList: true,
subtree: true
};
observer.observe(target, config);
}