/*jslint browser : true, continue : true, devel : true, indent : 2, maxerr : 50, newcap : true, nomen : true, plusplus : true, regexp : true, sloppy : true, vars : false, white : true */ /*global $, app */ app.search = (function() { "use strict"; //---------------- BEGIN MODULE SCOPE VARIABLES -------------- var stateMap = {}, configModule, onSearch, initModule; //----------------- END MODULE SCOPE VARIABLES --------------- //------------------- BEGIN UTILITY METHODS ------------------ //-------------------- END UTILITY METHODS ------------------- //------------------- BEGIN EVENT HANDLERS ------------------- //ONSEARCH // onSearch = function(event) { event.preventDefault(); $.gevent.publish("app-clear-error"); //get form data var query = $("#searchquery").val(); //app.api.get('customer/' + stateMap.id, function (res) { //app.get('/api/search?query=querytext' app.api.get("search?query=" + query, function(res) { if (res.error) { $.gevent.publish("app-show-error", res.msg); return false; } var $appList = $("#rf-list"); $appList.empty(); $.each(res, function(i, obj) { var editUrl = ""; switch (obj.obj) { case "customer": editUrl = "customerEdit/" + obj.id; break; case "site": editUrl = "customerSiteEdit/" + obj.id + "/" + obj.customerId; break; case "purchase": editUrl = "purchaseEdit/" + obj.id + "/" + obj.site_id; break; case "license": editUrl = "licenseView/" + obj.id; break; default: alert("UNKNOWN SEARCH TYPE OBJECT RESULT: " + obj.obj + " WHUPS!"); } $appList.append( '