1XA.component.search.query = (function ($, document) { 2 3 var QueryModel = Backbone.Model.extend({ 4 defaults: { 5 hash: "", 6 hashObj: {} 7 }, 8 initialize: function () { 9 var inst = this, 10 hash = window.location.hash; 11 12 if (hash.length) { 13 this.set({hash: hash}); 14 this.createHashObj(); 15 } 16 }, 17 createHashObj: function () { 18 this.set({hashObj: this.parseHashParameters(this.get("hash"))}); 19 }, 20 parseHashParameters: function (aURL) { 21 if (aURL === null || aURL === "") { 22 return {}; 23 } 24 25 aURL = aURL || window.location.hash; 26 var vars = {}; 27 var hashes = aURL.slice(aURL.indexOf('#') + 1).split('&'); 28 29 hashes = hashes.filter(function(x) { 30 return x != "" 31 }); 32 33 for (var i = 0; i < hashes.length; i++) { 34 var hash = hashes[i].split('='); 35 36 if(hash.length > 1) { 37 vars[decodeURIComponent(hash[0])] = decodeURIComponent(hash[1].replace("+", " ")); 38 } else { 39 vars[decodeURIComponent(hash[0])] = null; 40 } 41 } 42 return vars; 43 }, 44 updateHash: function(newHash, targetUrl) { 45 var inst = this, 46 hashStr = "#", 47 hashObj = this.parseHashParameters(window.location.hash); 48 49 _.each(newHash, function(item, key){ 50 if (item !== "") { 51 hashObj[key] = item; 52 } else { 53 delete hashObj[key]; 54 } 55 56 }); 57 58 if((targetUrl == "#") || (targetUrl == undefined)){ 59 targetUrl = window.location.pathname; 60 } 61 62 var i = 0; 63 _.each(hashObj, function(item, key){ 64 //if (item !== "") { 65 if(i > 0){ 66 hashStr += "&"; 67 } 68 i++; 69 //Fix filter in arabic language and fix by special characters 70 item = unescape(item); 71 item = item.replace(/&/g, "%26"); 72 hashStr += key + "=" + item; 73 //} 74 }); 75 76 Backbone.history.navigate(hashStr, {trigger: true}); 77 78 if (hashStr.length) { 79 this.set({hash: hashStr}); 80 this.createHashObj(); 81 } 82 }, 83 isSignaturePresentInHash: function(hash, signature) { 84 var hashKeys = Object.keys(hash), 85 isSignatureFoundInHash = false; 86 87 for (var len = hashKeys.length, i = 0; i < len; i++) { 88 if (hashKeys[i].startsWith(signature)) { 89 isSignatureFoundInHash = true; 90 break; 91 } 92 } 93 94 return isSignatureFoundInHash; 95 } 96 }); 97 98 return new QueryModel(); 99 100}(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.