detail.ejs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. <!-- Google tag (gtag.js) -->
  14. <script async src="https://www.googletagmanager.com/gtag/js?id=G-JBGGVGLHTP"></script>
  15. <script>
  16. window.dataLayer = window.dataLayer || [];
  17. function gtag() { dataLayer.push(arguments); }
  18. gtag('js', new Date());
  19. gtag('config', 'G-JBGGVGLHTP');
  20. </script>
  21. <body>
  22. <%- include('header') %>
  23. <div class="details">
  24. <div class="poster"><img src="<%= detail.thumb %>" alt="<%= detail.title %>"></div>
  25. <div class="description">
  26. <div style="font-size: 30px; font-weight: 700;">
  27. <%= detail.title %>
  28. </div>
  29. <p>
  30. <%= translate.designer[lang] %>: <a href="/<%= lang %>/designer/<%= detail.user._id %>"
  31. class="tag-button">
  32. <%= detail.user.username %>
  33. </a>
  34. </p>
  35. <p>
  36. <%= translate.publishTime[lang] %>: <%= detail.publishTime %>
  37. </p>
  38. <p>
  39. <%= translate.tag[lang] %>:
  40. <% detail.tags.forEach(tag=> { %>
  41. <a href="/<%= lang %>/tag/<%= tag %>" class="tag-button">
  42. <%= tag %>
  43. </a>
  44. <% }); %>
  45. </p>
  46. <div>
  47. <%= detail.desc %>
  48. </div>
  49. <div class="button-wrapper">
  50. <a href="/play/<%= detail._id %>" class="play-button">
  51. <%= translate.play[lang] %>
  52. </a>
  53. <a id="downloadBtn" class="play-button" style="background-color: lightseagreen;">
  54. <%= translate.download[lang] %>
  55. </a>
  56. </div>
  57. </div>
  58. </div>
  59. <p style=" display: flex; justify-content: center; color: #777; font-size: 18px; font-weight: 500;">
  60. <%= translate.mayYouLike[lang] %>:
  61. </p>
  62. <div class="content" style="margin-bottom: 40px;">
  63. <div class="image-grid">
  64. <% relates.forEach(item=> { %>
  65. <a href="<%= item.uri %>"><img src="<%= item.thumb %>"
  66. alt="<%= item.title %> | <%= translate.printableColoringPage[lang]%>"></a>
  67. <% }); %>
  68. </div>
  69. </div>
  70. <%- include('pagination') %>
  71. <script>
  72. // document.getElementById('downloadBtn').addEventListener('click', function () {
  73. // var link = document.createElement('a');
  74. // link.style.display = 'none';
  75. // link.href = '<%= detail.downlink %>';
  76. // link.download = '<%= detail._id %>.jpeg';
  77. // document.body.appendChild(link);
  78. // link.click();
  79. // document.body.removeChild(link);
  80. // });
  81. document.getElementById('downloadBtn').addEventListener('click', function () {
  82. const imageUrl = '<%= detail.downlink %>';
  83. fetch(imageUrl)
  84. .then(response => {
  85. if (!response.ok) {
  86. throw new Error('Network response was not ok');
  87. }
  88. return response.blob();
  89. })
  90. .then(blob => {
  91. const url = URL.createObjectURL(blob);
  92. const a = document.createElement('a');
  93. a.style.display = 'none';
  94. a.href = url;
  95. a.download = '<%= detail._id %>.jpeg';
  96. document.body.appendChild(a);
  97. a.click();
  98. URL.revokeObjectURL(url);
  99. document.body.removeChild(a);
  100. })
  101. .catch(error => {
  102. console.error('Image Download Error:', error);
  103. });
  104. });
  105. </script>
  106. </body>
  107. </html>