-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
108 lines (95 loc) · 3.43 KB
/
Copy pathscript.js
File metadata and controls
108 lines (95 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
(function () {
const navToggle = document.querySelector(".nav-toggle");
const siteNav = document.querySelector(".site-nav");
const topButton = document.querySelector(".back-to-top");
if (navToggle && siteNav) {
navToggle.addEventListener("click", () => {
const isOpen = siteNav.classList.toggle("is-open");
navToggle.setAttribute("aria-expanded", String(isOpen));
});
}
if (topButton) {
const updateTopButton = () => {
topButton.classList.toggle("is-visible", window.scrollY > 260);
};
window.addEventListener("scroll", updateTopButton, { passive: true });
updateTopButton();
topButton.addEventListener("click", () => {
window.scrollTo({ top: 0, behavior: "smooth" });
});
}
const form = document.querySelector("[data-support-form]");
const output = document.querySelector("[data-support-output]");
const copyButton = document.querySelector("[data-copy-support]");
const downloadButton = document.querySelector("[data-download-support]");
if (!form || !output) {
return;
}
const field = (name) => {
const input = form.elements.namedItem(name);
return input ? input.value.trim() : "";
};
const fallback = (value, text) => value || text;
const buildMarkdown = () => {
const name = fallback(field("name"), "[name or organisation]");
const contact = fallback(field("contact"), "[contact path]");
const lane = fallback(field("lane"), "General early supporter");
const offer = fallback(field("offer"), "[practical offer]");
const boundaries = fallback(field("boundaries"), "[privacy, timing, attribution or cultural protocol boundaries]");
const next = fallback(field("next"), "[useful next step]");
return [
"# Brisbane Peaceful Space & Civic AI Summit - Early Support Signal",
"",
"## Supporter",
`- Name or organisation: ${name}`,
`- Best contact path: ${contact}`,
`- Support lane: ${lane}`,
"",
"## Practical offer",
offer,
"",
"## Boundaries or conditions",
boundaries,
"",
"## Useful next step",
next,
"",
"## Public/private note",
"This is an early support signal for a proposed Brisbane gathering. It is not a public partner announcement, ticket sale, venue confirmation or official event commitment until both sides explicitly agree."
].join("\n");
};
const updateOutput = () => {
output.value = buildMarkdown();
};
form.addEventListener("input", updateOutput);
form.addEventListener("change", updateOutput);
updateOutput();
if (copyButton) {
copyButton.addEventListener("click", async () => {
output.select();
try {
await navigator.clipboard.writeText(output.value);
copyButton.textContent = "Copied";
} catch (error) {
document.execCommand("copy");
copyButton.textContent = "Copied";
}
window.setTimeout(() => {
copyButton.textContent = "Copy Markdown";
}, 1600);
});
}
if (downloadButton) {
downloadButton.addEventListener("click", () => {
const blob = new Blob([output.value], { type: "text/markdown;charset=utf-8" });
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = "brisbane-summit-early-support-signal.md";
document.body.appendChild(link);
link.click();
link.remove();
URL.revokeObjectURL(url);
});
}
})();