https://www.nakheel.com/ResourcePackages/NakheelComponents/assets/…/FAQ.js?package=NakheelComponents
1var FAQ = {} || FAQ; 2 3FAQ = { 4 renderMarkup: function (templateId, containerId, data) { 5 var template = document.getElementById(templateId).innerHTML; 6 var html = Mustache.to_html(template, data); 7 $('#' + containerId).html(""); 8 $('#' + containerId).append(html); 9 }, 10 searchInputEnterKeyPress: function () { 11 $('#faqSearch').bind('keypress', function (e) { 12 query = $(this).val(); 13 if (query != "") { 14 if (query.trim() != "" && query != undefined) { 15 if (e.keyCode != 38 && e.keyCode != 40 && e.keyCode != 27) { 16 17 if (e.keyCode == 13) { 18 // when enter is pressed 19 FAQ.updateFaqSearchResult(query); 20 } 21 } 22 } 23 $('#btnFaqClose').show(); 24 $('#btnFaqSearch').hide(); 25 } 26 else { 27 $('#btnFaqClose').hide(); 28 $('#btnFaqSearch').show(); 29 } 30 31 }); 32 }, 33 searchInputKeyPress: function () { 34 var debounceFunction = _.debounce(FAQ.updateFaqSearchResult, 500); 35 36 $("#faqSearch").on("input", function () { 37 var searchText = $(this).val().trim(); 38 39 if (searchText.length >= 3) { 40 debounceFunction(searchText); 41 } else if (searchText.length === 0) { 42 // If the text box becomes empty, show the initial result 43 $("#FaqResult").hide(); 44 $("#categoryListing").show(); 45 $("#NoResult").hide(); 46 } 47 }); 48 }, 49 searchBackSpaceKeyUp: function () { 50 $('#faqSearch').bind('keyup', function (e) { 51 52 if (e.keyCode != 38 && e.keyCode != 40 && e.keyCode != 27) { 53 if (e.keyCode == 8) { 54 query = $(this).val(); 55 if (query == "") { 56 $('#btnFaqClose').hide(); 57 $('#btnFaqSearch').show(); 58 } 59 else { 60 $('#btnFaqClose').show(); 61 $('#btnFaqSearch').hide(); 62 } 63 } 64 } 65 }); 66 }, 67 searchClearInput: function () { 68 $('#btnFaqClose').click(function () { 69 $('#faqSearch').val(""); 70 $('#btnFaqClose').hide(); 71 $('#btnFaqSearch').show(); 72 $("#FaqResult").hide(); 73 $("#categoryListing").show(); 74 $("#NoResult").hide(); 75 }); 76 }, 77 searchInputEnter: function () { 78 $('#btnFaqSearch').click(function () { 79 query = $('#faqSearch').val(); 80 if (query.trim() != "" && query != undefined) { 81 FAQ.updateFaqSearchResult(query); 82 } 83 }); 84 }, 85 updateFaqSearchResult: function (query) { 86 var faqs = FAQ.filteredFaqs(query); 87 FAQ.setFaqMarkup(faqs); 88 }, 89 filteredFaqs: function (query) { 90 var faqs = FAQCollections; 91 if (faqs != null && faqs.length > 0) { 92 query = query.toLowerCase(); 93 var filterFaqs = faqs.filter(x => x.Question.toLowerCase().indexOf(query) > -1) 94 95 return filterFaqs; 96 } 97 return null; 98 }, 99 setFaqMarkup: function (faqs) { 100 101 if (faqs != null && faqs.length > 0) { 102 for (var i = 0; i < faqs.length; i++) { 103 faqs[i].Id = "faq-" + i; 104 } 105 FAQ.renderMarkup("faqTemplate", "accordionMainParentFaq", faqs); 106 107 $("#FaqResult").show(); 108 $("#categoryListing").hide(); 109 $("#NoResult").hide(); 110 } 111 else { 112 $("#FaqResult").hide(); 113 $("#categoryListing").hide(); 114 $("#NoResult").show(); 115 } 116 }, 117 init: function () { 118 FAQ.searchInputEnterKeyPress(); 119 FAQ.searchInputEnter(); 120 FAQ.searchClearInput(); 121 FAQ.searchBackSpaceKeyUp(); 122 FAQ.searchInputKeyPress() 123 } 124} 125$(document).ready(function () { 126 FAQ.init(); 127});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.