myworks.ejs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <link rel="icon" href="/assets/icon/favicon.ico" type="image/x-icon">
  7. <title>Free Printable Coloring Pages Gallery - 20,000+ Designs | Art Number Coloring</title>
  8. <meta name="description" content="Explore our massive collection of over 20,000 free coloring pages! Find endless printable designs from animals to mandalas, cartoons, and more. Perfect for kids and adults – start your creative journey today!">
  9. <link rel="stylesheet" href="/stylesheets/v2/styles.css">
  10. <style>
  11. /* 标签导航样式 */
  12. .tab-nav {
  13. display: flex;
  14. border-bottom: 2px solid #eee;
  15. }
  16. .tab-button {
  17. padding: 1rem 2rem;
  18. border: none;
  19. background: none;
  20. cursor: pointer;
  21. font-size: 1.2rem;
  22. color: var(--text-color);
  23. transition: all 0.3s ease;
  24. position: relative;
  25. }
  26. .tab-button.active {
  27. color: var(--secondary-color);
  28. font-weight: 600;
  29. }
  30. .tab-button.active::after {
  31. content: '';
  32. position: absolute;
  33. bottom: -2px;
  34. left: 0;
  35. width: 100%;
  36. height: 3px;
  37. background: var(--secondary-color);
  38. }
  39. /* 内容区域样式 */
  40. .tab-content {
  41. display: none;
  42. }
  43. .tab-content.active {
  44. margin-top: 20px;
  45. display: flex;
  46. flex-direction: column;
  47. justify-content: center;
  48. animation: fadeIn 0.3s ease;
  49. }
  50. @keyframes fadeIn {
  51. from { opacity: 0; transform: translateY(10px); }
  52. to { opacity: 1; transform: translateY(0); }
  53. }
  54. /* 响应式设计, 如果是手机屏幕 */
  55. @media (max-width: 768px) {
  56. .tab-button {
  57. padding: 1rem 1rem;
  58. }
  59. }
  60. </style>
  61. </head>
  62. <!-- Google tag (gtag.js) -->
  63. <script async src="https://www.googletagmanager.com/gtag/js?id=G-JBGGVGLHTP"></script>
  64. <script>
  65. window.dataLayer = window.dataLayer || [];
  66. function gtag() { dataLayer.push(arguments); }
  67. gtag('js', new Date());
  68. gtag('config', 'G-JBGGVGLHTP');
  69. </script>
  70. <body>
  71. <%- include('header') %>
  72. <main class="container">
  73. <section>
  74. <!-- 标签导航 -->
  75. <nav class="tab-nav">
  76. <button class="tab-button active" data-tab="ongoing">In Progress</button>
  77. <button class="tab-button" data-tab="completed">Completed</button>
  78. <button class="tab-button" data-tab="favorite">Favorite</button>
  79. </nav>
  80. <!-- 进行中内容 -->
  81. <div id="ongoing" class="tab-content active">
  82. <div class="coloring-grid">
  83. </div>
  84. </div>
  85. <!-- 已完成内容 -->
  86. <div id="completed" class="tab-content">
  87. <div class="coloring-grid">
  88. </div>
  89. </div>
  90. <!-- 收藏内容 -->
  91. <div id="favorite" class="tab-content">
  92. <div class="coloring-grid">
  93. </div>
  94. </div>
  95. </section>
  96. </main>
  97. <script src="/scripts/script.js"></script>
  98. <script>
  99. const host = '<%= host %>';
  100. // 标签切换功能
  101. const tabButtons = document.querySelectorAll('.tab-button');
  102. const tabContents = document.querySelectorAll('.tab-content');
  103. tabButtons.forEach(button => {
  104. button.addEventListener('click', () => {
  105. const targetTab = button.dataset.tab;
  106. // 移除所有激活状态
  107. tabButtons.forEach(btn => btn.classList.remove('active'));
  108. tabContents.forEach(content => content.classList.remove('active'));
  109. // 添加当前激活状态
  110. button.classList.add('active');
  111. document.getElementById(targetTab).classList.add('active');
  112. });
  113. });
  114. // 加载
  115. const loadWorks = (tabType) => {
  116. let data = {};
  117. if (tabType === 'favorite') {
  118. const raw = localStorage.getItem('_storage_collection__') || '{}';
  119. data = JSON.parse(raw);
  120. } else {
  121. const rawMeta = localStorage.getItem('__storage_metadata__') || '{}';
  122. const metaData = JSON.parse(rawMeta);
  123. data = Object.entries(metaData).filter(([_, item]) =>
  124. tabType === 'ongoing' ? item.progress < 100 : item.progress >= 100
  125. ).reduce((acc, [id, item]) => ({ ...acc, [id]: item }), {});
  126. }
  127. return Object.entries(data).map(([id, item]) => ({
  128. id,
  129. uri: `/coloring-page/${id}`,
  130. thumbnail: `${host}/thumbs/coloring-page/${item.progress >= 100 ? 'work' : 'page'}/480/${id}.png`, // 缩略图拼接规则‌:ml-citation{ref="7" data="citationList"}
  131. progress: item.progress,
  132. timestamp: item.timestamp
  133. })).sort((a, b) => b.timestamp - a.timestamp); // 时间倒序排列
  134. };
  135. // 动态渲染
  136. const renderWorks = (container, items) => {
  137. container.innerHTML = '';
  138. items.forEach(item => {
  139. const card = document.createElement('div');
  140. card.className = 'coloring-card';
  141. card.innerHTML = `
  142. <div data-content-id="${item.id}" class="coloring-image">
  143. <a href="${item.uri}"><img src="${item.thumbnail}"></a>
  144. <div class="progress-badge" style="background-color: ${item.progress >= 100 ? 'var(--secondary-color)' : 'var(--primary-color)'}; transition: background-color 0.3s ease; ">
  145. <span>${item.progress >= 100 ? '✓' : item.progress + '%'}</span>
  146. </div>
  147. </div>
  148. `;
  149. container.appendChild(card);
  150. });
  151. };
  152. document.querySelectorAll('.tab-content').forEach(container => {
  153. const tabType = container.id;
  154. const works = loadWorks(tabType);
  155. const grid = container.querySelector('.coloring-grid');
  156. renderWorks(grid, works);
  157. });
  158. </script>
  159. </body>
  160. </html>