(text)
| 288 | } |
| 289 | |
| 290 | function createHistoryCopyButton(text) { |
| 291 | const btn = document.createElement('button'); |
| 292 | btn.className = 'tui-button tui-bg-green-black history-copy-btn'; |
| 293 | btn.textContent = '[ COPY ]'; |
| 294 | |
| 295 | btn.addEventListener('click', async function() { |
| 296 | const originalText = btn.textContent; |
| 297 | btn.textContent = '[ ... ]'; |
| 298 | btn.disabled = true; |
| 299 | |
| 300 | try { |
| 301 | if (window.isSecureContext && navigator.clipboard && navigator.clipboard.writeText) { |
| 302 | await navigator.clipboard.writeText(text); |
| 303 | } else { |
| 304 | const tempTextarea = document.createElement('textarea'); |
| 305 | tempTextarea.value = text; |
| 306 | tempTextarea.style.position = 'fixed'; |
| 307 | tempTextarea.style.left = '-9999px'; |
| 308 | document.body.appendChild(tempTextarea); |
| 309 | tempTextarea.select(); |
| 310 | document.execCommand('copy'); |
| 311 | document.body.removeChild(tempTextarea); |
| 312 | } |
| 313 | |
| 314 | btn.textContent = '[ ✓ ]'; |
| 315 | btn.classList.add('copied'); |
| 316 | |
| 317 | setTimeout(() => { |
| 318 | btn.textContent = originalText; |
| 319 | btn.classList.remove('copied'); |
| 320 | btn.disabled = false; |
| 321 | }, 2000); |
| 322 | |
| 323 | } catch (error) { |
| 324 | btn.textContent = '[ X ]'; |
| 325 | setTimeout(() => { |
| 326 | btn.textContent = originalText; |
| 327 | btn.disabled = false; |
| 328 | }, 2000); |
| 329 | } |
| 330 | }); |
| 331 | |
| 332 | return btn; |
| 333 | } |
| 334 | |
| 335 | function makePreviewClickable(previewDiv, fullContentDiv) { |
| 336 | let isExpanded = false; |
no outgoing calls
no test coverage detected