detail.ejs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <!DOCTYPE html>
  2. <html lang="<%= lang %>">
  3. <head>
  4. <%- include('common-meta') %>
  5. <link rel="alternate" href="https://art.pcoloring.com/en/<%= uri.substring(3) %>" hrefLang="en" />
  6. <link rel="alternate" href="https://art.pcoloring.com/zh/<%= uri.substring(3) %>" hrefLang="zh" />
  7. <link rel="alternate" href="https://art.pcoloring.com/es/<%= uri.substring(3) %>" hrefLang="es" />
  8. <link rel="alternate" href="https://art.pcoloring.com/pt/<%= uri.substring(3) %>" hrefLang="pt" />
  9. <link rel="alternate" href="https://art.pcoloring.com/ja/<%= uri.substring(3) %>" hrefLang="ja" />
  10. <link rel="stylesheet" href="/stylesheets/styles.css">
  11. <link rel="stylesheet" href="/stylesheets/detail.css">
  12. </head>
  13. <body>
  14. <%- include('header') %>
  15. <div class="details">
  16. <div class="poster"><img src="<%= detail.thumb %>" alt="<%= detail.title %>"></div>
  17. <div class="description">
  18. <div style="font-size: 30px; font-weight: 700;">
  19. <%= detail.title %>
  20. </div>
  21. <p>
  22. <%= translate.designer[lang] %>: <a href="/<%= lang %>/designer/<%= detail.user._id %>"
  23. class="tag-button">
  24. <%= detail.user.username %>
  25. </a>
  26. </p>
  27. <p>
  28. <%= translate.publishTime[lang] %>: <%= detail.publishTime %>
  29. </p>
  30. <p>
  31. <%= translate.tag[lang] %>:
  32. <% detail.tags.forEach(tag=> { %>
  33. <a href="/<%= lang %>/tag/<%= tag %>" class="tag-button">
  34. <%= tag %>
  35. </a>
  36. <% }); %>
  37. </p>
  38. <div>
  39. <%= detail.desc %>
  40. </div>
  41. <div class="button-wrapper">
  42. <a href="/play/<%= detail._id %>" class="play-button">
  43. <%= translate.play[lang] %>
  44. </a>
  45. <a id="downloadBtn" class="play-button" style="background-color: lightseagreen;">
  46. <%= translate.download[lang] %>
  47. </a>
  48. </div>
  49. </div>
  50. </div>
  51. <p style=" display: flex; justify-content: center; color: #777; font-size: 18px; font-weight: 500;">
  52. <%= translate.mayYouLike[lang] %>:
  53. </p>
  54. <div class="content" style="margin-bottom: 40px;">
  55. <div class="image-grid">
  56. <% relates.forEach(item=> { %>
  57. <a href="<%= item.uri %>"><img src="<%= item.thumb %>"
  58. alt="<%= item.title %> | <%= translate.printableColoringPage[lang]%>"></a>
  59. <% }); %>
  60. </div>
  61. </div>
  62. <%- include('pagination') %>
  63. <script>
  64. // document.getElementById('downloadBtn').addEventListener('click', function () {
  65. // var link = document.createElement('a');
  66. // link.style.display = 'none';
  67. // link.href = '<%= detail.downlink %>';
  68. // link.download = '<%= detail._id %>.jpeg';
  69. // document.body.appendChild(link);
  70. // link.click();
  71. // document.body.removeChild(link);
  72. // });
  73. document.getElementById('downloadBtn').addEventListener('click', function () {
  74. const imageUrl = '<%= detail.downlink %>';
  75. fetch(imageUrl)
  76. .then(response => {
  77. if (!response.ok) {
  78. throw new Error('Network response was not ok');
  79. }
  80. return response.blob();
  81. })
  82. .then(blob => {
  83. const url = URL.createObjectURL(blob);
  84. const a = document.createElement('a');
  85. a.style.display = 'none';
  86. a.href = url;
  87. a.download = '<%= detail._id %>.jpeg';
  88. document.body.appendChild(a);
  89. a.click();
  90. URL.revokeObjectURL(url);
  91. document.body.removeChild(a);
  92. })
  93. .catch(error => {
  94. console.error('Image Download Error:', error);
  95. });
  96. });
  97. </script>
  98. </body>
  99. </html>