浏览代码

Icon search now strips ending 's' from search queries.

William Boman 10 年之前
父节点
当前提交
c1768c1f8a
共有 1 个文件被更改,包括 9 次插入4 次删除
  1. 9 4
      src/assets/js/site.js

+ 9 - 4
src/assets/js/site.js

@@ -32,13 +32,18 @@ $(function() {
 
       var resultsCount = 0;
       $icons.each(function() {
-        var show = $(this).attr('data-filter').match(' '+val);
-        if( show ) resultsCount++;
+        var filter = $(this).attr('data-filter')
+        var show = filter.match(' '+val);
+        if (!show) {
+          if (val.slice(-1) === 's') {
+            // Try to be smart. Make plural terms singular.
+            show = filter.match(' '+val.slice(0, -1));
+          }
+        }
+        if (show) resultsCount++;
         $(this).toggle(!!show);
       });
 
-      console.log(resultsCount);
-
       if( resultsCount == 0 && val.length != 0 ) {
         $no_results.find('span').text(val);
         $no_results.show();