PageSourceSearch

https://www.kochi-tech.ac.jp/hachikin/assets/js/hachikin.js

js kochi-tech.ac.jp collected 2026-10-01 11:44:14 UTC 1,731 bytes, 49 lines download raw bytes

1(function ($) {
2	// Side-nav active-marker for hachikin.
3	//
4	// Background: common.js applies .current/.active by matching path
5	// segments — path[1] for navLevel3 anchors, path[3] for navLevel4
6	// anchors, path[2] for parent spans. That was designed for flat
7	// sections like /society/ where each level resolves uniquely.
8	// hachikin lives one level deeper (/hachikin/excavation/...),
9	// so the path-segment match collides:
10	//   - path[1] = "hachikin" → every nav link matches
11	//   - path[2] = "excavation" → both navLevel3 sections match
12	//   - path[3] = "wedsc" → both wedsc sub-items match
13	//
14	// Fix: run after common.js, wipe its assignments, then apply
15	// .current only to the single best (longest-prefix) match.
16	$(function () {
17		var path = location.pathname.replace(/index\.html$/, '');
18		var best = null;
19		var bestLen = 0;
20
21		$('.navLocal a[href]').each(function () {
22			var href = $(this).attr('href').replace(/index\.html$/, '');
23			if (href && path.indexOf(href) === 0 && href.length > bestLen) {
24				best = this;
25				bestLen = href.length;
26			}
27		});
28
29		// Reset common.js's path-segment matches.
30		$('.navLocal a').removeClass('current');
31		$('.navLocal span').removeClass('active');
32		$('.navLocal li').removeClass('current-section');
33
34		if (best) {
35			var $best = $(best);
36			$best.addClass('current');
37
38			// Mark every ancestor li with .current-section (for our
39			// CSS that expands the active section's navLevel4) and
40			// also set .active on each ancestor section's span
41			// (matches kochi-tech's convention for parent highlight).
42			$best.closest('li')
43				.parents('.navLocal li')
44				.addClass('current-section')
45				.children('span')
46				.addClass('active');
47		}
48	});
49})(jQuery);

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.