mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Added wonky date selector, unused so far
This commit is contained in:
@ -289,6 +289,26 @@ def module_filterselection(keys,time=True,delimit=False):
|
||||
keystr = "?" + urllib.parse.urlencode(retainkeys)
|
||||
|
||||
|
||||
# wonky selector for precise date range
|
||||
|
||||
# fromdate = start_of_scrobbling()
|
||||
# todate = end_of_scrobbling()
|
||||
# if keys.get("since") is not None: fromdate = keys.get("since")
|
||||
# if keys.get("to") is not None: todate = keys.get("to")
|
||||
# if keys.get("in") is not None: fromdate, todate = keys.get("in"), keys.get("in")
|
||||
# fromdate = time_fix(fromdate)
|
||||
# todate = time_fix(todate)
|
||||
# fromdate, todate = time_pad(fromdate,todate,full=True)
|
||||
# fromdate = [str(e) if e>9 else "0" + str(e) for e in fromdate]
|
||||
# todate = [str(e) if e>9 else "0" + str(e) for e in todate]
|
||||
#
|
||||
# html += "<div>"
|
||||
# html += "from <input id='dateselect_from' onchange='datechange()' type='date' value='" + "-".join(fromdate) + "'/> "
|
||||
# html += "to <input id='dateselect_to' onchange='datechange()' type='date' value='" + "-".join(todate) + "'/>"
|
||||
# html += "</div>"
|
||||
|
||||
|
||||
|
||||
html += "<div>"
|
||||
if keys.get("since") == "today" or keys.get("in") == "today":
|
||||
html += "<span class='stat_selector' style='opacity:0.5;'>Today</span>"
|
||||
@ -333,7 +353,7 @@ def module_filterselection(keys,time=True,delimit=False):
|
||||
html += "<a href='" + keystr + "&step=day'><span class='stat_selector'>Daily</span></a>"
|
||||
html += " | "
|
||||
|
||||
if keys.get("step") == "month":
|
||||
if keys.get("step") == "month" or keys.get("step") is None:
|
||||
html += "<span class='stat_selector' style='opacity:0.5;'>Monthly</span>"
|
||||
else:
|
||||
html += "<a href='" + keystr + "&step=month'><span class='stat_selector'>Monthly</span></a>"
|
||||
|
1
images/.gitignore
vendored
1
images/.gitignore
vendored
@ -4,4 +4,3 @@ cached/
|
||||
*.jpeg
|
||||
*.png
|
||||
*.gif
|
||||
!default.jpg
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 6.8 KiB |
@ -10,7 +10,15 @@ def register_scrobbletime(timestamp):
|
||||
if timestamp < FIRST_SCROBBLE:
|
||||
FIRST_SCROBBLE = int(timestamp)
|
||||
|
||||
def start_of_scrobbling():
|
||||
global FIRST_SCROBBLE
|
||||
f = datetime.datetime.utcfromtimestamp(FIRST_SCROBBLE)
|
||||
return [f.year]
|
||||
|
||||
def end_of_scrobbling():
|
||||
global FIRST_SCROBBLE
|
||||
f = datetime.datetime.now()
|
||||
return [f.year]
|
||||
|
||||
|
||||
|
||||
@ -50,12 +58,12 @@ def time_fix(t):
|
||||
return t[:3]
|
||||
|
||||
# makes times the same precision level
|
||||
def time_pad(f,t):
|
||||
def time_pad(f,t,full=False):
|
||||
f,t = time_fix(f), time_fix(t)
|
||||
while len(f) < len(t):
|
||||
while (len(f) < len(t)) or (full and len(f) < 3):
|
||||
if len(f) == 1: f.append(1)
|
||||
elif len(f) == 2: f.append(1)
|
||||
while len(f) > len(t):
|
||||
while (len(f) > len(t)) or (full and len(t) < 3):
|
||||
if len(t) == 1: t.append(12)
|
||||
elif len(t) == 2: t.append(monthrange(*t)[1])
|
||||
|
||||
@ -336,4 +344,3 @@ def _is_past(date,limit):
|
||||
if not date_[1] == limit_[1]:
|
||||
return date_[1] > limit_[1]
|
||||
return (date_[2] > limit_[2])
|
||||
|
||||
|
@ -84,6 +84,7 @@ replacetitle FEMALE PRESIDENT(여자 대통령) Female President
|
||||
# Mamamoo
|
||||
replaceartist Hwa Sa Hwasa
|
||||
replaceartist MAMAMOO Mamamoo
|
||||
replacetitle Egotistic(너나 해) Egotistic
|
||||
|
||||
# Hello Venus
|
||||
replaceartist Hello/Venus Hello Venus
|
||||
|
Can't render this file because it has a wrong number of fields in line 5.
|
@ -26,6 +26,16 @@ a:hover {
|
||||
}
|
||||
|
||||
|
||||
input[type="date"] {
|
||||
background-color:inherit;
|
||||
color:inherit;
|
||||
outline: none;
|
||||
border:0px;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Header (unused)
|
||||
**/
|
||||
|
43
website/javascript/datechange.js
Normal file
43
website/javascript/datechange.js
Normal file
@ -0,0 +1,43 @@
|
||||
function datechange() {
|
||||
|
||||
since = document.getElementById("dateselect_from").value;
|
||||
to = document.getElementById("dateselect_to").value;
|
||||
|
||||
since = since.split("-").join("/")
|
||||
to = to.split("-").join("/")
|
||||
|
||||
//url = window.location.href
|
||||
//var url = document.createElement("a")
|
||||
//url.href = window.location.href
|
||||
//console.log(url.search)
|
||||
|
||||
keys = window.location.search.substring(1).split("&")
|
||||
|
||||
|
||||
var keydict = {};
|
||||
for (var i=0;i<keys.length;i++) {
|
||||
kv = keys[i].split("=");
|
||||
key = kv[0]
|
||||
value = kv[1]
|
||||
keydict[key] = value
|
||||
}
|
||||
|
||||
delete keydict["in"]
|
||||
keydict["since"] = since
|
||||
keydict["to"] = to
|
||||
|
||||
console.log(keydict)
|
||||
|
||||
keys = []
|
||||
Object.keys(keydict).forEach(function(key) {
|
||||
keys.push(key + "=" + keydict[key])
|
||||
});
|
||||
console.log(keys)
|
||||
|
||||
window.location.href = window.location.protocol
|
||||
+ "//" + window.location.hostname
|
||||
+ ":" + window.location.port
|
||||
+ window.location.pathname
|
||||
+ "?" + keys.join("&");
|
||||
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Maloja - Top Artists</title>
|
||||
<script src="javascript/datechange.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -26,6 +26,9 @@ def instructions(keys):
|
||||
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
||||
|
||||
|
||||
replace = {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_ARTISTLIST":html_charts,"KEY_RANGE":limitstring,"KEY_FILTERSELECTOR":html_filterselector}
|
||||
replace = {"KEY_TOPARTIST_IMAGEURL":imgurl,
|
||||
"KEY_ARTISTLIST":html_charts,
|
||||
"KEY_RANGE":limitstring,
|
||||
"KEY_FILTERSELECTOR":html_filterselector}
|
||||
|
||||
return (replace,pushresources)
|
||||
|
Reference in New Issue
Block a user