-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent.html
More file actions
218 lines (194 loc) · 5.76 KB
/
event.html
File metadata and controls
218 lines (194 loc) · 5.76 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
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
216
217
218
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dorabangs Linkit Launching Day</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
background-color: #ffffff;
position: relative;
overflow: hidden;
}
#container {
text-align: center;
background: linear-gradient(to bottom right, #cddbff, #c4fff8);
padding: 30px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
z-index: 2;
position: relative;
color: white;
width: 100vw;
height: 100vh;
}
input {
padding: 12px;
margin: 8px;
border-radius: 5px;
border: 1px solid #ffffff;
width: calc(100% - 30px);
font-size: 14px;
}
button {
padding: 12px 20px;
margin: 8px;
border: none;
border-radius: 5px;
background-color: #9fd3fd;
color: white;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #a8b2fd;
}
/* Table styles */
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
background-color: white;
border-radius: 8px;
overflow: hidden;
}
th,
td {
border: 1px solid #e0f2f1;
padding: 10px;
text-align: center;
font-size: 14px;
color: black;
}
th {
background-color: #a396f9;
color: white;
}
/* Loading animation styles */
.loading {
display: flex;
align-items: center;
justify-content: center;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.8);
z-index: 10;
}
.loading.hidden {
display: none;
}
.loader {
border: 16px solid #f3f3f3;
border-top: 16px solid #83f19b;
border-radius: 50%;
width: 120px;
height: 120px;
animation: spin 1.5s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
</head>
<body>
<div id="container">
<h1>도라방스-Linkit: AI 따라잡기 챌린지</h1>
<form id="apiForm">
<input type="text" id="name" placeholder="Name" required />
<input type="text" id="keywords" placeholder="Keywords" required />
<input type="url" id="link" placeholder="Link" required />
<button type="submit">Send</button>
</form>
<div id="resultContainer">
<!-- Results Table will be inserted here -->
</div>
</div>
<!-- Custom Loading Animation -->
<div id="loading" class="loading hidden">
<div class="loader"></div>
</div>
<script>
const results = []; // Array to store all received results
document
.getElementById('apiForm')
.addEventListener('submit', async function (e) {
e.preventDefault();
const name = encodeURIComponent(
document.getElementById('name').value,
);
const keywords = encodeURIComponent(
document.getElementById('keywords').value,
);
const link = encodeURIComponent(
document.getElementById('link').value,
);
const loadingElement = document.getElementById('loading');
const resultContainer = document.getElementById('resultContainer');
// Show loading animation
loadingElement.classList.remove('hidden');
try {
// Construct the URL with query parameters
const url = `http://localhost:3000/launching-events?name=${name}&keywords=${keywords}&link=${link}`;
// Make the GET request
const response = await fetch(url, {
method: 'GET',
});
if (!response.ok) {
throw new Error('Network response was not ok');
}
const { data } = await response.json(); // Assume each API call returns a single result
// Add new result to the results array
results.push(data);
// Sort results by score in descending order
const sortedResults = results.sort((a, b) => b.score - a.score);
// Clear previous results and display the sorted ones in a table
resultContainer.innerHTML = `
<table>
<thead>
<tr>
<th>Name</th>
<th>Score</th>
<th>Link</th>
</tr>
</thead>
<tbody>
${sortedResults
.map(
(result) => `
<tr>
<td>${result.name}</td>
<td>${result.score.toFixed(2)}</td>
<td><a href="${link}" target="_blank">${decodeURIComponent(link)}</a></td>
</tr>
`,
)
.join('')}
</tbody>
</table>
`;
} catch (error) {
console.error('Error fetching API:', error);
resultContainer.innerHTML =
'<p style="color:red;">Failed to fetch results. Please try again.</p>';
} finally {
// Hide loading animation
loadingElement.classList.add('hidden');
}
});
</script>
</body>
</html>