<!--TCD145--><script>
document.addEventListener("DOMContentLoaded", function () {
const TCDformmassive = {comment: 100};
const TCDshowClear = false;
function TCDlimitInput(input, maxLength, TCDcountform) {
input.maxLength = maxLength;
const updateCounter = function () {
if (input.value.length > maxLength) {
input.value = input.value.slice(0, maxLength);
}
TCDcountform.textContent =
input.value.length + " / " + maxLength;
};
input.addEventListener("input", updateCounter);
updateCounter();
}
function TCDCount(input) {
const wrapper = document.createElement("div");
wrapper.className = "tcd-char-counter-wrapper";
wrapper.style.position = "relative";
wrapper.style.display = "block";
wrapper.style.width = "100%";
input.parentNode.insertBefore(wrapper, input);
wrapper.appendChild(input);
input.style.boxSizing = "border-box";
const TCDformcnt = document.createElement("div");
TCDformcnt.className = "tcd-char-counter-controls";
TCDformcnt.style.position = "absolute";
TCDformcnt.style.right = "8px";
TCDformcnt.style.bottom = "6px";
TCDformcnt.style.display = "flex";
TCDformcnt.style.alignItems = "center";
TCDformcnt.style.gap = "5px";
TCDformcnt.style.fontFamily = "sans-serif";
TCDformcnt.style.zIndex = "2";
const TCDcountform = document.createElement("div");
TCDcountform.className = "tcd-char-counter";
TCDcountform.style.fontSize = "12px";
TCDcountform.style.color = "#999";
TCDcountform.style.pointerEvents = "none";
TCDformcnt.appendChild(TCDcountform);
if (TCDshowClear) {
const TCDclearBtn = document.createElement("div");
TCDclearBtn.className = "tcd-char-counter-clear";
TCDclearBtn.textContent = "✕";
TCDclearBtn.title = "Очистить";
TCDclearBtn.setAttribute("role", "button");
TCDclearBtn.setAttribute("tabindex", "0");
TCDclearBtn.style.fontSize = "12px";
TCDclearBtn.style.color = "#999";
TCDclearBtn.style.cursor = "pointer";
TCDclearBtn.style.userSelect = "none";
TCDclearBtn.style.pointerEvents = "auto";
const clearInput = function () {
input.value = "";
input.dispatchEvent(
new Event("input", {
bubbles: true
})
);
input.dispatchEvent(
new Event("change", {
bubbles: true
})
);
input.focus();
};
TCDclearBtn.addEventListener("click", clearInput);
TCDclearBtn.addEventListener("keydown", function (event) {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
clearInput();
}
});
TCDformcnt.appendChild(TCDclearBtn);
}
wrapper.appendChild(TCDformcnt);
return TCDcountform;
}
function TCDinitializeField(input, maxLength) {
if (input.dataset.tcd145Observed === "true") {
return;
}
const limit = Number(maxLength);
if (!Number.isFinite(limit) || limit < 1) {
return;
}
input.dataset.tcd145Observed = "true";
const TCDcountform = TCDCount(input);
TCDlimitInput(
input,
limit,
TCDcountform
);
}
function Ticodestartcheckform() {
const fields = document.querySelectorAll(
"input[name], textarea[name]"
);
fields.forEach(function (input) {
const name = input.name;
if (
!Object.prototype.hasOwnProperty.call(
TCDformmassive,
name
)
) {
return;
}
TCDinitializeField(
input,
TCDformmassive[name]
);
});
}
let TCDscanScheduled = false;
function TCDscheduleScan() {
if (TCDscanScheduled) {
return;
}
TCDscanScheduled = true;
const schedule =
window.requestAnimationFrame ||
function (callback) {
return setTimeout(callback, 16);
};
schedule(function () {
TCDscanScheduled = false;
Ticodestartcheckform();
});
}
Ticodestartcheckform();
const Tildachekobs = new MutationObserver(function (mutationsList) {
const hasNewElements = mutationsList.some(function (mutation) {
return (
mutation.type === "childList" &&
mutation.addedNodes.length > 0
);
});
if (hasNewElements) {
TCDscheduleScan();
}
});
Tildachekobs.observe(document.body, {
childList: true,
subtree: true
});
});
</script>
<script>
(function TCDupdType() {
const TildahtmlBlock = document.currentScript;
if (!TildahtmlBlock) {
return;
}
const recordElement = TildahtmlBlock.closest(
".r[data-record-type]"
);
if (!recordElement) {
return;
}
recordElement.setAttribute(
"data-record-type",
Math.random().toString(36).substring(2, 12)
);
})();
</script>