Template:FAQItem: Difference between revisions

mNo edit summary
Tag: Reverted
m ST moved page Template:FAQItemL to Template:FAQItem without leaving a redirect: new version with link
 
(2 intermediate revisions by the same user not shown)
Line 44: Line 44:


<!-- Generate a stable anchor ID from the question text -->
<!-- Generate a stable anchor ID from the question text -->
<!-- Precompute everything BEFORE entering HTML mode -->
<span id="{{anchorencode:{{{question}}}}}"></span>
{{#vardefine:frag|{{anchorencode:{{{question}}}}} }}
{{#vardefine:q|{{{question}}}}}
{{#vardefine:a|{{{answer}}}}}
 
<span id="{{#var:frag}}"></span>


<html>
<html>
<details class="faq-item">
<details class="faq-item">
 
<summary style="font-weight: bold; font-size:larger;"></html>{{{question}}}<html></summary>
<summary style="font-weight: bold; font-size:larger;">
</html>
{{#var:q}}
</summary>


<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="#" class="copy-link" data-frag="{{#var:frag}}">
[[{{FULLPAGENAME}}#{{anchorencode:{{{question}}}}}|Link to this question]]
        Copy link to this question
    </a>
</div>
</div>


<html>
<blockquote class="faq-answer">
<blockquote class="faq-answer">
{{#var:a}}
</html>{{{answer}}}<html>
</blockquote>
</blockquote>
</details>
</details>
<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>