@@ -11,8 +11,13 @@ $(function() {
11
11
. reduce ( function ( lookup , tutorial ) {
12
12
_ ( $ ( tutorial ) . data ( ) . facets ) . each ( function ( val , key ) {
13
13
if ( ! _ ( lookup ) . has ( key ) ) { lookup [ key ] = { } ; }
14
- if ( ! _ ( lookup [ key ] ) . has ( val ) ) { lookup [ key ] [ val ] = [ ] ; }
15
- lookup [ key ] [ val ] . push ( tutorial ) ;
14
+ // We want to be able to have multiple values for vertain
15
+ // facets, so we convert strings to arrays and iterate over each
16
+ if ( _ ( val ) . isString ( ) ) { val = [ val ] ; }
17
+ _ ( val ) . each ( function ( v ) {
18
+ if ( ! _ ( lookup [ key ] ) . has ( v ) ) { lookup [ key ] [ v ] = [ ] ; }
19
+ lookup [ key ] [ v ] . push ( tutorial ) ;
20
+ } ) ;
16
21
} ) ;
17
22
return lookup ;
18
23
} , { } )
@@ -28,10 +33,8 @@ $(function() {
28
33
return filter . name === target . name && filter . value === target . value ;
29
34
} ) ;
30
35
if ( existing_filter ) {
31
- console . log ( "Removing filter: " + existing_filter . name ) ;
32
36
filters = _ ( filters ) . without ( existing_filter ) ;
33
37
} else {
34
- console . log ( "Applying filter: " + target . name ) ;
35
38
filters = _ ( filters ) . reject ( function ( filter ) { return filter . name === target . name ; } ) ;
36
39
filters . push ( target ) ;
37
40
}
@@ -49,13 +52,11 @@ function redraw() {
49
52
50
53
function update_visibility ( ) {
51
54
// Grab all the tutorials for each facet into an array
52
- console . log ( "Calculating all ..." )
53
55
all = _ . chain ( filters ) . map ( function ( filter ) {
54
56
return dict [ filter . name ] [ filter . value ] ;
55
57
} ) . flatten ( ) . value ( ) ;
56
58
57
59
// Only keep the tutorials that are visible
58
- console . log ( "Calculating keep ..." )
59
60
keep = _ ( tutorials ) . select ( function ( tutorial ) {
60
61
return all . length - _ ( all ) . without ( tutorial ) . length === filters . length
61
62
} ) ;
@@ -76,9 +77,12 @@ function update_sidebar() {
76
77
// Initialize the names
77
78
if ( ! _ ( counts ) . has ( key ) ) { counts [ key ] = { } ; }
78
79
// and the values/counts
79
- if ( ! _ ( counts [ key ] ) . has ( val ) ) { counts [ key ] [ val ] = 0 ; }
80
- // then increment the counts
81
- counts [ key ] [ val ] += 1 ;
80
+ if ( _ ( val ) . isString ( ) ) { val = [ val ] ; }
81
+ _ ( val ) . each ( function ( v ) {
82
+ if ( ! _ ( counts [ key ] ) . has ( v ) ) { counts [ key ] [ v ] = 0 ; }
83
+ // then increment the counts
84
+ counts [ key ] [ v ] += 1 ;
85
+ } ) ;
82
86
} ) ;
83
87
return counts ;
84
88
// This is where we're storing the new data
0 commit comments