summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Main.hs20
-rw-r--r--data/script.js30
2 files changed, 33 insertions, 17 deletions
diff --git a/Main.hs b/Main.hs
index 010dba7..5ec3915 100644
--- a/Main.hs
+++ b/Main.hs
@@ -153,14 +153,14 @@ protofeatures :: Database -> Protocol -> Html ()
protofeatures _ p | (M.size $ pfeatures p) == 0 = mempty
protofeatures db p = do
dt_ "Features"
- dd_ $ ul_ [class_ "features"] $ forM_ (sort $ M.keys $ pfeatures p) (\x -> li_ $ toHtml $ maybe ("" :: String) fname $ M.lookup x (dfeatures db))
+ dd_ $ ul_ [class_ "features"] $ forM_ (sort $ M.keys $ pfeatures p) (\x -> li_ [data_ "id" (T.pack x)] $ toHtml $ maybe ("" :: String) fname $ M.lookup x (dfeatures db))
-- |List of protocol publications
protopapers :: [T] -> Html ()
protopapers pubs | length pubs == 0 = mempty
protopapers pubs = do
dt_ "Published in"
- dd_ $ if length pubs == 1
+ dd_ [class_ "ref"] $ if length pubs == 1
then p_ $ bibentry $ head pubs
else ol_ $ forM_ pubs (li_ . bibentry)
@@ -194,16 +194,12 @@ protoentry db (ident, p) =
section_ [
id_ $ T.pack ident
, class_ "protocol"
- , data_ "name" (T.pack $ pname p)
- , data_ "longname" (maybe "" T.pack $ plongname p)
- , data_ "author" (maybe "" T.pack $ field "author")
- , data_ "year" (maybe "" T.pack $ field "year")
, data_ "rank" (T.pack $ show $ prank p)
] $ do
- h3_ $ do
- a_ [href_ (T.pack $ '#':ident), title_ "permalink", class_ "permalink"] $ toHtml $ pname p
+ h3_ [class_ "name"] $ do
+ a_ [href_ (T.pack $ '#':ident), title_ "permalink"] $ toHtml $ pname p
" "
- maybe "" (small_ . toHtml) $ plongname p
+ maybe "" (small_ [class_ "longname"] . toHtml) $ plongname p
dl_ $ do
protopapers pubs
protodesc p
@@ -226,11 +222,11 @@ bibentryurl bib = safeHead $ catMaybes [doi, url]
bibentry :: E.T -> Html ()
bibentry bib = do
let fields = E.fields bib
- a_ [href_ $ T.pack $ maybe "" id $ bibentryurl bib] $ maybeToHtml $ lookup "title" fields
+ a_ [href_ $ T.pack $ maybe "" id $ bibentryurl bib, class_ "title"] $ maybeToHtml $ lookup "title" fields
", "
- maybeToHtml $ lookup "author" fields
+ span_ [class_ "author"] $ maybeToHtml $ lookup "author" fields
", "
- maybeToHtml $ lookup "year" fields
+ span_ [class_ "year"] $ maybeToHtml $ lookup "year" fields
-- | References section
references :: [E.T] -> Html ()
diff --git a/data/script.js b/data/script.js
index 84cb562..43f2d05 100644
--- a/data/script.js
+++ b/data/script.js
@@ -9,15 +9,35 @@
(function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this);
$(document).ready (function () {
+ var protocache = {};
+
+ function extract (n) {
+ var e = protocache[n.attr ('id')];
+ if (e) {
+ return e;
+ }
+ e = {
+ 'name': n.children ('.name').first ().text (),
+ 'rank': parseFloat (n.data ('rank')),
+ }
+ var year = n.find ('dl dd.ref * .year').first ();
+ if (year.length == 1) {
+ e['year'] = parseInt (year.text ());
+ } else {
+ e['year'] = 0;
+ }
+
+ protocache[n.attr ('id')] = e;
+ return e;
+ }
+
function sortproto (by) {
var protolist = $('#protocols');
var items = protolist.children ('.protocol');
items.detach ().sort (function (nodeA, nodeB) {
- var a = $(nodeA).data (by);
- var b = $(nodeB).data (by);
+ var a = extract ($(nodeA))[by];
+ var b = extract ($(nodeB))[by];
if (by == 'rank' || by == 'year') {
- a = parseFloat (a);
- b = parseFloat (b);
return a > b ? 1 : (a < b ? -1 : 0);
} else {
return a.localeCompare (b);
@@ -30,7 +50,7 @@ $(document).ready (function () {
var items = $('#protocols .protocol');
for (var i = 0; i < items.length; i++) {
var e = $(items[i]);
- var val = e.data ('name') + ' ' + e.data ('longname') + ' ' + e.data ('author');
+ var val = extract (e)['name'];
if (val.toLowerCase ().indexOf (search) >= 0) {
e.show ();
} else {