Spaces:
Running
Running
Update index.html
Browse files- index.html +162 -19
index.html
CHANGED
@@ -1,19 +1,162 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Search Interface</title>
|
7 |
+
<link
|
8 |
+
rel="stylesheet"
|
9 |
+
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
|
10 |
+
>
|
11 |
+
<style>
|
12 |
+
body {
|
13 |
+
padding: 2rem;
|
14 |
+
display: flex;
|
15 |
+
justify-content: center;
|
16 |
+
flex-direction: column; /* Stack elements vertically */
|
17 |
+
align-items: center;
|
18 |
+
}
|
19 |
+
|
20 |
+
main {
|
21 |
+
width: 100%;
|
22 |
+
max-width: 800px; /* Set the max width to 800px */
|
23 |
+
}
|
24 |
+
|
25 |
+
header {
|
26 |
+
width: 100%;
|
27 |
+
margin-bottom: 1rem; /* Ensure some space between header and search bar */
|
28 |
+
text-align: center; /* Center align header text */
|
29 |
+
}
|
30 |
+
|
31 |
+
#searchQuery {
|
32 |
+
width: 100%;
|
33 |
+
padding: 0.8rem;
|
34 |
+
font-size: 1rem;
|
35 |
+
margin-bottom: 1rem; /* Add space below the input field */
|
36 |
+
border-radius: 5px;
|
37 |
+
border: 1px solid #ccc;
|
38 |
+
}
|
39 |
+
|
40 |
+
.result-item {
|
41 |
+
display: flex;
|
42 |
+
justify-content: center; /* Center content horizontally */
|
43 |
+
align-items: center; /* Center content vertically */
|
44 |
+
padding: 1rem;
|
45 |
+
margin: 0.5rem 0;
|
46 |
+
border: 1px solid #ddd;
|
47 |
+
border-radius: 8px;
|
48 |
+
cursor: pointer;
|
49 |
+
gap: 1rem; /* Add space between the image and text */
|
50 |
+
transition: background-color 0.3s ease;
|
51 |
+
}
|
52 |
+
|
53 |
+
.result-item img {
|
54 |
+
border-radius: 50%;
|
55 |
+
width: 50px;
|
56 |
+
height: 50px;
|
57 |
+
}
|
58 |
+
|
59 |
+
.result-item .result-text {
|
60 |
+
text-align: center; /* Center align text */
|
61 |
+
}
|
62 |
+
|
63 |
+
.result-item a {
|
64 |
+
display: flex;
|
65 |
+
justify-content: center; /* Ensure that the content inside the link is centered */
|
66 |
+
align-items: center;
|
67 |
+
gap: 1rem; /* Add space between image and text */
|
68 |
+
text-decoration: none;
|
69 |
+
color: inherit;
|
70 |
+
width: 100%; /* Make sure the link takes up the full width of the list item */
|
71 |
+
}
|
72 |
+
|
73 |
+
.result-item a:hover {
|
74 |
+
background-color: #f0f0f0; /* Light hover effect */
|
75 |
+
border-radius: 8px;
|
76 |
+
}
|
77 |
+
|
78 |
+
.result-item span {
|
79 |
+
display: block;
|
80 |
+
}
|
81 |
+
|
82 |
+
.result-item .name {
|
83 |
+
font-weight: bold;
|
84 |
+
}
|
85 |
+
|
86 |
+
ul {
|
87 |
+
padding: 0;
|
88 |
+
}
|
89 |
+
</style>
|
90 |
+
</head>
|
91 |
+
<body>
|
92 |
+
|
93 |
+
<header>
|
94 |
+
<h1>Search for Organizations on Hugging Face</h1>
|
95 |
+
</header>
|
96 |
+
|
97 |
+
<main>
|
98 |
+
<input type="text" id="searchQuery" placeholder="Search query" autofocus>
|
99 |
+
<ul id="resultsList"></ul>
|
100 |
+
</main>
|
101 |
+
|
102 |
+
<script>
|
103 |
+
const searchInput = document.getElementById('searchQuery');
|
104 |
+
const resultsList = document.getElementById('resultsList');
|
105 |
+
let debounceTimer;
|
106 |
+
|
107 |
+
searchInput.addEventListener('input', function() {
|
108 |
+
clearTimeout(debounceTimer);
|
109 |
+
debounceTimer = setTimeout(function() {
|
110 |
+
const query = searchInput.value.trim();
|
111 |
+
if (query) {
|
112 |
+
fetchResults(query);
|
113 |
+
} else {
|
114 |
+
resultsList.innerHTML = ''; // Clear results if search query is empty
|
115 |
+
}
|
116 |
+
}, 200); // Wait for 200ms after the user stops typing
|
117 |
+
});
|
118 |
+
|
119 |
+
async function fetchResults(query) {
|
120 |
+
try {
|
121 |
+
const params = new URLSearchParams({
|
122 |
+
type: 'org',
|
123 |
+
limit: 20,
|
124 |
+
q: query
|
125 |
+
});
|
126 |
+
const response = await fetch(`https://huggingface.co/api/quicksearch?${params.toString()}`);
|
127 |
+
const data = await response.json();
|
128 |
+
|
129 |
+
displayResults(data.orgs);
|
130 |
+
} catch (error) {
|
131 |
+
console.error('Error fetching search results:', error);
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
function displayResults(orgs) {
|
136 |
+
resultsList.innerHTML = ''; // Clear previous results
|
137 |
+
if (orgs.length === 0) {
|
138 |
+
resultsList.innerHTML = '<li>No organizations found.</li>';
|
139 |
+
return;
|
140 |
+
}
|
141 |
+
|
142 |
+
orgs.forEach(org => {
|
143 |
+
const listItem = document.createElement('li');
|
144 |
+
listItem.classList.add('result-item');
|
145 |
+
|
146 |
+
// Wrap the whole result item in an anchor link
|
147 |
+
listItem.innerHTML = `
|
148 |
+
<a href="https://huggingface.co/${org.name}" target="_blank">
|
149 |
+
<img src="${org.avatarUrl}" alt="${org.fullname}">
|
150 |
+
<div class="result-text">
|
151 |
+
<span class="name">${org.fullname}</span>
|
152 |
+
<span>(${org.name})</span>
|
153 |
+
</div>
|
154 |
+
</a>
|
155 |
+
`;
|
156 |
+
resultsList.appendChild(listItem);
|
157 |
+
});
|
158 |
+
}
|
159 |
+
</script>
|
160 |
+
|
161 |
+
</body>
|
162 |
+
</html>
|