Spaces:
Runtime error
Runtime error
LE Quoc Dat
commited on
Commit
·
3ba429a
1
Parent(s):
b07ae48
Refactor UI styles and collection interactions with dropdown menu
Browse files- static/css/styles.css +186 -11
- templates/index.html +60 -53
static/css/styles.css
CHANGED
|
@@ -4,9 +4,9 @@
|
|
| 4 |
--background-color: #ecf0f1;
|
| 5 |
--text-color: #34495e;
|
| 6 |
--highlight-color: #e74c3c;
|
| 7 |
-
--button-min-width:
|
| 8 |
-
--button-height:
|
| 9 |
-
--button-font-size:
|
| 10 |
}
|
| 11 |
|
| 12 |
body {
|
|
@@ -19,6 +19,7 @@ body {
|
|
| 19 |
overflow: hidden;
|
| 20 |
background-color: var(--background-color);
|
| 21 |
color: var(--text-color);
|
|
|
|
| 22 |
}
|
| 23 |
|
| 24 |
#top-bar {
|
|
@@ -87,7 +88,7 @@ body {
|
|
| 87 |
position: fixed;
|
| 88 |
right: 0;
|
| 89 |
top: 0;
|
| 90 |
-
padding:
|
| 91 |
box-sizing: border-box;
|
| 92 |
overflow-y: auto;
|
| 93 |
background-color: white;
|
|
@@ -111,7 +112,7 @@ body {
|
|
| 111 |
|
| 112 |
.mode-btn {
|
| 113 |
flex: 1;
|
| 114 |
-
padding:
|
| 115 |
border: 1px solid var(--secondary-color);
|
| 116 |
background-color: white;
|
| 117 |
color: var(--secondary-color);
|
|
@@ -120,7 +121,7 @@ body {
|
|
| 120 |
}
|
| 121 |
|
| 122 |
.mode-btn:not(:last-child) {
|
| 123 |
-
margin-right:
|
| 124 |
}
|
| 125 |
|
| 126 |
.mode-btn.selected {
|
|
@@ -213,21 +214,21 @@ body {
|
|
| 213 |
|
| 214 |
#flashcards {
|
| 215 |
border: 1px solid #ddd;
|
| 216 |
-
padding:
|
| 217 |
-
margin-top:
|
| 218 |
background-color: white;
|
| 219 |
border-radius: 3px;
|
| 220 |
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
| 221 |
}
|
| 222 |
|
| 223 |
.flashcard {
|
| 224 |
-
margin-bottom:
|
| 225 |
-
padding:
|
| 226 |
border: 1px solid #ddd;
|
| 227 |
background-color: white;
|
| 228 |
border-radius: 3px;
|
| 229 |
transition: box-shadow 0.3s ease;
|
| 230 |
-
font-size:
|
| 231 |
}
|
| 232 |
|
| 233 |
.flashcard:hover {
|
|
@@ -498,3 +499,177 @@ body {
|
|
| 498 |
width: 100%;
|
| 499 |
}
|
| 500 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
--background-color: #ecf0f1;
|
| 5 |
--text-color: #34495e;
|
| 6 |
--highlight-color: #e74c3c;
|
| 7 |
+
--button-min-width: 80px;
|
| 8 |
+
--button-height: 30px;
|
| 9 |
+
--button-font-size: 12px;
|
| 10 |
}
|
| 11 |
|
| 12 |
body {
|
|
|
|
| 19 |
overflow: hidden;
|
| 20 |
background-color: var(--background-color);
|
| 21 |
color: var(--text-color);
|
| 22 |
+
font-size: 80%;
|
| 23 |
}
|
| 24 |
|
| 25 |
#top-bar {
|
|
|
|
| 88 |
position: fixed;
|
| 89 |
right: 0;
|
| 90 |
top: 0;
|
| 91 |
+
padding: 10px;
|
| 92 |
box-sizing: border-box;
|
| 93 |
overflow-y: auto;
|
| 94 |
background-color: white;
|
|
|
|
| 112 |
|
| 113 |
.mode-btn {
|
| 114 |
flex: 1;
|
| 115 |
+
padding: 5px;
|
| 116 |
border: 1px solid var(--secondary-color);
|
| 117 |
background-color: white;
|
| 118 |
color: var(--secondary-color);
|
|
|
|
| 121 |
}
|
| 122 |
|
| 123 |
.mode-btn:not(:last-child) {
|
| 124 |
+
margin-right: 5px;
|
| 125 |
}
|
| 126 |
|
| 127 |
.mode-btn.selected {
|
|
|
|
| 214 |
|
| 215 |
#flashcards {
|
| 216 |
border: 1px solid #ddd;
|
| 217 |
+
padding: 10px;
|
| 218 |
+
margin-top: 10px;
|
| 219 |
background-color: white;
|
| 220 |
border-radius: 3px;
|
| 221 |
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
| 222 |
}
|
| 223 |
|
| 224 |
.flashcard {
|
| 225 |
+
margin-bottom: 8px;
|
| 226 |
+
padding: 10px;
|
| 227 |
border: 1px solid #ddd;
|
| 228 |
background-color: white;
|
| 229 |
border-radius: 3px;
|
| 230 |
transition: box-shadow 0.3s ease;
|
| 231 |
+
font-size: 1em;
|
| 232 |
}
|
| 233 |
|
| 234 |
.flashcard:hover {
|
|
|
|
| 499 |
width: 100%;
|
| 500 |
}
|
| 501 |
}
|
| 502 |
+
|
| 503 |
+
/* Add these new styles at the end of the file */
|
| 504 |
+
.api-settings {
|
| 505 |
+
margin-bottom: 15px;
|
| 506 |
+
padding: 10px;
|
| 507 |
+
background: #f5f5f5;
|
| 508 |
+
border-radius: 5px;
|
| 509 |
+
}
|
| 510 |
+
|
| 511 |
+
.model-group {
|
| 512 |
+
margin-bottom: 10px;
|
| 513 |
+
}
|
| 514 |
+
|
| 515 |
+
#model-select {
|
| 516 |
+
width: 100%;
|
| 517 |
+
padding: 8px;
|
| 518 |
+
margin-bottom: 10px;
|
| 519 |
+
border: 1px solid #ddd;
|
| 520 |
+
border-radius: 4px;
|
| 521 |
+
}
|
| 522 |
+
|
| 523 |
+
#custom-model-inputs {
|
| 524 |
+
margin-top: 10px;
|
| 525 |
+
}
|
| 526 |
+
|
| 527 |
+
#custom-model-inputs input {
|
| 528 |
+
width: 100%;
|
| 529 |
+
padding: 8px;
|
| 530 |
+
margin-bottom: 5px;
|
| 531 |
+
border: 1px solid #ddd;
|
| 532 |
+
border-radius: 4px;
|
| 533 |
+
}
|
| 534 |
+
|
| 535 |
+
.default-api-key input {
|
| 536 |
+
width: 100%;
|
| 537 |
+
padding: 8px;
|
| 538 |
+
border: 1px solid #ddd;
|
| 539 |
+
border-radius: 4px;
|
| 540 |
+
}
|
| 541 |
+
|
| 542 |
+
#recent-files {
|
| 543 |
+
margin-top: 20px;
|
| 544 |
+
padding: 15px;
|
| 545 |
+
background: #f8f8f8;
|
| 546 |
+
border-radius: 5px;
|
| 547 |
+
}
|
| 548 |
+
|
| 549 |
+
#recent-files h3 {
|
| 550 |
+
margin: 0 0 15px 0;
|
| 551 |
+
color: #333;
|
| 552 |
+
font-size: 1.1em;
|
| 553 |
+
}
|
| 554 |
+
|
| 555 |
+
#file-list {
|
| 556 |
+
list-style: none;
|
| 557 |
+
padding: 0;
|
| 558 |
+
margin: 0;
|
| 559 |
+
}
|
| 560 |
+
|
| 561 |
+
#file-list li {
|
| 562 |
+
margin-bottom: 10px;
|
| 563 |
+
padding: 8px;
|
| 564 |
+
background: white;
|
| 565 |
+
border-radius: 4px;
|
| 566 |
+
border: 1px solid #eee;
|
| 567 |
+
transition: background-color 0.2s;
|
| 568 |
+
}
|
| 569 |
+
|
| 570 |
+
#file-list li:hover {
|
| 571 |
+
background-color: #f0f0f0;
|
| 572 |
+
}
|
| 573 |
+
|
| 574 |
+
#file-list a {
|
| 575 |
+
text-decoration: none;
|
| 576 |
+
color: #2196F3;
|
| 577 |
+
display: block;
|
| 578 |
+
width: 100%;
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
#file-list a:hover {
|
| 582 |
+
color: #1976D2;
|
| 583 |
+
}
|
| 584 |
+
|
| 585 |
+
/* Dropdown styles for collection actions */
|
| 586 |
+
.dropdown {
|
| 587 |
+
position: relative;
|
| 588 |
+
display: block;
|
| 589 |
+
margin-bottom: 15px;
|
| 590 |
+
width: 100%;
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
.dropbtn {
|
| 594 |
+
background-color: var(--secondary-color);
|
| 595 |
+
color: white;
|
| 596 |
+
padding: 12px 20px;
|
| 597 |
+
font-size: 14px;
|
| 598 |
+
border: none;
|
| 599 |
+
cursor: pointer;
|
| 600 |
+
border-radius: 5px;
|
| 601 |
+
width: 100%;
|
| 602 |
+
display: flex;
|
| 603 |
+
align-items: center;
|
| 604 |
+
justify-content: space-between;
|
| 605 |
+
transition: all 0.3s ease;
|
| 606 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
| 607 |
+
}
|
| 608 |
+
|
| 609 |
+
/* Add a down arrow to the button */
|
| 610 |
+
.dropbtn::after {
|
| 611 |
+
content: '▼';
|
| 612 |
+
font-size: 10px;
|
| 613 |
+
margin-left: 8px;
|
| 614 |
+
transition: transform 0.3s ease;
|
| 615 |
+
}
|
| 616 |
+
|
| 617 |
+
/* Rotate arrow when dropdown is open */
|
| 618 |
+
.dropbtn.active::after {
|
| 619 |
+
transform: rotate(180deg);
|
| 620 |
+
}
|
| 621 |
+
|
| 622 |
+
.dropbtn:hover {
|
| 623 |
+
background-color: #34495e;
|
| 624 |
+
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
|
| 625 |
+
}
|
| 626 |
+
|
| 627 |
+
.dropdown-content {
|
| 628 |
+
display: none;
|
| 629 |
+
position: absolute;
|
| 630 |
+
background-color: white;
|
| 631 |
+
min-width: 100%;
|
| 632 |
+
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
| 633 |
+
z-index: 1001;
|
| 634 |
+
border-radius: 5px;
|
| 635 |
+
margin-top: 5px;
|
| 636 |
+
border: 1px solid rgba(0,0,0,0.1);
|
| 637 |
+
overflow: hidden;
|
| 638 |
+
animation: dropdownFade 0.3s ease;
|
| 639 |
+
}
|
| 640 |
+
|
| 641 |
+
@keyframes dropdownFade {
|
| 642 |
+
from {
|
| 643 |
+
opacity: 0;
|
| 644 |
+
transform: translateY(-10px);
|
| 645 |
+
}
|
| 646 |
+
to {
|
| 647 |
+
opacity: 1;
|
| 648 |
+
transform: translateY(0);
|
| 649 |
+
}
|
| 650 |
+
}
|
| 651 |
+
|
| 652 |
+
.dropdown-content a {
|
| 653 |
+
color: var(--text-color);
|
| 654 |
+
padding: 12px 20px;
|
| 655 |
+
text-decoration: none;
|
| 656 |
+
display: block;
|
| 657 |
+
border-bottom: 1px solid rgba(0,0,0,0.05);
|
| 658 |
+
transition: all 0.2s ease;
|
| 659 |
+
font-size: 14px;
|
| 660 |
+
}
|
| 661 |
+
|
| 662 |
+
.dropdown-content a:last-child {
|
| 663 |
+
border-bottom: none;
|
| 664 |
+
}
|
| 665 |
+
|
| 666 |
+
.dropdown-content a:hover {
|
| 667 |
+
background-color: #f8f9fa;
|
| 668 |
+
padding-left: 25px;
|
| 669 |
+
color: var(--primary-color);
|
| 670 |
+
}
|
| 671 |
+
|
| 672 |
+
/* Class to show the dropdown */
|
| 673 |
+
.show {
|
| 674 |
+
display: block;
|
| 675 |
+
}
|
templates/index.html
CHANGED
|
@@ -11,45 +11,6 @@
|
|
| 11 |
<link rel="stylesheet" href="/static/css/styles.css">
|
| 12 |
<script src="/static/js/prompts.js"></script>
|
| 13 |
<script src="/static/js/models.js"></script>
|
| 14 |
-
<style>
|
| 15 |
-
.api-settings {
|
| 16 |
-
margin-bottom: 15px;
|
| 17 |
-
padding: 10px;
|
| 18 |
-
background: #f5f5f5;
|
| 19 |
-
border-radius: 5px;
|
| 20 |
-
}
|
| 21 |
-
|
| 22 |
-
.model-group {
|
| 23 |
-
margin-bottom: 10px;
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
#model-select {
|
| 27 |
-
width: 100%;
|
| 28 |
-
padding: 8px;
|
| 29 |
-
margin-bottom: 10px;
|
| 30 |
-
border: 1px solid #ddd;
|
| 31 |
-
border-radius: 4px;
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
#custom-model-inputs {
|
| 35 |
-
margin-top: 10px;
|
| 36 |
-
}
|
| 37 |
-
|
| 38 |
-
#custom-model-inputs input {
|
| 39 |
-
width: 100%;
|
| 40 |
-
padding: 8px;
|
| 41 |
-
margin-bottom: 5px;
|
| 42 |
-
border: 1px solid #ddd;
|
| 43 |
-
border-radius: 4px;
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
-
.default-api-key input {
|
| 47 |
-
width: 100%;
|
| 48 |
-
padding: 8px;
|
| 49 |
-
border: 1px solid #ddd;
|
| 50 |
-
border-radius: 4px;
|
| 51 |
-
}
|
| 52 |
-
</style>
|
| 53 |
</head>
|
| 54 |
|
| 55 |
<body>
|
|
@@ -67,7 +28,7 @@
|
|
| 67 |
<div id="page-navigation">
|
| 68 |
<button id="zoom-out-btn">-</button>
|
| 69 |
<button id="zoom-in-btn">+</button>
|
| 70 |
-
<input type="number" id="page-input" min="1" placeholder="
|
| 71 |
<button id="go-to-page-btn">Go</button>
|
| 72 |
</div>
|
| 73 |
</div>
|
|
@@ -89,11 +50,14 @@
|
|
| 89 |
</div>
|
| 90 |
<button id="submit-btn" style="display: block;">Generate</button>
|
| 91 |
<div id="flashcards"></div>
|
| 92 |
-
<div id="collection">
|
| 93 |
-
<button id="
|
| 94 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
</div>
|
| 96 |
-
<button id="export-csv-btn" style="display: none;">Export Flashcards to CSV</button>
|
| 97 |
<div id="recent-files">
|
| 98 |
<h3>Recent Files</h3>
|
| 99 |
<ul id="file-list"></ul>
|
|
@@ -675,9 +639,9 @@
|
|
| 675 |
}
|
| 676 |
|
| 677 |
function updateAddToCollectionButtonText() {
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
|
| 681 |
}
|
| 682 |
|
| 683 |
// Initialize collection counts and flashcards from localStorage
|
|
@@ -687,12 +651,15 @@
|
|
| 687 |
collectedLanguageFlashcards = JSON.parse(localStorage.getItem('collectedLanguageFlashcards')) || [];
|
| 688 |
updateAddToCollectionButtonText();
|
| 689 |
|
| 690 |
-
document.getElementById('add-to-collection-
|
|
|
|
|
|
|
|
|
|
| 691 |
|
| 692 |
function updateExportButtonVisibility() {
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
|
| 696 |
}
|
| 697 |
|
| 698 |
function exportToCSV() {
|
|
@@ -720,7 +687,10 @@
|
|
| 720 |
document.body.removeChild(link);
|
| 721 |
}
|
| 722 |
|
| 723 |
-
document.getElementById('export-csv-
|
|
|
|
|
|
|
|
|
|
| 724 |
|
| 725 |
function clearCollection() {
|
| 726 |
if (confirm('Are you sure you want to clear the entire collection? This action cannot be undone.')) {
|
|
@@ -740,7 +710,10 @@
|
|
| 740 |
}
|
| 741 |
}
|
| 742 |
|
| 743 |
-
document.getElementById('clear-collection-
|
|
|
|
|
|
|
|
|
|
| 744 |
|
| 745 |
// Initialize export button visibility
|
| 746 |
updateExportButtonVisibility();
|
|
@@ -1373,6 +1346,40 @@
|
|
| 1373 |
const initialKey = MODEL_API_KEY_MAPPING[firstModel]; // Updated to use firstModel
|
| 1374 |
apiKeyInput.placeholder = `Enter ${initialKey}`;
|
| 1375 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1376 |
</script>
|
| 1377 |
</body>
|
| 1378 |
|
|
|
|
| 11 |
<link rel="stylesheet" href="/static/css/styles.css">
|
| 12 |
<script src="/static/js/prompts.js"></script>
|
| 13 |
<script src="/static/js/models.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
</head>
|
| 15 |
|
| 16 |
<body>
|
|
|
|
| 28 |
<div id="page-navigation">
|
| 29 |
<button id="zoom-out-btn">-</button>
|
| 30 |
<button id="zoom-in-btn">+</button>
|
| 31 |
+
<input type="number" id="page-input" min="1" placeholder="Page #">
|
| 32 |
<button id="go-to-page-btn">Go</button>
|
| 33 |
</div>
|
| 34 |
</div>
|
|
|
|
| 50 |
</div>
|
| 51 |
<button id="submit-btn" style="display: block;">Generate</button>
|
| 52 |
<div id="flashcards"></div>
|
| 53 |
+
<div class="dropdown" id="collection-dropdown">
|
| 54 |
+
<button class="dropbtn" id="collection-dropbtn">Collection Options</button>
|
| 55 |
+
<div class="dropdown-content" id="collection-dropdown-content">
|
| 56 |
+
<a href="#" id="add-to-collection-option">Add to Collection (0)</a>
|
| 57 |
+
<a href="#" id="clear-collection-option">Clear Collection</a>
|
| 58 |
+
<a href="#" id="export-csv-option" style="display: none;">Export Flashcards to CSV</a>
|
| 59 |
+
</div>
|
| 60 |
</div>
|
|
|
|
| 61 |
<div id="recent-files">
|
| 62 |
<h3>Recent Files</h3>
|
| 63 |
<ul id="file-list"></ul>
|
|
|
|
| 639 |
}
|
| 640 |
|
| 641 |
function updateAddToCollectionButtonText() {
|
| 642 |
+
var addToCollectionOption = document.getElementById('add-to-collection-option');
|
| 643 |
+
var count = mode === 'language' ? languageCollectionCount : flashcardCollectionCount;
|
| 644 |
+
addToCollectionOption.textContent = `Add to Collection (${count})`;
|
| 645 |
}
|
| 646 |
|
| 647 |
// Initialize collection counts and flashcards from localStorage
|
|
|
|
| 651 |
collectedLanguageFlashcards = JSON.parse(localStorage.getItem('collectedLanguageFlashcards')) || [];
|
| 652 |
updateAddToCollectionButtonText();
|
| 653 |
|
| 654 |
+
document.getElementById('add-to-collection-option').addEventListener('click', function(e) {
|
| 655 |
+
e.preventDefault();
|
| 656 |
+
addToCollection();
|
| 657 |
+
});
|
| 658 |
|
| 659 |
function updateExportButtonVisibility() {
|
| 660 |
+
var exportOption = document.getElementById('export-csv-option');
|
| 661 |
+
var currentCollection = mode === 'language' ? collectedLanguageFlashcards : collectedFlashcards;
|
| 662 |
+
exportOption.style.display = currentCollection.length > 0 ? 'block' : 'none';
|
| 663 |
}
|
| 664 |
|
| 665 |
function exportToCSV() {
|
|
|
|
| 687 |
document.body.removeChild(link);
|
| 688 |
}
|
| 689 |
|
| 690 |
+
document.getElementById('export-csv-option').addEventListener('click', function(e) {
|
| 691 |
+
e.preventDefault();
|
| 692 |
+
exportToCSV();
|
| 693 |
+
});
|
| 694 |
|
| 695 |
function clearCollection() {
|
| 696 |
if (confirm('Are you sure you want to clear the entire collection? This action cannot be undone.')) {
|
|
|
|
| 710 |
}
|
| 711 |
}
|
| 712 |
|
| 713 |
+
document.getElementById('clear-collection-option').addEventListener('click', function(e) {
|
| 714 |
+
e.preventDefault();
|
| 715 |
+
clearCollection();
|
| 716 |
+
});
|
| 717 |
|
| 718 |
// Initialize export button visibility
|
| 719 |
updateExportButtonVisibility();
|
|
|
|
| 1346 |
const initialKey = MODEL_API_KEY_MAPPING[firstModel]; // Updated to use firstModel
|
| 1347 |
apiKeyInput.placeholder = `Enter ${initialKey}`;
|
| 1348 |
});
|
| 1349 |
+
|
| 1350 |
+
// Ensure these run after the DOM is loaded
|
| 1351 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 1352 |
+
// Dropdown toggle logic for the collection dropdown
|
| 1353 |
+
var collectionDropbtn = document.getElementById('collection-dropbtn');
|
| 1354 |
+
var dropdownContent = document.getElementById('collection-dropdown-content');
|
| 1355 |
+
|
| 1356 |
+
collectionDropbtn.addEventListener('click', function(e) {
|
| 1357 |
+
e.stopPropagation();
|
| 1358 |
+
dropdownContent.classList.toggle('show');
|
| 1359 |
+
this.classList.toggle('active');
|
| 1360 |
+
});
|
| 1361 |
+
|
| 1362 |
+
document.addEventListener('click', function(e) {
|
| 1363 |
+
if (!dropdownContent.contains(e.target)) {
|
| 1364 |
+
dropdownContent.classList.remove('show');
|
| 1365 |
+
collectionDropbtn.classList.remove('active');
|
| 1366 |
+
}
|
| 1367 |
+
});
|
| 1368 |
+
|
| 1369 |
+
// Update event listeners for dropdown options instead of separate buttons
|
| 1370 |
+
document.getElementById('add-to-collection-option').addEventListener('click', function(e) {
|
| 1371 |
+
e.preventDefault();
|
| 1372 |
+
addToCollection();
|
| 1373 |
+
});
|
| 1374 |
+
document.getElementById('clear-collection-option').addEventListener('click', function(e) {
|
| 1375 |
+
e.preventDefault();
|
| 1376 |
+
clearCollection();
|
| 1377 |
+
});
|
| 1378 |
+
document.getElementById('export-csv-option').addEventListener('click', function(e) {
|
| 1379 |
+
e.preventDefault();
|
| 1380 |
+
exportToCSV();
|
| 1381 |
+
});
|
| 1382 |
+
});
|
| 1383 |
</script>
|
| 1384 |
</body>
|
| 1385 |
|