MCPcopy Create free account
hub / github.com/zxlie/FeHelper / initPreviewImageModal

Function initPreviewImageModal

website/static/js/script.js:72–108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70}
71
72function 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
110function initGitHubStats() {
111 const badges = Array.from(document.querySelectorAll('[data-github-stat]'));

Callers 1

script.jsFile · 0.85

Calls 2

closeModalFunction · 0.85
addEventListenerMethod · 0.45

Tested by

no test coverage detected