tradingview-alert-dispatcher/app/static/app.js
2026-05-15 22:04:05 +08:00

28 lines
1003 B
JavaScript

document.addEventListener("click", async (event) => {
const button = event.target.closest("[data-copy]");
if (!button) return;
const value = button.getAttribute("data-copy") || "";
try {
await navigator.clipboard.writeText(value);
const original = button.textContent;
button.textContent = "已复制";
setTimeout(() => {
button.textContent = original;
}, 1200);
} catch {
window.prompt("复制下面的内容", value);
}
});
document.addEventListener("change", (event) => {
const picker = event.target.closest("[data-template-picker]");
if (!picker) return;
const option = picker.selectedOptions[0];
if (!option || !option.value) return;
const form = picker.closest("form");
const titleInput = form?.querySelector("[data-title-template-input]");
const bodyInput = form?.querySelector("[data-body-template-input]");
if (titleInput) titleInput.value = option.dataset.title || "";
if (bodyInput) bodyInput.value = option.dataset.body || "";
});