Skip to content

Commit 5f448b8

Browse files
author
John Mulhausen
committed
Refactor of template demo instructions
1 parent 53a1a3e commit 5f448b8

File tree

3 files changed

+215
-77
lines changed

3 files changed

+215
-77
lines changed

_data/support.yml

+2
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ toc:
4040
path: https://github.com/kubernetes/kubernetes/milestones/
4141
- title: Contributing to Kubernetes Documentation
4242
path: /editdocs/
43+
- title: New Template Instructions
44+
path: /docs/templatedemos/

docs/sitemap.md

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
---
3+
<script language="JavaScript">
4+
var dropDownsPopulated = false;
5+
$( document ).ready(function() {
6+
// When the document loads, get the metadata JSON, and kick off tbl render
7+
$.get("/metadata.txt", function(data, status) {
8+
metadata = $.parseJSON(data);
9+
metadata.pages.sort(dynamicSort("t"));
10+
mainLogic()
11+
$(window).bind( 'hashchange', function(e) {
12+
mainLogic();
13+
});
14+
});
15+
});
16+
function mainLogic()
17+
{
18+
// If there's a tag filter, change the table/drop down output
19+
if (!dropDownsPopulated) populateDropdowns();
20+
var tag=window.location.hash.replace("#","");
21+
if(tag) {
22+
tag = $.trim(tag);
23+
for (i=0;i<tagName.length;i++) {
24+
querystringTag = tagName[i] + "=";
25+
if (tag.indexOf(querystringTag) > -1)
26+
{
27+
console.log("in mainLog: querystringTag of " + querystringTag + " matches tag of " + tag);
28+
tag = tag.replace(querystringTag,"");
29+
selectDropDown(tagName[i],tag);
30+
topicsFilter(tagName[i],tag,"output");
31+
}
32+
}
33+
} else {
34+
currentTopics = metadata.pages;
35+
}
36+
renderTable(currentTopics,"output");
37+
38+
}
39+
function populateDropdowns()
40+
{
41+
// Keeping mainLogic() brief by functionizing the initialization of the
42+
// drop-down filter boxes
43+
44+
for(i=0;i<metadata.pages.length;i++)
45+
{
46+
var metadataArrays = [metadata.pages[i].cr,metadata.pages[i].or,metadata.pages[i].mr];
47+
for(j=0;j<metadataArrays.length;j++)
48+
{
49+
if (metadataArrays[j]) {
50+
for (k=0;k<metadataArrays[j].length;k++) {
51+
if (typeof storedTagsArrays[j] == 'undefined') storedTagsArrays[j] = new Array();
52+
storedTagsArrays[j][metadataArrays[j][k][tagName[j]]] = true;
53+
// ^ conceptList[metadata.pages[i].cr[k].concept] = true; (if rolling through concepts)
54+
// ^ conceptList['container'] = true; (ultimate result)
55+
// ^ objectList[metadata.pages[i].or[k].object] = true; (if rolling through objects)
56+
// ^ objectList['restartPolicy'] = true; (ultimate result)
57+
}
58+
}
59+
}
60+
}
61+
var output = new Array();
62+
for(i=0;i<tagName.length;i++)
63+
{
64+
// Phew! All tags in conceptList, objectList, and commandList!
65+
// Loop through them and populate those drop-downs through html() injection
66+
output = [];
67+
output.push("<select id='" + tagName[i] + "' onchange='dropFilter(this)'>");
68+
output.push("<option>---</option>");
69+
Object.keys(storedTagsArrays[i]).sort().forEach(function (key) {
70+
output.push("<option>" + key + "</option>");
71+
});
72+
output.push("</select>")
73+
$(dropDowns[i]).html(output.join(""));
74+
}
75+
dropDownsPopulated = true;
76+
}
77+
function dropFilter(srcobj)
78+
{
79+
// process the change of a drop-down value
80+
// the ID of the drop down is either command, object, or concept
81+
// these exact values are what topicsFilter() expects, plus a filter val
82+
// which we get from .text() of :selected
83+
console.log("dropFilter:" + $(srcobj).attr('id') + ":" + $(srcobj).find(":selected").text());
84+
topicsFilter($(srcobj).attr('id').replace("#",""),$(srcobj).find(":selected").text(),"output");
85+
for(i=0;i<tagName.length;i++)
86+
{
87+
if($(srcobj).attr('id')!=tagName[i]) selectDropDown(tagName[i],"---");
88+
}
89+
}
90+
function selectDropDown(type,tag)
91+
{
92+
// change drop-down selection w/o filtering
93+
$("#" + type).val(tag);
94+
}
95+
</script>
96+
<style>
97+
#filters select{
98+
font-size: 14px;
99+
border: 1px #000 solid;
100+
}
101+
#filters {
102+
padding-top: 20px;
103+
}
104+
</style>
105+
106+
Click tags or use the drop downs to filter. Click table headers to sort or reverse sort.
107+
108+
<p id="filters">
109+
Filter by Concept: <span id="conceptFilter" /><br/>
110+
Filter by Object: <span id="objectFilter" /><br/>
111+
Filter by Command: <span id="commandFilter" />
112+
</p>
113+
114+
<div id="output" />

0 commit comments

Comments
 (0)