diff --git a/util.js b/util.js index 3ae7758..ea984e8 100644 --- a/util.js +++ b/util.js @@ -111,6 +111,21 @@ function navigateTo (url) { } } +function getTagList () { + var tagList = {}; + $(".se").each (function(){ + if ($(this).parents (".filtered").length > 0) return; + var taglist = $(this).text(); + + var tagarray = taglist.split (",") + for (i in tagarray) { + var tag = tagarray [i].replace(/^\s+/g,'').replace(/\s+$/g,''); + tagList [tag] = 1; + } + }); + return tagList; +} + function doFilter () { $(".books").removeClass("filtered"); if (jQuery.isEmptyObject(filterList)) return; @@ -134,6 +149,27 @@ function doFilter () { } if (toBeFiltered) $(this).parents (".books").addClass ("filtered"); }); + var tagList = getTagList (); + $("#filter ul li").each (function () { + var text = $(this).text (); + if (isDefined (tagList [text]) || $(this).attr ('class')) { + tagList [text] = 0; + } else { + tagList [text] = -1; + } + }); + for (var tag in tagList) { + var tagValue = tagList [tag]; + if (tagValue == -1) { + $("#filter ul li:contains('" + tag + "')").remove(); + } + if (tagValue == 1) { + $("#filter ul").append ("