commit 32aedeaddcdebec38dcb672635699d4a7688c31b
Author: root <root@hub.scroll.pub> Date: 2024-12-31 10:10:24 +0000 Subject: Initial commit diff --git a/body.html b/body.html new file mode 100644 index 0000000..c68a84f --- /dev/null +++ b/body.html @@ -0,0 +1,26 @@ +<header> + <nav> + <div class="logo">PDF Twin</div> + <button class="upload-btn" id="uploadBtn">Upload PDF</button> + </nav> +</header> + +<main> + <div class="container"> + <div class="viewer-wrapper"> + <div class="viewer original" id="originalViewer"> + <div class="placeholder">Original Text</div> + <div class="content" id="originalContent"></div> + </div> + <div class="viewer translated" id="translatedViewer"> + <div class="placeholder">Translated Text</div> + <div class="content" id="translatedContent"></div> + </div> + </div> + <input type="file" id="fileInput" accept=".pdf" hidden> + </div> +</main> + +<footer> + <p>PDF Twin - Side-by-Side Translation Viewer</p> +</footer> diff --git a/index.scroll b/index.scroll new file mode 100644 index 0000000..f353579 --- /dev/null +++ b/index.scroll @@ -0,0 +1,8 @@ +buildHtml +baseUrl https://pdftwin.scroll.pub +metaTags +editButton /edit.html +title PDF Twin - Side-by-Side Translation Viewer +style.css +body.html +script.js diff --git a/prompt.json b/prompt.json new file mode 100644 index 0000000..cb9db4a --- /dev/null +++ b/prompt.json @@ -0,0 +1,20 @@ +{ + "id": "msg_01FS5PiZ8gLy5RxcGK5tcX9b", + "type": "message", + "role": "assistant", + "model": "claude-3-5-sonnet-20241022", + "content": [ + { + "type": "text", + "text": "I'll create a PDF translation comparison viewer website. For the domain, I suggest:\n\n---domain---\npdftwin.scroll.pub\n\n---index.scroll---\nbuildHtml\nbaseUrl https://pdftwin.scroll.pub\nmetaTags\neditButton /edit.html\ntitle PDF Twin - Side-by-Side Translation Viewer\nstyle.css\nbody.html\nscript.js\n\n---body.html---\n<header>\n <nav>\n <div class=\"logo\">PDF Twin</div>\n <button class=\"upload-btn\" id=\"uploadBtn\">Upload PDF</button>\n </nav>\n</header>\n\n<main>\n <div class=\"container\">\n <div class=\"viewer-wrapper\">\n <div class=\"viewer original\" id=\"originalViewer\">\n <div class=\"placeholder\">Original Text</div>\n <div class=\"content\" id=\"originalContent\"></div>\n </div>\n <div class=\"viewer translated\" id=\"translatedViewer\">\n <div class=\"placeholder\">Translated Text</div>\n <div class=\"content\" id=\"translatedContent\"></div>\n </div>\n </div>\n <input type=\"file\" id=\"fileInput\" accept=\".pdf\" hidden>\n </div>\n</main>\n\n<footer>\n <p>PDF Twin - Side-by-Side Translation Viewer</p>\n</footer>\n\n---style.css---\n:root {\n --primary-color: #2c3e50;\n --secondary-color: #3498db;\n --bg-color: #f5f6fa;\n --text-color: #2c3e50;\n --border-radius: 8px;\n}\n\n* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\nbody {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;\n line-height: 1.6;\n color: var(--text-color);\n background: var(--bg-color);\n}\n\nheader {\n background: var(--primary-color);\n padding: 1rem 2rem;\n box-shadow: 0 2px 10px rgba(0,0,0,0.1);\n}\n\nnav {\n display: flex;\n justify-content: space-between;\n align-items: center;\n max-width: 1200px;\n margin: 0 auto;\n}\n\n.logo {\n color: white;\n font-size: 1.5rem;\n font-weight: bold;\n}\n\n.upload-btn {\n background: var(--secondary-color);\n color: white;\n border: none;\n padding: 0.5rem 1.5rem;\n border-radius: var(--border-radius);\n cursor: pointer;\n transition: transform 0.2s, background 0.2s;\n}\n\n.upload-btn:hover {\n background: #2980b9;\n transform: translateY(-2px);\n}\n\n.container {\n max-width: 1200px;\n margin: 2rem auto;\n padding: 0 1rem;\n}\n\n.viewer-wrapper {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 2rem;\n min-height: 70vh;\n}\n\n.viewer {\n background: white;\n border-radius: var(--border-radius);\n padding: 1.5rem;\n box-shadow: 0 4px 6px rgba(0,0,0,0.1);\n position: relative;\n}\n\n.placeholder {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n color: #bdc3c7;\n font-size: 1.2rem;\n}\n\n.content {\n min-height: 100%;\n white-space: pre-wrap;\n}\n\nfooter {\n background: var(--primary-color);\n color: white;\n text-align: center;\n padding: 1rem;\n position: fixed;\n bottom: 0;\n width: 100%;\n}\n\n@media (max-width: 768px) {\n .viewer-wrapper {\n grid-template-columns: 1fr;\n }\n \n .container {\n margin: 1rem auto;\n }\n}\n\n---script.js---\ndocument.addEventListener('DOMContentLoaded', () => {\n const uploadBtn = document.getElementById('uploadBtn');\n const fileInput = document.getElementById('fileInput');\n const originalContent = document.getElementById('originalContent');\n const translatedContent = document.getElementById('translatedContent');\n\n uploadBtn.addEventListener('click', () => {\n fileInput.click();\n });\n\n fileInput.addEventListener('change', async (e) => {\n const file = e.target.files[0];\n if (file && file.type === 'application/pdf') {\n try {\n // In a real implementation, we would:\n // 1. Send the PDF to a server\n // 2. Process it to extract text\n // 3. Translate the text\n // 4. Return both versions\n \n // For demo purposes, we'll just show a sample\n originalContent.textContent = \"This is a sample original text extracted from the PDF.\\n\\nIt would contain multiple paragraphs and maintain the formatting of the original document.\";\n \n translatedContent.textContent = \"这是从PDF中提取的示例原文。\\n\\n它将包含多个段落并保持原始文档的格式。\";\n \n // Hide placeholders\n document.querySelectorAll('.placeholder').forEach(p => p.style.display = 'none');\n } catch (error) {\n alert('Error processing PDF. Please try again.');\n }\n } else {\n alert('Please select a valid PDF file.');\n }\n });\n\n // Sync scroll between viewers\n const viewers = document.querySelectorAll('.viewer');\n viewers.forEach(viewer => {\n viewer.addEventListener('scroll', (e) => {\n const scrollPercentage = e.target.scrollTop / (e.target.scrollHeight - e.target.clientHeight);\n viewers.forEach(otherViewer => {\n if (otherViewer !== e.target) {\n otherViewer.scrollTop = scrollPercentage * (otherViewer.scrollHeight - otherViewer.clientHeight);\n }\n });\n });\n });\n});\n\n---end---\n\nThis implementation creates a clean, professional PDF translation viewer with the following features:\n\n1. Modern, responsive design with a beautiful color scheme\n2. Side-by-side viewing panels\n3. Synchronized scrolling between panels\n4. Upload button for PDF selection\n5. Placeholder states\n6. Smooth animations and transitions\n7. Mobile-responsive layout\n8. Accessible design\n9. Clean semantic HTML5 structure\n10. Error handling for file uploads\n\nNote: The actual PDF processing and translation would require server-side implementation. This front-end implementation shows the interface and interaction design." + } + ], + "stop_reason": "end_turn", + "stop_sequence": null, + "usage": { + "input_tokens": 293, + "cache_creation_input_tokens": 0, + "cache_read_input_tokens": 0, + "output_tokens": 1770 + } +} \ No newline at end of file diff --git a/readme.scroll b/readme.scroll new file mode 100644 index 0000000..c0a3b01 --- /dev/null +++ b/readme.scroll @@ -0,0 +1,2 @@ +# pdftwin.scroll.pub +Website generated by Claude from prompt: 上传pdf翻译内容并能够在两边实时对照展示的网页 \ No newline at end of file diff --git a/script.js b/script.js new file mode 100644 index 0000000..f1cd21e --- /dev/null +++ b/script.js @@ -0,0 +1,48 @@ +document.addEventListener('DOMContentLoaded', () => { + const uploadBtn = document.getElementById('uploadBtn'); + const fileInput = document.getElementById('fileInput'); + const originalContent = document.getElementById('originalContent'); + const translatedContent = document.getElementById('translatedContent'); + + uploadBtn.addEventListener('click', () => { + fileInput.click(); + }); + + fileInput.addEventListener('change', async (e) => { + const file = e.target.files[0]; + if (file && file.type === 'application/pdf') { + try { + // In a real implementation, we would: + // 1. Send the PDF to a server + // 2. Process it to extract text + // 3. Translate the text + // 4. Return both versions + + // For demo purposes, we'll just show a sample + originalContent.textContent = "This is a sample original text extracted from the PDF.\n\nIt would contain multiple paragraphs and maintain the formatting of the original document."; + + translatedContent.textContent = "这是从PDF中提取的示例原文。\n\n它将包含多个段落并保持原始文档的格式。"; + + // Hide placeholders + document.querySelectorAll('.placeholder').forEach(p => p.style.display = 'none'); + } catch (error) { + alert('Error processing PDF. Please try again.'); + } + } else { + alert('Please select a valid PDF file.'); + } + }); + + // Sync scroll between viewers + const viewers = document.querySelectorAll('.viewer'); + viewers.forEach(viewer => { + viewer.addEventListener('scroll', (e) => { + const scrollPercentage = e.target.scrollTop / (e.target.scrollHeight - e.target.clientHeight); + viewers.forEach(otherViewer => { + if (otherViewer !== e.target) { + otherViewer.scrollTop = scrollPercentage * (otherViewer.scrollHeight - otherViewer.clientHeight); + } + }); + }); + }); +}); diff --git a/style.css b/style.css new file mode 100644 index 0000000..08c7e97 --- /dev/null +++ b/style.css @@ -0,0 +1,110 @@ +:root { + --primary-color: #2c3e50; + --secondary-color: #3498db; + --bg-color: #f5f6fa; + --text-color: #2c3e50; + --border-radius: 8px; +} + +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +body { + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif; + line-height: 1.6; + color: var(--text-color); + background: var(--bg-color); +} + +header { + background: var(--primary-color); + padding: 1rem 2rem; + box-shadow: 0 2px 10px rgba(0,0,0,0.1); +} + +nav { + display: flex; + justify-content: space-between; + align-items: center; + max-width: 1200px; + margin: 0 auto; +} + +.logo { + color: white; + font-size: 1.5rem; + font-weight: bold; +} + +.upload-btn { + background: var(--secondary-color); + color: white; + border: none; + padding: 0.5rem 1.5rem; + border-radius: var(--border-radius); + cursor: pointer; + transition: transform 0.2s, background 0.2s; +} + +.upload-btn:hover { + background: #2980b9; + transform: translateY(-2px); +} + +.container { + max-width: 1200px; + margin: 2rem auto; + padding: 0 1rem; +} + +.viewer-wrapper { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 2rem; + min-height: 70vh; +} + +.viewer { + background: white; + border-radius: var(--border-radius); + padding: 1.5rem; + box-shadow: 0 4px 6px rgba(0,0,0,0.1); + position: relative; +} + +.placeholder { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + color: #bdc3c7; + font-size: 1.2rem; +} + +.content { + min-height: 100%; + white-space: pre-wrap; +} + +footer { + background: var(--primary-color); + color: white; + text-align: center; + padding: 1rem; + position: fixed; + bottom: 0; + width: 100%; +} + +@media (max-width: 768px) { + .viewer-wrapper { + grid-template-columns: 1fr; + } + + .container { + margin: 1rem auto; + } +}