diff --git a/htmlmodules.py b/htmlmodules.py index a611354..2d6753f 100644 --- a/htmlmodules.py +++ b/htmlmodules.py @@ -569,6 +569,7 @@ def module_paginate(page,pages,perpage,**keys): def module_filterselection(keys,time=True,delimit=False): filterkeys, timekeys, delimitkeys, extrakeys = uri_to_internal(keys) + internalkeys = {**filterkeys,**timekeys,**delimitkeys,**extrakeys} # drop keys that are not relevant so they don't clutter the URI if not time: timekeys = {} @@ -581,7 +582,6 @@ def module_filterselection(keys,time=True,delimit=False): # all other keys that will not be changed by clicking another filter unchangedkeys = internal_to_uri({**filterkeys,**delimitkeys,**extrakeys}) - # wonky selector for precise date range # fromdate = start_of_scrobbling() @@ -616,82 +616,56 @@ def module_filterselection(keys,time=True,delimit=False): nextrange = timekeys.get("timerange").next(1) html += "" + nextrange.desc() + "" - html += "" - - # predefined ranges - delimit_ranges = { - "Today":today(), - "This Week":thisweek(), - "This Month":thismonth(), - "This Year":thisyear(), - "All Time":alltime() + categories = [ + { + "active":time, + "options":{ + "Today":{"timerange":today()}, + "This Week":{"timerange":thisweek()}, + "This Month":{"timerange":thismonth()}, + "This Year":{"timerange":thisyear()}, + "All Time":{"timerange":alltime()} + } + }, + { + "active":delimit, + "options":{ + "Daily":{"step":"day","stepn":1}, + "Weekly":{"step":"week","stepn":1}, + "Fortnightly":{"step":"week","stepn":2}, + "Monthly":{"step":"month","stepn":1}, + "Quarterly":{"step":"month","stepn":3}, + "Yearly":{"step":"year","stepn":1} + } + }, + { + "active":delimit, + "options":{ + "Standard":{"trail":1}, + "Trailing":{"trail":2}, + "Long Trailing":{"trail":3}, + "Inert":{"trail":10}, + "Cumulative":{"trail":math.inf} + } } - optionlist = [] - for option in delimit_ranges: - value = delimit_ranges[option] - link = "?" + compose_querystring(unchangedkeys,internal_to_uri({"timerange":value})) + ] - if timekeys.get("timerange") == value: - optionlist.append("" + option + "") - else: - optionlist.append("" + option + "") + for c in categories: - html += "