Skip to content

Commit c03c044

Browse files
fixes
1 parent db05bb0 commit c03c044

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

app/static/assets/search.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ const DS_SEARCH = (function () {
2020
return cfr11_data.text();
2121
}
2222

23+
function shouldAppendExample(element, example, cfrPart11) {
24+
const isEsignature = element.Name.toLowerCase() === API_TYPES.ESIGNATURE.toLowerCase();
25+
const isCFREnabledForAll = example.CFREnabled === "AllAccounts";
26+
const isCFREnabledForCFROnly = cfrPart11 === "True" && example.CFREnabled === "CFROnly";
27+
const isCFREnabledForNonCFR = cfrPart11 !== "True" && example.CFREnabled === "NonCFR";
28+
29+
return !isEsignature || isCFREnabledForAll || isCFREnabledForCFROnly || isCFREnabledForNonCFR;
30+
}
31+
2332
function checkIfExampleMatches(example, matches) {
2433
const name = example.ExampleName;
2534
const description = example.ExampleDescription;
@@ -150,10 +159,7 @@ const DS_SEARCH = (function () {
150159
!example.SkipForLanguages ||
151160
!example.SkipForLanguages.toLowerCase().includes("python")
152161
) {
153-
if (element.Name.toLowerCase() !== API_TYPES.ESIGNATURE.toLowerCase() ||
154-
((example.CFREnabled == "AllAccounts") ||
155-
((cfrPart11 == "True") && (example.CFREnabled == "CFROnly")) ||
156-
((cfrPart11 != "True") && (example.CFREnabled == "NonCFR"))))
162+
if (shouldAppendExample(element, example, cfrPart11))
157163
{
158164
$("#filtered_code_examples").append(
159165
"<h4 id=" +
@@ -226,6 +232,7 @@ const DS_SEARCH = (function () {
226232
findCodeExamplesByKeywords,
227233
textCouldNotBeFound,
228234
addCodeExampleToHomepage,
235+
shouldAppendExample,
229236
};
230237
})();
231238

0 commit comments

Comments
 (0)