-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
215 lines (185 loc) · 6.43 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
210
211
212
213
214
215
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GitHub Project Finder</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #181818;
color: #e1e4e8;
padding: 20px;
}
h1 {
color: #58a6ff;
text-align: center;
font-size: 2.5rem;
margin-bottom: 20px;
}
.search-container {
display: flex;
justify-content: center;
margin-bottom: 40px;
}
.search-bar {
display: flex;
align-items: center;
gap: 10px;
}
.search-bar input {
padding: 12px;
font-size: 16px;
width: 300px;
border: 1px solid #444;
border-radius: 8px;
background-color: #333;
color: #e1e4e8;
}
.search-bar button {
padding: 12px 20px;
font-size: 16px;
background-color: #58a6ff;
color: #fff;
border: none;
border-radius: 8px;
cursor: pointer;
}
.search-bar button:hover {
background-color: #3399cc;
}
.repo-container {
display: flex;
justify-content: space-around;
margin-top: 20px;
}
.repo-section {
width: 45%;
background-color: #222;
padding: 20px;
border-radius: 8px;
}
.repo-card {
background-color: #333;
margin: 15px 0;
padding: 15px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.repo-title a {
color: #58a6ff;
font-size: 1.2rem;
font-weight: bold;
text-decoration: none;
}
.repo-info {
color: #ccc;
margin: 8px 0;
}
.repo-stats span {
color: #58a6ff;
font-size: 0.9rem;
margin-right: 10px;
}
.clone-btn {
padding: 10px 20px;
font-size: 14px;
background-color: #1d7d9c;
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
display: block;
margin-top: 10px;
width: 100%;
}
.clone-btn:hover {
background-color: #34d1e0;
}
.loading {
text-align: center;
color: #58a6ff;
font-size: 1.2rem;
display: none;
}
</style>
</head>
<body>
<h1>GitHub Project Finder</h1>
<div class="search-container">
<div class="search-bar">
<input type="text" id="query" placeholder="Search for GitHub repositories..." />
<button onclick="searchRepos()">Search</button>
</div>
</div>
<div class="loading" id="loading">Loading...</div>
<div class="repo-container">
<div class="repo-section" id="popular">
<h2>Popular Projects</h2>
</div>
<div class="repo-section" id="niche">
<h2>Niche Projects</h2>
</div>
</div>
<script>
async function searchRepos() {
const query = document.getElementById('query').value;
if (!query) return;
document.getElementById('loading').style.display = 'block';
document.getElementById('popular').innerHTML = '<h2>Popular Projects</h2>';
document.getElementById('niche').innerHTML = '<h2>Niche Projects</h2>';
try {
const response = await fetch(`https://api.github.com/search/repositories?q=${query}&per_page=100`);
const data = await response.json();
let hasPopular = false;
let hasNiche = false;
data.items.forEach(item => {
const repoCard = document.createElement('div');
repoCard.classList.add('repo-card');
const description = item.description ? item.description.slice(0, 80) + '...' : 'No description available';
repoCard.innerHTML = `
<div class="repo-title">
<a href="${item.html_url}" target="_blank">${item.name}</a>
</div>
<div class="repo-info">${description}</div>
<div class="repo-stats">
<span>⭐ ${item.stargazers_count}</span>
<span>🍴 ${item.forks_count}</span>
</div>
<button class="clone-btn" onclick="copyCloneURL('${item.clone_url}')">Clone to VS Code</button>
`;
if (item.stargazers_count >= 1000) {
document.getElementById('popular').appendChild(repoCard);
hasPopular = true;
}
if (item.stargazers_count < 100) {
document.getElementById('niche').appendChild(repoCard);
hasNiche = true;
}
});
if (!hasPopular) {
document.getElementById('popular').innerHTML += '<p>No popular projects found.</p>';
}
if (!hasNiche) {
document.getElementById('niche').innerHTML += '<p>No niche projects found.</p>';
}
} catch (error) {
console.error('Error fetching data:', error);
document.getElementById('popular').innerHTML += '<p>Error loading data for Popular Projects.</p>';
document.getElementById('niche').innerHTML += '<p>Error loading data for Niche Projects.</p>';
}
document.getElementById('loading').style.display = 'none';
}
function copyCloneURL(cloneURL) {
// Copy the clone URL to clipboard
const el = document.createElement('textarea');
el.value = cloneURL;
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
alert('Clone URL copied! Use "git clone" or open it in VS Code.');
}
</script>
</body>
</html>