/** * technical-support.main.js */ var timer; var queryStr; var prodName = ""; var industryStr = ""; var supportSearchCall; var productListCall; String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); }; $(document).ready(function () { $(".loading").hide(); $(".ui-icon").css("cursor","hand").css("cursor","pointer"); initProductBrowser(); initSupportSearch(); $("#techSupportTabs").tabs(); $("#techSupportTabs").show(); }); function initProductBrowser() { initIndustryPicker(); initProductNameInput(); } function initProductNameInput() { $("#filter").hide(); $("#clearProdName").hide(); $(":input[name=productName]").keyup(function(){ if ($(this).val().trim() != prodName) { clearTimeout(timer); prodName = $(this).val().trim(); timer = setTimeout("getProductList()",300); } if ($(this).val().length > 0) $("#clearProdName").show(); else $("#clearProdName").hide(); }); $("#clearProdName").click(function () { $(":input[name=productName]").val(""); $(this).hide(); clearTimeout(timer); prodName = ""; getProductList(); }); } function initIndustryPicker() { $(":input[name=industryPicker]").val(""); $(":input[name=industryPicker]").change(function() { industryStr = $(this).val(); $(":input[name=productName]").val(""); $("#clearProdName").hide(); prodName = ""; getProductList(); }); } function initSupportSearch() { $("#clearSearch").hide(); $(":input[name=query]").keyup(function(){ if ($(this).val().trim() != queryStr && $(this).val().trim().length > 0) { clearTimeout(timer); queryStr = $(this).val().trim(); timer = setTimeout("getSearchResult()",300); } if ($(this).val().length > 0) $("#clearSearch").show(); else $("#clearSearch").hide(); }); $("#clearSearch").click(function () { $(":input[name=query]").val(""); $(this).hide(); }); } function getSearchResult() { if (supportSearchCall) supportSearchCall.abort(); $("#loading-searchsupport").show(); supportSearchCall = $.post("ajax_getSuportSearchResult.jsp", { query: queryStr, supportSearch: true }, function(result) { $("#loading-searchsupport").hide(); $("#searchResult").html(result); } ); } function getProductList() { if (productListCall) productListCall.abort(); if (industryStr != "") { $("#filter").show(); $("#loading-productlist").show(); productListCall = $.get("ajax_getProductList.jsp", { industry: industryStr, name: prodName }, function(data) { var dat = ""; if ($("product",data).length > 0) { $("product",data).each(function () { var entry = ""; var productName = $("name",this).text(); var productDesc = $("desc",this).text(); var productCategory = $("category",this).text(); var productUri = $("uri",this).text(); entry = ""; dat += entry; }); } else { dat = "Sorry, no matching product for your search criteria."; } $("#loading-productlist").hide(); $("#product").html(dat); } ); } else { $("#filter").hide(); $("#product").html("Select an industry to show a list of products then select a product to view the technical support page."); } }