PageSourceSearch

https://www.st-grp.co.jp/common/js/common.js?1766115847

js st-grp.co.jp collected 2026-10-02 03:46:50 UTC 5,471 bytes, 190 lines download raw bytes

1var ua = {
2	all: navigator.userAgent.toLowerCase(),
3	device: "",
4};
5
6if ((ua.all.indexOf("iphone") > -1 && ua.all.indexOf("ipad") == -1) || ua.all.indexOf("ipod") > -1 || (ua.all.indexOf("android") > -1 && ua.all.indexOf("mobile") > -1)) {
7	ua.device = "smp";
8} else if (ua.all.indexOf("ipad") > -1 || (ua.all.indexOf("android") > -1 && ua.all.indexOf("mobile") == -1)) {
9	ua.device = "tablet";
10	tabViewport();
11} else {
12	ua.device = "pc";
13}
14
15function tabViewport() {
16	var metalist = document.getElementsByTagName("meta");
17	for (var i = 0; i < metalist.length; i++) {
18		var name = metalist[i].getAttribute("name");
19		if (name && name.toLowerCase() === "viewport") {
20			metalist[i].setAttribute("content", "width=1120");
21			break;
22		}
23	}
24}
25
26$(function () {
27	// Disable hover on touch device
28	var currentLocation = window.location.protocol + "//" + window.location.host;
29	if (ua.device != "pc") {
30		try {
31			// prevent exception on browsers not supporting DOM styleSheets properly
32			for (var si in document.styleSheets) {
33				var styleSheet = document.styleSheets[si];
34				if (!styleSheet.href.match(currentLocation)) continue; // internal style sheet only
35				if (!styleSheet.cssRules) continue;
36				for (var ri = styleSheet.cssRules.length - 1; ri >= 0; ri--) {
37					if (styleSheet.cssRules[ri].selectorText) {
38						if (styleSheet.cssRules[ri].selectorText.match(":hover")) {
39							styleSheet.deleteRule(ri);
40						}
41					} else if (styleSheet.cssRules[ri].cssRules) {
42						var media = styleSheet.cssRules[ri];
43						for (var qi = media.cssRules.length - 1; qi >= 0; qi--) {
44							if (media.cssRules[qi].selectorText.match(":hover")) {
45								media.deleteRule(qi);
46							}
47						}
48					}
49				}
50			}
51		} catch (ex) {}
52	}
53
54	// scroll init
55	var scrollY = $(this).scrollTop();
56	$(window).on("scroll", function () {
57		scrollY = $(this).scrollTop();
58		toPageTop();
59	});
60	$(window).scroll();
61
62	// to Page top button
63	function toPageTop() {
64		if (scrollY > 200) {
65			$("#to_pagetop").addClass("is-show");
66		} else {
67			$("#to_pagetop").removeClass("is-show");
68		}
69	}
70
71	// Language
72	$(".gh_language select").on("change", function () {
73		if ($(this).val() != "") {
74			location.href = $(this).val();
75		}
76	});
77
78	// search
79	$(".gh_search_btn").on("mousedown", function () {
80		$(this).toggleClass("js-clicked-when-active", $(".search").hasClass("is-active"));
81	});
82	$(".gh_search_btn").on("mouseup", function () {
83		if ($(this).hasClass("js-clicked-when-active")) {
84			$(".search :focus").blur();
85			$(this).removeClass("js-clicked-when-active");
86		} else {
87			$("#i_search_input").focus();
88		}
89	});
90	$(".gh_search").on("focusin", function () {
91		$(".search").addClass("is-active");
92	});
93	$(".gh_search").on("focusout", function () {
94		$(".search").removeClass("is-active");
95	});
96
97	// sp btn
98	$(".gh_btn_search").on("click", function () {
99		$(this).toggleClass("is-open");
100		$(".gh_btn_nav").removeClass("is-open");
101		$(".gh_inner").slideToggle();
102		$(".gh_inner_sp").slideUp();
103	});
104	$(".gh_btn_nav").on("click", function () {
105		$(this).toggleClass("is-open");
106		$(".gh_btn_search").removeClass("is-open");
107		$(".gh_inner_sp").slideToggle();
108		$(".gh_inner").slideUp();
109	});
110
111	// sp toggle
112	$(".gh_nav_parent").on("click", function () {
113		$(this).toggleClass("is-open");
114		$(this).next().slideToggle();
115	});
116
117	// slidetable
118	$(".table_wrap").each(function () {
119		var slideIcon = $('<div class="slide_icon">');
120		$(this).append(slideIcon);
121		var scrollX = $(this).scrollLeft();
122		var iconFlag = true;
123		$(this).scroll(function () {
124			scrollX = $(this).scrollLeft();
125			if (iconFlag) {
126				if (scrollX > 10) {
127					slideIcon.fadeOut("fast");
128					iconFlag = false;
129				}
130			} else {
131				if (scrollX <= 10) {
132					slideIcon.fadeIn("fast");
133					iconFlag = true;
134				}
135			}
136		});
137	});
138
139	// megamenu
140	const activeCategory = location.pathname.split("/")[1];
141	if (!!activeCategory) {
142		$(`#gh_nav_${activeCategory}`).addClass("is-active");
143	}
144	if ($(window).width() > 640) {
145		const l_mega_bg = document.querySelector(".l-mega-bg");
146		const toggleMega = function (id, state) {
147			const target_l_mega = document.getElementById(id);
148			const menu_item = document.getElementById(target_l_mega.getAttribute("aria-owns"));
149			l_mega_bg.classList.toggle("is-open", state);
150			target_l_mega.classList.toggle("is-open", state);
151			target_l_mega.setAttribute("aria-hidden", state ? "false" : "true");
152			menu_item.setAttribute("aria-selected", state ? "true" : "false");
153		};
154		$(".gh_has_mega").on("mouseenter", function () {
155			toggleMega($(this).attr("aria-controls"), true);
156		});
157		$(".gh_has_mega").on("mouseleave", function () {
158			toggleMega($(this).attr("aria-controls"), false);
159		});
160		$(".l-mega").on("mouseenter", function () {
161			toggleMega($(this).attr("id"), true);
162		});
163		$(".l-mega").on("mouseleave", function () {
164			toggleMega($(this).attr("id"), false);
165		});
166	}
167});
168
169//st-icon
170
171class StIcon extends HTMLElement {
172	static cache = new Map();
173	static get observedAttributes() {
174		return ["name"];
175	}
176
177	async attributeChangedCallback(_, __, name) {
178		if (!name) return;
179		if (StIcon.cache.has(name)) {
180			this.innerHTML = StIcon.cache.get(name);
181			return;
182		}
183		const res = await fetch(`/common/img/st-icons/${name}.svg`);
184		let text = await res.text();
185		text += "<style>:host{color:inherit;}svg{fill:currentColor;height:1em;width:auto;vertical-align:-.1em}</style>";
186		StIcon.cache.set(name, text);
187		this.innerHTML = text;
188	}
189}
190customElements.define("st-icon", StIcon);

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.