/* ========================================================================== btnSearch_Click() ========================================================================== */ /** * Event handler for the search button. This conducts three different searches. */ function btnSearch_Click() { // // Hide the results panel. // document.getElementById("js-results").setAttribute("hidden", ""); // // This is done because I don't want users to research and think nothing // happened. // setTimeout(function() { // // Set Button Text // document.getElementById("btnSearch").innerText = "Search Again"; // // Primary search // get_results( "primary", document.getElementById("cmbPrimary").value, document.getElementById("divPrimary"), document.getElementById("lstPrimary") ); // // Secondary search // get_results( "secondary", document.getElementById("cmbSecondary").value, document.getElementById("divSecondary"), document.getElementById("lstSecondary") ); // // Tertiary search // get_results( "tertiary", document.getElementById("cmbTertiary").value, document.getElementById("divTertiary"), document.getElementById("lstTertiary") ); // // Show the results panel. // document.getElementById("js-results").removeAttribute("hidden"); }, 200); } /* ========================================================================== get_results() ========================================================================== */ function get_results(_category, _code, _div_el, _list_el) { // // Set the detail's hidden attribute. // if(_code != "") { _div_el.removeAttribute("hidden"); } else { _div_el.setAttribute("hidden", ""); } // // Set the detail's open attribute. // _div_el.setAttribute("open", ""); // // Fetch the results from the JSON. // if(_code !== "") { mvccObjectTemplate(window.data, _list_el, item => { if(item[_category] == _code) { return ` ${item.name}
`; } } ); } }