itpro2005

pastebin.html

Jul 10th, 2025
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.71 KB | None | 0 0
  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>Mini Pastebin</title>
  7.   <link href="https://cdn.jsdelivr.net/npm/[email protected]/themes/prism-tomorrow.css" rel="stylesheet"/>
  8.   <style>
  9.     body { font-family: sans-serif; background: #1e1e1e; color: #f5f5f5; margin: 0; padding: 1rem; }
  10.     .container { max-width: 800px; margin: auto; background: #2d2d2d; padding: 1rem; border-radius: 8px; }
  11.     textarea, select, button { width: 100%; margin-top: 1rem; padding: 0.5rem; font-size: 1rem; }
  12.     pre { padding: 1rem; border-radius: 8px; overflow-x: auto; background: #1e1e1e; }
  13.     .meta { margin-top: 1rem; font-size: 0.85rem; color: #aaa; }
  14.     .hidden { display: none; }
  15.   </style>
  16. </head>
  17. <body>
  18.   <div class="container" id="create-section">
  19.     <h2>Create a New Paste</h2>
  20.     <textarea id="pasteText" rows="10" placeholder="Paste your text or code here..."></textarea>
  21.     <select id="language">
  22.       <option value="plaintext">Plain Text</option>
  23.       <option value="javascript">JavaScript</option>
  24.       <option value="python">Python</option>
  25.       <option value="bash">Bash</option>
  26.       <option value="json">JSON</option>
  27.       <option value="html">HTML</option>
  28.     </select>
  29.     <button onclick="createPaste()">Create Paste</button>
  30.   </div>
  31.  
  32.   <div class="container hidden" id="view-section">
  33.     <div style="display: flex; justify-content: space-between; align-items: center;">
  34.       <h2>View Paste</h2>
  35.       <button onclick="copyLink()">Copy Link</button>
  36.     </div>
  37.     <pre><code id="pasteOutput" class="language-plaintext"></code></pre>
  38.     <div class="meta" id="metaInfo"></div>
  39.   </div>
  40.  
  41.   <script src="https://cdn.jsdelivr.net/npm/[email protected]/prism.js"></script>
  42.   <script src="https://cdn.jsdelivr.net/npm/[email protected]/components/prism-python.min.js"></script>
  43.   <script src="https://cdn.jsdelivr.net/npm/[email protected]/components/prism-javascript.min.js"></script>
  44.   <script src="https://cdn.jsdelivr.net/npm/[email protected]/components/prism-json.min.js"></script>
  45.   <script src="https://cdn.jsdelivr.net/npm/[email protected]/components/prism-bash.min.js"></script>
  46.   <script src="https://cdn.jsdelivr.net/npm/[email protected]/components/prism-markup.min.js"></script>
  47.  
  48.   <script>
  49.     const storage = window.localStorage;
  50.  
  51.     function createPaste() {
  52.       const text = document.getElementById("pasteText").value;
  53.       const language = document.getElementById("language").value;
  54.       const id = Math.random().toString(36).substr(2, 8);
  55.       const createdAt = new Date().toISOString();
  56.  
  57.       const paste = { text, language, createdAt };
  58.       storage.setItem("paste-" + id, JSON.stringify(paste));
  59.       window.location.hash = id;
  60.       location.reload();
  61.     }
  62.  
  63.     function showPaste(id) {
  64.       const raw = storage.getItem("paste-" + id);
  65.       if (!raw) return alert("Paste not found.");
  66.  
  67.       const { text, language, createdAt } = JSON.parse(raw);
  68.       document.getElementById("create-section").classList.add("hidden");
  69.       document.getElementById("view-section").classList.remove("hidden");
  70.  
  71.       const codeBlock = document.getElementById("pasteOutput");
  72.       codeBlock.className = "language-" + language;
  73.       codeBlock.textContent = text;
  74.       Prism.highlightElement(codeBlock);
  75.  
  76.       document.getElementById("metaInfo").textContent = "Created at: " + new Date(createdAt).toLocaleString();
  77.     }
  78.  
  79.     function copyLink() {
  80.       navigator.clipboard.writeText(window.location.href);
  81.       alert("Link copied to clipboard!");
  82.     }
  83.  
  84.     const hash = window.location.hash.replace("#", "");
  85.     if (hash) {
  86.       showPaste(hash);
  87.     }
  88.   </script>
  89. </body>
  90. </html>
  91.  
Advertisement
Add Comment
Please, Sign In to add comment