
$(function () {
    const MANUAL_MESSAGE_SOURCE = "DEXTUploadX5_MANUAL";
    const iframes = document.getElementsByTagName("iframe");
    if (iframes && iframes.length > 0) {
        //iframes[0].src = iframes[0].src + location.hash;
        iframes[0].src = iframes[0].dataset["source"] + (location.hash || "");
    }
	const btnMenu = document.querySelector("#btn-mobile-menu");
	if (btnMenu) {
		btnMenu.addEventListener("click", function (evt) {
			const snb = document.querySelector(".snb");
			const isVisible = snb.className.indexOf(" visible") >= 0;
			if (!snb) return;
			if (isVisible) {
				snb.className = "snb";
			} else {
				snb.className = "snb visible";
			}
		}, false);
	}

	if (window.addEventListener) {
	    window.addEventListener("message", function (evt) {
	        if (!evt.data || evt.data.source !== MANUAL_MESSAGE_SOURCE || typeof evt.data.href !== "string") return;
            // 디스크에서 로드하는 경우 http/https 대신 null/가 들어온다.
	        var idx = evt.data.href.indexOf("null/");
	        document.location.href = idx < 0 ? evt.data.href : "file:///" + evt.data.href.substring(5);
		}, false);
	}
	prettyPrint();
});
