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

Links to full pages are now adjusted by choices in onpage selector

This commit is contained in:
Krateng 2019-06-17 13:02:06 +02:00
parent e6aa0a25c8
commit f484c768ab
7 changed files with 67 additions and 58 deletions

View File

@ -391,6 +391,7 @@ def time_fix(t):
if isinstance(t,MRangeDescriptor): return t if isinstance(t,MRangeDescriptor): return t
if isinstance(t, str): if isinstance(t, str):
if t in ["alltime"]: return None
tod = datetime.datetime.utcnow() tod = datetime.datetime.utcnow()
months = ["january","february","march","april","may","june","july","august","september","october","november","december"] months = ["january","february","march","april","may","june","july","august","september","october","november","december"]
weekdays = ["sunday","monday","tuesday","wednesday","thursday","friday","saturday"] weekdays = ["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]

View File

@ -27,8 +27,8 @@ LOCAL_IMAGE_ROTATE = 3600 # when multiple images are present locally, how many s
DEFAULT_RANGE_CHARTS_ARTISTS = year DEFAULT_RANGE_CHARTS_ARTISTS = year
DEFAULT_RANGE_CHARTS_TRACKS = year DEFAULT_RANGE_CHARTS_TRACKS = year
# same for pulse view # same for pulse view
# can be days, weeks, months, years # can be day, week, month, year
DEFAULT_RANGE_PULSE = months DEFAULT_STEP_PULSE = month
[Fluff] [Fluff]

View File

@ -33,35 +33,35 @@
<table class="twopart"> <table class="twopart">
<tr> <tr>
<td> <td>
<h2><a href='/pulse?artist=KEY_ENC_ARTISTNAME&step=year&trail=1'>Pulse</a></h2> <h2><a class="stat_link_pulse" href='/pulse?artist=KEY_ENC_ARTISTNAME&trail=1&step=month'>Pulse</a></h2>
<span onclick="showRangeManual('pulse','days')" class="stat_selector_pulse selector_pulse_days">7 days</span> <span onclick="showRangeManual('pulse','day')" class="stat_selector_pulse selector_pulse_day">7 days</span>
| <span onclick="showRangeManual('pulse','weeks')" class="stat_selector_pulse selector_pulse_weeks">12 weeks</span> | <span onclick="showRangeManual('pulse','week')" class="stat_selector_pulse selector_pulse_week">12 weeks</span>
| <span onclick="showRangeManual('pulse','months')" class="stat_selector_pulse selector_pulse_months" style="opacity:0.5;">12 months</span> | <span onclick="showRangeManual('pulse','month')" class="stat_selector_pulse selector_pulse_month" style="opacity:0.5;">12 months</span>
| <span onclick="showRangeManual('pulse','years')" class="stat_selector_pulse selector_pulse_years">10 years</span> | <span onclick="showRangeManual('pulse','year')" class="stat_selector_pulse selector_pulse_year">10 years</span>
<br/><br/> <br/><br/>
<span class="stat_module_pulse pulse_months">KEY_PULSE_MONTHS</span> <span class="stat_module_pulse pulse_month">KEY_PULSE_MONTHS</span>
<span class="stat_module_pulse pulse_days" style="display:none;">KEY_PULSE_DAYS</span> <span class="stat_module_pulse pulse_day" style="display:none;">KEY_PULSE_DAYS</span>
<span class="stat_module_pulse pulse_years" style="display:none;">KEY_PULSE_YEARS</span> <span class="stat_module_pulse pulse_year" style="display:none;">KEY_PULSE_YEARS</span>
<span class="stat_module_pulse pulse_weeks" style="display:none;">KEY_PULSE_WEEKS</span> <span class="stat_module_pulse pulse_week" style="display:none;">KEY_PULSE_WEEKS</span>
</td> </td>
<td> <td>
<!-- We use the same classes / function calls here because we want it to switch together with pulse --> <!-- We use the same classes / function calls here because we want it to switch together with pulse -->
<h2><a href='/performance?artist=KEY_ENC_CREDITEDARTISTNAME&step=year&trail=1'>Performance</a></h2> <h2><a class="stat_link_pulse" href='/performance?artist=KEY_ENC_CREDITEDARTISTNAME&trail=1&step=month'>Performance</a></h2>
<span onclick="showRangeManual('pulse','days')" class="stat_selector_pulse selector_pulse_days">7 days</span> <span onclick="showRangeManual('pulse','day')" class="stat_selector_pulse selector_pulse_day">7 days</span>
| <span onclick="showRangeManual('pulse','weeks')" class="stat_selector_pulse selector_pulse_weeks">12 weeks</span> | <span onclick="showRangeManual('pulse','week')" class="stat_selector_pulse selector_pulse_week">12 weeks</span>
| <span onclick="showRangeManual('pulse','months')" class="stat_selector_pulse selector_pulse_months" style="opacity:0.5;">12 months</span> | <span onclick="showRangeManual('pulse','month')" class="stat_selector_pulse selector_pulse_month" style="opacity:0.5;">12 months</span>
| <span onclick="showRangeManual('pulse','years')" class="stat_selector_pulse selector_pulse_years">10 years</span> | <span onclick="showRangeManual('pulse','year')" class="stat_selector_pulse selector_pulse_year">10 years</span>
<br/><br/> <br/><br/>
<span class="stat_module_pulse pulse_months">KEY_PERFORMANCE_MONTHS</span> <span class="stat_module_pulse pulse_month">KEY_PERFORMANCE_MONTHS</span>
<span class="stat_module_pulse pulse_days" style="display:none;">KEY_PERFORMANCE_DAYS</span> <span class="stat_module_pulse pulse_day" style="display:none;">KEY_PERFORMANCE_DAYS</span>
<span class="stat_module_pulse pulse_years" style="display:none;">KEY_PERFORMANCE_YEARS</span> <span class="stat_module_pulse pulse_year" style="display:none;">KEY_PERFORMANCE_YEARS</span>
<span class="stat_module_pulse pulse_weeks" style="display:none;">KEY_PERFORMANCE_WEEKS</span> <span class="stat_module_pulse pulse_week" style="display:none;">KEY_PERFORMANCE_WEEKS</span>
</td> </td>
</tr> </tr>
</table> </table>

View File

@ -1,29 +1,37 @@
function showRange(identifier,unit) { function showRange(identifier,unit) {
// Make all modules disappear // Make all modules disappear
modules = document.getElementsByClassName("stat_module_" + identifier) modules = document.getElementsByClassName("stat_module_" + identifier);
for (var i=0;i<modules.length;i++) { for (var i=0;i<modules.length;i++) {
//modules[i].setAttribute("style","width:0px;overflow:hidden;") //modules[i].setAttribute("style","width:0px;overflow:hidden;")
// cheesy trick to make the allocated space always whatever the biggest module needs // cheesy trick to make the allocated space always whatever the biggest module needs
// somehow that messes up pulse on the start page tho // somehow that messes up pulse on the start page tho
modules[i].setAttribute("style","display:none;") modules[i].setAttribute("style","display:none;");
} }
// Make requested module appear // Make requested module appear
reactivate = document.getElementsByClassName(identifier + "_" + unit) reactivate = document.getElementsByClassName(identifier + "_" + unit);
for (var i=0;i<reactivate.length;i++) { for (var i=0;i<reactivate.length;i++) {
reactivate[i].setAttribute("style","") reactivate[i].setAttribute("style","");
} }
// Set all selectors to unselected // Set all selectors to unselected
selectors = document.getElementsByClassName("stat_selector_" + identifier) selectors = document.getElementsByClassName("stat_selector_" + identifier);
for (var i=0;i<selectors.length;i++) { for (var i=0;i<selectors.length;i++) {
selectors[i].setAttribute("style","") selectors[i].setAttribute("style","");
} }
// Set the active selector to selected // Set the active selector to selected
reactivate = document.getElementsByClassName("selector_" + identifier + "_" + unit) reactivate = document.getElementsByClassName("selector_" + identifier + "_" + unit);
for (var i=0;i<reactivate.length;i++) { for (var i=0;i<reactivate.length;i++) {
reactivate[i].setAttribute("style","opacity:0.5;") reactivate[i].setAttribute("style","opacity:0.5;");
}
links = document.getElementsByClassName("stat_link_" + identifier);
for (let l of links) {
var a = l.href.split("=");
a.splice(-1);
a.push(unit);
l.href = a.join("=");
} }
} }

View File

@ -20,7 +20,7 @@
</div>--> </div>-->
<h1><a href="/charts_artists?max=50">Top Artists</a></h1> <h1><a class="stat_link_topartists" href="/charts_artists?max=50&in=alltime">Top Artists</a></h1>
<!--All Time | This Year | This Month | This Week--> <!--All Time | This Year | This Month | This Week-->
@ -40,7 +40,7 @@
<h1><a href="/charts_tracks?max=50">Top Tracks</a></h1> <h1><a class="stat_link_toptracks" href="/charts_tracks?max=50&in=alltime">Top Tracks</a></h1>
<span onclick="showRange('toptracks','week')" class="stat_selector_toptracks selector_toptracks_week">This Week</span> <span onclick="showRange('toptracks','week')" class="stat_selector_toptracks selector_toptracks_week">This Week</span>
@ -75,7 +75,7 @@
<br/> <br/>
<h1><a href="/pulse?step=month&trail=1">Pulse</a></h1> <h1><a class="stat_link_pulse" href="/pulse?trail=1&step=month">Pulse</a></h1>
<!-- <!--
<a href="/pulse?step=day&trail=1">Days</a> <a href="/pulse?step=day&trail=1">Days</a>
<a href="/pulse?step=week&trail=1">Weeks</a> <a href="/pulse?step=week&trail=1">Weeks</a>
@ -83,10 +83,10 @@
<a href="/pulse?step=year&trail=1">Years</a> <a href="/pulse?step=year&trail=1">Years</a>
--> -->
<span onclick="showRangeManual('pulse','days')" class="stat_selector_pulse selector_pulse_days">7 days</span> <span onclick="showRangeManual('pulse','day')" class="stat_selector_pulse selector_pulse_day">7 days</span>
| <span onclick="showRangeManual('pulse','weeks')" class="stat_selector_pulse selector_pulse_weeks">12 weeks</span> | <span onclick="showRangeManual('pulse','week')" class="stat_selector_pulse selector_pulse_week">12 weeks</span>
| <span onclick="showRangeManual('pulse','months')" class="stat_selector_pulse selector_pulse_months" style="opacity:0.5;">12 months</span> | <span onclick="showRangeManual('pulse','month')" class="stat_selector_pulse selector_pulse_month" style="opacity:0.5;">12 months</span>
| <span onclick="showRangeManual('pulse','years')" class="stat_selector_pulse selector_pulse_years">10 years</span> | <span onclick="showRangeManual('pulse','year')" class="stat_selector_pulse selector_pulse_year">10 years</span>
<!-- <!--
### this is for extra views of the current canonical week / month / year ### this is for extra views of the current canonical week / month / year
<br/> <br/>
@ -96,10 +96,10 @@
--> -->
<br/><br/> <br/><br/>
<span class="stat_module_pulse pulse_months">KEY_PULSE_MONTHS</span> <span class="stat_module_pulse pulse_month">KEY_PULSE_MONTHS</span>
<span class="stat_module_pulse pulse_days" style="display:none;">KEY_PULSE_DAYS</span> <span class="stat_module_pulse pulse_day" style="display:none;">KEY_PULSE_DAYS</span>
<span class="stat_module_pulse pulse_years" style="display:none;">KEY_PULSE_YEARS</span> <span class="stat_module_pulse pulse_year" style="display:none;">KEY_PULSE_YEARS</span>
<span class="stat_module_pulse pulse_weeks" style="display:none;">KEY_PULSE_WEEKS</span> <span class="stat_module_pulse pulse_week" style="display:none;">KEY_PULSE_WEEKS</span>
<!-- <!--
<span class="stat_module_pulse pulse_week" style="display:none;">KEY_PULSE_WEEK</span> <span class="stat_module_pulse pulse_week" style="display:none;">KEY_PULSE_WEEK</span>
<span class="stat_module_pulse pulse_month" style="display:none;">KEY_PULSE_MONTH</span> <span class="stat_module_pulse pulse_month" style="display:none;">KEY_PULSE_MONTH</span>

View File

@ -12,7 +12,7 @@ def instructions(keys):
# commands to execute on load for default ranges # commands to execute on load for default ranges
js_command = "showRange('topartists','" + get_settings("DEFAULT_RANGE_CHARTS_ARTISTS") + "');" js_command = "showRange('topartists','" + get_settings("DEFAULT_RANGE_CHARTS_ARTISTS") + "');"
js_command += "showRange('toptracks','" + get_settings("DEFAULT_RANGE_CHARTS_TRACKS") + "');" js_command += "showRange('toptracks','" + get_settings("DEFAULT_RANGE_CHARTS_TRACKS") + "');"
js_command += "showRange('pulse','" + get_settings("DEFAULT_RANGE_PULSE") + "');" js_command += "showRange('pulse','" + get_settings("DEFAULT_STEP_PULSE") + "');"
clock() clock()

View File

@ -30,32 +30,32 @@
<table class="twopart"> <table class="twopart">
<tr> <tr>
<td> <td>
<h2><a href='/pulse?KEY_SCROBBLELINK&step=year&trail=1'>Pulse</a></h2> <h2><a class="stat_link_pulse" href='/pulse?KEY_SCROBBLELINK&trail=1&step=month'>Pulse</a></h2>
<span onclick="showRangeManual('pulse','days')" class="stat_selector_pulse selector_pulse_days">7 days</span> <span onclick="showRangeManual('pulse','day')" class="stat_selector_pulse selector_pulse_day">7 days</span>
| <span onclick="showRangeManual('pulse','weeks')" class="stat_selector_pulse selector_pulse_weeks">12 weeks</span> | <span onclick="showRangeManual('pulse','week')" class="stat_selector_pulse selector_pulse_week">12 weeks</span>
| <span onclick="showRangeManual('pulse','months')" class="stat_selector_pulse selector_pulse_months" style="opacity:0.5;">12 months</span> | <span onclick="showRangeManual('pulse','month')" class="stat_selector_pulse selector_pulse_month" style="opacity:0.5;">12 months</span>
| <span onclick="showRangeManual('pulse','years')" class="stat_selector_pulse selector_pulse_years">10 years</span> | <span onclick="showRangeManual('pulse','year')" class="stat_selector_pulse selector_pulse_year">10 years</span>
<br/><br/> <br/><br/>
<span class="stat_module_pulse pulse_months">KEY_PULSE_MONTHS</span> <span class="stat_module_pulse pulse_month">KEY_PULSE_MONTHS</span>
<span class="stat_module_pulse pulse_days" style="display:none;">KEY_PULSE_DAYS</span> <span class="stat_module_pulse pulse_day" style="display:none;">KEY_PULSE_DAYS</span>
<span class="stat_module_pulse pulse_years" style="display:none;">KEY_PULSE_YEARS</span> <span class="stat_module_pulse pulse_year" style="display:none;">KEY_PULSE_YEARS</span>
<span class="stat_module_pulse pulse_weeks" style="display:none;">KEY_PULSE_WEEKS</span> <span class="stat_module_pulse pulse_week" style="display:none;">KEY_PULSE_WEEKS</span>
</td> </td>
<td> <td>
<h2><a href='/performance?KEY_SCROBBLELINK&step=year&trail=1'>Performance</a></h2> <h2><a class="stat_link_pulse" href='/performance?KEY_SCROBBLELINK&trail=1&step=month'>Performance</a></h2>
<span onclick="showRangeManual('pulse','days')" class="stat_selector_pulse selector_pulse_days">7 days</span> <span onclick="showRangeManual('pulse','day')" class="stat_selector_pulse selector_pulse_day">7 days</span>
| <span onclick="showRangeManual('pulse','weeks')" class="stat_selector_pulse selector_pulse_weeks">12 weeks</span> | <span onclick="showRangeManual('pulse','week')" class="stat_selector_pulse selector_pulse_week">12 weeks</span>
| <span onclick="showRangeManual('pulse','months')" class="stat_selector_pulse selector_pulse_months" style="opacity:0.5;">12 months</span> | <span onclick="showRangeManual('pulse','month')" class="stat_selector_pulse selector_pulse_month" style="opacity:0.5;">12 months</span>
| <span onclick="showRangeManual('pulse','years')" class="stat_selector_pulse selector_pulse_years">10 years</span> | <span onclick="showRangeManual('pulse','year')" class="stat_selector_pulse selector_pulse_year">10 years</span>
<br/><br/> <br/><br/>
<span class="stat_module_pulse pulse_months">KEY_PERFORMANCE_MONTHS</span> <span class="stat_module_pulse pulse_month">KEY_PERFORMANCE_MONTHS</span>
<span class="stat_module_pulse pulse_days" style="display:none;">KEY_PERFORMANCE_DAYS</span> <span class="stat_module_pulse pulse_day" style="display:none;">KEY_PERFORMANCE_DAYS</span>
<span class="stat_module_pulse pulse_years" style="display:none;">KEY_PERFORMANCE_YEARS</span> <span class="stat_module_pulse pulse_year" style="display:none;">KEY_PERFORMANCE_YEARS</span>
<span class="stat_module_pulse pulse_weeks" style="display:none;">KEY_PERFORMANCE_WEEKS</span> <span class="stat_module_pulse pulse_week" style="display:none;">KEY_PERFORMANCE_WEEKS</span>
</td> </td>
</tr> </tr>
</table> </table>