";
}
document.getElementById("search_results").innerHTML += text;
}
function oldest_movie(array, functions_data) {
var html = "";
html += "
";
html += "
";
html += functions_data.get_user_movie_stats_oldest_title.replaceAll('{movie_title}', '' + array.title + " (" + array.year + ")");
html += ' ';
html += ' ';
if(array.year < 1950) {
html += functions_data.get_user_movie_stats_oldest_subtitle_pre_1950;
} else if(array.year < 1975) {
html += functions_data.get_user_movie_stats_oldest_subtitle_pre_1975;
} else if(array.year < 2000) {
html += functions_data.get_user_movie_stats_oldest_subtitle_pre_2000;
} else {
html += functions_data.get_user_movie_stats_oldest_subtitle;
}
html += ' ';
html += "
";
html += "
";
return html;
}
function oldest_album(album, functions_data) {
var html = "";
html += "
";
html += "
";
html += functions_data.get_user_music_stats_oldest_album_title.replaceAll('{album_title}', '' + album.parent_title + " (" + album.year + ")").replaceAll('{album_artist}', album.grandparent_title);
html += "
";
html += functions_data.get_user_music_stats_oldest_album_subtitle;
html += ' ';
html += "
";
html += "
";
return html;
}
function completion_movie(user_movie_finishing_percent, single, functions_data) {
var html = "";
html += "
";
html += "
";
var str = JSON.stringify(user_movie_finishing_percent);
if(str.includes('.')) {
var percent = str.split('.');
percent = percent[0] + '.' + percent[1].slice(0, 2);
} else {
var percent = str;
}
if(!single) {
html += "" + functions_data.get_user_movie_stats_movie_completion_title_plural.replaceAll('{movie_finish_percent}', percent) + "";
} else {
html += "" + functions_data.get_user_movie_stats_movie_completion_title.replaceAll('{movie_finish_percent}', percent) + "";
}
if(user_movie_finishing_percent >= 90.0) {
html += '';
} else {
html += '
';
}
html += functions_data.get_user_movie_stats_movie_completion_subtitle;
html += "
";
html += "
";
return html;
}
function paused_movie(array, single, functions_data) {
var html = "";
html += "
";
if(array.paused_counter > 0) {
var pause_time = seconds_to_time(array.paused_counter, false);
if(!single) {
html += "
";
html += functions_data.get_user_movie_stats_pause_title.replaceAll('{movie_title}', '' + array.title + '' + ' (' + array.year + ')');
html += " ";
html += " ";
html += functions_data.get_user_movie_stats_pause_subtitle.replaceAll('{pause_duration}', pause_time);
html += "
";
} else {
html += "
";
html += functions_data.get_user_movie_stats_pause_title_one;
html += " ";
html += " ";
html += functions_data.get_user_movie_stats_pause_subtitle_one.replaceAll('{pause_duration}', pause_time);
html += "
";
}
} else {
html += "
";
html += '' + functions_data.get_user_movie_stats_pause_title_none + '';
html += ' ';
html += " ";
html += functions_data.get_user_movie_stats_pause_subtitle_none;
html += "
";
}
html += "
";
return html;
}
function load_showbuddy(buddy_object, top_show, functions_data) {
var html = "";
html += "
";
html += "
";
if(!buddy_object.error) {
if(!buddy_object.buddy_found) {
html += functions_data.get_user_show_stats_buddy_title_none.replaceAll('{top_show_title}', '' + top_show.grandparent_title + '');
html += '
';
html += functions_data.get_user_show_stats_buddy_subtitle_none;
} else {
html += functions_data.get_user_show_stats_buddy_title.replaceAll('{top_show_title}', '' + top_show.grandparent_title + '').replaceAll('{buddy_username}', buddy_object.buddy_name);
var combined = parseInt(top_show.duration) + parseInt(buddy_object.buddy_duration);
var combined_2 = seconds_to_time(combined);
html += '';
html += functions_data.get_user_show_stats_buddy_subtitle.replaceAll('{buddy_duration_sum}', combined_2).replaceAll('{top_show_title}', top_show.grandparent_title);
}
}
html += "
";
html += "
";
return html;
}
function load_longest_episode(array, functions_data) {
var html = "";
html += "
";
html += "
";
html += functions_data.get_user_show_stats_most_played_title.replaceAll('{show_episode}', '' + array.title + '').replaceAll('{show_title}', array.grandparent_title);
html += '
';
html += functions_data.get_user_show_stats_most_played_subtitle.replaceAll('{episode_play_sum}', play_plays(array.plays)).replaceAll('{episode_duration_sum}', seconds_to_time(array.duration, false));
html += "
";
html += "
";
return html;
}
function you_spent(time, category, functions_data) {
var html = "";
var time_str = seconds_to_time(time, false);
if(category === 'movies') {
html += "
";
html += "
";
html += functions_data.get_user_movie_stats_spent_title.replaceAll('{movie_sum_duration}', time_str);
html += ' ';
html += "
";
html += "
";
} else if(category === 'shows') {
html += "
";
html += functions_data.get_user_show_stats_spent_title.replaceAll('{show_sum_duration}', time_str);
html += ' ';
html += "
";
} else if(category === 'music') {
html += "
";
html += "
";
html += functions_data.get_user_music_stats_spent_title.replaceAll('{music_sum_duration}', time_str);
if(time > 3600) {
var time_min = Math.floor(time / 60);
html += '
';
html += functions_data.get_user_music_stats_spent_subtitle.replaceAll('{music_sum_minutes}', number_with_spaces(time_min));
}
html += ' ';
html += "
";
html += "
";
} else {
html += "
";
html += "Unknown category.";
html += "
";
}
return html;
}
function top_list(array, title, music, show, year, div_id) {
var html = "";
html += "
";
html += "
";
html += "
" + title + "
";
html += "
";
for(i = 0; (i < array.length); i++) {
html += "
";
html += "
";
html += i+1 + ". ";
html += "
";
html += "
";
if(music === "track" || music === "album") {
html+= array[i].grandparent_title + " ";
} else if(show) {
html+= "" + array[i].grandparent_title + "";
}
if(!show) {
html += "";
if(music === "album") {
html += array[i].parent_title;
} else if(music === "artist") {
html += array[i].grandparent_title;
} else {
html += array[i].title;
}
}
html += "";
var movie_hour = seconds_to_time(array[i].duration, true);
if(typeof(array[i].year) !== "undefined" && year) {
html += " (" + array[i].year + ")";
}
html += " " + movie_hour + " " + play_plays(array[i].plays);
html += "
";
html += "
";
}
html += "
";
html += "
";
html += "
";
return html;
}
function top_list_names(array, title, div_id) {
var html = "";
html += "
";
html += "
";
html += "
" + title + "
";
html += "
";
for(i = 0; i < array.length; i++) {
if(i == 0) {
html += "
";
} else if(i == 1) {
html += "
";
} else if(i == 2) {
html += "
";
} else {
html += "
";
}
html += "
";
html += i+1 + ". ";
html += "
";
html += "
";
html += array[i].user;
if(array[i].duration !== 0 && array[i].plays !== 0) {
var duration_string = seconds_to_time(array[i].duration, true);
html += " "
html += duration_string
html += " "
html += play_plays(array[i].plays)
}
html += "
";
html += "
";
}
html += "
";
html += "
";
html += "
";
return html;
}
// Toggle names list to plays or duration
function top_list_names_sort_by(array, title, div_id, button_id, functions_data) {
document.getElementById(div_id).outerHTML = top_list_names(array, title, div_id);
var button_text = document.getElementById(button_id + '_text');
if(button_text.innerHTML.includes(functions_data.wrapperr_sort_plays)) {
button_text.innerHTML = button_text.innerHTML = functions_data.wrapperr_sort_duration;
} else {
button_text.innerHTML = button_text.innerHTML = functions_data.wrapperr_sort_plays;
}
var button = document.getElementById(button_id);
if(button.getAttribute('onclick').includes('_duration')) {
button.setAttribute( "onclick", button.getAttribute('onclick').replaceAll('_duration', '_plays'));
} else {
button.setAttribute( "onclick", button.getAttribute('onclick').replaceAll('_plays', '_duration'));
}
}
//TOP USERS
function load_users() {
var text = "";
text += "
";
text += "
" + functions.get_year_stats_title + "
";
text += "
" + functions.get_year_stats_subtitle + "
";
text += "
" + functions.get_year_stats_subsubtitle + "
";
text += "
";
if(functions.get_year_stats_leaderboard) {
text += "
";
if(functions.stats_order_by_plays !== false && functions.stats_order_by_duration !== false) {
text += '';
}
if(functions.stats_order_by_duration !== false) {
text += top_list_names(results.year_stats.year_users.data.users_duration, functions.get_year_stats_leaderboard_title, 'year_stats_year_users');
} else {
text += top_list_names(results.year_stats.year_users.data.users_plays, functions.get_year_stats_leaderboard_title, 'year_stats_year_users');
}
text += "
";
var time_movies = seconds_to_time(results.year_stats.year_movies.data.movie_duration, false);
var time_shows = seconds_to_time(results.year_stats.year_shows.data.show_duration, false);
var time_artists = seconds_to_time(results.year_stats.year_music.data.music_duration, false);
var function_sum = 0;
var time = 0;
text += "
";
text += "
";
text += "
";
if(functions.get_year_stats_movies && results.year_stats.year_movies.data.movie_plays > 0) {
text += functions.get_year_stats_movies_duration_title.replaceAll('{movie_duration_sum}', '' + time_movies + '');
text += "
";
function_sum += 1;
time += results.year_stats.year_movies.data.movie_duration;
}
if(functions.get_year_stats_shows && results.year_stats.year_shows.data.show_plays > 0) {
text += functions.get_year_stats_shows_duration_title.replaceAll('{show_duration_sum}', '' + time_shows + '');
text += "
";
function_sum += 1;
time += results.year_stats.year_shows.data.show_duration;
}
if(functions.get_year_stats_music && results.year_stats.year_music.data.music_plays > 0) {
text += functions.get_year_stats_music_duration_title.replaceAll('{music_duration_sum}', '' + time_artists + '');
text += "
";
function_sum += 1;
time += results.year_stats.year_music.data.music_duration;
}
if(function_sum > 1) {
var time_all = seconds_to_time(Math.floor(time), false);
text += functions.get_year_stats_duration_sum_title.replaceAll('{all_duration_sum}', '' + time_all + '');
}
text += '';
text += "
";
text += "
";
text += "
";
}
text += "
";
text += "
";
if(functions.get_year_stats_movies && results.year_stats.year_movies.data.movie_plays > 0) {
text += "
";
if(functions.stats_order_by_plays !== false && functions.stats_order_by_duration !== false) {
text += '';
}
if(functions.stats_order_by_duration !== false) {
text += top_list(results.year_stats.year_movies.data.movies_duration, functions.get_year_stats_movies_title, false, false, true, 'year_stats_year_movies');
} else {
text += top_list(results.year_stats.year_movies.data.movies_plays, functions.get_year_stats_movies_title, false, false, true, 'year_stats_year_movies');
}
text += "