HEX
Server: nginx/1.28.3
System: Linux ip-172-31-12-242 6.17.0-1007-aws #7~24.04.1-Ubuntu SMP Thu Jan 22 21:04:49 UTC 2026 x86_64
User: root (0)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/nasuhang.com/wp-content/plugins/comment-image-lightbox/js/lightbox.js
(function () {
	'use strict';

	var overlay = null;
	var closeBtn = null;
	var lightboxImg = null;

	function createLightbox() {
		if (document.getElementById('comment-image-lightbox-overlay')) {
			return;
		}

		overlay = document.createElement('div');
		overlay.id = 'comment-image-lightbox-overlay';

		lightboxImg = document.createElement('img');
		lightboxImg.alt = '';
		overlay.appendChild(lightboxImg);

		closeBtn = document.createElement('button');
		closeBtn.id = 'comment-image-lightbox-close';
		closeBtn.type = 'button';
		closeBtn.setAttribute('aria-label', '关闭');
		closeBtn.textContent = '\u00D7';
		document.body.appendChild(closeBtn);

		document.body.appendChild(overlay);

		overlay.addEventListener('click', closeLightbox);
		closeBtn.addEventListener('click', closeLightbox);
		document.addEventListener('keydown', function (e) {
			if (e.key === 'Escape' && overlay.classList.contains('active')) {
				closeLightbox();
			}
		});
	}

	function openLightbox(src, alt) {
		if (!overlay) {
			createLightbox();
		}
		lightboxImg.src = src;
		lightboxImg.alt = alt || '';
		overlay.classList.add('active');
		closeBtn.classList.add('active');
		document.body.style.overflow = 'hidden';
	}

	function closeLightbox() {
		if (!overlay) return;
		overlay.classList.remove('active');
		closeBtn.classList.remove('active');
		document.body.style.overflow = '';
	}

	function init() {
		var selectors = [
			'.wp-block-comment-content img',
			'.comment-content img',
			'.wp-block-post-comments .commentlist img'
		];

		var commentImages = document.querySelectorAll(selectors.join(','));

		commentImages.forEach(function (img) {
			if (img.closest('a')) return;

			if (img.classList.contains('comment-lightbox-bound')) return;
			img.classList.add('comment-lightbox-bound');

			img.addEventListener('click', function (e) {
				e.preventDefault();
				e.stopPropagation();
				var src = img.getAttribute('data-full') || img.src;
				openLightbox(src, img.alt);
			});
		});
	}

	if (document.readyState === 'loading') {
		document.addEventListener('DOMContentLoaded', init);
	} else {
		init();
	}

	var observer = new MutationObserver(function () {
		init();
	});
	observer.observe(document.body, { childList: true, subtree: true });
})();