summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2015-04-28 14:01:30 +0200
committerLars-Dominik Braun <lars@6xq.net>2015-04-28 14:01:30 +0200
commitd91e09af7d968afddf6f4f963611e0e37b0bbbd5 (patch)
tree758de759b26096f66f814ed2304ce07db91b1b75
parent9b7883b6a60fa8ac7fb2112135f2f0dd8b6a051a (diff)
downloadcomatose-d91e09af7d968afddf6f4f963611e0e37b0bbbd5.tar.gz
comatose-d91e09af7d968afddf6f4f963611e0e37b0bbbd5.tar.bz2
comatose-d91e09af7d968afddf6f4f963611e0e37b0bbbd5.zip
Add simple filter function
-rw-r--r--Main.hs8
-rw-r--r--data/script.js13
-rw-r--r--data/style.css1
3 files changed, 20 insertions, 2 deletions
diff --git a/Main.hs b/Main.hs
index 8d65915..fd18465 100644
--- a/Main.hs
+++ b/Main.hs
@@ -160,10 +160,14 @@ introduction = section_ $ do
protocols :: Database -> Html ()
protocols db = section_ [id_ "protocols"] $ do
h2_ "Protocols"
- div_ [id_ "protosort"] $ do
+ div_ [id_ "protosort", class_ "form-inline"] $ do
+ label_ [for_ "filter"] "Filter"
+ " "
+ input_ [id_ "filter", type_ "text", class_ "form-control"]
+ " "
label_ [for_ "sort"] "Sort by"
" "
- select_ [id_ "sort"] $ do
+ select_ [id_ "sort", class_ "form-control"] $ do
option_ [value_ "name"] "Name"
option_ [value_ "year"] "Year"
forM_ (M.toList $ dalgos db) (protoentry db)
diff --git a/data/script.js b/data/script.js
index 94175b1..997a02e 100644
--- a/data/script.js
+++ b/data/script.js
@@ -18,5 +18,18 @@ $(document).ready (function () {
$('#sort').change (function () {
sortproto ($(this).val ());
});
+ $('#filter').keyup (function () {
+ var search = $(this).val ().toLowerCase ();
+ var items = $('#protocols .protocol');
+ for (var i = 0; i < items.length; i++) {
+ var e = $(items[i]);
+ if (e.data ('name').toLowerCase ().indexOf (search) >= 0) {
+ e.show ();
+ } else {
+ e.hide ();
+ }
+ }
+ });
+ $('#protosort').show ();
sortproto ('name');
});
diff --git a/data/style.css b/data/style.css
index cc65ba2..41b24dd 100644
--- a/data/style.css
+++ b/data/style.css
@@ -1,5 +1,6 @@
#protosort {
text-align: right;
+ display: hidden;
}
.protocol dt {