@@ -346,7 +346,30 @@ <h5 class="card-title"><a :href="documentation['@id']">{{ documentation.name }}<
346346 < h2 > Libraries</ h2 >
347347
348348 < div class ="row ">
349- < div class ="col-md-4 " v-for ="library in libraries ">
349+ < div class ="col-md-4 ">
350+ < div class ="form-group ">
351+ < label for ="librariesSort "> Sort</ label >
352+ < select class ="form-control " id ="librariesSort " v-model ="librariesSort " @change ="updateLibraries ">
353+ < option value =""> </ option >
354+ < option value ="asc "> A-Z</ option >
355+ < option value ="desc "> Z-A</ option >
356+ </ select >
357+ </ div >
358+ </ div >
359+
360+ < div class ="col-md-4 ">
361+ < div class ="form-group ">
362+ < label for ="librariesFilter "> Interface</ label >
363+ < select class ="form-control " id ="librariesFilter " v-model ="librariesFilter " @change ="updateLibraries ">
364+ < option value =""> </ option >
365+ < option v-for ="interface of interfaces " :value ="interface "> {{ interface }}</ option >
366+ </ select >
367+ </ div >
368+ </ div >
369+ </ div >
370+
371+ < div class ="row ">
372+ < div class ="col-md-4 " v-for ="library in libraryList ">
350373 < div class ="card ">
351374 < div class ="card-body ">
352375 < h5 class ="card-title "> < a :href ="library['@id'] "> {{ library.name }}</ a > </ h5 >
@@ -363,22 +386,49 @@ <h5 class="card-title"><a :href="library['@id']">{{ library.name }}</a></h5>
363386 </ div >
364387
365388 < script >
389+ let libraryList = [ ]
390+ let librariesSort = ''
391+ let librariesFilter = ''
392+
366393 const content = JSON . parse ( document . getElementById ( 'content' ) . innerText )
367394
368395 const { specifications, documentations, libraries } = content . breadcrumb . reduce ( ( list , item ) => {
369- list [ item [ '@id' ] . substr ( 1 ) ] = item . breadcrumb
396+ list [ item [ '@id' ] . slice ( 1 ) ] = item . breadcrumb
370397
371398 return list
372399 } , { } )
373400
374- new Vue ( {
401+ const interfaces = [ ...new Set ( libraries . flatMap ( library => library . implements ) ) ] . sort ( )
402+
403+ const app = new Vue ( {
375404 el : '#app' ,
376405 data : {
377406 specifications,
378407 documentations,
379- libraries
408+ libraries,
409+ libraryList
380410 }
381411 } )
412+
413+ function updateLibraries ( ) {
414+ libraryList = libraries . slice ( )
415+
416+ if ( librariesFilter ) {
417+ libraryList = libraryList . filter ( library => library . implements . includes ( librariesFilter ) )
418+ }
419+
420+ if ( librariesSort === 'asc' ) {
421+ libraryList = libraryList . sort ( ( a , b ) => a . name . localeCompare ( b . name ) )
422+ }
423+
424+ if ( librariesSort === 'desc' ) {
425+ libraryList = libraryList . sort ( ( a , b ) => b . name . localeCompare ( a . name ) )
426+ }
427+
428+ app . libraryList = libraryList
429+ }
430+
431+ updateLibraries ( )
382432 </ script >
383433</ body >
384434</ html >
0 commit comments