";
for(i = 0; i < 10 && 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 += "
";
if(array[i].user == results.user.name) {
html += "
";
html += array[i].user;
html += "
";
}else {
html += "
";
html += array[i].user;
html += "
";
}
html += "
";
}
html += "
";
html += "
";
html += "
";
return html;
}
//TOP USERS
function load_users() {
var text = "";
text += "
";
text += "
Finally, let's look at the top users, movies and shows!
";
text += "
It's okay to feel shame if you are on the list.
(or missing from it...)
"
text += "
";
text += "
";
text += "
";
text += top_list_names(results.year_stats.data.users, 'Top users');
text += "
";
var sum_movies = 0;
for(i = 0; (i < results.year_stats.data.top_movies.length); i++) {
sum_movies += results.year_stats.data.top_movies[i].duration;
}
var sum_shows = 0;
for(i = 0; (i < results.year_stats.data.top_shows.length); i++) {
sum_shows += results.year_stats.data.top_shows[i].duration;
}
var time_movies = seconds_to_time(sum_movies, false);
var time_shows = seconds_to_time(sum_shows, false);
var time_all = seconds_to_time(Math.floor(sum_movies + sum_shows), false);
text += "
";
text += "
";
text += "
";
text += "All the different users combined spent
" + time_movies + "";
text += " watching movies.";
text += "
And, the users spent
" + time_shows + "";
text += " watching shows.";
text += "
That is
" + time_all + "of content!";
text += '
';
text += "
";
text += "
";
text += "
";
text += "
";
text += "
";
text += "
";
text += top_list(results.year_stats.data.top_movies, "Top movies");
text += "
";
text += "
";
text += top_list(results.year_stats.data.top_shows, "Top shows");
text += "
";
text += "
";
text += "
";
document.getElementById("search_results").innerHTML += text;
}
//Outro
function load_outro() {
var text = "";
text += "
";
text += "
";
text += "
";
text += '
';
text += "
";
text += "
";
text += "
Hope you are staying safe!
Goodybye.
";
text += "";
text += "
";
text += "
";
document.getElementById("search_results").innerHTML += text;
}
function play_plays(plays) {
plays = parseInt(plays);
if(plays == 1) {
var play_string = plays + ' play';
} else {
var play_string = plays + ' plays';
}
return play_string;
}
//Converting seconds to time in string
var seconds_in_day = 86400;
var seconds_in_hour = 3600;
var seconds_in_minute = 60;
function seconds_to_time(seconds, comma) {
if(seconds >= seconds_in_day) {
var time = seconds_to_days(seconds, comma);
} else if(seconds >= seconds_in_hour) {
var time = seconds_to_hours(seconds, comma);
} else if(seconds >= seconds_in_minute) {
var time = seconds_to_minutes(seconds, comma);
} else {
var time = seconds_to_seconds(seconds);
}
return time;
}
function seconds_to_days(seconds, comma) {
var day = Math.floor(seconds / seconds_in_day);
var rest = Math.floor(seconds % seconds_in_day);
var hour = Math.floor(rest / seconds_in_hour);
rest = Math.floor(rest % seconds_in_hour);
var minute = Math.floor(rest / seconds_in_minute);
rest = Math.floor(rest % seconds_in_minute);
var day_string = '';
var hour_string = '';
var minute_string = '';
if(day < 2) {
day_string += day + ' day';
} else {
day_string += day + ' days';
}
if(hour < 2) {
hour_string += hour + ' hour';
} else {
hour_string += hour + ' hours';
}
if(minute < 2) {
minute_string += minute + ' minute';
} else {
minute_string += minute + ' minutes';
}
if(!hour == 0) {
if(!minute == 0) {
if(comma) {
return day_string + ', ' + hour_string + ', ' + minute_string;
} else {
return day_string + ', ' + hour_string + ' and ' + minute_string;
}
} else {
if(comma) {
return day_string + ', ' + hour_string;
} else {
return day_string + ' and ' + hour_string;
}
}
} else {
return day_string;
}
}
function seconds_to_hours(seconds, comma) {
var hour = Math.floor(seconds / seconds_in_hour);
var rest = Math.floor(seconds % seconds_in_hour);
var minute = Math.floor(rest / seconds_in_minute);
rest = Math.floor(rest % seconds_in_minute);
var hour_string = '';
var minute_string = '';
if(hour < 2) {
hour_string += hour + ' hour';
} else {
hour_string += hour + ' hours';
}
if(minute < 2) {
minute_string += minute + ' minute';
} else {
minute_string += minute + ' minutes';
}
if(!minute == 0) {
if(comma) {
return hour_string + ', ' + minute_string;
} else {
return hour_string + ' and ' + minute_string;
}
} else {
return hour_string;
}
}
function seconds_to_minutes(seconds, comma) {
seconds = parseInt(seconds);
var minute = Math.floor(seconds / seconds_in_minute);
var rest = Math.floor(seconds % seconds_in_minute);
var minute_string = '';
var second_string = '';
if(minute < 2) {
minute_string += minute + ' minute';
} else {
minute_string += minute + ' minutes';
}
if(seconds < 2) {
second_string += rest + ' second';
} else {
second_string += rest + ' seconds';
}
if(!seconds == 0) {
if(comma) {
return minute_string + ', ' + second_string;
} else {
return minute_string + ' and ' + second_string;
}
} else {
return minute_string;
}
}
function seconds_to_seconds(seconds) {
var second_string = '';
if(seconds == 1) {
second_string += seconds + ' second';
} else {
second_string += seconds + ' seconds';
}
return second_string;
}