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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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, maximum-scale=1, user-scalable=no, viewport-fit=cover" />
|
6 |
+
<title>Data Search XY</title>
|
7 |
+
<link rel="shortcut icon" href="https://github.githubassets.com/favicons/favicon.svg" />
|
8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" />
|
9 |
+
<style>
|
10 |
+
.container {
|
11 |
+
max-width: 100%;
|
12 |
+
margin: 0 auto;
|
13 |
+
padding: 0 10px;
|
14 |
+
box-sizing: border-box;
|
15 |
+
}
|
16 |
+
.input-container {
|
17 |
+
display: flex;
|
18 |
+
align-items: center;
|
19 |
+
margin-bottom: 10px;
|
20 |
+
border: 1px solid #ddd;
|
21 |
+
border-radius: 5px;
|
22 |
+
overflow: hidden;
|
23 |
+
}
|
24 |
+
#filterInput {
|
25 |
+
padding: 8px;
|
26 |
+
width: 100%;
|
27 |
+
font-size: 16px;
|
28 |
+
border: none;
|
29 |
+
box-sizing: border-box;
|
30 |
+
}
|
31 |
+
.btn, .clear-btn {
|
32 |
+
padding: 8px 12px;
|
33 |
+
font-size: 16px;
|
34 |
+
cursor: pointer;
|
35 |
+
border: none;
|
36 |
+
background-color: #f5f5f5;
|
37 |
+
transition: background-color 0.2s;
|
38 |
+
}
|
39 |
+
.btn:hover, .clear-btn:hover {
|
40 |
+
background-color: #e5e5e5;
|
41 |
+
}
|
42 |
+
.icon {
|
43 |
+
font-size: 16px;
|
44 |
+
}
|
45 |
+
table {
|
46 |
+
width: 100%;
|
47 |
+
border-collapse: collapse;
|
48 |
+
}
|
49 |
+
th, td {
|
50 |
+
padding: 8px;
|
51 |
+
text-align: left;
|
52 |
+
border: 1px solid #ddd;
|
53 |
+
}
|
54 |
+
th {
|
55 |
+
cursor: pointer;
|
56 |
+
}
|
57 |
+
th:hover {
|
58 |
+
background-color: #f5f5f5;
|
59 |
+
}
|
60 |
+
tr:nth-child(even) {
|
61 |
+
background-color: #f2f2f2;
|
62 |
+
}
|
63 |
+
.delete-btn {
|
64 |
+
background-color: #ff4d4d; /* Red background */
|
65 |
+
color: white; /* White text */
|
66 |
+
border: none; /* No border */
|
67 |
+
border-radius: 5px; /* Rounded corners */
|
68 |
+
padding: 5px 10px; /* Padding */
|
69 |
+
cursor: pointer; /* Pointer cursor */
|
70 |
+
}
|
71 |
+
.delete-btn:hover {
|
72 |
+
background-color: #ff1a1a; /* Darker red on hover */
|
73 |
+
}
|
74 |
+
|
75 |
+
/* Hide Hyperlink and Action columns on mobile */
|
76 |
+
@media screen and (max-width: 767px) {
|
77 |
+
#myTable th:nth-child(4), /* Hyperlink column */
|
78 |
+
#myTable td:nth-child(4),
|
79 |
+
#myTable th:nth-child(5), /* Action column */
|
80 |
+
#myTable td:nth-child(5) {
|
81 |
+
display: none;
|
82 |
+
}
|
83 |
+
|
84 |
+
/* Hide specific buttons */
|
85 |
+
.btn {
|
86 |
+
display: none;
|
87 |
+
}
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
/* Hide specific buttons on mobile */
|
92 |
+
/* 在手机上确保显示这两个按钮 */
|
93 |
+
@media screen and (max-width: 767px) {
|
94 |
+
.add-xlsx-btn, .download-xlsx-btn {
|
95 |
+
display: inline-block; /* 确保按钮显示为内联块元素 */
|
96 |
+
}
|
97 |
+
}
|
98 |
+
/* 为表格单元格设置换行 */
|
99 |
+
td {
|
100 |
+
word-wrap: break-word; /* 允许单元格内容换行 */
|
101 |
+
overflow-wrap: break-word; /* 兼容性增强 */
|
102 |
+
}
|
103 |
+
|
104 |
+
/* 针对手机屏幕缩小字体大小 */
|
105 |
+
@media screen and (max-width: 767px) {
|
106 |
+
table {
|
107 |
+
font-size: 14px; /* 当屏幕宽度小于767px时,缩小字体 */
|
108 |
+
}
|
109 |
+
td, th {
|
110 |
+
padding: 5px; /* 调整单元格内边距以节省空间 */
|
111 |
+
}
|
112 |
+
#filterInput {
|
113 |
+
font-size: 14px; /* 搜索框字体大小调整 */
|
114 |
+
}
|
115 |
+
.btn, .clear-btn {
|
116 |
+
font-size: 14px; /* 按钮字体调整 */
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
</style>
|
121 |
+
<script>
|
122 |
+
function sortDefault() {
|
123 |
+
sortTable(4);
|
124 |
+
}
|
125 |
+
|
126 |
+
function sortTable(n) {
|
127 |
+
var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
|
128 |
+
table = document.getElementById("myTable");
|
129 |
+
switching = true;
|
130 |
+
dir = "asc";
|
131 |
+
while (switching) {
|
132 |
+
switching = false;
|
133 |
+
rows = table.getElementsByTagName("TR");
|
134 |
+
for (i = 1; i < (rows.length - 1); i++) {
|
135 |
+
shouldSwitch = false;
|
136 |
+
x = rows[i].getElementsByTagName("TD")[n];
|
137 |
+
y = rows[i + 1].getElementsByTagName("TD")[n];
|
138 |
+
var xContent = x.innerText || x.textContent;
|
139 |
+
var yContent = y.innerText || y.textContent;
|
140 |
+
|
141 |
+
var xNum = parseFloat(xContent.replace(/[^0-9.]/g, ''));
|
142 |
+
var yNum = parseFloat(yContent.replace(/[^0-9.]/g, ''));
|
143 |
+
|
144 |
+
if (dir == "asc") {
|
145 |
+
if (!isNaN(xNum) && !isNaN(yNum)) {
|
146 |
+
if (xNum > yNum) {
|
147 |
+
shouldSwitch = true;
|
148 |
+
break;
|
149 |
+
}
|
150 |
+
} else {
|
151 |
+
if (xContent.toLowerCase() > yContent.toLowerCase()) {
|
152 |
+
shouldSwitch = true;
|
153 |
+
break;
|
154 |
+
}
|
155 |
+
}
|
156 |
+
} else if (dir == "desc") {
|
157 |
+
if (!isNaN(xNum) && !isNaN(yNum)) {
|
158 |
+
if (xNum < yNum) {
|
159 |
+
shouldSwitch = true;
|
160 |
+
break;
|
161 |
+
}
|
162 |
+
} else {
|
163 |
+
if (xContent.toLowerCase() < yContent.toLowerCase()) {
|
164 |
+
shouldSwitch = true;
|
165 |
+
break;
|
166 |
+
}
|
167 |
+
}
|
168 |
+
}
|
169 |
+
}
|
170 |
+
if (shouldSwitch) {
|
171 |
+
rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
|
172 |
+
switching = true;
|
173 |
+
switchcount++;
|
174 |
+
} else {
|
175 |
+
if (switchcount == 0 && dir == "asc") {
|
176 |
+
dir = "desc";
|
177 |
+
switching = true;
|
178 |
+
}
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
function filterTable() {
|
184 |
+
var input, filter, table, tr, td, i, j, txtValue;
|
185 |
+
input = document.getElementById("filterInput");
|
186 |
+
filter = input.value.toLowerCase();
|
187 |
+
table = document.getElementById("myTable");
|
188 |
+
tr = table.getElementsByTagName("tr");
|
189 |
+
for (i = 1; i < tr.length; i++) {
|
190 |
+
tr[i].style.display = "none";
|
191 |
+
td = tr[i].getElementsByTagName("td");
|
192 |
+
for (j = 0; j < td.length; j++) {
|
193 |
+
if (td[j]) {
|
194 |
+
txtValue = td[j].textContent || td[j].innerText;
|
195 |
+
if (txtValue.toLowerCase().indexOf(filter) > -1) {
|
196 |
+
tr[i].style.display = "";
|
197 |
+
break;
|
198 |
+
}
|
199 |
+
}
|
200 |
+
}
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
function startSpeechRecognition() {
|
205 |
+
var recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
|
206 |
+
recognition.lang = 'en-US';
|
207 |
+
recognition.onresult = function(event) {
|
208 |
+
var transcript = event.results[0][0].transcript;
|
209 |
+
transcript = transcript.replace(/[^a-zA-Z0-9\s]/g, '');
|
210 |
+
document.getElementById('filterInput').value = transcript;
|
211 |
+
filterTable();
|
212 |
+
}
|
213 |
+
recognition.start();
|
214 |
+
}
|
215 |
+
|
216 |
+
function clearInput() {
|
217 |
+
document.getElementById('filterInput').value = '';
|
218 |
+
filterTable();
|
219 |
+
}
|
220 |
+
|
221 |
+
// Add a new row to the table
|
222 |
+
function addRow() {
|
223 |
+
var table = document.getElementById("myTable");
|
224 |
+
var row = table.insertRow(-1); // Insert at the end of the table
|
225 |
+
|
226 |
+
var name = prompt("Enter Name:");
|
227 |
+
var year = prompt("Enter Year:");
|
228 |
+
var dataType = prompt("Enter Data Type:");
|
229 |
+
var capacity = prompt("Enter Domain (x.com):");
|
230 |
+
var hyperlink = prompt("Enter Hyperlink (https://x.com):");
|
231 |
+
|
232 |
+
// Ask if the user wants to add a hyperlink for the name
|
233 |
+
var addLink = confirm("Do you want to add a hyperlink for the name?");
|
234 |
+
var nameCell = addLink && hyperlink ? `<a target="_blank" href="${hyperlink}">${name}</a>` : name;
|
235 |
+
|
236 |
+
// For Hyperlink column: if there's a hyperlink, make the text a clickable link
|
237 |
+
var displayText = capacity || 'N/A'; // Default to 'N/A' if nothing is entered
|
238 |
+
|
239 |
+
// If hyperlink is provided, wrap the text in an <a> tag to make it clickable
|
240 |
+
var displayContent = hyperlink ? `<a target="_blank" href="${hyperlink}">${displayText}</a>` : displayText;
|
241 |
+
|
242 |
+
row.innerHTML = `
|
243 |
+
<td>${nameCell}</td>
|
244 |
+
<td>${year}</td>
|
245 |
+
<td>${dataType}</td>
|
246 |
+
<td contenteditable="true" onblur="updateLink(this.parentNode, 3)">
|
247 |
+
${displayContent}
|
248 |
+
</td>
|
249 |
+
<td><button class="delete-btn" onclick="deleteRow(this)">Delete</button></td>
|
250 |
+
`;
|
251 |
+
|
252 |
+
// Save the current table data to localStorage
|
253 |
+
saveTableToLocalStorage();
|
254 |
+
}
|
255 |
+
|
256 |
+
// Update the hyperlink in the table when the user edits the cell
|
257 |
+
function updateLink(row, cellIndex) {
|
258 |
+
var cell = row.cells[cellIndex];
|
259 |
+
var url = cell.innerText.trim();
|
260 |
+
|
261 |
+
// Check if the content is a valid URL
|
262 |
+
if (url && (url.startsWith('http://') || url.startsWith('https://'))) {
|
263 |
+
cell.innerHTML = `<a target="_blank" href="${url}">${url}</a>`;
|
264 |
+
} else {
|
265 |
+
// If the text is not a valid URL, leave it as plain text or 'N/A'
|
266 |
+
cell.innerHTML = url || 'N/A';
|
267 |
+
}
|
268 |
+
|
269 |
+
// After updating the link, save the table to localStorage again
|
270 |
+
saveTableToLocalStorage();
|
271 |
+
}
|
272 |
+
|
273 |
+
// Delete a row
|
274 |
+
function deleteRow(btn) {
|
275 |
+
var row = btn.parentNode.parentNode;
|
276 |
+
row.parentNode.removeChild(row);
|
277 |
+
|
278 |
+
// After deleting the row, save the updated table to localStorage
|
279 |
+
saveTableToLocalStorage();
|
280 |
+
}
|
281 |
+
|
282 |
+
// Save the current table data to localStorage
|
283 |
+
function saveTableToLocalStorage() {
|
284 |
+
var table = document.getElementById("myTable");
|
285 |
+
var rows = table.getElementsByTagName("tr");
|
286 |
+
var tableData = [];
|
287 |
+
|
288 |
+
for (var i = 1; i < rows.length; i++) { // Skip the header row
|
289 |
+
var row = rows[i];
|
290 |
+
var rowData = [];
|
291 |
+
|
292 |
+
for (var j = 0; j < row.cells.length - 1; j++) { // Skip the last cell (Action)
|
293 |
+
var cell = row.cells[j];
|
294 |
+
rowData.push(cell.innerHTML);
|
295 |
+
}
|
296 |
+
|
297 |
+
tableData.push(rowData);
|
298 |
+
}
|
299 |
+
|
300 |
+
// Save table data to localStorage
|
301 |
+
localStorage.setItem('tableData', JSON.stringify(tableData));
|
302 |
+
}
|
303 |
+
|
304 |
+
// Load the table data from localStorage
|
305 |
+
function loadTableFromLocalStorage() {
|
306 |
+
var tableData = localStorage.getItem('tableData');
|
307 |
+
if (tableData) {
|
308 |
+
tableData = JSON.parse(tableData);
|
309 |
+
var table = document.getElementById("myTable");
|
310 |
+
|
311 |
+
tableData.forEach(function(rowData) {
|
312 |
+
var row = table.insertRow(-1);
|
313 |
+
rowData.forEach(function(cellData) {
|
314 |
+
var cell = row.insertCell();
|
315 |
+
cell.innerHTML = cellData;
|
316 |
+
});
|
317 |
+
var deleteCell = row.insertCell();
|
318 |
+
deleteCell.innerHTML = `<button class="delete-btn" onclick="deleteRow(this)">Delete</button>`;
|
319 |
+
});
|
320 |
+
}
|
321 |
+
}
|
322 |
+
|
323 |
+
// Call this function when the page loads to restore table data
|
324 |
+
window.onload = function() {
|
325 |
+
loadTableFromLocalStorage();
|
326 |
+
};
|
327 |
+
|
328 |
+
// Update the link if user modifies the hyperlink column
|
329 |
+
function updateLink(row, cellIndex) {
|
330 |
+
var cell = row.cells[cellIndex];
|
331 |
+
var text = cell.innerText.trim();
|
332 |
+
|
333 |
+
// Check if the content is a valid URL and if so, update the cell to be a hyperlink
|
334 |
+
if (text && (text.startsWith('http://') || text.startsWith('https://'))) {
|
335 |
+
cell.innerHTML = `<a target="_blank" href="${text}">${text}</a>`;
|
336 |
+
} else {
|
337 |
+
cell.innerHTML = text || 'N/A';
|
338 |
+
}
|
339 |
+
}
|
340 |
+
|
341 |
+
|
342 |
+
|
343 |
+
|
344 |
+
|
345 |
+
function updateLink(row, cellIndex) {
|
346 |
+
var cell = row.cells[cellIndex];
|
347 |
+
var url = cell.innerText.trim();
|
348 |
+
|
349 |
+
// Check if the content is a valid URL
|
350 |
+
if (url && (url.startsWith('http://') || url.startsWith('https://'))) {
|
351 |
+
cell.innerHTML = `<a target="_blank" href="${url}">${url}</a>`;
|
352 |
+
} else {
|
353 |
+
// If the text is not a valid URL, leave it as plain text or 'N/A'
|
354 |
+
cell.innerHTML = url || 'N/A';
|
355 |
+
}
|
356 |
+
}
|
357 |
+
|
358 |
+
function deleteRow(btn) {
|
359 |
+
var row = btn.parentNode.parentNode;
|
360 |
+
row.parentNode.removeChild(row);
|
361 |
+
}
|
362 |
+
|
363 |
+
function downloadPage() {
|
364 |
+
const link = document.createElement('a');
|
365 |
+
link.href = 'data:text/html;charset=utf-8,' + encodeURIComponent(document.documentElement.outerHTML);
|
366 |
+
link.download = 'data_page.html';
|
367 |
+
document.body.appendChild(link);
|
368 |
+
link.click();
|
369 |
+
document.body.removeChild(link);
|
370 |
+
}
|
371 |
+
|
372 |
+
function downloadXLSX() {
|
373 |
+
var table = document.getElementById("myTable");
|
374 |
+
var workbook = XLSX.utils.book_new();
|
375 |
+
var wsData = [];
|
376 |
+
|
377 |
+
// Extract the header row
|
378 |
+
var headers = [];
|
379 |
+
var headerCells = table.getElementsByTagName("th");
|
380 |
+
for (var i = 0; i < headerCells.length; i++) {
|
381 |
+
headers.push(headerCells[i].innerText);
|
382 |
+
}
|
383 |
+
wsData.push(headers); // Add headers as the first row
|
384 |
+
|
385 |
+
// Extract the data rows
|
386 |
+
var rows = table.getElementsByTagName("tr");
|
387 |
+
for (var i = 1; i < rows.length; i++) { // Skip the first row (header)
|
388 |
+
var row = rows[i];
|
389 |
+
var rowData = [];
|
390 |
+
var cells = row.getElementsByTagName("td");
|
391 |
+
|
392 |
+
for (var j = 0; j < cells.length - 1; j++) { // Exclude the last cell (Action button)
|
393 |
+
var cell = cells[j];
|
394 |
+
// Check if the cell contains a link
|
395 |
+
if (cell.firstChild && cell.firstChild.tagName === 'A') {
|
396 |
+
// If it's a link, store the text content
|
397 |
+
rowData.push(cell.firstChild.innerText); // Use innerText of the link (not HTML)
|
398 |
+
} else {
|
399 |
+
rowData.push(cell.innerText || cell.textContent); // Regular text content
|
400 |
+
}
|
401 |
+
}
|
402 |
+
|
403 |
+
wsData.push(rowData); // Add the data row
|
404 |
+
}
|
405 |
+
|
406 |
+
// Create a worksheet from the data
|
407 |
+
var ws = XLSX.utils.aoa_to_sheet(wsData);
|
408 |
+
|
409 |
+
// Add the worksheet to the workbook
|
410 |
+
XLSX.utils.book_append_sheet(workbook, ws, "Sheet1");
|
411 |
+
|
412 |
+
// Write the XLSX file with the correct extension
|
413 |
+
XLSX.writeFile(workbook, "data.xlsx");
|
414 |
+
}
|
415 |
+
|
416 |
+
|
417 |
+
function handleFileUpload(event) {
|
418 |
+
var file = event.target.files[0];
|
419 |
+
if (file && file.name.endsWith('.xlsx')) {
|
420 |
+
var reader = new FileReader();
|
421 |
+
reader.onload = function(e) {
|
422 |
+
var data = new Uint8Array(e.target.result);
|
423 |
+
var workbook = XLSX.read(data, { type: 'array' });
|
424 |
+
|
425 |
+
// Get the first sheet
|
426 |
+
var sheetName = workbook.SheetNames[0];
|
427 |
+
var worksheet = workbook.Sheets[sheetName];
|
428 |
+
var jsonData = XLSX.utils.sheet_to_json(worksheet);
|
429 |
+
|
430 |
+
// Add data to the table
|
431 |
+
jsonData.forEach(function(rowData) {
|
432 |
+
var name = rowData.Name || 'N/A';
|
433 |
+
var hyperlink = rowData.Hyperlink || 'N/A';
|
434 |
+
var year = rowData.Year || 'N/A';
|
435 |
+
var dataType = rowData['Data type'] || 'N/A';
|
436 |
+
|
437 |
+
// Check if the row is a duplicate
|
438 |
+
if (!isRowDuplicate(name, hyperlink, year, dataType)) {
|
439 |
+
var table = document.getElementById("myTable");
|
440 |
+
var row = table.insertRow(-1); // Insert at the end of the table
|
441 |
+
|
442 |
+
var nameCell = `<a target="_blank" href="${hyperlink}">${name}</a>`;
|
443 |
+
var displayContent = hyperlink ? `<a target="_blank" href="${hyperlink}">${hyperlink}</a>` : 'N/A';
|
444 |
+
|
445 |
+
row.innerHTML = `
|
446 |
+
<td>${nameCell}</td>
|
447 |
+
<td>${year}</td>
|
448 |
+
<td>${dataType}</td>
|
449 |
+
<td contenteditable="true" onblur="updateLink(this.parentNode, 3)">
|
450 |
+
${displayContent}
|
451 |
+
</td>
|
452 |
+
<td><button class="delete-btn" onclick="deleteRow(this)">Delete</button></td>
|
453 |
+
`;
|
454 |
+
}
|
455 |
+
});
|
456 |
+
};
|
457 |
+
reader.readAsArrayBuffer(file);
|
458 |
+
} else {
|
459 |
+
alert('Please upload a valid XLSX file.');
|
460 |
+
}
|
461 |
+
}
|
462 |
+
|
463 |
+
// Check if the row already exists based on all columns (Name, Hyperlink, Year, Data type)
|
464 |
+
function isRowDuplicate(name, hyperlink, year, dataType) {
|
465 |
+
var table = document.getElementById("myTable");
|
466 |
+
var rows = table.getElementsByTagName("tr");
|
467 |
+
|
468 |
+
for (var i = 1; i < rows.length; i++) { // Skip the header row
|
469 |
+
var cells = rows[i].getElementsByTagName("td");
|
470 |
+
|
471 |
+
// Compare each column (Name, Hyperlink, Year, Data type)
|
472 |
+
var existingName = cells[0].textContent.trim();
|
473 |
+
var existingHyperlink = cells[3].textContent.trim();
|
474 |
+
var existingYear = cells[1].textContent.trim();
|
475 |
+
var existingDataType = cells[2].textContent.trim();
|
476 |
+
|
477 |
+
// If any column differs, it's not a duplicate
|
478 |
+
if (existingName === name && existingHyperlink === hyperlink && existingYear === year && existingDataType === dataType) {
|
479 |
+
return true; // Row is a duplicate
|
480 |
+
}
|
481 |
+
}
|
482 |
+
return false; // Row is not a duplicate
|
483 |
+
}
|
484 |
+
|
485 |
+
|
486 |
+
|
487 |
+
</script>
|
488 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.1/xlsx.full.min.js"></script>
|
489 |
+
</head>
|
490 |
+
<body onload="sortDefault()">
|
491 |
+
<div class="container">
|
492 |
+
<div class="input-container">
|
493 |
+
<input type="text" id="filterInput" onkeyup="filterTable()" placeholder="Search for Data.." />
|
494 |
+
<button class="clear-btn" onclick="clearInput()">✕</button>
|
495 |
+
<button class="btn" onclick="startSpeechRecognition()"><i class="fas fa-microphone icon"></i></button>
|
496 |
+
|
497 |
+
|
498 |
+
|
499 |
+
<button class="btn add add-xlsx-btn" title="upload xlsx" onclick="document.getElementById('file-input').click()">
|
500 |
+
<i class="fas fa-plus icon"></i>
|
501 |
+
</button>
|
502 |
+
<input type="file" id="file-input" style="display: none;" accept=".xlsx" onchange="handleFileUpload(event)" />
|
503 |
+
|
504 |
+
|
505 |
+
<button class="btn download-xlsx-btn" title="download xlsx" onclick="downloadXLSX()">
|
506 |
+
<i class="fa fa-download"></i>
|
507 |
+
</button>
|
508 |
+
|
509 |
+
<button class="btn" title="download html" onclick="downloadPage()"><i class="fab fa-chrome"></i></button>
|
510 |
+
<button class="btn" title="DatXY Project"onclick="window.open('https://github.com/feeday/DatXY')"><i class="fas fa-cog"></i></button>
|
511 |
+
|
512 |
+
<!--
|
513 |
+
<button class="btn" title="add data" onclick="addRow()"><i class="fas fa-plus icon"></i></button>
|
514 |
+
<button class="btn" title="add data" onclick="addRow()"><i class="fas fa-plus icon"></i></button>
|
515 |
+
<button class="btn download-xlsx-btn" title="download xlsx" onclick="downloadXLSX()"><i class="fa fa-download"></i></button>
|
516 |
+
<button class="btn" title="download add xlsx" onclick="window.open('https://datxy.com/add.xlsx', '_blank')">
|
517 |
+
<i class="fas fa-file-excel icon"></i>
|
518 |
+
</button>
|
519 |
+
-->
|
520 |
+
|
521 |
+
</div>
|
522 |
+
<table id="myTable">
|
523 |
+
<tbody>
|
524 |
+
<tr>
|
525 |
+
<th onclick="sortTable(0)">Name</th>
|
526 |
+
<th onclick="sortTable(1)">Year</th>
|
527 |
+
<th onclick="sortTable(2)">Data type</th>
|
528 |
+
<th onclick="sortTable(3)">Hyperlink</th>
|
529 |
+
<th>Action</th>
|
530 |
+
</tr>
|
531 |
+
<tr>
|
532 |
+
<td><a target="_blank" href="https://github.com/deepseek-ai/DeepSeek-R1">DeepSeek-R1</a></td>
|
533 |
+
<td>202501</td>
|
534 |
+
<td>Code-LLM</td>
|
535 |
+
<td><a target="_blank" href="https://github.com/deepseek-ai/DeepSeek-R1">https://github.com/deepseek-ai/DeepSeek-R1</a></td>
|
536 |
+
<td><button class="delete-btn" onclick="deleteRow(this)">Delete</button></td>
|
537 |
+
</tr>
|
538 |
+
<tr>
|
539 |
+
<td><a target="_blank" href="https://chat.scnet.cn">DeepSeek-R1</a></td>
|
540 |
+
<td>202502</td>
|
541 |
+
<td>Web-LLM</td>
|
542 |
+
<td><a target="_blank" href="https://chat.scnet.cn">https://chat.scnet.cn</a></td>
|
543 |
+
<td><button class="delete-btn" onclick="deleteRow(this)">Delete</button></td>
|
544 |
+
</tr>
|
545 |
+
<tr>
|
546 |
+
<td><a target="_blank" href="https://www.superclueai.com">SuperCLUE</a></td>
|
547 |
+
<td>202502</td>
|
548 |
+
<td>Ranking-AIGC</td>
|
549 |
+
<td><a target="_blank" href="https://www.superclueai.com/">https://www.superclueai.com</a></td>
|
550 |
+
<td><button class="delete-btn" onclick="deleteRow(this)">Delete</button></td>
|
551 |
+
</tr>
|
552 |
+
<tr>
|
553 |
+
<td><a target="_blank" href="https://www.iresearch.com.cn/report.shtml">IResearch</a></td>
|
554 |
+
<td>202502</td>
|
555 |
+
<td>PDF-Report</td>
|
556 |
+
<td><a target="_blank" href="https://www.iresearch.com.cn/report.shtml">https://www.iresearch.com.cn/report.shtml</a></td>
|
557 |
+
<td><button class="delete-btn" onclick="deleteRow(this)">Delete</button></td>
|
558 |
+
</tr>
|
559 |
+
<tr>
|
560 |
+
<td><a target="_blank" href="https://www.tradingview.com/markets/?aff_id=149508">TradingView</a></td>
|
561 |
+
<td>202502</td>
|
562 |
+
<td>Deal-Price</td>
|
563 |
+
<td><a target="_blank" href="https://www.tradingview.com/markets/?aff_id=149508">https://www.tradingview.com/markets</a></td>
|
564 |
+
<td><button class="delete-btn" onclick="deleteRow(this)">Delete</button></td>
|
565 |
+
</tr>
|
566 |
+
|
567 |
+
<tr>
|
568 |
+
<td><a target="_blank" href="https://www.w3schools.com/icons/icons_reference.asp">Font Awesome 5</a></td>
|
569 |
+
<td>201707</td>
|
570 |
+
<td>Web-Image</td>
|
571 |
+
<td><a target="_blank" href="https://www.w3schools.com/icons/icons_reference.asp">https://www.w3schools.com/icons/icons_reference.asp</a></td>
|
572 |
+
<td><button class="delete-btn" onclick="deleteRow(this)">Delete</button></td>
|
573 |
+
</tr>
|
574 |
+
<tr>
|
575 |
+
<td><a target="_blank" href="https://chatgpt.com/">ChatGPT</a></td>
|
576 |
+
<td>202303</td>
|
577 |
+
<td>Web-LLM</td>
|
578 |
+
<td><a target="_blank" href="https://chatgpt.com/">https://chatgpt.com</a></td>
|
579 |
+
<td><button class="delete-btn" onclick="deleteRow(this)">Delete</button></td>
|
580 |
+
</tr>
|
581 |
+
|
582 |
+
<tr>
|
583 |
+
<td><a target="_blank" href="https://jimeng.jianying.com/ai-tool/home">Jimeng</a></td>
|
584 |
+
<td>202502</td>
|
585 |
+
<td>Web-AIGC</td>
|
586 |
+
<td><a target="_blank" href="https://jimeng.jianying.com/ai-tool/home">https://jimeng.jianying.com/ai-tool/home</a></td>
|
587 |
+
<td><button class="delete-btn" onclick="deleteRow(this)">Delete</button></td>
|
588 |
+
</tr>
|
589 |
+
|
590 |
+
<tr>
|
591 |
+
<td><a target="_blank" href="https://www.midjourney.com/explore">Midjourney</a></td>
|
592 |
+
<td>202502</td>
|
593 |
+
<td>Web-AIGC</td>
|
594 |
+
<td><a target="_blank" href="https://www.midjourney.com/explore">https://www.midjourney.com/explore</a></td>
|
595 |
+
<td><button class="delete-btn" onclick="deleteRow(this)">Delete</button></td>
|
596 |
+
</tr>
|
597 |
+
|
598 |
+
<tr>
|
599 |
+
<td><a target="_blank" href="https://ai-bot.cn/ai-tools/">AI-Bot</a></td>
|
600 |
+
<td>202502</td>
|
601 |
+
<td>Message-AIGC</td>
|
602 |
+
<td><a target="_blank" href="https://ai-bot.cn/ai-tools/">https://ai-bot.cn/ai-tools</a></td>
|
603 |
+
<td><button class="delete-btn" onclick="deleteRow(this)">Delete</button></td>
|
604 |
+
</tr>
|
605 |
+
<tr>
|
606 |
+
<td><a target="_blank" href="https://huggingface.co/spaces/Sanster/Lama-Cleaner-lama">Lama-Cleaner</a></td>
|
607 |
+
<td>202502</td>
|
608 |
+
<td>Web-Image</td>
|
609 |
+
<td><a target="_blank" href="https://huggingface.co/spaces/Sanster/Lama-Cleaner-lama">https://huggingface.co/spaces/Sanster/Lama-Cleaner-lama</a></td>
|
610 |
+
<td><button class="delete-btn" onclick="deleteRow(this)">Delete</button></td>
|
611 |
+
</tr>
|
612 |
+
|
613 |
+
<tr>
|
614 |
+
<td><a target="_blank" href="https://chat18.aichatos18.com/">AIchatOS2</a></td>
|
615 |
+
<td>202502</td>
|
616 |
+
<td>Web-LLM</td>
|
617 |
+
<td><a target="_blank" href="https://chat18.aichatos18.com/">https://chat18.aichatos18.com</a></td>
|
618 |
+
<td><button class="delete-btn" onclick="deleteRow(this)">Delete</button></td>
|
619 |
+
</tr>
|
620 |
+
<tr>
|
621 |
+
<td><a target="_blank" href="https://wormhole.app/">Wormhole</a></td>
|
622 |
+
<td>202502</td>
|
623 |
+
<td>Files-Share</td>
|
624 |
+
<td><a target="_blank" href="https://wormhole.app">https://wormhole.app</a></td>
|
625 |
+
<td><button class="delete-btn" onclick="deleteRow(this)">Delete</button></td>
|
626 |
+
</tr>
|
627 |
+
<tr>
|
628 |
+
<td><a target="_blank" href="https://www.seeprettyface.com/mydataset.html">StyleGAN</a></td>
|
629 |
+
<td>202012</td>
|
630 |
+
<td>Dataset-Image-Face</td>
|
631 |
+
<td><a target="_blank" href="https://www.seeprettyface.com">https://www.seeprettyface.com</a></td>
|
632 |
+
<td><button class="delete-btn" onclick="deleteRow(this)">Delete</button></td>
|
633 |
+
</tr>
|
634 |
+
</tbody>
|
635 |
+
</table>
|
636 |
+
</div>
|
637 |
+
</body>
|
638 |
+
</html>
|