File size: 51,921 Bytes
9b8659c af87529 6414083 af87529 5a7babe af87529 5a7babe af87529 9b8659c af87529 9b8659c c50a91b 9b8659c 42c2745 9b8659c c50a91b 42c2745 9b8659c 42c2745 9b8659c 42c2745 9b8659c c50a91b 42c2745 9b8659c 42c2745 9b8659c c0da993 a1d6fad bf3d263 908a76b bf3d263 177eef9 c50a91b 177eef9 c0da993 177eef9 9b8659c c0da993 177eef9 c0da993 9b8659c c0da993 9b8659c c0da993 177eef9 9b8659c 1aa49ec 0cc17f3 9b8659c 0cc17f3 bef585f 908a76b af87529 23239a2 90b78ed bef585f 0bfa106 90b78ed 6414083 af87529 42f47b4 af87529 386bb07 af87529 d61c80e 23239a2 bef585f 9b8659c 42c2745 9b8659c 42c2745 9b8659c 42c2745 9b8659c 42c2745 9b8659c 59ead40 177eef9 c50a91b 177eef9 c50a91b 177eef9 1aa49ec 59ead40 b41f7f8 bf3d263 c0da993 42c2745 9b8659c c0da993 9b8659c 936d8d9 42c2745 936d8d9 42c2745 9b8659c 936d8d9 9b8659c 936d8d9 9b8659c 936d8d9 42c2745 09d288e af87529 09d288e 936d8d9 af87529 936d8d9 af87529 936d8d9 9b8659c c50a91b 90b78ed c50a91b 90b78ed bef585f d27e581 846ca30 bef585f 6414083 0bfa106 d27e581 846ca30 0bfa106 9b8659c 677a35d 42c2745 846ca30 42c2745 2fcd836 d27e581 5840f5c 42c2745 9b8659c d84dc85 42c2745 09d288e 42c2745 936d8d9 9b8659c 09d288e 9b8659c 09d288e 9b8659c 936d8d9 9b8659c 42c2745 9b8659c 936d8d9 9e10e0f 936d8d9 af87529 936d8d9 9b8659c 936d8d9 9b8659c 1094cbb 9b8659c 1094cbb 6aa12a9 9b8659c 09d288e 9b8659c c50a91b 9b8659c c50a91b 9b8659c c50a91b 936d8d9 09d288e 936d8d9 9e10e0f 936d8d9 1094cbb 936d8d9 09d288e 936d8d9 09d288e 936d8d9 6aa12a9 908a76b 6aa12a9 bf3d263 908a76b bf3d263 6aa12a9 c50a91b 90b78ed 1b19224 90b78ed 9b8659c |
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 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 |
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio,line-clamp"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.2.1/flowbite.min.css" rel="stylesheet" />
<script>
function fetchAndDisplaySubmissionInfo() {
const articleLoadingSpinner = document.getElementById('articleLoadingSpinner');
articleLoadingSpinner.classList.remove('hidden');
fetch('/submission_info')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json(); // Parse the JSON response
})
.then(data => {
// Populate the 'content' div with the HTML from the response
const contentDiv = document.getElementById('content');
contentDiv.innerHTML = marked.parse(data.response);
addTargetBlankToLinks();
articleLoadingSpinner.classList.add('hidden');
})
.catch(error => {
console.error('There has been a problem with your fetch operation:', error);
articleLoadingSpinner.classList.add('hidden');
});
}
function fetchAndDisplaySubmissions() {
const apiEndpoint = '/my_submissions';
const articleLoadingSpinner = document.getElementById('articleLoadingSpinner');
articleLoadingSpinner.classList.remove('hidden');
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
}
};
fetch(apiEndpoint, requestOptions)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
const contentDiv = document.getElementById('content');
const teamNameDiv = `<h2>${data.response.team_name}</h2>`
// console.log(data.response.submissions);
// contentDiv.innerHTML = marked.parse(data.response.submission_text) + data.response.submissions;
if (data.response.submissions && data.response.submissions.length > 0 && data.response.error.length == 0) {
// Start building the table HTML
let tableHTML = teamNameDiv;
tableHTML += '<table border="1"><tr><th width: 17%;>Datetime</th><th style="width: 40%;">Submission ID</th><th style="width: 20%;">Score</th><th style="width: 8%;">Status</th><th style="width: 15%;">Error</th></tr>';
// Iterate over each submission and add it to the table
data.response.submissions.forEach(submission => {
logFileLink = submission.log_file_url === "" ? "" : `<a href="${submission.log_file_url}" target="_blank">log_file.txt</a>`;
tableHTML += `<tr>
<td>${submission.datetime}</td>
<td>${submission.submission_id}</td>
<td>${submission.score}</td>
<td>${submission.status}</td>
<td>${submission.error_message}<br> ${logFileLink}</td>
</tr>`;
});
// Close the table HTML and set it as the content
tableHTML += '</table>';
// add a text field which displays team name and a button to update team name
contentDiv.innerHTML = marked.parse(data.response.submission_text) + tableHTML;
} else {
// Display message if there are no submissions
contentDiv.innerHTML = teamNameDiv + marked.parse(data.response.submission_text) + marked.parse(data.response.error);
}
document.getElementById('updateTeamNameButton').addEventListener('click', function () {
updateTeamName();
});
articleLoadingSpinner.classList.add('hidden');
})
.catch(error => {
console.error('There was a problem with the fetch operation:', error);
articleLoadingSpinner.classList.add('hidden');
});
}
function showSubmissionModal() {
const modal = document.getElementById('submission-modal');
modal.classList.add('flex');
modal.classList.remove('hidden');
}
document.addEventListener('DOMContentLoaded', function () {
function hideSubmissionModal() {
const modal = document.getElementById('submission-modal');
modal.classList.remove('flex');
modal.classList.add('hidden');
}
function addTargetBlankToLinks() {
const content = document.getElementById('content');
const links = content.getElementsByTagName('a');
for (let i = 0; i < links.length; i++) {
if (!links[i].hasAttribute('target')) {
links[i].setAttribute('target', '_blank');
}
}
}
function fetchAndDisplayCompetitionInfo() {
const articleLoadingSpinner = document.getElementById('articleLoadingSpinner');
articleLoadingSpinner.classList.remove('hidden');
fetch('/competition_info')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json(); // Parse the JSON response
})
.then(data => {
// Populate the 'content' div with the HTML from the response
const contentDiv = document.getElementById('content');
contentDiv.style.display = 'block';
contentDiv.innerHTML = marked.parse(data.response);
addTargetBlankToLinks();
articleLoadingSpinner.classList.add('hidden');
})
.catch(error => {
console.error('There has been a problem with your fetch operation:', error);
articleLoadingSpinner.classList.add('hidden');
});
}
function fetchAndDisplayDatasetInfo() {
const articleLoadingSpinner = document.getElementById('articleLoadingSpinner');
articleLoadingSpinner.classList.remove('hidden');
fetch('/dataset_info')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json(); // Parse the JSON response
})
.then(data => {
// Populate the 'content' div with the HTML from the response
const contentDiv = document.getElementById('content');
contentDiv.innerHTML = marked.parse(data.response);
addTargetBlankToLinks();
articleLoadingSpinner.classList.add('hidden');
})
.catch(error => {
console.error('There has been a problem with your fetch operation:', error);
articleLoadingSpinner.classList.add('hidden');
});
}
// function fetchAndDisplayLeaderboard(leaderboardType) {
// const articleLoadingSpinner = document.getElementById('articleLoadingSpinner');
// articleLoadingSpinner.classList.remove('hidden');
// const payload = {
// lb: leaderboardType,
// };
// fetch('/leaderboard', {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json'
// },
// body: JSON.stringify(payload)
// })
// .then(response => {
// if (!response.ok) {
// throw new Error('Network response was not ok');
// }
// return response.json();
// })
// .then(data => {
// const contentDiv = document.getElementById('content');
// contentDiv.innerHTML = marked.parse(data.response);
// articleLoadingSpinner.classList.add('hidden');
// })
// .catch(error => {
// console.error('There has been a problem with your fetch operation:', error);
// articleLoadingSpinner.classList.add('hidden');
// });
// }
// function fetchAndDisplayPublicLeaderboard() {
// fetchAndDisplayLeaderboard('public');
// }
// function fetchAndDisplayPrivateLeaderboard() {
// fetchAndDisplayLeaderboard('private');
// }
function fetchAndDisplayTeamInfo() {
const apiEndpoint = '/team_info';
const articleLoadingSpinner = document.getElementById('articleLoadingSpinner');
articleLoadingSpinner.classList.remove('hidden');
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
}
};
fetch(apiEndpoint, requestOptions)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json(); // Parse the JSON response
})
.then(data => {
// Populate the 'content' div with the HTML from the response
const contentDiv = document.getElementById('content');
if (data.team_exists) {
contentHTML = "<h2>Team</h2>";
contentHTML += "<p>" + data.team_name + "</p>";
contentDiv.innerHTML = marked.parse(contentHTML);
} else {
contentDiv.innerHTML = marked.parse(data.response);
}
contentDiv.innerHTML = marked.parse(data.response);
articleLoadingSpinner.classList.add('hidden');
})
.catch(error => {
console.error('There has been a problem with your fetch operation:', error);
articleLoadingSpinner.classList.add('hidden');
});
}
function fetchAndDisplayRules() {
const articleLoadingSpinner = document.getElementById('articleLoadingSpinner');
articleLoadingSpinner.classList.remove('hidden');
fetch('/rules')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json(); // Parse the JSON response
})
.then(data => {
// Populate the 'content' div with the HTML from the response
const contentDiv = document.getElementById('content');
contentDiv.innerHTML = marked.parse(data.response);
addTargetBlankToLinks();
articleLoadingSpinner.classList.add('hidden');
})
.catch(error => {
console.error('There has been a problem with your fetch operation:', error);
articleLoadingSpinner.classList.add('hidden');
});
}
function fetchAndDisplayLeaderboard() {
const articleLoadingSpinner = document.getElementById('articleLoadingSpinner');
articleLoadingSpinner.classList.remove('hidden');
fetch('/leaderboard', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
}).then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
}).then(data => {
const contentDiv = document.getElementById('content');
contentDiv.innerHTML = marked.parse(data.response);
articleLoadingSpinner.classList.add('hidden');
}).catch(error => {
console.error('There has been a problem with your fetch operation:', error);
articleLoadingSpinner.classList.add('hidden');
});
}
const homeLink = document.getElementById('home');
const datasetLink = document.getElementById('dataset');
// const publicLBLink = document.getElementById('public_lb');
// const privateLBLink = document.getElementById('private_lb');
const rulesLink = document.getElementById('rules');
const leaderBoardLink = document.getElementById('leaderboard');
leaderBoardLink.addEventListener('click', function (event) {
event.preventDefault(); // Prevent the default link behavior
fetchAndDisplayLeaderboard(); // Fetch and display info on click
});
// Add a click event listener to the 'Home' link
homeLink.addEventListener('click', function (event) {
event.preventDefault(); // Prevent the default link behavior
fetchAndDisplayCompetitionInfo(); // Fetch and display info on click
});
datasetLink.addEventListener('click', function (event) {
event.preventDefault(); // Prevent the default link behavior
fetchAndDisplayDatasetInfo(); // Fetch and display info on click
});
// publicLBLink.addEventListener('click', function (event) {
// event.preventDefault(); // Prevent the default link behavior
// fetchAndDisplayPublicLeaderboard(); // Fetch and display info on click
// });
// privateLBLink.addEventListener('click', function (event) {
// event.preventDefault(); // Prevent the default link behavior
// fetchAndDisplayPrivateLeaderboard(); // Fetch and display info on click
// });
rulesLink.addEventListener('click', function (event) {
event.preventDefault(); // Prevent the default link behavior
fetchAndDisplayRules(); // Fetch and display info on click
});
// Fetch and display info when the page loads
fetchAndDisplayCompetitionInfo();
document.querySelector('#submission-modal .cancel').addEventListener('click', function () {
hideSubmissionModal();
});
});
</script>
<script>
function makeApiRequest(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
var response = JSON.parse(xhr.responseText);
callback(response.response);
}
};
xhr.send();
}
function checkOAuth() {
var url = "/login_status";
const submissionInfo = document.getElementById('submission_info');
const mySubmissions = document.getElementById('my_submissions');
const newSubmission = document.getElementById('new_submission');
makeApiRequest(url, function ({is_login, is_admin, is_registered, is_white_team}) {
const registerRemoveStyle = ["pointer-events-none", "text-gray-400", "cursor-not-allowed"];
const registerNewStyle = ["ext-gray-900", "hover:bg-gray-100"]
if (is_login) {
document.getElementById("loginButton").style.display = "none";
document.getElementById("logoutButton").style.display = "block";
} else {
document.getElementById("loginButton").style.display = "block";
document.getElementById("logoutButton").style.display = "none";
}
if (is_admin) {
document.getElementById("admin").classList.remove("hidden");
}
if (is_registered) {
document.getElementById("updateTeamInfo").style.display = "block";
}
submissionInfo.addEventListener('click', function (event) {
event.preventDefault(); // Prevent the default link behavior
if (is_registered) {
fetchAndDisplaySubmissionInfo(); // Fetch and display info on click
} else {
alert(`You need to register to access the "Submission Information."`)
}
});
mySubmissions.addEventListener('click', function (event) {
event.preventDefault(); // Prevent the default link behavior
if (is_white_team) {
fetchAndDisplaySubmissions(); // Fetch and display info on click
} else {
alert(`Access to "SUBMIT" will be granted after we manually review your registration. This process usually takes up to 24 hours.`)
}
});
newSubmission.addEventListener('click', function (event) {
event.preventDefault(); // Prevent the default link behavior
if (is_white_team) {
showSubmissionModal(); // Show the submission modal
} else {
alert(`Access to "SUBMIT" will be granted after we manually review your registration. This process usually takes up to 24 hours.`)
}
});
if (is_login && !is_registered) {
document.getElementById("registerButton").style.display = "block";
}
});
}
window.onload = checkOAuth;
</script>
</head>
<body class="flex h-screen">
<!-- Sidebar -->
<aside id="sidebar-multi-level-sidebar"
class="fixed top-0 left-0 z-40 w-64 h-screen transition-transform -translate-x-full sm:translate-x-0"
aria-label="Sidebar">
<div class="h-full px-3 py-4 overflow-y-auto">
<ul class="space-y-2 font-medium">
<li>
<a href="#" id="home"
class="flex items-center p-2 text-gray-900 rounded-lg hover:bg-gray-100 group">
<svg class="w-5 h-5 text-gray-500 transition duration-75 group-hover:text-gray-900"
viewBox="0 0 22 21" xmlns="http://www.w3.org/2000/svg" fill="currentColor">
<path d="M1,10 L11,1 L21,10 L21,20 L1,20 Z" /> <!-- House structure -->
<path d="M6,20 L6,14 L16,14 L16,20" /> <!-- Door -->
</svg>
<span class="ms-3">Home</span>
</a>
</li>
<li>
<a href="#" id="dataset"
class="flex items-center p-2 text-gray-900 rounded-lg hover:bg-gray-100 group">
<svg class="flex-shrink-0 w-5 h-5 text-gray-500 transition duration-75 group-hover:text-gray-900"
aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor"
viewBox="0 0 18 18">
<path
d="M6.143 0H1.857A1.857 1.857 0 0 0 0 1.857v4.286C0 7.169.831 8 1.857 8h4.286A1.857 1.857 0 0 0 8 6.143V1.857A1.857 1.857 0 0 0 6.143 0Zm10 0h-4.286A1.857 1.857 0 0 0 10 1.857v4.286C10 7.169 10.831 8 11.857 8h4.286A1.857 1.857 0 0 0 18 6.143V1.857A1.857 1.857 0 0 0 16.143 0Zm-10 10H1.857A1.857 1.857 0 0 0 0 11.857v4.286C0 17.169.831 18 1.857 18h4.286A1.857 1.857 0 0 0 8 16.143v-4.286A1.857 1.857 0 0 0 6.143 10Zm10 0h-4.286A1.857 1.857 0 0 0 10 11.857v4.286c0 1.026.831 1.857 1.857 1.857h4.286A1.857 1.857 0 0 0 18 16.143v-4.286A1.857 1.857 0 0 0 16.143 10Z" />
</svg>
<span class="flex-1 ms-3 whitespace-nowrap">Dataset</span>
</a>
</li>
<!-- {% if rules_available %}
<li>
<a href="#" id="rules"
class="flex items-center p-2 text-gray-900 rounded-lg hover:bg-gray-100 group">
<svg class="flex-shrink-0 w-5 h-5 text-gray-500 transition duration-75 group-hover:text-gray-900"
aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor"
viewBox="0 0 24 24">
<path
d="M3 0h18v2H3V0zm0 4h18v2H3V4zm0 4h18v2H3V8zm0 4h18v2H3v-2zm0 4h18v2H3v-2zm0 4h18v2H3v-2z" />
</svg>
<span class="flex-1 ms-3 whitespace-nowrap">Rules</span>
</a>
</li>
{% else %}
<span id="rules"></span>
{% endif %} -->
<span id="rules"></span>
<li>
<a href="#" id="leaderboard"
class="flex items-center p-2 text-gray-900 rounded-lg hover:bg-gray-100 group">
<svg class="flex-shrink-0 w-5 h-5 text-gray-500 transition duration-75 group-hover:text-gray-900"
aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor"
viewBox="0 0 18 21">
<path d="M2,4 L20,4 L20,16 L2,16 Z" />
<path d="M6,17 L16,17 L16,18 L6,18 Z" />
</svg>
<span class="flex-1 ms-3 text-left rtl:text-right whitespace-nowrap">Leaderboard</span>
</a>
</li>
<li>
<button type="button"
class="flex items-center w-full p-2 text-base text-gray-900 transition duration-75 rounded-lg group hover:bg-gray-100"
aria-controls="submissions-dropdown" data-collapse-toggle="submissions-dropdown">
<svg class="flex-shrink-0 w-5 h-5 text-gray-500 transition duration-75 group-hover:text-gray-900"
aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor"
viewBox="0 0 20 20">
<path d="M5 5V.13a2.96 2.96 0 0 0-1.293.749L.879 3.707A2.96 2.96 0 0 0 .13 5H5Z" />
<path
d="M6.737 11.061a2.961 2.961 0 0 1 .81-1.515l6.117-6.116A4.839 4.839 0 0 1 16 2.141V2a1.97 1.97 0 0 0-1.933-2H7v5a2 2 0 0 1-2 2H0v11a1.969 1.969 0 0 0 1.933 2h12.134A1.97 1.97 0 0 0 16 18v-3.093l-1.546 1.546c-.413.413-.94.695-1.513.81l-3.4.679a2.947 2.947 0 0 1-1.85-.227 2.96 2.96 0 0 1-1.635-3.257l.681-3.397Z" />
<path
d="M8.961 16a.93.93 0 0 0 .189-.019l3.4-.679a.961.961 0 0 0 .49-.263l6.118-6.117a2.884 2.884 0 0 0-4.079-4.078l-6.117 6.117a.96.96 0 0 0-.263.491l-.679 3.4A.961.961 0 0 0 8.961 16Zm7.477-9.8a.958.958 0 0 1 .68-.281.961.961 0 0 1 .682 1.644l-.315.315-1.36-1.36.313-.318Zm-5.911 5.911 4.236-4.236 1.359 1.359-4.236 4.237-1.7.339.341-1.699Z" />
</svg>
<span class="flex-1 ms-3 text-left rtl:text-right whitespace-nowrap">Submissions</span>
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
viewBox="0 0 10 6">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="m1 1 4 4 4-4" />
</svg>
</button>
<ul id="submissions-dropdown" class="py-2 space-y-2">
<li>
<a href="#" id="submission_info"
class="flex items-center w-full p-2 transition duration-75 rounded-lg pl-11 group ext-gray-900 hover:bg-gray-100">Submission
information</a>
</li>
<li>
<a href="#" id="my_submissions"
class="flex items-center w-full p-2 transition duration-75 rounded-lg pl-11 group ext-gray-900 hover:bg-gray-100">My
submissions</a>
</li>
<li>
<a href="#" id="new_submission"
class="flex items-center w-full p-2 transition duration-75 rounded-lg pl-11 group ext-gray-900 hover:bg-gray-100">New
submission</a>
</li>
</ul>
</li>
<li>
<a href="#" id="admin"
class="flex items-center p-2 text-gray-900 rounded-lg hover:bg-gray-100 group hidden">
<svg class="flex-shrink-0 w-5 h-5 text-gray-500 transition duration-75 group-hover:text-gray-900"
aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor"
viewBox="0 0 24 24">
<path
d="M12 15.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5zm7.43-3.5c.04-.33.07-.66.07-1s-.03-.67-.07-1l2.11-1.65c.19-.15.23-.42.12-.63l-2-3.46c-.11-.21-.35-.3-.57-.24l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.57 2.18 14.3 2 14 2h-4c-.3 0-.57.18-.64.45L8.98 5.1c-.61.25-1.17.58-1.69.98l-2.49-1c-.22-.06-.46.03-.57.24l-2 3.46c-.11.21-.07.48.12.63l2.11 1.65c-.04.33-.07.66-.07 1s.03.67.07 1L2.46 14.1c-.19.15-.23.42-.12.63l2 3.46c.11.21.35.3.57.24l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.07.27.34.45.64.45h4c.3 0 .57-.18.64-.45l.38-2.65c.61-.25 1.17-.58 1.69-.98l2.49 1c.22.06.46-.03.57-.24l2-3.46c.11-.21.07-.48-.12-.63l-2.11-1.65zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z" />
</svg>
<span class="flex-1 ms-3 whitespace-nowrap">Admin</span>
</a>
</li>
<li id="registerButton" style="display: none;">
<a href="#"
class="flex justify-center items-center bg-blue-400 hover:bg-blue-600 text-white text-center font-bold py-2 px-4 rounded transition duration-200 ease-in-out">
Register
</a>
</li>
<li id="loginButton" style="display: none;">
<a href="/login/huggingface"
class="flex justify-center items-center bg-blue-400 hover:bg-blue-600 text-white text-center font-bold py-2 px-4 rounded transition duration-200 ease-in-out">
Login with Hugging Face
</a>
</li>
<li id="updateTeamInfo" style="display: none;">
<a href="/update_team_info_page"
class="flex justify-center items-center bg-green-600 hover:bg-green-800 text-white text-center font-bold py-2 px-4 rounded transition duration-200 ease-in-out">
Update Team Info
</a>
</li>
<li id="logoutButton" style="display: none;">
<a href="/logout"
class="flex justify-center items-center bg-red-400 hover:bg-red-600 text-white text-center font-bold py-2 px-4 rounded transition duration-200 ease-in-out">
Logout
</a>
</li>
</ul>
<footer>
<div class="w-full mx-auto max-w-screen-xl p-4 md:flex md:items-center md:justify-between">
<span class="text-sm text-gray-500 sm:text-center">Powered by <a
href="https://github.com/huggingface/competitions" target="_blank"
class="hover:underline">Hugging Face
Competitions</a>
</span>
</div>
<div class="text-center">
<span class="text-xs text-gray-400">{{version}}
</span>
</div>
</footer>
</div>
</aside>
<div class="p-1 sm:ml-64 overflow-x-hidden">
<img src={{logo}} alt="Competition logo">
<hr class="mt-3 mb-2">
<div id="articleLoadingSpinner" role="status"
class="hidden absolute -translate-x-1/2 -translate-y-1/2 top-2/4 left-1/2">
<div class="animate-spin rounded-full h-32 w-32 border-b-2 border-gray-900"></div>
<span class="sr-only">Loading...</span>
</div>
<article class="prose w-full mx-auto max-w-screen-xl p-4 md:flex md:items-center md:justify-between"
id="content">
</article>
</div>
<div id="submission-modal" tabindex="-1"
class="hidden overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 justify-center items-center w-full md:inset-0 h-[calc(100%-1rem)] max-h-full">
<div id="loadingSpinner" role="status"
class="hidden absolute -translate-x-1/2 -translate-y-1/2 top-2/4 left-1/2">
<div class="animate-spin rounded-full h-32 w-32 border-b-2 border-gray-900"></div>
<span class="sr-only">Loading...</span>
</div>
<div class="form-container max-w-5xl mx-auto mt-3 p-6 shadow-2xl bg-white">
<p class="text-lg font-medium text-gray-900">New Submission</p>
<form action="#" method="post" class="gap-2" enctype="multipart/form-data">
{% if competition_type == 'generic' %}
<div class="form-group">
<label class="block mb-2 text-sm font-medium text-gray-900" for="submission_file">Upload
file</label>
<input
class="block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 focus:outline-none "
id="submission_file" type="file" name="submission_file">
</div>
{% endif %}
{% if competition_type == 'script' %}
<div class="form-group">
<label for="hub_model" class="text-sm font-medium text-gray-700">Hub Model
</label>
<input type="text" name="hub_model" id="hub_model"
class="mt-1 block w-full border border-gray-300 px-3 py-1.5 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
placeholder="username/my-model">
</div>
{% endif %}
<div class="form-group mt-2">
<label for="submission_comment" class="text-sm font-medium text-gray-700">Submission description
(optional)
</label>
<textarea id="submission_comment" name="submission_comment" rows="5"
class="p-2.5 w-full text-sm text-gray-900" placeholder=" "></textarea>
</div>
<div class="form-actions mt-6">
<button data-modal-hide="submission-modal" type="button"
class="confirm text-white bg-green-600 hover:bg-green-800 focus:ring-4 focus:outline-none focus:ring-green-300font-medium rounded-lg text-sm inline-flex items-center px-5 py-2.5 text-center me-2">
Submit
</button>
<button data-modal-hide="submission-modal" type="button"
class="cancel text-white bg-red-600 hover:bg-red-100 focus:ring-4 focus:outline-none focus:ring-red-200 rounded-lg border border-red-200 text-sm font-medium px-5 py-2.5 hover:text-red-900 focus:z-10">Cancel</button>
</div>
</form>
<hr class="mt-3">
<div id="error-message" style="color: red;"></div>
<div id="success-message" style="color: green;"></div>
</div>
</div>
<div id="admin-modal" tabindex="-1"
class="hidden fixed inset-0 z-40 flex items-center justify-center w-full h-full bg-black bg-opacity-50">
<div id="adminLoadingSpinner" role="status"
class="hidden fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50">
<div class="animate-spin rounded-full h-32 w-32 border-b-2 border-gray-900"></div>
<span class="sr-only">Loading...</span>
</div>
<div class="relative w-full max-w-5xl p-4">
<div class="relative bg-white rounded-lg shadow-2xl">
<button type="button"
class="absolute top-3 right-3 text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 inline-flex justify-center items-center"
data-modal-hide="admin-modal">
<svg class="w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
viewBox="0 0 14 14">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6" />
</svg>
<span class="sr-only">Close</span>
</button>
<div class="p-6 md:p-8 text-center">
<h3 class="mb-5 text-lg font-medium text-gray-900">Admin</h3>
<div class="tabs">
<ul class="flex border-b">
<li class="mr-1">
<a class="tab bg-white inline-block py-2 px-4 text-blue-500 hover:text-blue-800 font-semibold"
href="#config">Config</a>
</li>
<li class="mr-1">
<a class="tab bg-white inline-block py-2 px-4 text-blue-500 hover:text-blue-800 font-semibold"
href="#competition-desc">Competition Desc</a>
</li>
<li class="mr-1">
<a class="tab bg-white inline-block py-2 px-4 text-blue-500 hover:text-blue-800 font-semibold"
href="#dataset-desc">Dataset Desc</a>
</li>
<li class="mr-1">
<a class="tab bg-white inline-block py-2 px-4 text-blue-500 hover:text-blue-800 font-semibold"
href="#submission-desc">Submission Desc</a>
</li>
<li class="mr-1">
<a class="tab bg-white inline-block py-2 px-4 text-blue-500 hover:text-blue-800 font-semibold"
href="#rules-desc">Rules</a>
</li>
</ul>
</div>
<div id="tab-contents"
class="text-xs font-normal text-left overflow-y-auto max-h-[calc(100vh-400px)] border-t border-gray-200 pt-4">
<div id="config">
<textarea id="config-textarea" class="w-full h-64 p-2 border rounded">Loading..</textarea>
<p class="text-xs text-gray-500">Note: The config should be a valid JSON object. To learn
details about entries, click <a
href="https://huggingface.co/docs/competitions/competition_repo#confjson"
target="_blank">here</a>.
</p>
</div>
<div id="competition-desc" class="hidden">
<textarea id="competition-desc-textarea"
class="w-full h-64 p-2 border rounded">Loading..</textarea>
</div>
<div id="dataset-desc" class="hidden">
<textarea id="dataset-desc-textarea"
class="w-full h-64 p-2 border rounded">Loading..</textarea>
</div>
<div id="submission-desc" class="hidden">
<textarea id="submission-desc-textarea"
class="w-full h-64 p-2 border rounded">Loading..</textarea>
</div>
<div id="rules-desc" class="hidden">
<textarea id="rules-desc-textarea"
class="w-full h-64 p-2 border rounded">Loading..</textarea>
</div>
</div>
<button id="save-button" class="mt-4 px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-700">
Save
</button>
</div>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.2.1/flowbite.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
const content = document.getElementById('content');
const links = content.getElementsByTagName('a');
for (let i = 0; i < links.length; i++) {
if (!links[i].hasAttribute('target')) {
links[i].setAttribute('target', '_blank');
}
}
});
</script>
</body>
<script>
document.addEventListener("DOMContentLoaded", function () {
document.querySelectorAll('.tabs a').forEach(tab => {
tab.addEventListener('click', event => {
event.preventDefault();
document.querySelectorAll('.tabs a').forEach(t => t.classList.remove('active'));
tab.classList.add('active');
document.querySelectorAll('#tab-contents > div').forEach(content => content.classList.add('hidden'));
const selectedTab = document.querySelector(tab.getAttribute('href'));
selectedTab.classList.remove('hidden');
});
});
async function fetchAdminCompInfo() {
const adminLoadingSpinner = document.getElementById('adminLoadingSpinner');
adminLoadingSpinner.classList.remove('hidden');
try {
const response = await fetch("/admin/comp_info", {
method: "POST",
headers: {
"Content-Type": "application/json"
}
});
const data = await response.json();
if (response.ok) {
populateAdminModal(data.response);
} else {
alert(data.response || "Failed to fetch competition info");
}
} catch (error) {
console.error("Error fetching admin competition info:", error);
alert("An error occurred while fetching competition info.");
} finally {
adminLoadingSpinner.classList.add('hidden');
}
}
function populateAdminModal(data) {
document.getElementById("config-textarea").value = JSON.stringify(data.config, null, 2);
document.getElementById("competition-desc-textarea").value = data.markdowns["competition_desc"] || "";
document.getElementById("dataset-desc-textarea").value = data.markdowns["dataset_desc"] || "";
document.getElementById("submission-desc-textarea").value = data.markdowns["submission_desc"] || "";
document.getElementById("rules-desc-textarea").value = data.markdowns["rules"] || "No rules available.";
}
document.querySelectorAll(".tab").forEach(tab => {
tab.addEventListener("click", function (event) {
event.preventDefault();
const targetId = this.getAttribute("href").substring(1);
document.querySelectorAll("#tab-contents > div").forEach(content => {
content.classList.add("hidden");
});
document.getElementById(targetId).classList.remove("hidden");
document.querySelectorAll(".tab").forEach(t => {
t.classList.remove("text-blue-800");
t.classList.add("text-blue-500");
});
this.classList.remove("text-blue-500");
this.classList.add("text-blue-800");
});
});
document.getElementById("admin").addEventListener("click", function () {
document.getElementById("admin-modal").classList.remove("hidden");
fetchAdminCompInfo();
});
document.querySelector("[data-modal-hide='admin-modal']").addEventListener("click", function () {
document.getElementById("admin-modal").classList.add("hidden");
});
document.getElementById("save-button").addEventListener("click", async function () {
const adminLoadingSpinner = document.getElementById('adminLoadingSpinner');
adminLoadingSpinner.classList.remove('hidden');
const config = document.getElementById("config-textarea").value;
const competitionDesc = document.getElementById("competition-desc-textarea").value;
const datasetDesc = document.getElementById("dataset-desc-textarea").value;
const submissionDesc = document.getElementById("submission-desc-textarea").value;
const rulesDesc = document.getElementById("rules-desc-textarea").value;
const data = {
config: JSON.parse(config),
markdowns: {
competition_desc: competitionDesc,
dataset_desc: datasetDesc,
submission_desc: submissionDesc,
rules: rulesDesc
}
};
try {
const response = await fetch("/admin/update_comp_info", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(data)
});
const result = await response.json();
if (response.ok) {
alert(result.response || "Successfully updated competition info");
} else {
alert(result.response || "Failed to update competition info");
}
} catch (error) {
console.error("Error updating competition info:", error);
alert("An error occurred while updating competition info.");
} finally {
adminLoadingSpinner.classList.add('hidden');
}
});
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function () {
document.querySelector('.confirm').addEventListener('click', function (event) {
event.preventDefault();
document.getElementById('error-message').textContent = '';
document.getElementById('success-message').textContent = '';
const loadingSpinner = document.getElementById('loadingSpinner');
loadingSpinner.classList.remove('hidden');
var formData = new FormData();
var competitionType = '{{ competition_type }}';
if (competitionType === 'generic') {
var submissionFile = document.getElementById('submission_file').files[0];
formData.append('submission_file', submissionFile);
formData.append('hub_model', 'None');
} else if (competitionType === 'script') {
var hubModel = document.getElementById('hub_model').value;
if (!hubModel) {
alert('Hub model is required.');
return;
}
formData.append('hub_model', hubModel);
} else {
alert('Invalid competition type.');
return;
}
var submissionComment = document.getElementById('submission_comment').value;
formData.append('submission_comment', submissionComment);
fetch('/new_submission', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
loadingSpinner.classList.add('hidden');
document.getElementById('success-message').textContent = data.response;
})
.catch((error) => {
console.error('Error:', error);
loadingSpinner.classList.add('hidden');
document.getElementById('error-message').textContent = error;
});
});
});
</script>
<script>
function updateSelectedSubmissions() {
const selectedSubmissions = document.querySelectorAll('input[name="selectedSubmissions"]:checked');
const articleLoadingSpinner = document.getElementById('articleLoadingSpinner');
articleLoadingSpinner.classList.remove('hidden');
let selectedSubmissionIds = [];
selectedSubmissions.forEach((submission) => {
selectedSubmissionIds.push(submission.value);
});
const updateEndpoint = '/update_selected_submissions';
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
"submission_ids": selectedSubmissionIds.join(',')
})
};
fetch(updateEndpoint, requestOptions)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
if (data.success) {
// Optionally, display a success message or handle accordingly
console.log('Update successful');
articleLoadingSpinner.classList.add('hidden');
} else {
// Handle failure case
console.log('Update failed');
articleLoadingSpinner.classList.add('hidden');
alert(data.error);
}
// Refresh submissions display
fetchAndDisplaySubmissions();
})
.catch(error => {
console.error('There was a problem with the fetch operation for updating:', error);
});
}
</script>
<script>
function updateTeamName() {
const teamName = document.getElementById('team_name').value;
const articleLoadingSpinner = document.getElementById('articleLoadingSpinner');
articleLoadingSpinner.classList.remove('hidden');
const updateEndpoint = '/update_team_name';
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
"new_team_name": teamName
})
};
fetch(updateEndpoint, requestOptions)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
if (data.success) {
// Optionally, display a success message or handle accordingly
console.log('Update successful');
articleLoadingSpinner.classList.add('hidden');
} else {
// Handle failure case
console.log('Update failed');
articleLoadingSpinner.classList.add('hidden');
alert(data.error);
}
// Refresh submissions display
fetchAndDisplaySubmissions();
})
.catch(error => {
console.error('There was a problem with the fetch operation for updating:', error);
});
}
</script>
<script>
function showAdminModal() {
const modal = document.getElementById('admin-modal');
modal.classList.add('flex');
modal.classList.remove('hidden');
}
function hideAdminModal() {
const modal = document.getElementById('admin-modal');
modal.classList.remove('flex');
modal.classList.add('hidden');
}
document.querySelector('#admin').addEventListener('click', function () {
showAdminModal();
});
document.querySelector('[data-modal-hide="admin-modal"]').addEventListener('click', function () {
hideAdminModal();
});
</script>
<script>
document.getElementById("registerButton").addEventListener("click", function () {
window.location.href = "/register_page";
});
</script>
</html> |