|
| 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 | + <title>Jina Reader</title> |
| 7 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/marked/4.0.2/marked.min.js"></script> |
| 8 | + <style> |
| 9 | + body { |
| 10 | + font-family: Helvetica, sans-serif; |
| 11 | + max-width: 800px; |
| 12 | + margin: 0 auto; |
| 13 | + padding: 20px; |
| 14 | + box-sizing: border-box; |
| 15 | + } |
| 16 | + h1 { |
| 17 | + font-size: 24px; |
| 18 | + margin-bottom: 20px; |
| 19 | + } |
| 20 | + #url-input, #submit-btn, #markdown-raw, #copy-btn { |
| 21 | + font-size: 16px; |
| 22 | + padding: 10px; |
| 23 | + margin-bottom: 10px; |
| 24 | + box-sizing: border-box; |
| 25 | + } |
| 26 | + #url-input { |
| 27 | + width: 70%; |
| 28 | + } |
| 29 | + #submit-btn, #copy-btn { |
| 30 | + background-color: #4CAF50; |
| 31 | + color: white; |
| 32 | + border: none; |
| 33 | + cursor: pointer; |
| 34 | + } |
| 35 | + #submit-btn:hover, #copy-btn:hover { |
| 36 | + background-color: #45a049; |
| 37 | + } |
| 38 | + #markdown-raw { |
| 39 | + width: 100%; |
| 40 | + height: 200px; |
| 41 | + margin-top: 20px; |
| 42 | + resize: vertical; |
| 43 | + } |
| 44 | + #markdown-rendered { |
| 45 | + margin-top: 20px; |
| 46 | + border: 1px solid #ccc; |
| 47 | + padding: 10px; |
| 48 | + overflow-wrap: break-word; |
| 49 | + } |
| 50 | + @media (min-width: 768px) { |
| 51 | + #url-input { |
| 52 | + width: 70%; |
| 53 | + display: inline-block; |
| 54 | + } |
| 55 | + #submit-btn { |
| 56 | + display: inline-block; |
| 57 | + margin-left: 2%; |
| 58 | + } |
| 59 | + #copy-btn { |
| 60 | + width: auto; |
| 61 | + } |
| 62 | + } |
| 63 | + </style> |
| 64 | +</head> |
| 65 | +<body> |
| 66 | + <h1>Jina Reader</h1> |
| 67 | + <p>An interface for the <a href="https://jina.ai/reader/">Jina Reader API</a>.</p> |
| 68 | + <input type="text" id="url-input" placeholder="Enter URL"> |
| 69 | + <button id="submit-btn">Submit</button> |
| 70 | + <textarea id="markdown-raw" readonly></textarea> |
| 71 | + <button id="copy-btn">Copy to clipboard</button> |
| 72 | + <div id="markdown-rendered"></div> |
| 73 | + |
| 74 | + <script> |
| 75 | + const urlInput = document.getElementById('url-input'); |
| 76 | + const submitBtn = document.getElementById('submit-btn'); |
| 77 | + const markdownRaw = document.getElementById('markdown-raw'); |
| 78 | + const copyBtn = document.getElementById('copy-btn'); |
| 79 | + const markdownRendered = document.getElementById('markdown-rendered'); |
| 80 | + |
| 81 | + submitBtn.addEventListener('click', async () => { |
| 82 | + const url = urlInput.value; |
| 83 | + if (!url) return; |
| 84 | + |
| 85 | + try { |
| 86 | + const response = await fetch(`https://r.jina.ai/${url}`); |
| 87 | + const markdown = await response.text(); |
| 88 | + markdownRaw.value = markdown; |
| 89 | + markdownRendered.innerHTML = marked.parse(markdown); |
| 90 | + } catch (error) { |
| 91 | + console.error('Error fetching markdown:', error); |
| 92 | + markdownRaw.value = 'Error fetching markdown. Please try again.'; |
| 93 | + markdownRendered.innerHTML = ''; |
| 94 | + } |
| 95 | + }); |
| 96 | + |
| 97 | + copyBtn.addEventListener('click', () => { |
| 98 | + markdownRaw.select(); |
| 99 | + document.execCommand('copy'); |
| 100 | + |
| 101 | + const originalText = copyBtn.textContent; |
| 102 | + copyBtn.textContent = 'Copied'; |
| 103 | + |
| 104 | + setTimeout(() => { |
| 105 | + copyBtn.textContent = originalText; |
| 106 | + }, 1500); |
| 107 | + }); |
| 108 | + </script> |
| 109 | +</body> |
| 110 | +</html> |
0 commit comments