Skip to content

Commit

Permalink
disable search for deprecated tags by default
Browse files Browse the repository at this point in the history
  • Loading branch information
dungscout96 committed Sep 6, 2023
1 parent 313a6df commit c893f37
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions _layouts/display_hed_layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ <h5 class="mb-0">
</div>
</div>
</div>
<div class="row" name="checkbox-section">
<div class="btn invisible">
<button type="button" class="btn btn-light">Expand/Collapse all</button>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="searchDeprecatedTags" onchange="getSchemaNodes()">
<label class="form-check-label" for="searchDeprecatedTags">Search deprecated tags</label>
</div>
</div>
<div class="row" name="hed-version">
<div class="col col-lg-3">
<h1 id="hed" style="font-family:ultra, sans-serif;color:#0099ff">HED</h1>
Expand Down
18 changes: 18 additions & 0 deletions schema_browser/schema-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,10 @@ function toNode(nodeName) {
node.effect("highlight", {}, 3000);
}
function getSchemaNodes() {
/**
* Set autocomplete behavior
*/
allowDeprecated = $("#searchDeprecatedTags")[0].checked;
// clear array
schemaNodes.length = 0;
allSchemaNodes.length = 0;
Expand All @@ -497,6 +501,11 @@ function getSchemaNodes() {
suggestedTagsDict = {};
/* Initialize schema nodes list and set behavior of search box */
$("a[name='schemaNode']").each(function() {
attributes = getAttributesOfNode($(this));
if (!allowDeprecated && attributes.includes('deprecatedFrom')) {
return;
}

var nodeName = $(this).attr("tag");
allSchemaNodes.push(nodeName);

Expand Down Expand Up @@ -545,6 +554,15 @@ function getSchemaNodes() {
});
}

function getAttributesOfNode(tagNode) {
attributes = []
attributeDivs = tagNode.nextUntil("a", ".attribute");
for (var i=0; i < attributeDivs.length; i++) {
attributes.push(attributeDivs[i].innerText.split(':')[0]);
}
return attributes
}

function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
Expand Down

0 comments on commit c893f37

Please sign in to comment.