Skip to content

Commit

Permalink
CSS updates and leaderboard stats
Browse files Browse the repository at this point in the history
Expanding items on hover
Admin can enable/disable leaderboard stats
  • Loading branch information
aunefyren committed Oct 15, 2022
1 parent 65e8669 commit dd51c32
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 15 deletions.
1 change: 1 addition & 0 deletions config_default.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"get_year_stats_music":true,
"get_year_stats_music_title":"Top artists",
"get_year_stats_leaderboard":true,
"get_year_stats_leaderboard_number":false,
"get_year_stats_leaderboard_title":"Top users",
"get_year_stats_movies_duration_title":"All users combined spent {movie_duration_sum} watching movies.",
"get_year_stats_shows_duration_title":"All users combined spent {show_duration_sum} watching shows.",
Expand Down
1 change: 1 addition & 0 deletions file_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func CreateConfigFile() error {
config.WrapperrCustomize.GetYearStatsShows = true
config.WrapperrCustomize.GetYearStatsMusic = true
config.WrapperrCustomize.GetYearStatsLeaderboard = true
config.WrapperrCustomize.GetYearStatsLeaderboardNumbers = false

err := SaveConfig(&config)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions models.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ type WrapperrCustomize struct {
GetYearStatsMusic bool `json:"get_year_stats_music"`
GetYearStatsMusicTitle string `json:"get_year_stats_music_title"`
GetYearStatsLeaderboard bool `json:"get_year_stats_leaderboard"`
GetYearStatsLeaderboardNumbers bool `json:"get_year_stats_leaderboard_numbers"`
GetYearStatsLeaderboardTitle string `json:"get_year_stats_leaderboard_title"`
GetYearStatsMoviesDurationTitle string `json:"get_year_stats_movies_duration_title"`
GetYearStatsShowsDurationTitle string `json:"get_year_stats_shows_duration_title"`
Expand Down
20 changes: 20 additions & 0 deletions route_statistics.go
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,26 @@ func WrapperrLoopData(user_id int, config *WrapperrConfig, wrapperr_data []Wrapp

wrapperr_reply.YearStats.YearMovies.Message = "All users processed."

// Scrub the data after ordering array
if !config.WrapperrCustomize.GetYearStatsLeaderboardNumbers {
for index, _ := range wrapperr_reply.YearStats.YearUsers.Data.UsersPlays {
wrapperr_reply.YearStats.YearUsers.Data.UsersPlays[index].Duration = 0
wrapperr_reply.YearStats.YearUsers.Data.UsersPlays[index].DurationArtists = 0
wrapperr_reply.YearStats.YearUsers.Data.UsersPlays[index].DurationMovies = 0
wrapperr_reply.YearStats.YearUsers.Data.UsersPlays[index].DurationShows = 0
wrapperr_reply.YearStats.YearUsers.Data.UsersPlays[index].Plays = 0
wrapperr_reply.YearStats.YearUsers.Data.UsersPlays[index].PausedCounter = 0
}
for index, _ := range wrapperr_reply.YearStats.YearUsers.Data.UsersDuration {
wrapperr_reply.YearStats.YearUsers.Data.UsersDuration[index].Duration = 0
wrapperr_reply.YearStats.YearUsers.Data.UsersDuration[index].DurationArtists = 0
wrapperr_reply.YearStats.YearUsers.Data.UsersDuration[index].DurationMovies = 0
wrapperr_reply.YearStats.YearUsers.Data.UsersDuration[index].DurationShows = 0
wrapperr_reply.YearStats.YearUsers.Data.UsersDuration[index].Plays = 0
wrapperr_reply.YearStats.YearUsers.Data.UsersDuration[index].PausedCounter = 0
}
}

} else {
wrapperr_reply.YearStats.YearUsers.Data.UsersDuration = []WrapperrYearUserEntry{}
wrapperr_reply.YearStats.YearUsers.Data.UsersPlays = []WrapperrYearUserEntry{}
Expand Down
12 changes: 12 additions & 0 deletions web/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,15 @@ function set_wrapperr_customization() {
html += '/><br>';
html += '</div>';

html += '<div class="form-group">';
html += '<label for="get_year_stats_leaderboard_numbers" title="Displays the statistics of users on the leaderboard.">Display server-wide leaderboard numbers:<br>';
html += '<input type="checkbox" class="form-control" id="get_year_stats_leaderboard_numbers" ';
if(get_year_stats_leaderboard_numbers) {
html += 'checked="' + get_year_stats_leaderboard_numbers + '" ';
}
html += '/><br>';
html += '</div>';

html += '<div class="form-group newline">';
html += '</div>';

Expand Down Expand Up @@ -1733,6 +1742,7 @@ function set_wrapperr_customization_call() {
get_year_stats_music_title = document.getElementById('get_year_stats_music_title').value;
get_year_stats_music_duration_title = document.getElementById('get_year_stats_music_duration_title').value;
get_year_stats_leaderboard = document.getElementById('get_year_stats_leaderboard').checked;
get_year_stats_leaderboard_numbers = document.getElementById('get_year_stats_leaderboard_numbers').checked;
get_year_stats_leaderboard_title = document.getElementById('get_year_stats_leaderboard_title').value;
get_year_stats_duration_sum_title = document.getElementById('get_year_stats_duration_sum_title').value;
clear_cache = document.getElementById('clear_cache').checked;
Expand Down Expand Up @@ -1838,6 +1848,7 @@ function set_wrapperr_customization_call() {
"get_year_stats_music_title" : get_year_stats_music_title,
"get_year_stats_music_duration_title" : get_year_stats_music_duration_title,
"get_year_stats_leaderboard" : get_year_stats_leaderboard,
"get_year_stats_leaderboard_numbers" : get_year_stats_leaderboard_numbers,
"get_year_stats_leaderboard_title" : get_year_stats_leaderboard_title,
"get_year_stats_duration_sum_title" : get_year_stats_duration_sum_title,
"wrapperr_and" : wrapperr_and,
Expand Down Expand Up @@ -2489,6 +2500,7 @@ function get_config(cookie) {
get_year_stats_music_title = result.data.wrapperr_customize.get_year_stats_music_title;
get_year_stats_music_duration_title = result.data.wrapperr_customize.get_year_stats_music_duration_title;
get_year_stats_leaderboard = result.data.wrapperr_customize.get_year_stats_leaderboard;
get_year_stats_leaderboard_numbers = result.data.wrapperr_customize.get_year_stats_leaderboard_numbers;
get_year_stats_leaderboard_title = result.data.wrapperr_customize.get_year_stats_leaderboard_title;
get_year_stats_duration_sum_title = result.data.wrapperr_customize.get_year_stats_duration_sum_title;

Expand Down
1 change: 1 addition & 0 deletions web/admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ <h1 id='application_name'>Wrapperr Setup</h1>
var get_year_stats_music_title = '';
var get_year_stats_music_duration_title = '';
var get_year_stats_leaderboard = '';
var get_year_stats_leaderboard_number = false;
var get_year_stats_leaderboard_title = '';
var get_year_stats_duration_sum_title = '';

Expand Down
15 changes: 9 additions & 6 deletions web/assets/css/wrapped.css
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,20 @@ img {
.item:hover {
background-color: var(--black) !important;
border-radius: 0.5em;
margin: 0.5em 0;
max-height: none;
}

.item {
padding: 0.5em;
display: flex;
justify-content: space-between;
transition: 1s;
}

.item-expandable {
max-height: 1.25em;
overflow-y: hidden;
}

.gold {
Expand Down Expand Up @@ -338,9 +347,7 @@ img {
text-align: right;
margin: 0.1em;
display: inline-block;
width: 10%;
vertical-align: top;
float: left;
}

.info {
Expand All @@ -355,8 +362,6 @@ img {
text-align: right;
margin: 0.1em;
display: inline-block;
width: 90%;
vertical: center;
text-overflow: ellipsis;
vertical-align: top;
}
Expand All @@ -366,7 +371,6 @@ img {
}

.movie_name {
width: 90%;
text-align: right;
display: inline-block;
margin: 0.1em;
Expand All @@ -376,7 +380,6 @@ img {
}

.info_name {
width: 14em;
text-align: right;
display: inline-block;
margin: 0.1em;
Expand Down
24 changes: 15 additions & 9 deletions web/get_stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,16 +782,22 @@ function top_list_names(array, title, div_id) {
html += "<div class='number'>";
html += i+1 + ". ";
html += "</div>";

html += "<div class='name'>";

html += array[i].user;

if(array[i].duration !== 0 && array[i].plays !== 0) {
var duration_string = seconds_to_time(array[i].duration, true);
html += "<br>"
html += duration_string

html += "<br>"
html += play_plays(array[i].plays)
}

html += "</div>";

if(array[i].user == results.user.name) {
html += "<div class='name you'>";
html += array[i].user;
html += "</div>";
}else {
html += "<div class='name'>";
html += array[i].user;
html += "</div>";
}
html += "</div>";
}
html += "</div>";
Expand Down

0 comments on commit dd51c32

Please sign in to comment.