poster_updates.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. // Most Watched Movies with Posters
  2. if (' . $showMostWatchedMovies . ' && stats.most_watched_movies && stats.most_watched_movies.length > 0) {
  3. console.log("Rendering most watched movies:", stats.most_watched_movies);
  4. html += "<div class=\"col-lg-12\" style=\"margin-top: 30px;\">";
  5. html += "<h5><i class=\"fa fa-film text-primary\"></i> Most Watched Movies</h5>";
  6. html += "<div style=\"margin-top: 15px; overflow-x: auto; white-space: nowrap; padding: 10px 0;\">";
  7. stats.most_watched_movies.forEach(function(movie) {
  8. console.log("Processing movie:", movie);
  9. var posterUrl = getPosterUrl(movie.poster_path, movie.id, movie.server_id);
  10. var playCount = movie.play_count || 0;
  11. var year = movie.year || "N/A";
  12. var title = movie.title || "Unknown Movie";
  13. html += "<div style=\"display: inline-block; margin: 10px; width: 150px; vertical-align: top;\">";
  14. html += "<div class=\"poster-card\" style=\"position: relative; background: #f8f9fa; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); width: 150px; height: 290px;\">";
  15. // Poster image container
  16. html += "<div class=\"poster-image\" style=\"position: relative; width: 150px; height: 225px; background: #e9ecef;\">";
  17. if (posterUrl) {
  18. html += "<img src=\"" + posterUrl + "\" alt=\"" + title + "\" style=\"width: 150px; height: 225px; object-fit: cover;\" onerror=\"this.style.display='none'; this.nextElementSibling.style.display='flex';\">";
  19. }
  20. html += "<div class=\"poster-placeholder\" style=\"position: absolute; top: 0; left: 0; width: 150px; height: 225px; display: " + (posterUrl ? "none" : "flex") + "; align-items: center; justify-content: center; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white;\">";
  21. html += "<i class=\"fa fa-film fa-3x\"></i>";
  22. html += "</div>";
  23. // Play count badge
  24. html += "<div class=\"play-count-badge\" style=\"position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.8); color: white; padding: 4px 8px; border-radius: 12px; font-size: 11px;\">";
  25. html += "<i class=\"fa fa-play\"></i> " + playCount;
  26. html += "</div>";
  27. html += "</div>";
  28. // Movie info with improved height and text clipping
  29. html += "<div class=\"poster-info\" style=\"padding: 8px; text-align: center; height: 65px; display: flex; flex-direction: column; justify-content: space-between;\">";
  30. html += "<div style=\"font-size: 12px; font-weight: bold; line-height: 1.2; height: 36px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;\" title=\"" + title + "\">" + title + "</div>";
  31. html += "<small class=\"text-muted\">" + year + "</small>";
  32. html += "</div>";
  33. html += "</div></div>";
  34. });
  35. html += "</div></div>";
  36. } else {
  37. console.log("Movies not showing because:");
  38. console.log("- Setting enabled:", ' . $showMostWatchedMovies . ');
  39. console.log("- Has data:", stats.most_watched_movies && stats.most_watched_movies.length > 0);
  40. console.log("- Data:", stats.most_watched_movies);
  41. }
  42. // Most Watched TV Shows with Posters (updated to match movies)
  43. if (' . $showMostWatchedShows . ' && stats.most_watched_shows && stats.most_watched_shows.length > 0) {
  44. html += "<div class=\"col-lg-12\" style=\"margin-top: 30px;\">";
  45. html += "<h5><i class=\"fa fa-television text-info\"></i> Most Watched TV Shows</h5>";
  46. html += "<div style=\"margin-top: 15px; overflow-x: auto; white-space: nowrap; padding: 10px 0;\">";
  47. stats.most_watched_shows.forEach(function(show) {
  48. var posterUrl = getPosterUrl(show.poster_path, show.id, show.server_id);
  49. var playCount = show.play_count || 0;
  50. var year = show.year || "N/A";
  51. var title = show.title || "Unknown Show";
  52. html += "<div style=\"display: inline-block; margin: 10px; width: 150px; vertical-align: top;\">";
  53. html += "<div class=\"poster-card\" style=\"position: relative; background: #f8f9fa; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); width: 150px; height: 290px;\">";
  54. // Poster image with fixed dimensions like movies
  55. html += "<div class=\"poster-image\" style=\"position: relative; width: 150px; height: 225px; background: #e9ecef;\">";
  56. if (posterUrl) {
  57. html += "<img src=\"" + posterUrl + "\" alt=\"" + title + "\" style=\"width: 150px; height: 225px; object-fit: cover;\" onerror=\"this.style.display='none'; this.nextElementSibling.style.display='flex';\">";
  58. }
  59. html += "<div class=\"poster-placeholder\" style=\"position: absolute; top: 0; left: 0; width: 150px; height: 225px; display: " + (posterUrl ? "none" : "flex") + "; align-items: center; justify-content: center; background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%); color: white;\">";
  60. html += "<i class=\"fa fa-television fa-3x\"></i>";
  61. html += "</div>";
  62. // Play count badge
  63. html += "<div class=\"play-count-badge\" style=\"position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.8); color: white; padding: 4px 8px; border-radius: 12px; font-size: 11px;\">";
  64. html += "<i class=\"fa fa-play\"></i> " + playCount;
  65. html += "</div>";
  66. html += "</div>";
  67. // Show info matching movies format
  68. html += "<div class=\"poster-info\" style=\"padding: 8px; text-align: center; height: 65px; display: flex; flex-direction: column; justify-content: space-between;\">";
  69. html += "<div style=\"font-size: 12px; font-weight: bold; line-height: 1.2; height: 36px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;\" title=\"" + title + "\">" + title + "</div>";
  70. html += "<small class=\"text-muted\">" + year + "</small>";
  71. html += "</div>";
  72. html += "</div></div>";
  73. });
  74. html += "</div></div>";
  75. }
  76. // Most Listened Music with Cover Art (updated to match movies)
  77. if (' . $showMostListenedMusic . ' && stats.most_listened_music && stats.most_listened_music.length > 0) {
  78. html += "<div class=\"col-lg-12\" style=\"margin-top: 30px;\">";
  79. html += "<h5><i class=\"fa fa-music text-success\"></i> Most Listened Music</h5>";
  80. html += "<div style=\"margin-top: 15px; overflow-x: auto; white-space: nowrap; padding: 10px 0;\">";
  81. stats.most_listened_music.forEach(function(music) {
  82. var posterUrl = getPosterUrl(music.poster_path || music.cover_art, music.id, music.server_id);
  83. var playCount = music.play_count || 0;
  84. var artist = music.artist || "Unknown Artist";
  85. var title = music.title || music.album || "Unknown";
  86. html += "<div style=\"display: inline-block; margin: 10px; width: 150px; vertical-align: top;\">";
  87. html += "<div class=\"poster-card\" style=\"position: relative; background: #f8f9fa; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); width: 150px; height: 290px;\">";
  88. // Cover art with fixed dimensions like movies (square for music)
  89. html += "<div class=\"poster-image\" style=\"position: relative; width: 150px; height: 150px; background: #e9ecef;\">";
  90. if (posterUrl) {
  91. html += "<img src=\"" + posterUrl + "\" alt=\"" + title + "\" style=\"width: 150px; height: 150px; object-fit: cover;\" onerror=\"this.style.display='none'; this.nextElementSibling.style.display='flex';\">";
  92. }
  93. html += "<div class=\"poster-placeholder\" style=\"position: absolute; top: 0; left: 0; width: 150px; height: 150px; display: " + (posterUrl ? "none" : "flex") + "; align-items: center; justify-content: center; background: linear-gradient(135deg, #fd79a8 0%, #e84393 100%); color: white;\">";
  94. html += "<i class=\"fa fa-music fa-3x\"></i>";
  95. html += "</div>";
  96. // Play count badge
  97. html += "<div class=\"play-count-badge\" style=\"position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,0.8); color: white; padding: 4px 8px; border-radius: 12px; font-size: 11px;\">";
  98. html += "<i class=\"fa fa-play\"></i> " + playCount;
  99. html += "</div>";
  100. html += "</div>";
  101. // Music info with proper space for title and artist
  102. html += "<div class=\"poster-info\" style=\"padding: 8px; text-align: center; height: 140px; display: flex; flex-direction: column; justify-content: space-between;\">";
  103. html += "<div style=\"font-size: 12px; font-weight: bold; line-height: 1.2; height: 36px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;\" title=\"" + title + "\">" + title + "</div>";
  104. html += "<small class=\"text-muted\">" + artist + "</small>";
  105. html += "</div>";
  106. html += "</div></div>";
  107. });
  108. html += "</div></div>";
  109. }