diff --git a/styles/style-default.css b/styles/style-default.css index 6875370..1cee6f6 100644 --- a/styles/style-default.css +++ b/styles/style-default.css @@ -55,6 +55,41 @@ a:hover { color:#000; text-decoration: none; } margin: 20px auto; } +.filtered { +display: none; +} + +#filter { +clear:both; +} + +#filter ul { +margin: 0; +padding: 0; +list-style-type: none; +text-align: left; +text-transform:none; +} + +#filter li { +display: inline-block; +padding: .2em 1em; +margin: 2px; +color: black; +background-color: white; +opacity: 0.5; +} + +.filter-include { + border-left:thick solid blue; + opacity: 1; +} + +.filter-exclude { + border-right:thick solid red; + opacity: 1; +} + img { @@ -246,7 +281,6 @@ line-height: 100%; #tool { width:100%; -height:32px; overflow: hidden; } @@ -259,11 +293,6 @@ width: 100%; margin: 3px; } -#tool div, #tool form -{ -height: 32px; -} - .stop select { vertical-align: middle; diff --git a/styles/style-eink.css b/styles/style-eink.css index a3da88e..d1508be 100644 --- a/styles/style-eink.css +++ b/styles/style-eink.css @@ -60,6 +60,43 @@ a:hover { color:#000; text-decoration: none; } margin: 20px auto; } +.filtered { +display: none; +} + +#filter { +clear:both; +} + +#filter ul { +margin: 0; +padding: 0; +list-style-type: none; +text-align: left; +text-transform:none; +font-variant: normal; +} + +#filter li { +display: inline-block; +padding: .2em 1em; +margin: 2px; +color: black; +background-color: #ddd; +opacity: 0.5; +} + +.filter-include { + border-left:thick solid blue; + opacity: 1; +} + +.filter-exclude { + border-right:thick solid red; + opacity: 1; +} + + img { margin:0; @@ -256,7 +293,6 @@ line-height: 100%; #tool { width:100%; -height:32px; overflow: hidden; } diff --git a/templates/default/header.html b/templates/default/header.html index 5c62527..15f3539 100644 --- a/templates/default/header.html +++ b/templates/default/header.html @@ -39,5 +39,9 @@ +
+ +
diff --git a/templates/default/main.html b/templates/default/main.html index 9af16d3..a495b3a 100644 --- a/templates/default/main.html +++ b/templates/default/main.html @@ -33,7 +33,7 @@ {{? entry.book.rating != ""}}{{=entry.book.rating}}{{?}}

{{=it.const.i18n.authorsTitle}} :

{{=htmlEscape (entry.book.authorsName)}}
- {{? entry.book.tagsName != ""}}

{{=it.const.i18n.tagsTitle}} :

{{=htmlEscape (entry.book.tagsName)}}
{{?}} + {{? entry.book.tagsName != ""}}

{{=it.const.i18n.tagsTitle}} :

{{=htmlEscape (entry.book.tagsName)}}
{{?}} {{? entry.book.seriesName != ""}}

{{=it.const.i18n.seriesTitle}} :

{{=htmlEscape (entry.book.seriesName)}}
{{?}} diff --git a/util.js b/util.js index 8f492d7..3ae7758 100644 --- a/util.js +++ b/util.js @@ -1,4 +1,4 @@ -var templatePage, templateBookDetail, templateMain, currentData, before; +var templatePage, templateBookDetail, templateMain, currentData, before, filterList; var cache = new LRUCache(30); @@ -111,8 +111,34 @@ function navigateTo (url) { } } +function doFilter () { + $(".books").removeClass("filtered"); + if (jQuery.isEmptyObject(filterList)) return; + + $(".se").each (function(){ + var taglist = ", " + $(this).text() + ", "; + var toBeFiltered = false; + for (var filter in filterList) { + var onlyThisTag = filterList [filter]; + filter = ', ' + filter + ', '; + var myreg = new RegExp (filter); + if (myreg.test (taglist)) { + if (onlyThisTag === false) { + toBeFiltered = true; + } + } else { + if (onlyThisTag === true) { + toBeFiltered = true; + } + } + } + if (toBeFiltered) $(this).parents (".books").addClass ("filtered"); + }); +} + function updatePage (data) { var result; + filterList = {}; data ["const"] = currentData ["const"]; if (false && $("section").length && currentData.isPaginated == 0 && data.isPaginated == 0) { // Partial update (for now disabled) @@ -133,6 +159,36 @@ function updatePage (data) { if ($.cookie('toolbar') == 1) $("#tool").show (); if (currentData.containsBook == 1) { $("#sortForm").show (); + $("#filter ul").empty (); + $(".se").each (function(){ + var taglist = $(this).text(); + + var tagarray = taglist.split (",") + for (i in tagarray) { + var tag = tagarray [i].replace(/^\s+/g,'').replace(/\s+$/g,''); + if ( $('#filter ul li:contains("' + tag + '")').length == 0 ) { + $("#filter ul").append ("
  • " + tag + "
  • "); + } + } + }); + $("li").click(function(){ + var filter = $(this).text (); + switch ($(this).attr("class")) { + case "filter-include" : + $(this).attr("class", "filter-exclude"); + filterList [filter] = false; + break; + case "filter-exclude" : + $(this).removeClass ("filter-exclude");; + delete filterList [filter];; + break; + default : + $(this).attr("class", "filter-include"); + filterList [filter] = true; + break; + } + doFilter (); + }); } else { $("#sortForm").hide (); }