()
| 70 | } |
| 71 | |
| 72 | function initPreviewImageModal() { |
| 73 | document.querySelectorAll('.tool-preview .preview-item img').forEach(function (img) { |
| 74 | img.addEventListener('click', function () { |
| 75 | const modal = document.createElement('div'); |
| 76 | modal.className = 'img-modal'; |
| 77 | |
| 78 | const close = document.createElement('button'); |
| 79 | close.type = 'button'; |
| 80 | close.className = 'img-modal-close'; |
| 81 | close.setAttribute('aria-label', '关闭预览'); |
| 82 | close.textContent = '×'; |
| 83 | |
| 84 | const image = document.createElement('img'); |
| 85 | image.src = img.src; |
| 86 | image.alt = img.alt || 'FeHelper 截图预览'; |
| 87 | |
| 88 | modal.appendChild(close); |
| 89 | modal.appendChild(image); |
| 90 | document.body.appendChild(modal); |
| 91 | |
| 92 | function closeModal() { |
| 93 | modal.remove(); |
| 94 | document.removeEventListener('keydown', onKeydown); |
| 95 | } |
| 96 | |
| 97 | function onKeydown(event) { |
| 98 | if (event.key === 'Escape') closeModal(); |
| 99 | } |
| 100 | |
| 101 | close.addEventListener('click', closeModal); |
| 102 | modal.addEventListener('click', function (event) { |
| 103 | if (event.target === modal) closeModal(); |
| 104 | }); |
| 105 | document.addEventListener('keydown', onKeydown); |
| 106 | }); |
| 107 | }); |
| 108 | } |
| 109 | |
| 110 | function initGitHubStats() { |
| 111 | const badges = Array.from(document.querySelectorAll('[data-github-stat]')); |
no test coverage detected