Skip to content

Commit

Permalink
Reorder parameter list alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
gassmoeller committed Jan 4, 2019
1 parent c34781e commit 729fd3a
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
56 changes: 56 additions & 0 deletions doc/parameter_view/parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@


demangleStrings();
reorderList();

function demangleStrings() {
mangledStrings = document.getElementsByClassName("mangled");
Expand Down Expand Up @@ -83,3 +84,58 @@ for (i = 0; i < coll.length; i++) {
}
});
}

function sortTopNodes(ClassType) {
var list, i, switching, shouldSwitch;
list = document.getElementById("ParameterList");
switching = true;

/* Make a loop that will continue until
no switching has been done: */
while (switching) {
// Start by saying: no switching is done:
switching = false;
children = list.children;
// parameters = children.getElementbyClassName("parameter");

// Loop through all list items:
for (i = 0; i < (children.length - 1); i++) {
if (children[i].children[0].classList.contains(ClassType) && children[i+1].children[0].classList.contains(ClassType)) {
// Start by saying there should be no switching:
shouldSwitch = false;
/* Check if the next item should
switch place with the current item: */
if (children[i].children[0].innerHTML.toLowerCase() > children[i + 1].children[0].innerHTML.toLowerCase()) {
/* If next item is alphabetically lower than current item,
mark as a switch and break the loop: */
shouldSwitch = true;
break;
}
}
}

if (shouldSwitch) {
/* If a switch has been marked, make the switch
and mark the switch as done: */
children[i].parentNode.insertBefore(children[i + 1], children[i]);
switching = true;
}
}
}

function reorderList() {
var list, i;
list = document.getElementById("ParameterList");

/* Move parameters to the front */
children = list.children;

for (i = 0; i < children.length; i++) {
if (children[i].children[0].classList.contains("parameter")) {
children[i].parentNode.insertBefore(children[i], children[0]);
}
}

sortTopNodes("parameter");
sortTopNodes("subsection");
}
7 changes: 5 additions & 2 deletions doc/parameter_view/parameters.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
<body>
<h2>
ASPECT input parameters
</h2>

<div>
<button onclick="expandAll()">Expand all</button>
<button onclick="collapseAll()">Collapse all</button>
<button onclick="expandAllSubsections()">Expand subsections</button>
<button onclick="collapseAllSubsections()">Collapse subsections</button>
</h2>
<ul>
</div>
<ul id="ParameterList">
<xsl:apply-templates
select="ParameterHandler/*" />
</ul>
Expand Down

0 comments on commit 729fd3a

Please sign in to comment.