Repository navigation
Expand file tree
/
Copy pathnote.html
More file actions
152 lines (134 loc) · 7.94 KB
/
Copy pathnote.html
File metadata and controls
152 lines (134 loc) · 7.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DevVault</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/base16/oceanic-next.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<style>
body { background-color: #0c0c0e; color: #e4e4e7; scroll-behavior: smooth; }
.code-block { background: #18181b !important; border: 1px solid #27272a; border-radius: 8px; }
.input-bar { background: rgba(9, 9, 11, 0.95); backdrop-filter: blur(10px); border-top: 1px solid #27272a; }
pre code { font-family: 'Fira Code', 'JetBrains Mono', monospace !important; font-size: 13px !important; }
#feed { padding-bottom: 320px; }
.custom-input { background: #09090b; border: 1px solid #27272a; transition: all 0.2s; }
.custom-input:focus { border-color: #3b82f6; outline: none; box-shadow: 0 0 0 1px #3b82f6; }
</style>
</head>
<body>
<div id="login-screen" class="fixed inset-0 bg-black flex items-center justify-center z-[100]">
<div class="bg-zinc-900 p-8 rounded-2xl border border-zinc-800 w-full max-w-sm shadow-2xl">
<h2 class="text-xl font-bold mb-6 text-white tracking-tight">Root Access Required</h2>
<input type="email" id="email" placeholder="Email" class="w-full p-3 mb-4 custom-input rounded-lg text-sm">
<input type="password" id="password" placeholder="Password" class="w-full p-3 mb-6 custom-input rounded-lg text-sm">
<button id="login-btn" class="w-full bg-blue-600 text-white py-3 rounded-lg font-bold hover:bg-blue-500 active:scale-95 transition">Authorize</button>
<p id="error-msg" class="text-red-400 mt-4 text-[10px] text-center uppercase tracking-widest"></p>
</div>
</div>
<div id="app" class="hidden min-h-screen">
<header class="p-6 border-b border-zinc-800 flex justify-between items-center bg-zinc-950/50">
<h1 class="font-black text-xl tracking-tighter italic">DEV<span class="text-blue-500">_NOTES</span></h1>
<button id="logout-btn" class="text-xs text-zinc-500 hover:text-white uppercase tracking-widest">Disconnect</button>
</header>
<main id="feed" class="max-w-4xl mx-auto p-6 space-y-12"></main>
<footer class="fixed bottom-0 left-0 w-full input-bar">
<div class="max-w-4xl mx-auto p-6">
<div class="flex flex-col gap-4">
<textarea id="code-input" placeholder="// Paste code here..." class="w-full h-32 p-4 custom-input rounded-lg font-mono text-xs resize-none"></textarea>
<div class="flex flex-col md:flex-row gap-4">
<textarea id="expl-input" placeholder="Explain what this does..." class="flex-1 p-3 custom-input rounded-lg text-sm resize-none h-12 md:h-auto"></textarea>
<div class="flex gap-2">
<select id="lang-select" class="custom-input p-2 rounded-lg text-xs font-bold uppercase">
<option value="python">Python</option>
<option value="cpp">C++</option>
<option value="c">C</option>
<option value="csharp">C#</option>
<option value="xml">XML</option>
<option value="javascript">JavaScript</option>
<option value="java">Java</option>
<option value="sql">SQL</option>
</select>
<button id="post-btn" class="bg-white text-black px-8 py-2 rounded-lg font-black hover:bg-blue-500 hover:text-white transition uppercase text-xs">Post</button>
</div>
</div>
</div>
</div>
</footer>
</div>
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/11.0.1/firebase-app.js";
import { getAuth, signInWithEmailAndPassword, onAuthStateChanged, signOut } from "https://www.gstatic.com/firebasejs/11.0.1/firebase-auth.js";
import { getFirestore, collection, addDoc, query, orderBy, onSnapshot } from "https://www.gstatic.com/firebasejs/11.0.1/firebase-firestore.js";
const firebaseConfig = {
apiKey: "AIzaSyA8txKtjKZlwtNq7_u5c0no3sN845FBHps",
authDomain: "note-533db.firebaseapp.com",
projectId: "note-533db",
storageBucket: "note-533db.firebasestorage.app",
messagingSenderId: "431837021498",
appId: "1:431837021498:web:3023f8c1b1a906362ebc03"
};
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const db = getFirestore(app);
const loginScreen = document.getElementById('login-screen');
const appScreen = document.getElementById('app');
const feed = document.getElementById('feed');
document.getElementById('login-btn').onclick = async () => {
try {
await signInWithEmailAndPassword(auth, document.getElementById('email').value, document.getElementById('password').value);
} catch (e) {
document.getElementById('error-msg').innerText = "Auth Failed";
}
};
document.getElementById('logout-btn').onclick = () => signOut(auth);
onAuthStateChanged(auth, (user) => {
if (user && user.email === "mail.iciiwhite@gmail.com") {
loginScreen.classList.add('hidden');
appScreen.classList.remove('hidden');
syncFeed();
} else {
loginScreen.classList.remove('hidden');
appScreen.classList.add('hidden');
}
});
function syncFeed() {
const q = query(collection(db, "notes"), orderBy("ts", "desc"));
onSnapshot(q, (snap) => {
feed.innerHTML = '';
snap.forEach((doc) => {
const data = doc.data();
const el = document.createElement('div');
el.className = 'space-y-3 slide-up';
el.innerHTML = `
<div class="flex items-center gap-3">
<span class="text-[10px] font-black bg-white text-black px-2 py-0.5 rounded uppercase">${data.lang}</span>
<div class="h-[1px] flex-1 bg-zinc-800"></div>
</div>
<pre class="code-block p-4 overflow-x-auto"><code class="language-${data.lang}">${escape(data.code)}</code></pre>
<p class="text-zinc-400 text-sm font-medium pl-2 border-l border-blue-500/50">${data.expl}</p>
`;
feed.appendChild(el);
});
document.querySelectorAll('pre code').forEach(hljs.highlightElement);
});
}
document.getElementById('post-btn').onclick = async () => {
const code = document.getElementById('code-input').value;
const expl = document.getElementById('expl-input').value;
const lang = document.getElementById('lang-select').value;
if(!code || !expl) return;
await addDoc(collection(db, "notes"), {
code, expl, lang, ts: new Date()
});
document.getElementById('code-input').value = '';
document.getElementById('expl-input').value = '';
window.scrollTo(0,0);
};
function escape(html) {
return html.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
}
</script>
</body>
</html>