WebContent/resources/js/sfmain.js
/**
 * Intializes the filter and sort dropdowns based on the hash url values.
 * TODO: Horribly implemented with no generic use of filter or sort dropdown values.
 * Change to use a more efficient and cleaner way to implement this.
 * 
 **/
Intializes the filter and sort dropdowns based on the hash url values.
TODO: Horribly implemented with no generic use of filter or sort dropdown values.
Change to use a more efficient and cleaner way to implement this.
Intializes the filter and sort dropdowns based on the hash url values . TODO : Horribly implemented with no generic use of filter or sort dropdown values . Change to use a more efficient and cleaner way to implement this .
function initFilterSortDropdowns ( filterValue, sortValue ) {
	console.log( "filtervalue " + filterValue );
	console.log( "sortvalue " + sortValue );
	var filterParts = [];
	var hasNeighbourhoodFilter = false;
	var hasDecadeFilter = false;
	if ( filterValue != undefined && filterValue != null && filterValue != "" ) {
		filterParts = filterValue.split( "," );
		$.each( filterParts, function ( index, value ) {
			if ( value != null && value != "" ) {
				var filterPart = [];
				filterPart = value.split( ":" );
				if ( filterPart[ 0 ] == "neighbourhood" ) {
					if ( ( filterPart[ 1 ] != null) ) {
						console.log( "filter part is neighbourhood " + filterPart[ 1 ] );
						hasNeighbourhoodFilter = true;
						$( "#neighbourhoodDropdown .btn:first-child" ).text( filterPart[ 1 ] );
						$( "#neighbourhoodDropdown .btn:first-child" ).val( filterPart[ 1 ] );
					} else {
						$( "#neighbourhoodDropdown .btn:first-child" ).text( "All Neighbourhoods" );
						$( "#neighbourhoodDropdown .btn:first-child" ).val( "All Neighbourhoods" );
					}
				}
				if ( filterPart[ 0 ] == "releaseDecade" ) {
					if ( filterPart[ 1 ] != null) {
						hasDecadeFilter = true;
						console.log( "filter part is decade " + filterPart[ 1 ] );
						$( "#decadeDropdown .btn:first-child" ).text( filterPart[ 1 ] );
						$( "#decadeDropdown .btn:first-child" ).val( filterPart[ 1 ] );
					} else {
						$( "#decadeDropdown .btn:first-child" ).text( "Any Year" );
						$( "#decadeDropdown .btn:first-child" ).val( "Any Year" );
					}
				}
			}
		} );
	}
	else {
		$( "#neighbourhoodDropdown .btn:first-child" ).text( "All Neighbourhoods" );
		$( "#neighbourhoodDropdown .btn:first-child" ).val( "All Neighbourhoods" );
		$( "#decadeDropdown .btn:first-child" ).text( "Any Year" );
		$( "#decadeDropdown .btn:first-child" ).val( "Any Year" );
	}
	if (hasNeighbourhoodFilter == false) {
		$( "#neighbourhoodDropdown .btn:first-child" ).text( "All Neighbourhoods" );
		$( "#neighbourhoodDropdown .btn:first-child" ).val( "All Neighbourhoods" );
	}
	if (hasDecadeFilter == false) {
		$( "#decadeDropdown .btn:first-child" ).text( "Any Year" );
		$( "#decadeDropdown .btn:first-child" ).val( "Any Year" );
	}
	if ( sortValue != undefined && sortValue != null && sortValue != "" ) {
		$( "#sortDropdown .btn:first-child" ).text( sortValue );
		$( "#sortDropdown .btn:first-child" ).val( sortValue );
	} else {
		$( "#sortDropdown .btn:first-child" ).text( "Default (Name)" );
		$( "#sortDropdown .btn:first-child" ).val( "Default (Name)" );
	}
}
function initFilterSortDropdowns ( filterValue , sortValue ) { console . log ( "filtervalue " + filterValue ) ; console . log ( "sortvalue " + sortValue ) ; var filterParts = [ ] ; var hasNeighbourhoodFilter = false ; var hasDecadeFilter = false ; if ( filterValue != undefined && filterValue != null && filterValue != "" ) { filterParts = filterValue . split ( "," ) ; $ . each ( filterParts , function ( index , value ) { if ( value != null && value != "" ) { var filterPart = [ ] ; filterPart = value . split ( ":" ) ; if ( filterPart [ 0 ] == "neighbourhood" ) { if ( ( filterPart [ 1 ] != null ) ) { console . log ( "filter part is neighbourhood " + filterPart [ 1 ] ) ; hasNeighbourhoodFilter = true ; $ ( "#neighbourhoodDropdown .btn:first-child" ) . text ( filterPart [ 1 ] ) ; $ ( "#neighbourhoodDropdown .btn:first-child" ) . val ( filterPart [ 1 ] ) ; } else { $ ( "#neighbourhoodDropdown .btn:first-child" ) . text ( "All Neighbourhoods" ) ; $ ( "#neighbourhoodDropdown .btn:first-child" ) . val ( "All Neighbourhoods" ) ; } } if ( filterPart [ 0 ] == "releaseDecade" ) { if ( filterPart [ 1 ] != null ) { hasDecadeFilter = true ; console . log ( "filter part is decade " + filterPart [ 1 ] ) ; $ ( "#decadeDropdown .btn:first-child" ) . text ( filterPart [ 1 ] ) ; $ ( "#decadeDropdown .btn:first-child" ) . val ( filterPart [ 1 ] ) ; } else { $ ( "#decadeDropdown .btn:first-child" ) . text ( "Any Year" ) ; $ ( "#decadeDropdown .btn:first-child" ) . val ( "Any Year" ) ; } } } } ) ; } else { $ ( "#neighbourhoodDropdown .btn:first-child" ) . text ( "All Neighbourhoods" ) ; $ ( "#neighbourhoodDropdown .btn:first-child" ) . val ( "All Neighbourhoods" ) ; $ ( "#decadeDropdown .btn:first-child" ) . text ( "Any Year" ) ; $ ( "#decadeDropdown .btn:first-child" ) . val ( "Any Year" ) ; } if ( hasNeighbourhoodFilter == false ) { $ ( "#neighbourhoodDropdown .btn:first-child" ) . text ( "All Neighbourhoods" ) ; $ ( "#neighbourhoodDropdown .btn:first-child" ) . val ( "All Neighbourhoods" ) ; } if ( hasDecadeFilter == false ) { $ ( "#decadeDropdown .btn:first-child" ) . text ( "Any Year" ) ; $ ( "#decadeDropdown .btn:first-child" ) . val ( "Any Year" ) ; } if ( sortValue != undefined && sortValue != null && sortValue != "" ) { $ ( "#sortDropdown .btn:first-child" ) . text ( sortValue ) ; $ ( "#sortDropdown .btn:first-child" ) . val ( sortValue ) ; } else { $ ( "#sortDropdown .btn:first-child" ) . text ( "Default (Name)" ) ; $ ( "#sortDropdown .btn:first-child" ) . val ( "Default (Name)" ) ; } }
Intializes the filter and sort dropdowns based on the hash url values.
Intializes the filter and sort dropdowns based on the hash url values .