Template:FAQItem: Difference between revisions
mNo edit summary Tag: Reverted |
mNo edit summary Tag: Reverted |
||
| Line 51: | Line 51: | ||
</html> | </html> | ||
<!-- Copy link control (outside HTML so wikitext variables expand) --> | |||
<div style="margin:0.5em 0 1em 0; font-size:smaller; opacity:0.7;"> | <div style="margin:0.5em 0 1em 0; font-size:smaller; opacity:0.7;"> | ||
<a href=" | <a href="#" class="copy-link" data-frag="{{anchorencode:{{{question}}}}}"> | ||
Copy link to this question | |||
</a> | </a> | ||
</div> | </div> | ||
| Line 65: | Line 63: | ||
</blockquote> | </blockquote> | ||
</details> | </details> | ||
<!-- JavaScript block that MediaWiki will NOT escape --> | |||
<script> | |||
document.addEventListener('DOMContentLoaded', function() { | |||
document.querySelectorAll('.copy-link').forEach(function(link) { | |||
link.addEventListener('click', function(e) { | |||
e.preventDefault(); | |||
const frag = this.getAttribute('data-frag'); | |||
const url = window.location.origin + window.location.pathname + '#' + frag; | |||
navigator.clipboard.writeText(url).then(() => { | |||
const original = this.innerText; | |||
this.innerText = 'Copied!'; | |||
setTimeout(() => { this.innerText = original; }, 1500); | |||
}); | |||
}); | |||
}); | |||
}); | |||
</script> | |||
</html> | </html> | ||