1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Added different pulses on start page

This commit is contained in:
Krateng
2019-03-03 13:38:53 +01:00
parent 2468b8d706
commit 1809da38e6
4 changed files with 93 additions and 158 deletions

View File

@@ -109,6 +109,11 @@ a {
span.stat_selector_pulse {
cursor:pointer;
}
/*
**
**

View File

@@ -5,8 +5,27 @@
<meta charset="UTF-8" />
<title>Maloja</title>
<link rel="stylesheet" href="maloja.css" />
<script>
function showPulse(unit) {
modules = document.getElementsByClassName("stat_module_pulse")
for (var i=0;i<modules.length;i++) {
modules[i].setAttribute("style","display:none;")
}
document.getElementById("pulse_" + unit).setAttribute("style","")
selectors = document.getElementsByClassName("stat_selector_pulse")
for (var i=0;i<selectors.length;i++) {
selectors[i].setAttribute("style","")
}
document.getElementById("selector_pulse_" + unit).setAttribute("style","opacity:0.5;")
}
</script>
</head>
<body>
<h1><a href="/topartists?max=50">Top Artists</a></h1>
<table class="tiles_top">
@@ -117,7 +136,7 @@
<span class="stats">All Time</span> KEY_SCROBBLES_TOTAL
<br/><br/>
KEY_SCROBBLES
<span class="stat_module">KEY_SCROBBLES</span>
<br/>
@@ -130,10 +149,18 @@
<a href="/pulse?step=month&trail=1">Months</a>
<a href="/pulse?step=year&trail=1">Years</a>
-->
<span onclick="showPulse('days')" class="stat_selector_pulse" id="selector_pulse_days">7 days</span>
| <span onclick="showPulse('weeks')" class="stat_selector_pulse" id="selector_pulse_weeks">12 weeks</span>
| <span onclick="showPulse('months')" class="stat_selector_pulse" id="selector_pulse_months" style="opacity:0.5;">12 months</span>
| <span onclick="showPulse('years')" class="stat_selector_pulse" id="selector_pulse_years">10 years</span>
<br/><br/>
KEY_PULSE
<span class="stat_module_pulse" id="pulse_months">KEY_PULSE_MONTHS</span>
<span class="stat_module_pulse" id="pulse_days" style="display:none;">KEY_PULSE_DAYS</span>
<span class="stat_module_pulse" id="pulse_years" style="display:none;">KEY_PULSE_YEARS</span>
<span class="stat_module_pulse" id="pulse_weeks" style="display:none;">KEY_PULSE_WEEKS</span>
</div>
@@ -142,4 +169,6 @@
</div>
</body>
</html>

View File

@@ -1,5 +1,5 @@
import urllib
from datetime import datetime
from datetime import datetime, timedelta
import database
from htmlmodules import module_scrobblelist, module_pulse
@@ -49,14 +49,25 @@ def instructions(keys):
# get pulse
dt = datetime.utcnow()
dtl = [dt.year-1,dt.month+1]
if dtl[1] > 12: dtl = [dtl[0]+1,dtl[1]-12]
dts = "/".join([str(e) for e in dtl])
first_month = [dt.year-1,dt.month+1]
dt_firstweek = dt - timedelta(11*7) - timedelta((6-dt.weekday()))
first_week = [dt_firstweek.year,dt_firstweek.month,dt_firstweek.day]
dt_firstday = dt - timedelta(6)
first_day = [dt_firstday.year,dt_firstday.month,dt_firstday.day]
first_year = [dt.year - 9]
if first_month[1] > 12: first_month = [first_month[0]+1,first_month[1]-12]
#while first_week[2]
#first_month = "/".join([str(e) for e in first_month])
# this is literally the ugliest piece of code i have written in my entire feckin life
# good lord
html_pulse = module_pulse(max_=12,since=dts,step="month",trail=1)
html_pulse_days = module_pulse(max_=7,since=first_day,step="day",trail=1)
html_pulse_weeks = module_pulse(max_=12,since=first_week,step="week",trail=1)
html_pulse_months = module_pulse(max_=12,since=first_month,step="month",trail=1)
html_pulse_years = module_pulse(max_=10,since=first_year,step="year",trail=1)
pushresources = [{"file":img,"type":"image"} for img in artistimages + trackimages] #can't push scrobble images as we don't get them from the module function, need to think about that
@@ -66,7 +77,7 @@ def instructions(keys):
#"KEY_SCROBBLE_TIME":scrobbletimes,"KEY_SCROBBLE_ARTISTS":scrobbleartists,"KEY_SCROBBLE_TITLE":scrobbletracklinks,"KEY_SCROBBLE_IMAGE":scrobbleimages,
"KEY_SCROBBLES":html_scrobbles,
#"KEY_PULSE_TERM":pulse_rangedescs,"KEY_PULSE_AMOUNT":pulse_amounts,"KEY_PULSE_BAR":pulse_bars
"KEY_PULSE":html_pulse
"KEY_PULSE_MONTHS":html_pulse_months,"KEY_PULSE_YEARS":html_pulse_years,"KEY_PULSE_DAYS":html_pulse_days,"KEY_PULSE_WEEKS":html_pulse_weeks
}
return (replace,pushresources)