25 lines
905 B
JavaScript
25 lines
905 B
JavaScript
(() => {
|
|
document.querySelectorAll('#marketing-language, [data-language-switch]').forEach(select => {
|
|
select.addEventListener('change', event => {
|
|
const next = new URL(window.location.href);
|
|
next.searchParams.set('lang', event.target.value);
|
|
window.location.assign(next.toString());
|
|
});
|
|
});
|
|
|
|
document.querySelectorAll('.copy-code').forEach(button => {
|
|
button.addEventListener('click', async () => {
|
|
const target = document.getElementById(button.dataset.copyTarget);
|
|
if (!target) return;
|
|
const original = button.dataset.label || button.textContent;
|
|
try {
|
|
await navigator.clipboard.writeText(target.textContent);
|
|
button.textContent = button.dataset.copied || original;
|
|
window.setTimeout(() => { button.textContent = original; }, 1200);
|
|
} catch (_) {
|
|
button.textContent = original;
|
|
}
|
|
});
|
|
});
|
|
})();
|