PageSourceSearch

https://itexamanswers.net/wp-content/plugins/code-block-copy-button/cbc-script.js?ver=47923d3a0e65

js itexamanswers.net collected 2026-10-03 23:18:12 UTC 2,797 bytes, 49 lines download raw bytes

1
2document.addEventListener('DOMContentLoaded', function() {
3    function attachCopyButtons() {
4        document.querySelectorAll('.cbc-copy-button').forEach(function(button) {
5            if (button.dataset.bound) return;
6            button.dataset.bound = true;
7
8            const originalBgColor = button.dataset.originalColor || button.style.backgroundColor;
9
10            button.addEventListener('click', function() {
11                const wrapper = button.closest('.cbc-code-wrapper');
12                const pre = wrapper ? wrapper.querySelector('pre') : null;
13                if (!pre) return;
14
15                const code = pre.querySelector('code');
16                const text = code ? code.innerText : pre.innerText;
17
18                navigator.clipboard.writeText(text).then(() => {
19                    // Step 1: Show "Copied"
20                    button.style.backgroundColor = '#ADADAD';
21                    button.style.color = '#fff';
22                    button.innerHTML = `
23                        <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" height="16" width="16" style="vertical-align:middle;margin-right:6px;">
24                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
25                        </svg>Copied`;
26
27                    // Step 2: Switch to "Copy Again"
28                    setTimeout(() => {
29                        button.style.backgroundColor = originalBgColor;
30                        button.innerHTML = `
31                            <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" height="16" width="16" style="vertical-align:middle;margin-right:6px;">
32                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" />
33                            </svg>Copy Again`;
34                    }, 1000);
35                });
36            });
37
38            button.dataset.originalColor = button.style.backgroundColor;
39            button.innerHTML = `
40                <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" height="16" width="16" style="vertical-align:middle;margin-right:6px;">
41                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" />
42                </svg>Copy`;
43        });
44    }
45
46    attachCopyButtons();
47    const observer = new MutationObserver(attachCopyButtons);
48    observer.observe(document.body, { childList: true, subtree: true });
49});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.