src/main/webapp/js/singlepage.js
/**
	 * Encodes search parameters into a page url as understood by fromPageUrl().
	 * N.B. we assume we're mounted under /<contextRoot>/<corpus>/search/[hits|docs][/]?query=...
	 * The contextRoot can be anything, even multiple segments (due to reverse proxy, different WAR deploy path, etc)
	 * But we assume the /search/ part still exists.
	 *
	 * Removes any empty strings, arrays, null, undefineds prior to conversion, to shorten the resulting query string.
	 *
	 * @param {SearchParameters} searchParams the search parameters
	 * @returns the query string, beginning with ?, or an empty string when no searchParams with a proper value
	 */
Encodes search parameters into a page url as understood by fromPageUrl().

Removes any empty strings, arrays, null, undefineds prior to conversion, to shorten the resulting query string.

@param {SearchParameters} searchParams the search parameters
@returns the query string, beginning with ?, or an empty string when no searchParams with a proper value
Encodes search parameters into a page url as understood by fromPageUrl () . Removes any empty strings arrays null undefineds prior to conversion to shorten the resulting query string . @param { SearchParameters } searchParams the search parameters @returns the query string beginning with ? or an empty string when no searchParams with a proper value
function toPageUrl(searchParams) {
		var operation = searchParams && searchParams.operation; 
		searchParams = SINGLEPAGE.BLS.getBlsParam(searchParams);
		var uri = new URI();
		var paths = uri.segmentCoded();
		var basePath = paths.slice(0, paths.lastIndexOf('search')+1);
		if (searchParams == null) {
			return uri.directory(basePath).search(null).toString();
		}
		var modifiedParams = {};
		$.each(searchParams, function(key, value) {
			if (value == null)
				return true;
			if (value.length === 0)
				return true;
			modifiedParams[key] = value;
		});
		return uri.segmentCoded(basePath).segmentCoded(operation).search(searchParams).toString();
	}
function toPageUrl ( searchParams ) { var operation = searchParams && searchParams . operation ; searchParams = SINGLEPAGE . BLS . getBlsParam ( searchParams ) ; var uri = new URI ( ) ; var paths = uri . segmentCoded ( ) ; var basePath = paths . slice ( 0 , paths . lastIndexOf ( 'search' ) + 1 ) ; if ( searchParams == null ) { return uri . directory ( basePath ) . search ( null ) . toString ( ) ; } var modifiedParams = { } ; $ . each ( searchParams , function ( key , value ) { if ( value == null ) return true ; if ( value . length === 0 ) return true ; modifiedParams [ key ] = value ; } ) ; return uri . segmentCoded ( basePath ) . segmentCoded ( operation ) . search ( searchParams ) . toString ( ) ; }
Encodes search parameters into a page url as understood by fromPageUrl().
Encodes search parameters into a page url as understood by fromPageUrl () .
// store, as blsParams doesn't contain it: 'hits' or 'docs' or undefined // basePath now contains our url path, up to and including /search/ // If we're not searching, return a bare url pointing to /search/ // remove null, undefined, empty strings and empty arrays from our query params // Append the operation, query params, etc, and return.