offerpk3 commited on
Commit
405ff9d
Β·
verified Β·
1 Parent(s): 475a817

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +187 -18
index.html CHANGED
@@ -1,19 +1,188 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Live Temp Mail</title>
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <style>
9
+ body { background-color: #0f172a; color: white; }
10
+ #toast {
11
+ position: fixed;
12
+ bottom: 20px;
13
+ right: 20px;
14
+ background-color: #22c55e;
15
+ color: white;
16
+ padding: 10px 20px;
17
+ border-radius: 8px;
18
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
19
+ opacity: 0;
20
+ transition: opacity 0.3s ease-in-out;
21
+ }
22
+ #toast.show {
23
+ opacity: 1;
24
+ }
25
+ </style>
26
+ </head>
27
+ <body class="flex items-center justify-center min-h-screen">
28
+ <div id="toast">πŸ“‹ Copied Successfully!</div>
29
+ <div class="bg-gray-900 rounded-2xl shadow-2xl p-6 max-w-2xl w-full">
30
+ <h1 class="text-2xl font-bold text-center mb-4 text-indigo-400">πŸ“§ Live Temp Mail</h1>
31
+
32
+ <div class="bg-gray-800 rounded-xl p-4 flex justify-between items-center">
33
+ <input id="email" readonly class="bg-transparent text-white w-full font-mono text-sm" />
34
+ <button onclick="copyEmail()" class="ml-2 px-3 py-1 text-sm bg-indigo-600 hover:bg-indigo-700 rounded">πŸ“‹ Copy</button>
35
+ </div>
36
+
37
+ <div class="flex justify-between mt-4 mb-2">
38
+ <button onclick="generateEmail()" class="bg-blue-600 hover:bg-blue-700 px-4 py-2 rounded">πŸ”„ New Email</button>
39
+ <button onclick="fetchInbox()" class="bg-green-600 hover:bg-green-700 px-4 py-2 rounded">πŸ“© Refresh Inbox</button>
40
+ </div>
41
+
42
+ <div class="text-right text-sm text-yellow-300 mb-2">⏳ Time left: <span id="timer">10:00</span></div>
43
+
44
+ <h2 class="mt-4 mb-2 font-semibold text-lg text-indigo-300">πŸ“₯ Inbox</h2>
45
+ <div id="inbox" class="bg-gray-800 p-4 rounded-xl space-y-3 max-h-64 overflow-y-auto text-sm">
46
+ <p class="text-gray-400">πŸ“­ No messages yet.</p>
47
+ </div>
48
+
49
+ <h2 class="mt-6 mb-2 font-semibold text-lg text-yellow-300">πŸ“¨ Message Content</h2>
50
+ <div id="messageContent" class="bg-gray-800 p-4 rounded-xl text-sm overflow-y-auto max-h-64">
51
+ <p class="text-gray-400">Select a message to view its content.</p>
52
+ </div>
53
+ </div>
54
+
55
+ <script>
56
+ let currentEmail = "";
57
+ let currentLogin = "";
58
+ let currentDomain = "";
59
+ let timerInterval;
60
+ let inboxInterval;
61
+ let timeLeft = 600;
62
+
63
+ function showToast(msg) {
64
+ const toast = document.getElementById("toast");
65
+ toast.textContent = msg;
66
+ toast.classList.add("show");
67
+ setTimeout(() => toast.classList.remove("show"), 2000);
68
+ }
69
+
70
+ function randomStr(len = 10) {
71
+ const chars = "abcdefghijklmnopqrstuvwxyz123456789";
72
+ return Array.from({length: len}, () => chars[Math.floor(Math.random() * chars.length)]).join('');
73
+ }
74
+
75
+ function startTimer() {
76
+ clearInterval(timerInterval);
77
+ timeLeft = 600;
78
+ const timerEl = document.getElementById("timer");
79
+ timerInterval = setInterval(() => {
80
+ const minutes = Math.floor(timeLeft / 60).toString().padStart(2, '0');
81
+ const seconds = (timeLeft % 60).toString().padStart(2, '0');
82
+ timerEl.textContent = `${minutes}:${seconds}`;
83
+ timeLeft--;
84
+ if (timeLeft < 0) {
85
+ clearInterval(timerInterval);
86
+ clearInterval(inboxInterval);
87
+ generateEmail();
88
+ }
89
+ }, 1000);
90
+ }
91
+
92
+ function startAutoRefreshInbox() {
93
+ clearInterval(inboxInterval);
94
+ inboxInterval = setInterval(fetchInbox, 5000);
95
+ }
96
+
97
+ function generateEmail() {
98
+ currentLogin = randomStr();
99
+ currentDomain = "1secmail.com";
100
+ currentEmail = `${currentLogin}@${currentDomain}`;
101
+ document.getElementById("email").value = currentEmail;
102
+ document.getElementById("inbox").innerHTML = '<p class="text-gray-400">πŸ“­ No messages yet.</p>';
103
+ document.getElementById("messageContent").innerHTML = '<p class="text-gray-400">Select a message to view its content.</p>';
104
+ startTimer();
105
+ startAutoRefreshInbox();
106
+ }
107
+
108
+ function copyEmail() {
109
+ navigator.clipboard.writeText(currentEmail);
110
+ showToast("πŸ“‹ Email copied!");
111
+ }
112
+
113
+ async function fetchInbox() {
114
+ const inboxDiv = document.getElementById("inbox");
115
+ if (!currentLogin || !currentDomain) {
116
+ inboxDiv.innerHTML = '<p class="text-gray-400">⏳ Waiting for email setup...</p>';
117
+ return;
118
+ }
119
+ inboxDiv.innerHTML = '<p class="text-gray-400">πŸ”„ Fetching messages...</p>';
120
+ try {
121
+ const res = await fetch(`https://www.1secmail.com/api/v1/?action=getMessages&login=${currentLogin}&domain=${currentDomain}`);
122
+ const data = await res.json();
123
+
124
+ if (data.length === 0) {
125
+ inboxDiv.innerHTML = '<p class="text-gray-400">πŸ“­ No messages found.</p>';
126
+ return;
127
+ }
128
+
129
+ inboxDiv.innerHTML = '';
130
+ data.forEach(msg => {
131
+ const msgDiv = document.createElement("div");
132
+ msgDiv.className = "border-b border-gray-700 pb-2 cursor-pointer hover:bg-gray-700 p-2 rounded";
133
+ msgDiv.innerHTML = `
134
+ <p class="font-bold text-white">${msg.from}</p>
135
+ <p class="text-gray-300">${msg.subject}</p>
136
+ <div class="flex gap-2 mt-2">
137
+ <button onclick="fetchMessage(${msg.id})" class="bg-blue-600 px-2 py-1 text-xs rounded">πŸ“– Open</button>
138
+ <button onclick="copyMessage(${msg.id})" class="bg-indigo-600 px-2 py-1 text-xs rounded">πŸ“‹ Copy</button>
139
+ <button onclick="deleteMessage(${msg.id})" class="bg-red-600 px-2 py-1 text-xs rounded">πŸ—‘οΈ Delete</button>
140
+ <button onclick="forwardMessage(${msg.id})" class="bg-yellow-600 px-2 py-1 text-xs rounded">πŸ“€ Forward</button>
141
+ </div>`;
142
+ inboxDiv.appendChild(msgDiv);
143
+ });
144
+ } catch (err) {
145
+ inboxDiv.innerHTML = '<p class="text-red-500">❌ Error fetching inbox. Check connection or domain.</p>';
146
+ }
147
+ }
148
+
149
+ async function fetchMessage(id) {
150
+ const contentDiv = document.getElementById("messageContent");
151
+ contentDiv.innerHTML = '<p class="text-gray-400">πŸ”„ Loading message...</p>';
152
+ try {
153
+ const res = await fetch(`https://www.1secmail.com/api/v1/?action=readMessage&login=${currentLogin}&domain=${currentDomain}&id=${id}`);
154
+ const data = await res.json();
155
+ contentDiv.innerHTML = `
156
+ <p class="text-indigo-400 font-bold mb-2">From: ${data.from}</p>
157
+ <p class="text-green-400 font-bold mb-2">Subject: ${data.subject}</p>
158
+ <div class="text-gray-200 mt-2">${data.htmlBody || data.textBody}</div>
159
+ `;
160
+ } catch (err) {
161
+ contentDiv.innerHTML = '<p class="text-red-500">❌ Error loading message.</p>';
162
+ }
163
+ }
164
+
165
+ function copyMessage(id) {
166
+ fetch(`https://www.1secmail.com/api/v1/?action=readMessage&login=${currentLogin}&domain=${currentDomain}&id=${id}`)
167
+ .then(res => res.json())
168
+ .then(data => {
169
+ const content = data.htmlBody || data.textBody;
170
+ navigator.clipboard.writeText(content);
171
+ showToast("πŸ“‹ Message copied!");
172
+ });
173
+ }
174
+
175
+ function deleteMessage(id) {
176
+ alert("πŸ—‘οΈ Delete not supported by 1secmail API (for demo only)");
177
+ }
178
+
179
+ function forwardMessage(id) {
180
+ alert("πŸ“€ Forward not implemented β€” requires SMTP backend");
181
+ }
182
+
183
+ window.addEventListener('DOMContentLoaded', () => {
184
+ generateEmail();
185
+ });
186
+ </script>
187
+ </body>
188
  </html>