879311b7 by Adam Heath

Split applyQueryParameters, into applyQueryString, to allow for outside

code to have a local instance of Solr, and pre-configured the search
terms.
1 parent b0833fc2
...@@ -75,16 +75,20 @@ define(function(require) { ...@@ -75,16 +75,20 @@ define(function(require) {
75 }; 75 };
76 }, 76 },
77 applyQueryParameters: function() { 77 applyQueryParameters: function() {
78 var queryStringMatch = document.location.href.match(/.*\?(.*)/);
79 this.applyQueryString(queryStringMatch ? queryStringMatch[1] : null);
80 },
81 applyQueryString: function(queryString) {
82 console.log('solr: applyQueryString', queryString);
78 var skipOptions = {skipSearch: true}; 83 var skipOptions = {skipSearch: true};
79 var parts = document.location.href.match(/.*\?(.*)/);
80 var facets = this.get('facets'); 84 var facets = this.get('facets');
81 facets.resetParameters(skipOptions); 85 facets.resetParameters(skipOptions);
82 this.get('queryFields').resetParameters(skipOptions); 86 this.get('queryFields').resetParameters(skipOptions);
83 87
84 if (parts) { 88 if (queryString) {
85 var formNameMap = this.get('formNameMap'); 89 var formNameMap = this.get('formNameMap');
86 var pagination = {}; 90 var pagination = {};
87 var keyValueParts = parts[1].split('&'); 91 var keyValueParts = queryString.split('&');
88 _.each(keyValueParts, function(keyValuePart, i) { 92 _.each(keyValueParts, function(keyValuePart, i) {
89 var keyFieldValue = keyValuePart.match(/^([^.]+)(?:\.([^.]+))?=(.*)$/); 93 var keyFieldValue = keyValuePart.match(/^([^.]+)(?:\.([^.]+))?=(.*)$/);
90 if (keyFieldValue) { 94 if (keyFieldValue) {
......