Skip to content

Commit efb3147

Browse files
committed
Adding index.html
1 parent 7404e92 commit efb3147

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed

docs/index.html

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>LeetCode Solutions – efrat-dev</title>
6+
<style>
7+
body {
8+
font-family: sans-serif;
9+
display: flex;
10+
height: 100vh;
11+
margin: 0;
12+
}
13+
#sidebar {
14+
width: 300px;
15+
background: #f4f4f4;
16+
padding: 1rem;
17+
overflow-y: auto;
18+
border-right: 1px solid #ddd;
19+
}
20+
#content {
21+
flex: 1;
22+
padding: 1rem;
23+
overflow: auto;
24+
}
25+
ul {
26+
list-style-type: none;
27+
padding-left: 1rem;
28+
}
29+
li {
30+
cursor: pointer;
31+
margin: 0.2rem 0;
32+
}
33+
pre {
34+
background: #1e1e1e;
35+
color: #dcdcdc;
36+
padding: 1rem;
37+
border-radius: 8px;
38+
overflow-x: auto;
39+
}
40+
</style>
41+
<!-- Highlight.js -->
42+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css">
43+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
44+
<script>hljs.highlightAll();</script>
45+
</head>
46+
<body>
47+
<div id="sidebar"><strong>📁 תפריט קבצים</strong><div id="tree"></div></div>
48+
<div id="content"><em>בחר קובץ מהתפריט כדי לצפות בקוד.</em></div>
49+
50+
<script>
51+
const owner = "efrat-dev";
52+
const repo = "algo-ds-leetcode";
53+
const branch = "main";
54+
const baseUrl = `https://raw.githubusercontent.com/${owner}/${repo}/${branch}/`;
55+
56+
fetch(`https://api.github.com/repos/${owner}/${repo}/git/trees/${branch}?recursive=1`)
57+
.then(res => res.json())
58+
.then(data => {
59+
const files = data.tree.filter(item => item.type === "blob" && item.path.endsWith(".cs"));
60+
const treeData = buildTree(files.map(f => f.path));
61+
renderTree(treeData, document.getElementById("tree"));
62+
});
63+
64+
function buildTree(paths) {
65+
const root = {};
66+
for (const path of paths) {
67+
const parts = path.split("/");
68+
let curr = root;
69+
for (let i = 0; i < parts.length; i++) {
70+
const part = parts[i];
71+
if (!curr[part]) curr[part] = (i === parts.length - 1) ? path : {};
72+
curr = curr[part];
73+
}
74+
}
75+
return root;
76+
}
77+
78+
function renderTree(tree, container) {
79+
const ul = document.createElement("ul");
80+
for (const key in tree) {
81+
const li = document.createElement("li");
82+
if (typeof tree[key] === "string") {
83+
li.textContent = key;
84+
li.onclick = () => loadFile(tree[key]);
85+
} else {
86+
li.innerHTML = `📁 ${key}`;
87+
renderTree(tree[key], li);
88+
}
89+
ul.appendChild(li);
90+
}
91+
container.appendChild(ul);
92+
}
93+
94+
function loadFile(path) {
95+
const url = baseUrl + path;
96+
fetch(url)
97+
.then(res => res.text())
98+
.then(code => {
99+
document.getElementById("content").innerHTML = `
100+
<h3>${path}</h3>
101+
<pre><code class="language-csharp">${escapeHtml(code)}</code></pre>
102+
`;
103+
hljs.highlightAll();
104+
});
105+
}
106+
107+
function escapeHtml(text) {
108+
return text.replace(/[&<>"']/g, m => ({
109+
'&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#039;'
110+
})[m]);
111+
}
112+
</script>
113+
</body>
114+
</html>

0 commit comments

Comments
 (0)