1/** 2 * Provides methods for working searches using Ajax 3 * @module ajax 4 * @param {jQuery} $ Instance of jQuery 5 * @param {Document} document dom document object 6 * @return {ApiModel} list of Api methods for Search Ajax functionality 7*/ 8XA.component.search.ajax = (function ($, document) { 9 var ApiModel, getPrameterByName; 10 11 /** 12 * @name module:ajax.ApiModel 13 * @constructor 14 * @augments Backbone.Model 15 */ 16 ApiModel = Backbone.Model.extend( 17 /** @lends module:ajax.ApiModel.prototype **/ 18 19 { 20 /** 21 * Makes ajax request and calls callback on success 22 * @method 23 * @param {Object} properties properties of ajax call and callback 24 */ 25 getData: function (properties) { 26 var siteName = this.getPrameterByName("sc_site"), 27 url = typeof properties.excludeSiteName !== "undefined" && properties.excludeSiteName 28 ? properties.url 29 : XA.component.search.url.createSiteUrl(properties.url, siteName); 30 Backbone.ajax({ 31 dataType: "json", 32 url: url, 33 success: function (data) { 34 properties.callback(data); 35 } 36 }); 37 }, 38 /** 39 * Gets value of parameter from url 40 * @method 41 * @param {String} name name of parameter that should be taken from url 42 * @param {String} url link from which parameter should be taken 43 * @returns {string} parameter value 44 */ 45 getPrameterByName: function (name, url) { 46 if (!url) url = window.location.href; 47 name = name.replace(/[\[\]]/g, "\\$&"); 48 var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), 49 results = regex.exec(url); 50 if (!results) return null; 51 if (!results[2]) return ''; 52 return decodeURIComponent(results[2].replace(/\+/g, " ")); 53 } 54 }); 55 56 return new ApiModel(); 57 58}(jQuery, document));
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.