detail.ejs 5.0 KB

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