()
| 286 | } |
| 287 | |
| 288 | function setUpCopyButtons(){ |
| 289 | document.querySelectorAll('#assistant_response pre').forEach(pre => { |
| 290 | |
| 291 | const btn = document.createElement('i'); |
| 292 | btn.classList.add('copy-btn'); |
| 293 | btn.classList.add('bi-copy'); |
| 294 | const msg = document.createElement('span'); |
| 295 | msg.textContent = 'Copied!'; |
| 296 | msg.style.display = 'none'; |
| 297 | msg.style.marginLeft = '8px'; |
| 298 | btn.appendChild(msg); |
| 299 | pre.appendChild(btn); |
| 300 | |
| 301 | btn.addEventListener('click', function() { |
| 302 | const code = this.parentNode.firstElementChild.innerText; |
| 303 | navigator.clipboard.writeText(code).then(() => { |
| 304 | msg.style.display = 'inline'; |
| 305 | setTimeout(() => { |
| 306 | msg.style.display = 'none'; |
| 307 | }, 2000); |
| 308 | }).catch(err => { |
| 309 | console.error('Error in copying text: ', err); |
| 310 | }); |
| 311 | }); |
| 312 | }); |
| 313 | } |
no outgoing calls
no test coverage detected