PageSourceSearch

https://www.koreaboardgames.com/js/product/product-detail-video-embed.js

js koreaboardgames.com collected 2026-09-24 10:23:00 UTC 2,757 bytes, 83 lines download raw bytes

1/**
2 * 상품 상세 본문(.product_detail_content) 유튜브 iframe: width/height(속성·인라인)로 가로·세로 미판별 레거시만 보정.
3 * BO 정제 HTML(.video-container--shorts | --standard)는 클래스 고정 — 치수만 제거.
4 * 레거시: .video-container 가 있으면 부모에 .video-container--portrait, 없으면 iframe에 .youtube-embed--portrait.
5 */
6(function () {
7	var PORTRAIT_WRAP_CLASS = 'video-container--portrait';
8	var PORTRAIT_IFRAME_CLASS = 'youtube-embed--portrait';
9	var BO_SHORTS_CLASS = 'video-container--shorts';
10	var BO_STANDARD_CLASS = 'video-container--standard';
11	var IFRAME_SELECTOR = '#pdDetailArea .product_detail_content iframe';
12
13	function isYoutubeEmbed(src) {
14		if (!src || typeof src !== 'string') {
15			return false;
16		}
17		return /youtube\.com\/embed\//i.test(src) || /youtube-nocookie\.com\/embed\//i.test(src);
18	}
19
20	function getNumericDims(iframe) {
21		var w = parseInt(iframe.getAttribute('width'), 10);
22		var h = parseInt(iframe.getAttribute('height'), 10);
23		if (isNaN(w) || w <= 0) {
24			w = parseInt(iframe.style.width, 10);
25		}
26		if (isNaN(h) || h <= 0) {
27			h = parseInt(iframe.style.height, 10);
28		}
29		return { w: w, h: h };
30	}
31
32	function stripIframeDimensions(iframe) {
33		iframe.removeAttribute('width');
34		iframe.removeAttribute('height');
35		iframe.style.removeProperty('width');
36		iframe.style.removeProperty('height');
37		if (!iframe.style || !iframe.style.cssText || iframe.style.cssText.trim() === '') {
38			iframe.removeAttribute('style');
39		}
40	}
41
42	function wrapHasBoModifier(wrap) {
43		if (!wrap) {
44			return false;
45		}
46		return wrap.classList.contains(BO_SHORTS_CLASS) || wrap.classList.contains(BO_STANDARD_CLASS);
47	}
48
49	function processYoutubeIframe(iframe) {
50		if (!isYoutubeEmbed(iframe.getAttribute('src'))) {
51			return;
52		}
53		var wrap = iframe.closest('.video-container');
54		if (wrapHasBoModifier(wrap)) {
55			stripIframeDimensions(iframe);
56			iframe.classList.remove(PORTRAIT_IFRAME_CLASS);
57			return;
58		}
59		var d = getNumericDims(iframe);
60		var isPortrait = d.w && d.h && !isNaN(d.w) && !isNaN(d.h) && d.w <= d.h;
61		stripIframeDimensions(iframe);
62
63		iframe.classList.remove(PORTRAIT_IFRAME_CLASS);
64		if (wrap) {
65			if (isPortrait) {
66				wrap.classList.add(PORTRAIT_WRAP_CLASS);
67			} else {
68				wrap.classList.remove(PORTRAIT_WRAP_CLASS);
69			}
70		} else if (isPortrait) {
71			iframe.classList.add(PORTRAIT_IFRAME_CLASS);
72		}
73	}
74
75	function initProductDetailVideoEmbeds() {
76		var iframes = document.querySelectorAll(IFRAME_SELECTOR);
77		for (var i = 0; i < iframes.length; i++) {
78			processYoutubeIframe(iframes[i]);
79		}
80	}
81
82	window.initProductDetailVideoEmbeds = initProductDetailVideoEmbeds;
83})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.