Spaces:
Runtime error
Runtime error
Create index.html
Browse files- index.html +78 -0
index.html
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="id">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<title>Temp Email Farel</title>
|
| 6 |
+
<style>
|
| 7 |
+
body{background:#020617;color:#fff;font-family:sans-serif}
|
| 8 |
+
.box{max-width:500px;margin:40px auto;background:#0f172a;padding:20px;border-radius:10px}
|
| 9 |
+
input,select,button{width:100%;padding:10px;margin:6px 0}
|
| 10 |
+
button{background:#38bdf8;border:0;cursor:pointer}
|
| 11 |
+
.msg{background:#020617;padding:8px;border-radius:5px;margin:5px 0}
|
| 12 |
+
</style>
|
| 13 |
+
</head>
|
| 14 |
+
<body>
|
| 15 |
+
|
| 16 |
+
<div class="box">
|
| 17 |
+
<h2>📧 Temp Email Farel</h2>
|
| 18 |
+
|
| 19 |
+
<input id="name" placeholder="username">
|
| 20 |
+
<select id="domain"></select>
|
| 21 |
+
<button onclick="createEmail()">Buat Email</button>
|
| 22 |
+
|
| 23 |
+
<b id="email"></b>
|
| 24 |
+
<div id="inbox"></div>
|
| 25 |
+
</div>
|
| 26 |
+
|
| 27 |
+
<script>
|
| 28 |
+
let currentEmail = null;
|
| 29 |
+
let timer = null;
|
| 30 |
+
|
| 31 |
+
// load domain
|
| 32 |
+
async function loadDomains(){
|
| 33 |
+
const r = await fetch('/api/domains');
|
| 34 |
+
const j = await r.json();
|
| 35 |
+
j.domains.forEach(d=>{
|
| 36 |
+
domain.innerHTML += `<option>${d}</option>`;
|
| 37 |
+
});
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
// create email
|
| 41 |
+
async function createEmail(){
|
| 42 |
+
const r = await fetch('/api/email/new',{
|
| 43 |
+
method:'POST',
|
| 44 |
+
headers:{'Content-Type':'application/json'},
|
| 45 |
+
body:JSON.stringify({
|
| 46 |
+
name: name.value,
|
| 47 |
+
domain: domain.value
|
| 48 |
+
})
|
| 49 |
+
});
|
| 50 |
+
const j = await r.json();
|
| 51 |
+
if(!j.success) return alert(j.error);
|
| 52 |
+
|
| 53 |
+
currentEmail = j.email;
|
| 54 |
+
email.innerText = "📬 " + j.email;
|
| 55 |
+
|
| 56 |
+
if(timer) clearInterval(timer);
|
| 57 |
+
timer = setInterval(loadInbox, 5000);
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
// load inbox
|
| 61 |
+
async function loadInbox(){
|
| 62 |
+
if(!currentEmail) return;
|
| 63 |
+
const r = await fetch('/api/email/' + currentEmail + '/messages');
|
| 64 |
+
const j = await r.json();
|
| 65 |
+
inbox.innerHTML = '';
|
| 66 |
+
j.messages?.forEach(m=>{
|
| 67 |
+
inbox.innerHTML += `
|
| 68 |
+
<div class="msg">
|
| 69 |
+
<b>${m.from}</b><br>
|
| 70 |
+
${m.subject}
|
| 71 |
+
</div>`;
|
| 72 |
+
});
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
loadDomains();
|
| 76 |
+
</script>
|
| 77 |
+
</body>
|
| 78 |
+
</html>
|