-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathcommands.html
More file actions
189 lines (165 loc) · 6.84 KB
/
Copy pathcommands.html
File metadata and controls
189 lines (165 loc) · 6.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
{% extends "left-aside.html" %}
{% import "macros/command.html" as commands %}
{% block main_content %}
{% if section.pages | length == 0 %}
<strong>No command pages found.</strong> You likely need to build the command pages. See "Building additional content" in README.md file.
{% endif %}
{% set_global group_descriptions = load_data(path= "../_data/groups.json", required= false) %}
{% set commands_entries = [] %}
<!-- command search box -->
<div class="search-container">
<label>Search Commands:</label>
<input type="text" id="search-box" placeholder="Search commands..." onkeyup="searchCommands()" />
</div>
<!-- No results message -->
<div id="no-results-message" class="no-results-message" style="display: none;">
<span></></span>
<h4>We couldn't find any results matching your search</h4>
<p>Check your spelling or try different keywords</p>
</div>
{% for page in section.pages %}
{% for json_path in [
commands::command_json_path(slug=page.slug),
commands::command_bloom_json_path(slug=page.slug),
commands::command_json_json_path(slug=page.slug),
commands::command_search_json_path(slug=page.slug)
] %}
{% set command_data = load_data(path= json_path, required= false) %}
{% if command_data %}
{% set command_obj_name = commands::command_obj_name(command_data= command_data) %}
{% set command_data_obj = command_data[command_obj_name] %}
{% set command_display = command_obj_name %}
{% if command_data_obj.container %}
{% set command_display = command_data_obj.container ~ " " ~ command_display %}
{% endif %}
{% set command_entry = [
command_display,
page.permalink | safe,
command_data_obj.summary,
command_data_obj.group
] %}
{% set_global commands_entries = commands_entries | concat(with= [ command_entry ]) %}
{% endif %}
{% endfor %}
{% endfor %}
{% set_global grouped = commands_entries | sort(attribute="3") | group_by(attribute="3") %}
{% for command_group_name, command_group in grouped %}
<div class="command-group">
{% set command_group_description_name = command_group_name | replace(from="_", to="-") %}
<h2 id="{{command_group_description_name}}">{{ group_descriptions[command_group_description_name].display }}
<span>{{ group_descriptions[command_group_description_name].description }}</span>
</h2>
{% for entry in command_group | sort(attribute="0") %}
<div class="command-entry"><code><a href="{{ entry[1] }}">{{ entry[0] }}</a></code> {{entry[2]}}</div>
{% endfor %}
<div class="command-group-meta">
<small><a href="#top">Back to top</a></small>
</div>
</div>
{% endfor %}
<script>
function searchCommands() {
var input = document.getElementById("search-box").value.toLowerCase();
var groups = document.querySelectorAll(".command-group");
var noResultsMessage = document.getElementById("no-results-message");
var totalVisible = 0;
groups.forEach(function (group) {
var items = group.querySelectorAll(".command-entry");
var found = false;
items.forEach(function (item) {
var text = item.querySelector("a").innerText.toLowerCase();
if (text.includes(input)) {
item.style.display = "";
found = true;
totalVisible++;
} else {
item.style.display = "none";
}
});
group.style.display = found ? "" : "none";
});
// Show/hide no results message based on search results
noResultsMessage.style.display = totalVisible === 0 ? "block" : "none";
}
function filterByCategory() {
var hash = window.location.hash.substring(1);
var groups = document.querySelectorAll(".command-group");
var sidebarLinks = document.querySelectorAll(".category-link");
var noResultsMessage = document.getElementById("no-results-message");
// Clear search box when filtering by category
var searchBox = document.getElementById("search-box");
if (searchBox) searchBox.value = "";
// Update active state on sidebar links
sidebarLinks.forEach(function (link) {
link.classList.remove("active");
if (link.getAttribute("href") === "#" + hash) {
link.classList.add("active");
}
});
// If no hash or hash is "top", show all groups
if (!hash || hash === "top") {
groups.forEach(function (group) {
group.style.display = "";
group.querySelectorAll(".command-entry").forEach(function (item) {
item.style.display = "";
});
});
noResultsMessage.style.display = "none";
sidebarLinks.forEach(function (link) { link.classList.remove("active"); });
var showAllLink = document.querySelector(".show-all-link");
if (showAllLink) showAllLink.classList.add("active");
return;
}
// Show only the matching group
var found = false;
groups.forEach(function (group) {
var heading = group.querySelector("h2");
if (heading && heading.id === hash) {
group.style.display = "";
group.querySelectorAll(".command-entry").forEach(function (item) {
item.style.display = "";
});
found = true;
} else {
group.style.display = "none";
}
});
noResultsMessage.style.display = found ? "none" : "block";
}
</script>
<script>
document.addEventListener("DOMContentLoaded", function() {
document.getElementById("search-box").focus();
// Filter on initial page load if URL has a hash
if (window.location.hash) {
filterByCategory();
}
// Filter when hash changes (sidebar link clicked)
window.addEventListener("hashchange", filterByCategory);
});
</script>
{% endblock main_content %}
{% block related_content %}
<h2 id="top">Command Categories</h2>
<ul>
<li><a href="#top" class="show-all-link active" onclick="window.location.hash='top';">Show All</a></li>
{% if group_descriptions %}
{% for command_group_name, group_description in group_descriptions %}
{% set replaced_group_id = command_group_name | replace(from="-", to="_") %}
{% if grouped[replaced_group_id] %}<li> <a href="#{{ command_group_name }}" class="category-link">{{ group_description.display }}</a></li>{% endif %}
{% endfor %}
{% endif %}
</ul>
<h2>Alphabetical Command List</h2>
<ul>
{% set alpha_entries = commands_entries | sort(attribute="0") %}
{% for entry in alpha_entries %}
<li><code><a href="{{ entry[1] }}">{{ entry[0] }}</a></code></li>
{% endfor %}
</ul>
{% endblock related_content %}
{% block subhead_content %}
<div class="styled-title">
<h1>Documentation: Command Reference</h1>
</div>
{% endblock subhead_content %}