PageSourceSearch

https://winchestercollegeatwar.com/Scripts/sideTreeView.js

js winchestercollegeatwar.com collected 2026-10-02 07:09:44 UTC 2,909 bytes, 104 lines download raw bytes

1
2if (typeof (sds) === "undefined") sds = {};
3
4sds.sideTreeView = function () {
5
6	var LOCAL_STORAGE_STATE_NAME = "SideTreeViewState";
7
8	function _saveState() {
9		var state = {
10			visibleChildrenNodeIDs: []
11		};
12		// Get the IDs of all the nodes with visible children
13		$(".tree-node.show-children").each(function () {
14			state.visibleChildrenNodeIDs.push(this.getAttribute("id"));
15		});
16
17		// JSON-ify and save the state
18		localStorage.setItem("SideTreeViewState", JSON.stringify(state));
19	}
20
21	var loadState = function () {
22		// Get the current state from the local storage
23		var stateJSON = localStorage.getItem(LOCAL_STORAGE_STATE_NAME);
24
25		// If we have a state then parse it
26		var state = null;
27		if (stateJSON != null) {
28			try {
29				state = JSON.parse(stateJSON);
30			}
31			catch (e) { /* Invalid state */ }
32		}
33
34		// Load the state if it was parsed
35		if (state != null) {
36			// Show the children that should be visible
37			for (var i = 0; i < state.visibleChildrenNodeIDs.length; i++) {
38				var nodeID = state.visibleChildrenNodeIDs[i];
39
40				var $node = $("#" + nodeID);
41				$node.addClass("show-children");
42				$node.find("> .node-children").slideDown();
43			}
44		}
45        
46		// If we're on one of the pages of the menu items then highlight it
47		$("#sideTreeView .tree-node .node-title[href='" + (window.location.pathname + window.location.search) + "']").addClass("active");
48	};
49
50	var toggleVisibility = function () {
51		$("#sideTreeView").toggleClass("visible");
52	};
53
54	var toggleChildren = function (expander) {
55		var treeNode = expander.parentNode;
56		var $childrenContainer = $(treeNode).find("> .node-children");
57		if (treeNode.classList.contains("show-children")) { // Hide the children
58			treeNode.classList.remove("show-children");
59			$childrenContainer.slideUp();
60		}
61		else { // Show the children
62			treeNode.classList.add("show-children");
63			$childrenContainer.slideDown();
64		}
65
66		// Save the state of the node
67		_saveState();
68	};
69
70
71	var performSearch = function () {
72		window.location = "/Authenticated/Search.aspx?q=" + encodeURIComponent($("#sideTreeViewSearchText").val()) + "&" + $("#sideTreeViewSearchType").val() + "=true&triggered=true";
73	};
74
75	var searchInputOnKeyPress = function (e) {
76		var keycode;
77		if (window.event) {
78			keycode = window.event.keyCode;
79		} else if (e) {
80			keycode = e.which;
81		}
82
83		if (keycode == 13) {
84			e.preventDefault();
85			sds.sideTreeView.performSearch();
86		}
87	};
88
89	return {
90		loadState: loadState,
91		toggleVisibility: toggleVisibility,
92		toggleChildren: toggleChildren,
93		performSearch: performSearch,
94		searchInputOnKeyPress: searchInputOnKeyPress
95	};
96
97}();
98
99$(document).ready(function () {
100	// Load the state of the site menu
101	sds.sideTreeView.loadState();
102
103	$("#sideTreeViewSearchText").on("keydown", sds.sideTreeView.searchInputOnKeyPress);
104});

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.