-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
209 lines (201 loc) · 7.28 KB
/
index.html
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Excalidraw File Manager</title>
<link href="https://fonts.googleapis.com/css?family=Lato:600" rel="stylesheet">
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
background: #222;
color: white;
font-family: 'Noto Color Emoji', 'Segoe UI Emoji', 'Twemoji', sans-serif;
}
.header-container {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
padding: 20px;
}
.rotating-text {
font-weight: 600;
font-size: 36px;
color: white;
transform: translateX(-80px);
}
.rotating-text p {
display: inline-flex;
margin: 0;
vertical-align: top;
}
.rotating-text .word {
position: absolute;
display: flex;
opacity: 0;
}
.rotating-text .letter {
transform-origin: center center 25px;
}
.rotating-text .letter.out {
transform: rotateX(90deg);
transition: 0.32s cubic-bezier(0.6, 0, 0.7, 0.2);
}
.rotating-text .letter.in {
transition: 0.38s ease;
}
.rotating-text .letter.behind {
transform: rotateX(-90deg);
}
.alizarin { color: #e74c3c; }
.wisteria { color: #8e44ad; }
.peter-river { color: #3498db; }
.emerald { color: #2ecc71; }
.sun-flower { color: #f1c40f; }
.lw { font-size: 60px; }
.file-list {
margin-top: 10px;
padding: 10px;
background-color: #f0f0f0;
border: 1px solid #ccc;
border-radius: 5px;
color: black;
}
button {
margin-left: 10px;
}
.header-container img {
max-height: 450px;
margin-left: 10px;
}
#pdf-container {
width: 100%;
height: calc(100vh - 20px);
display: none;
}
#pdf-viewer {
width: 100%;
height: 100%;
margin-top: 20px;
}
</style>
</head>
<body>
<div class="header-container">
<div class="rotating-text">
<p>\=\=->Excalidraw files..Enjoy</p>
<p>
<span class="word alizarin">Learning.</span>
<span class="word wisteria">Scribbling.</span>
<span class="word peter-river">Brainstorming.</span>
<span class="word emerald">Coding.</span>
<span class="word wisteria">a Bomb Hydrogen.</span>
<span class="word sun-flower">Innovative.</span>
<span class="word alizarin">Diligent.</span>
<span class="word peter-river">Knowledgeable.</span>
</p>
</div>
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQJFTzgzWJXddO-2mlTGU0mXEuPwpWzASnZCw&s" alt="Baba Image">
</div>
<div>
<label for="folder-select">Select a folder:</label>
<select id="folder-select" onchange="showFileNames()">
<option value="">Select a folder</option>
<option value="DSA">DSA</option>
<option value="JAVA">Java</option>
<option value="S Design">S Design</option>
</select>
</div>
<div id="file-list-container">
<div class="file-list" id="file-list"></div>
</div>
<div>
<button onclick="saveFile()">Save File</button>
<button onclick="commitFile()">Commit File</button>
</div>
<div id="excalidraw-container"></div>
<script>
const token = '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';
const username = 'Siddhnak';
const repo = 'NotMLes';
let currentFilePath = '';
async function getLatestSHA(filePath) {
const response = await fetch(`https://api.github.com/repos/${username}/${repo}/contents/${filePath}`, {
headers: {
'Authorization': `token ${token}`
}
});
const fileData = await response.json();
return fileData.sha;
}
async function saveFile() {
const content = btoa('Your Excalidraw content here');
const response = await fetch(`https://api.github.com/repos/${username}/${repo}/contents/DSA/yourfile.excalidraw`, {
method: 'PUT',
headers: {
'Authorization': `token ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: 'Add new Excalidraw file',
content: content
})
});
const result = await response.json();
console.log(result);
}
async function commitFile() {
const content = btoa('Your updated Excalidraw content here');
const sha = await getLatestSHA(currentFilePath);
const response = await fetch(`https://api.github.com/repos/${username}/${repo}/contents/${currentFilePath}`, {
method: 'PUT',
headers: {
'Authorization': `token ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: 'Update Excalidraw file',
content: content,
sha: sha
})
});
const result = await response.json();
console.log(result);
}
async function showFileNames() {
const folder = document.getElementById('folder-select').value;
if (!folder) return;
const response = await fetch(`https://api.github.com/repos/${username}/${repo}/contents/${folder}`, {
headers: {
'Authorization': `token ${token}`
}
});
const files = await response.json();
const fileList = document.getElementById('file-list');
fileList.innerHTML = '';
files.forEach(file => {
const fileItem = document.createElement('div');
fileItem.textContent = file.name;
fileItem.style.cursor = 'pointer';
fileItem.onclick = () => openFile(file.path);
fileList.appendChild(fileItem);
});
}
async function openFile(filePath) {
currentFilePath = filePath;
const response = await fetch(`https://api.github.com/repos/${username}/${repo}/contents/${filePath}`, {
headers: {
'Authorization': `token ${token}`
}
});
const fileData = await response.json();
const content = atob(fileData.content);
const excalidrawContainer = document.getElementById('excalidraw-container');
excalidrawContainer.innerHTML = `<pre>${content}</pre>`;
}
</script>
</body>
</html>