Spaces:
Running
Running
File size: 50,486 Bytes
401662a | 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 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AdMagic - Transform Your Product Images</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.dropzone {
border: 2px dashed #ccc;
transition: all 0.3s;
}
.dropzone.active {
border-color: #4f46e5;
background-color: rgba(79, 70, 229, 0.05);
}
.template-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}
.color-option {
width: 30px;
height: 30px;
cursor: pointer;
transition: transform 0.2s;
}
.color-option:hover {
transform: scale(1.1);
}
.color-option.selected {
border: 2px solid #000;
transform: scale(1.1);
}
.preview-container {
perspective: 1000px;
}
.preview-device {
transition: all 0.3s;
}
.preview-device:hover {
transform: translateY(-5px);
}
#adPreview {
transition: all 0.3s;
}
.slider {
-webkit-appearance: none;
width: 100%;
height: 8px;
border-radius: 4px;
background: #ddd;
outline: none;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 18px;
height: 18px;
border-radius: 50%;
background: #4f46e5;
cursor: pointer;
}
.slider::-moz-range-thumb {
width: 18px;
height: 18px;
border-radius: 50%;
background: #4f46e5;
cursor: pointer;
}
.step-indicator {
width: 30px;
height: 30px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
}
.step-indicator.active {
background-color: #4f46e5;
color: white;
}
.step-indicator.completed {
background-color: #10b981;
color: white;
}
</style>
</head>
<body class="bg-gray-50">
<div class="container mx-auto px-4 py-8 max-w-7xl">
<!-- Header -->
<header class="mb-10 text-center">
<h1 class="text-4xl font-bold text-indigo-700 mb-2">AdMagic</h1>
<p class="text-lg text-gray-600">Transform your product images into captivating advertisements in minutes</p>
</header>
<!-- Progress Steps -->
<div class="flex justify-between items-center mb-10 px-10 relative">
<div class="absolute top-1/2 left-0 right-0 h-1 bg-gray-200 -z-10"></div>
<div class="flex flex-col items-center">
<div id="step1Indicator" class="step-indicator active">1</div>
<span class="mt-2 text-sm font-medium">Upload Image</span>
</div>
<div class="flex flex-col items-center">
<div id="step2Indicator" class="step-indicator">2</div>
<span class="mt-2 text-sm font-medium">Choose Template</span>
</div>
<div class="flex flex-col items-center">
<div id="step3Indicator" class="step-indicator">3</div>
<span class="mt-2 text-sm font-medium">Customize</span>
</div>
<div class="flex flex-col items-center">
<div id="step4Indicator" class="step-indicator">4</div>
<span class="mt-2 text-sm font-medium">Branding</span>
</div>
<div class="flex flex-col items-center">
<div id="step5Indicator" class="step-indicator">5</div>
<span class="mt-2 text-sm font-medium">Export</span>
</div>
</div>
<!-- Main Content Area -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
<!-- Left Panel - Controls -->
<div class="lg:col-span-1 bg-white rounded-xl shadow-md p-6 h-fit sticky top-6">
<div id="step1" class="step-content">
<h2 class="text-xl font-semibold mb-4">Upload Your Product Image</h2>
<div id="dropzone" class="dropzone rounded-lg p-8 text-center mb-4">
<i class="fas fa-cloud-upload-alt text-4xl text-indigo-500 mb-3"></i>
<p class="mb-2">Drag & drop your image here</p>
<p class="text-sm text-gray-500 mb-4">or</p>
<label for="fileUpload" class="bg-indigo-600 text-white px-4 py-2 rounded-md cursor-pointer hover:bg-indigo-700 transition">
Browse Files
</label>
<input type="file" id="fileUpload" accept="image/*" class="hidden">
</div>
<div id="imagePreviewContainer" class="hidden mb-4">
<h3 class="font-medium mb-2">Image Preview</h3>
<div class="border rounded-lg overflow-hidden">
<img id="imagePreview" src="" alt="Preview" class="w-full">
</div>
</div>
<div id="enhancementControls" class="hidden">
<h3 class="font-medium mb-2">Image Enhancement</h3>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium mb-1">Brightness</label>
<input type="range" min="0" max="200" value="100" class="slider" id="brightnessSlider">
<div class="flex justify-between text-xs text-gray-500">
<span>0%</span>
<span>100%</span>
<span>200%</span>
</div>
</div>
<div>
<label class="block text-sm font-medium mb-1">Contrast</label>
<input type="range" min="0" max="200" value="100" class="slider" id="contrastSlider">
<div class="flex justify-between text-xs text-gray-500">
<span>0%</span>
<span>100%</span>
<span>200%</span>
</div>
</div>
<div>
<label class="block text-sm font-medium mb-1">Saturation</label>
<input type="range" min="0" max="200" value="100" class="slider" id="saturationSlider">
<div class="flex justify-between text-xs text-gray-500">
<span>0%</span>
<span>100%</span>
<span>200%</span>
</div>
</div>
<div class="flex space-x-2">
<button id="autoEnhanceBtn" class="flex-1 bg-indigo-100 text-indigo-700 px-3 py-1 rounded text-sm hover:bg-indigo-200">
Auto Enhance
</button>
<button id="resetEnhancementBtn" class="flex-1 bg-gray-100 text-gray-700 px-3 py-1 rounded text-sm hover:bg-gray-200">
Reset
</button>
</div>
</div>
</div>
<button id="nextStep1Btn" class="w-full bg-indigo-600 text-white py-2 rounded-md mt-4 hover:bg-indigo-700 disabled:bg-indigo-300 disabled:cursor-not-allowed" disabled>
Next: Choose Template
</button>
</div>
<div id="step2" class="step-content hidden">
<h2 class="text-xl font-semibold mb-4">Choose a Template</h2>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Industry</label>
<select id="industrySelect" class="w-full border rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500">
<option value="all">All Industries</option>
<option value="fashion">Fashion</option>
<option value="food">Food & Beverage</option>
<option value="electronics">Electronics</option>
<option value="beauty">Beauty & Cosmetics</option>
<option value="home">Home & Living</option>
</select>
</div>
<div class="grid grid-cols-2 gap-3 mb-4" id="templateGallery">
<!-- Templates will be loaded here -->
</div>
<div class="flex space-x-2">
<button id="backStep2Btn" class="flex-1 bg-gray-200 text-gray-700 py-2 rounded-md hover:bg-gray-300">
Back
</button>
<button id="nextStep2Btn" class="flex-1 bg-indigo-600 text-white py-2 rounded-md hover:bg-indigo-700 disabled:bg-indigo-300 disabled:cursor-not-allowed" disabled>
Next: Customize
</button>
</div>
</div>
<div id="step3" class="step-content hidden">
<h2 class="text-xl font-semibold mb-4">Customize Your Ad</h2>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Headline</label>
<input type="text" id="headlineInput" class="w-full border rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Enter catchy headline">
<div class="mt-1 flex flex-wrap gap-1" id="suggestedHeadlines">
<span class="text-xs bg-gray-100 px-2 py-1 rounded cursor-pointer hover:bg-gray-200">Summer Sale!</span>
<span class="text-xs bg-gray-100 px-2 py-1 rounded cursor-pointer hover:bg-gray-200">Limited Time Offer</span>
<span class="text-xs bg-gray-100 px-2 py-1 rounded cursor-pointer hover:bg-gray-200">New Collection</span>
</div>
</div>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Description</label>
<textarea id="descriptionInput" rows="3" class="w-full border rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Enter product description"></textarea>
</div>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Call to Action</label>
<input type="text" id="ctaInput" class="w-full border rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="e.g. Shop Now, Learn More">
</div>
<div class="flex space-x-2">
<button id="backStep3Btn" class="flex-1 bg-gray-200 text-gray-700 py-2 rounded-md hover:bg-gray-300">
Back
</button>
<button id="nextStep3Btn" class="flex-1 bg-indigo-600 text-white py-2 rounded-md hover:bg-indigo-700">
Next: Branding
</button>
</div>
</div>
<div id="step4" class="step-content hidden">
<h2 class="text-xl font-semibold mb-4">Add Your Branding</h2>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Upload Logo</label>
<div class="flex items-center">
<div id="logoPreview" class="w-16 h-16 border rounded-md flex items-center justify-center bg-gray-100 mr-3 overflow-hidden">
<i class="fas fa-camera text-gray-400"></i>
</div>
<label for="logoUpload" class="bg-gray-100 text-gray-700 px-3 py-1 rounded text-sm hover:bg-gray-200 cursor-pointer">
Choose File
</label>
<input type="file" id="logoUpload" accept="image/*" class="hidden">
</div>
</div>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Brand Colors</label>
<div class="flex flex-wrap gap-2 mt-2">
<div class="color-option bg-indigo-600 rounded-full selected" data-color="#4f46e5"></div>
<div class="color-option bg-red-600 rounded-full" data-color="#dc2626"></div>
<div class="color-option bg-green-600 rounded-full" data-color="#16a34a"></div>
<div class="color-option bg-yellow-500 rounded-full" data-color="#eab308"></div>
<div class="color-option bg-pink-600 rounded-full" data-color="#db2777"></div>
<div class="color-option bg-purple-600 rounded-full" data-color="#9333ea"></div>
<div class="color-option bg-blue-600 rounded-full" data-color="#2563eb"></div>
<div class="color-option bg-gray-800 rounded-full" data-color="#1f2937"></div>
</div>
<div class="mt-2">
<label class="inline-flex items-center">
<input type="checkbox" id="customColorToggle" class="rounded border-gray-300 text-indigo-600 focus:ring-indigo-500">
<span class="ml-2 text-sm">Use custom color</span>
</label>
<div id="customColorPicker" class="mt-2 hidden">
<input type="color" id="brandColorPicker" class="w-full h-10">
</div>
</div>
</div>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Font Style</label>
<select id="fontSelect" class="w-full border rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500">
<option value="'Inter', sans-serif">Inter (Modern)</option>
<option value="'Playfair Display', serif">Playfair Display (Elegant)</option>
<option value="'Roboto', sans-serif">Roboto (Clean)</option>
<option value="'Montserrat', sans-serif">Montserrat (Bold)</option>
<option value="'Open Sans', sans-serif">Open Sans (Friendly)</option>
</select>
</div>
<div class="flex space-x-2">
<button id="backStep4Btn" class="flex-1 bg-gray-200 text-gray-700 py-2 rounded-md hover:bg-gray-300">
Back
</button>
<button id="nextStep4Btn" class="flex-1 bg-indigo-600 text-white py-2 rounded-md hover:bg-indigo-700">
Next: Export
</button>
</div>
</div>
<div id="step5" class="step-content hidden">
<h2 class="text-xl font-semibold mb-4">Export Your Ad</h2>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Format</label>
<div class="flex space-x-2">
<label class="flex-1 border rounded-md px-3 py-2 text-center cursor-pointer hover:bg-gray-50">
<input type="radio" name="exportFormat" value="png" class="mr-1" checked> PNG
</label>
<label class="flex-1 border rounded-md px-3 py-2 text-center cursor-pointer hover:bg-gray-50">
<input type="radio" name="exportFormat" value="jpg" class="mr-1"> JPG
</label>
<label class="flex-1 border rounded-md px-3 py-2 text-center cursor-pointer hover:bg-gray-50">
<input type="radio" name="exportFormat" value="pdf" class="mr-1"> PDF
</label>
</div>
</div>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Quality</label>
<select id="qualitySelect" class="w-full border rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500">
<option value="high">High (Recommended)</option>
<option value="medium">Medium</option>
<option value="low">Low</option>
</select>
</div>
<div class="mb-6">
<label class="block text-sm font-medium mb-1">Size</label>
<select id="sizeSelect" class="w-full border rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500">
<option value="original">Original Size</option>
<option value="instagram">Instagram Post (1080x1080)</option>
<option value="facebook">Facebook Ad (1200x628)</option>
<option value="twitter">Twitter Post (1200x675)</option>
<option value="pinterest">Pinterest Pin (1000x1500)</option>
</select>
</div>
<div class="flex space-x-2">
<button id="backStep5Btn" class="flex-1 bg-gray-200 text-gray-700 py-2 rounded-md hover:bg-gray-300">
Back
</button>
<button id="exportBtn" class="flex-1 bg-green-600 text-white py-2 rounded-md hover:bg-green-700 flex items-center justify-center">
<i class="fas fa-download mr-2"></i> Export
</button>
</div>
<div class="mt-4">
<p class="text-sm font-medium mb-2">Share directly:</p>
<div class="flex space-x-2">
<button class="bg-blue-500 text-white p-2 rounded-full hover:bg-blue-600">
<i class="fab fa-facebook-f"></i>
</button>
<button class="bg-blue-400 text-white p-2 rounded-full hover:bg-blue-500">
<i class="fab fa-twitter"></i>
</button>
<button class="bg-pink-600 text-white p-2 rounded-full hover:bg-pink-700">
<i class="fab fa-instagram"></i>
</button>
<button class="bg-red-600 text-white p-2 rounded-full hover:bg-red-700">
<i class="fab fa-pinterest-p"></i>
</button>
</div>
</div>
</div>
</div>
<!-- Right Panel - Preview -->
<div class="lg:col-span-2">
<div class="bg-white rounded-xl shadow-md p-6 mb-6">
<h2 class="text-xl font-semibold mb-4">Ad Preview</h2>
<div class="preview-container">
<div class="flex justify-center space-x-4 mb-6">
<button class="preview-device bg-gray-100 px-4 py-2 rounded-lg text-sm font-medium" data-size="desktop">
<i class="fas fa-desktop mr-1"></i> Desktop
</button>
<button class="preview-device bg-gray-100 px-4 py-2 rounded-lg text-sm font-medium" data-size="tablet">
<i class="fas fa-tablet-alt mr-1"></i> Tablet
</button>
<button class="preview-device bg-gray-100 px-4 py-2 rounded-lg text-sm font-medium active" data-size="mobile">
<i class="fas fa-mobile-alt mr-1"></i> Mobile
</button>
</div>
<div class="flex justify-center">
<div id="previewFrame" class="border-8 border-gray-800 rounded-3xl w-full max-w-md bg-gray-800 p-1">
<div id="adPreview" class="bg-white w-full aspect-[9/16] overflow-hidden relative">
<!-- Ad content will be rendered here -->
<div class="absolute inset-0 flex items-center justify-center text-gray-400">
<div class="text-center">
<i class="fas fa-ad text-4xl mb-2"></i>
<p>Your ad preview will appear here</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Feedback Section -->
<div class="bg-white rounded-xl shadow-md p-6">
<h2 class="text-xl font-semibold mb-4">Help Us Improve</h2>
<p class="text-gray-600 mb-4">We'd love to hear your feedback about AdMagic. What features would you like to see?</p>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Your Feedback</label>
<textarea id="feedbackInput" rows="3" class="w-full border rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Share your thoughts..."></textarea>
</div>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Rating</label>
<div class="flex space-x-1">
<button class="text-gray-400 hover:text-yellow-500 feedback-star" data-rating="1">
<i class="far fa-star text-2xl"></i>
</button>
<button class="text-gray-400 hover:text-yellow-500 feedback-star" data-rating="2">
<i class="far fa-star text-2xl"></i>
</button>
<button class="text-gray-400 hover:text-yellow-500 feedback-star" data-rating="3">
<i class="far fa-star text-2xl"></i>
</button>
<button class="text-gray-400 hover:text-yellow-500 feedback-star" data-rating="4">
<i class="far fa-star text-2xl"></i>
</button>
<button class="text-gray-400 hover:text-yellow-500 feedback-star" data-rating="5">
<i class="far fa-star text-2xl"></i>
</button>
</div>
</div>
<button id="submitFeedbackBtn" class="bg-indigo-600 text-white px-4 py-2 rounded-md hover:bg-indigo-700">
Submit Feedback
</button>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Step management
let currentStep = 1;
// DOM elements
const stepContents = document.querySelectorAll('.step-content');
const stepIndicators = [
document.getElementById('step1Indicator'),
document.getElementById('step2Indicator'),
document.getElementById('step3Indicator'),
document.getElementById('step4Indicator'),
document.getElementById('step5Indicator')
];
// Navigation buttons
const nextButtons = [
document.getElementById('nextStep1Btn'),
document.getElementById('nextStep2Btn'),
document.getElementById('nextStep3Btn'),
document.getElementById('nextStep4Btn')
];
const backButtons = [
document.getElementById('backStep2Btn'),
document.getElementById('backStep3Btn'),
document.getElementById('backStep4Btn'),
document.getElementById('backStep5Btn')
];
// Initialize template gallery
initializeTemplates();
// Initialize event listeners
setupEventListeners();
function setupEventListeners() {
// File upload
const dropzone = document.getElementById('dropzone');
const fileUpload = document.getElementById('fileUpload');
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
dropzone.addEventListener(eventName, preventDefaults, false);
});
['dragenter', 'dragover'].forEach(eventName => {
dropzone.addEventListener(eventName, highlight, false);
});
['dragleave', 'drop'].forEach(eventName => {
dropzone.addEventListener(eventName, unhighlight, false);
});
dropzone.addEventListener('drop', handleDrop, false);
fileUpload.addEventListener('change', handleFileSelect, false);
// Image enhancement controls
const brightnessSlider = document.getElementById('brightnessSlider');
const contrastSlider = document.getElementById('contrastSlider');
const saturationSlider = document.getElementById('saturationSlider');
const autoEnhanceBtn = document.getElementById('autoEnhanceBtn');
const resetEnhancementBtn = document.getElementById('resetEnhancementBtn');
brightnessSlider.addEventListener('input', updateImageEnhancement);
contrastSlider.addEventListener('input', updateImageEnhancement);
saturationSlider.addEventListener('input', updateImageEnhancement);
autoEnhanceBtn.addEventListener('click', autoEnhanceImage);
resetEnhancementBtn.addEventListener('click', resetEnhancement);
// Navigation
nextButtons.forEach((btn, index) => {
btn.addEventListener('click', () => goToStep(index + 2));
});
backButtons.forEach((btn, index) => {
btn.addEventListener('click', () => goToStep(index + 1));
});
// Template selection
document.getElementById('industrySelect').addEventListener('change', filterTemplates);
// Branding
document.getElementById('logoUpload').addEventListener('change', handleLogoUpload);
document.querySelectorAll('.color-option').forEach(option => {
option.addEventListener('click', selectBrandColor);
});
document.getElementById('customColorToggle').addEventListener('change', toggleCustomColorPicker);
document.getElementById('brandColorPicker').addEventListener('input', updateCustomBrandColor);
document.getElementById('fontSelect').addEventListener('change', updateFontStyle);
// Suggested headlines
document.querySelectorAll('#suggestedHeadlines span').forEach(span => {
span.addEventListener('click', applySuggestedHeadline);
});
// Text inputs
document.getElementById('headlineInput').addEventListener('input', updateAdPreview);
document.getElementById('descriptionInput').addEventListener('input', updateAdPreview);
document.getElementById('ctaInput').addEventListener('input', updateAdPreview);
// Preview devices
document.querySelectorAll('.preview-device').forEach(btn => {
btn.addEventListener('click', switchPreviewDevice);
});
// Export
document.getElementById('exportBtn').addEventListener('click', exportAd);
// Feedback
document.querySelectorAll('.feedback-star').forEach(star => {
star.addEventListener('click', rateApp);
});
document.getElementById('submitFeedbackBtn').addEventListener('click', submitFeedback);
}
function preventDefaults(e) {
e.preventDefault();
e.stopPropagation();
}
function highlight() {
dropzone.classList.add('active');
}
function unhighlight() {
dropzone.classList.remove('active');
}
function handleDrop(e) {
const dt = e.dataTransfer;
const files = dt.files;
handleFiles(files);
}
function handleFileSelect(e) {
const files = e.target.files;
handleFiles(files);
}
function handleFiles(files) {
if (files.length > 0) {
const file = files[0];
if (file.type.match('image.*')) {
const reader = new FileReader();
reader.onload = function(e) {
const imagePreview = document.getElementById('imagePreview');
const imagePreviewContainer = document.getElementById('imagePreviewContainer');
const enhancementControls = document.getElementById('enhancementControls');
const nextStep1Btn = document.getElementById('nextStep1Btn');
imagePreview.src = e.target.result;
imagePreviewContainer.classList.remove('hidden');
enhancementControls.classList.remove('hidden');
nextStep1Btn.disabled = false;
// Store original image for reset functionality
originalImageSrc = e.target.result;
// Update ad preview
updateAdPreview();
};
reader.readAsDataURL(file);
} else {
alert('Please upload an image file.');
}
}
}
function handleLogoUpload(e) {
const files = e.target.files;
if (files.length > 0) {
const file = files[0];
if (file.type.match('image.*')) {
const reader = new FileReader();
reader.onload = function(e) {
const logoPreview = document.getElementById('logoPreview');
logoPreview.innerHTML = `<img src="${e.target.result}" class="w-full h-full object-contain">`;
// Update ad preview with logo
updateAdPreview();
};
reader.readAsDataURL(file);
}
}
}
let originalImageSrc = '';
function updateImageEnhancement() {
const imagePreview = document.getElementById('imagePreview');
const brightness = document.getElementById('brightnessSlider').value;
const contrast = document.getElementById('contrastSlider').value;
const saturation = document.getElementById('saturationSlider').value;
imagePreview.style.filter = `brightness(${brightness}%) contrast(${contrast}%) saturate(${saturation}%)`;
// Update ad preview
updateAdPreview();
}
function autoEnhanceImage() {
// Simulate auto-enhance by setting "optimal" values
document.getElementById('brightnessSlider').value = 110;
document.getElementById('contrastSlider').value = 120;
document.getElementById('saturationSlider').value = 115;
updateImageEnhancement();
}
function resetEnhancement() {
document.getElementById('brightnessSlider').value = 100;
document.getElementById('contrastSlider').value = 100;
document.getElementById('saturationSlider').value = 100;
updateImageEnhancement();
}
function initializeTemplates() {
const templateGallery = document.getElementById('templateGallery');
// Sample templates data (in a real app, this would come from a database)
const templates = [
{ id: 1, name: 'Modern', industry: 'all', thumbnail: 'https://via.placeholder.com/150/4f46e5/ffffff?text=Modern' },
{ id: 2, name: 'Elegant', industry: 'fashion', thumbnail: 'https://via.placeholder.com/150/db2777/ffffff?text=Elegant' },
{ id: 3, name: 'Bold', industry: 'electronics', thumbnail: 'https://via.placeholder.com/150/1f2937/ffffff?text=Bold' },
{ id: 4, name: 'Fresh', industry: 'food', thumbnail: 'https://via.placeholder.com/150/16a34a/ffffff?text=Fresh' },
{ id: 5, name: 'Minimal', industry: 'all', thumbnail: 'https://via.placeholder.com/150/ffffff/1f2937?text=Minimal' },
{ id: 6, name: 'Vibrant', industry: 'beauty', thumbnail: 'https://via.placeholder.com/150/eab308/ffffff?text=Vibrant' }
];
// Render templates
templates.forEach(template => {
const templateCard = document.createElement('div');
templateCard.className = 'template-card border rounded-lg overflow-hidden cursor-pointer transition';
templateCard.dataset.id = template.id;
templateCard.dataset.industry = template.industry;
templateCard.innerHTML = `
<img src="${template.thumbnail}" alt="${template.name}" class="w-full h-24 object-cover">
<div class="p-2 text-center">
<p class="text-sm font-medium">${template.name}</p>
</div>
`;
templateCard.addEventListener('click', () => selectTemplate(template.id));
templateGallery.appendChild(templateCard);
});
}
function filterTemplates() {
const industry = document.getElementById('industrySelect').value;
const templates = document.querySelectorAll('.template-card');
templates.forEach(template => {
if (industry === 'all' || template.dataset.industry === industry) {
template.style.display = 'block';
} else {
template.style.display = 'none';
}
});
}
let selectedTemplateId = null;
function selectTemplate(id) {
selectedTemplateId = id;
// Highlight selected template
document.querySelectorAll('.template-card').forEach(card => {
if (card.dataset.id == id) {
card.classList.add('ring-2', 'ring-indigo-500');
} else {
card.classList.remove('ring-2', 'ring-indigo-500');
}
});
// Enable next button
document.getElementById('nextStep2Btn').disabled = false;
// Update ad preview
updateAdPreview();
}
function applySuggestedHeadline(e) {
document.getElementById('headlineInput').value = e.target.textContent;
updateAdPreview();
}
let selectedBrandColor = '#4f46e5';
function selectBrandColor(e) {
selectedBrandColor = e.target.dataset.color;
// Update color selection UI
document.querySelectorAll('.color-option').forEach(option => {
option.classList.remove('selected');
});
e.target.classList.add('selected');
// Hide custom color picker if it's visible
document.getElementById('customColorToggle').checked = false;
document.getElementById('customColorPicker').classList.add('hidden');
// Update ad preview
updateAdPreview();
}
function toggleCustomColorPicker(e) {
const picker = document.getElementById('customColorPicker');
if (e.target.checked) {
picker.classList.remove('hidden');
} else {
picker.classList.add('hidden');
}
}
function updateCustomBrandColor(e) {
selectedBrandColor = e.target.value;
// Update ad preview
updateAdPreview();
}
function updateFontStyle() {
const font = document.getElementById('fontSelect').value;
// In a real app, you would load the font dynamically
updateAdPreview();
}
function switchPreviewDevice(e) {
const previewFrame = document.getElementById('previewFrame');
const size = e.target.dataset.size;
// Update active button
document.querySelectorAll('.preview-device').forEach(btn => {
btn.classList.remove('active', 'bg-indigo-100', 'text-indigo-700');
btn.classList.add('bg-gray-100');
});
e.target.classList.remove('bg-gray-100');
e.target.classList.add('active', 'bg-indigo-100', 'text-indigo-700');
// Update preview frame
if (size === 'desktop') {
previewFrame.classList.remove('border-8', 'rounded-3xl', 'max-w-md');
previewFrame.classList.add('border', 'rounded-lg', 'max-w-4xl');
previewFrame.querySelector('#adPreview').classList.remove('aspect-[9/16]');
previewFrame.querySelector('#adPreview').classList.add('aspect-[16/9]');
} else if (size === 'tablet') {
previewFrame.classList.remove('border-8', 'rounded-3xl', 'max-w-md');
previewFrame.classList.add('border-4', 'rounded-xl', 'max-w-lg');
previewFrame.querySelector('#adPreview').classList.remove('aspect-[9/16]');
previewFrame.querySelector('#adPreview').classList.add('aspect-[4/3]');
} else { // mobile
previewFrame.classList.remove('border', 'rounded-lg', 'max-w-4xl');
previewFrame.classList.add('border-8', 'rounded-3xl', 'max-w-md');
previewFrame.querySelector('#adPreview').classList.remove('aspect-[16/9]', 'aspect-[4/3]');
previewFrame.querySelector('#adPreview').classList.add('aspect-[9/16]');
}
}
function updateAdPreview() {
const adPreview = document.getElementById('adPreview');
const imagePreview = document.getElementById('imagePreview');
const headline = document.getElementById('headlineInput').value;
const description = document.getElementById('descriptionInput').value;
const cta = document.getElementById('ctaInput').value;
const logoPreview = document.getElementById('logoPreview').querySelector('img');
// Clear previous content
adPreview.innerHTML = '';
// Add background (image or color)
if (imagePreview.src) {
const bgDiv = document.createElement('div');
bgDiv.className = 'absolute inset-0 overflow-hidden';
const bgImg = document.createElement('img');
bgImg.src = imagePreview.src;
bgImg.style.filter = imagePreview.style.filter;
bgImg.className = 'w-full h-full object-cover';
bgDiv.appendChild(bgImg);
adPreview.appendChild(bgDiv);
// Add overlay for better text visibility
const overlay = document.createElement('div');
overlay.className = 'absolute inset-0 bg-black bg-opacity-30';
adPreview.appendChild(overlay);
} else {
adPreview.style.backgroundColor = selectedBrandColor;
}
// Add content based on template (simplified for demo)
const contentDiv = document.createElement('div');
contentDiv.className = 'relative z-10 h-full flex flex-col p-6 text-white';
// Add logo if uploaded
if (logoPreview) {
const logoDiv = document.createElement('div');
logoDiv.className = 'mb-4';
const logoImg = document.createElement('img');
logoImg.src = logoPreview.src;
logoImg.className = 'h-10 object-contain';
logoDiv.appendChild(logoImg);
contentDiv.appendChild(logoDiv);
}
// Add headline if provided
if (headline) {
const headlineDiv = document.createElement('h2');
headlineDiv.className = 'text-3xl font-bold mb-2';
headlineDiv.textContent = headline;
contentDiv.appendChild(headlineDiv);
}
// Add description if provided
if (description) {
const descDiv = document.createElement('p');
descDiv.className = 'text-lg mb-4';
descDiv.textContent = description;
contentDiv.appendChild(descDiv);
}
// Add CTA button if provided
if (cta) {
const ctaDiv = document.createElement('div');
ctaDiv.className = 'mt-auto';
const ctaBtn = document.createElement('button');
ctaBtn.className = 'bg-white text-indigo-700 px-6 py-2 rounded-full font-medium shadow-lg hover:bg-gray-100 transition';
ctaBtn.textContent = cta;
ctaDiv.appendChild(ctaBtn);
contentDiv.appendChild(ctaDiv);
}
adPreview.appendChild(contentDiv);
}
function goToStep(step) {
// Hide current step
document.getElementById(`step${currentStep}`).classList.add('hidden');
stepIndicators[currentStep - 1].classList.remove('active', 'completed');
// Update current step
currentStep = step;
// Show new step
document.getElementById(`step${currentStep}`).classList.remove('hidden');
// Update step indicators
for (let i = 0; i < stepIndicators.length; i++) {
if (i < currentStep - 1) {
stepIndicators[i].classList.add('completed');
stepIndicators[i].classList.remove('active');
} else if (i === currentStep - 1) {
stepIndicators[i].classList.add('active');
stepIndicators[i].classList.remove('completed');
} else {
stepIndicators[i].classList.remove('active', 'completed');
}
}
// Scroll to top of controls
document.querySelector('.lg\\:col-span-1').scrollTo(0, 0);
}
function exportAd() {
// In a real app, this would use a library like html2canvas to export the ad
alert('Your ad has been exported! (This is a demo - in a real app, the ad would be downloaded)');
// Show success message
const exportBtn = document.getElementById('exportBtn');
const originalText = exportBtn.innerHTML;
exportBtn.innerHTML = '<i class="fas fa-check mr-2"></i> Success!';
exportBtn.classList.remove('bg-green-600', 'hover:bg-green-700');
exportBtn.classList.add('bg-green-500');
// Reset button after delay
setTimeout(() => {
exportBtn.innerHTML = originalText;
exportBtn.classList.remove('bg-green-500');
exportBtn.classList.add('bg-green-600', 'hover:bg-green-700');
}, 2000);
}
function rateApp(e) {
const rating = parseInt(e.target.dataset.rating);
const stars = document.querySelectorAll('.feedback-star');
stars.forEach((star, index) => {
if (index < rating) {
star.innerHTML = '<i class="fas fa-star text-2xl text-yellow-500"></i>';
} else {
star.innerHTML = '<i class="far fa-star text-2xl text-gray-400"></i>';
}
});
}
function submitFeedback() {
const feedback = document.getElementById('feedbackInput').value;
const stars = document.querySelectorAll('.feedback-star i.fas.fa-star').length;
if (feedback || stars > 0) {
// In a real app, this would send the feedback to a server
alert('Thank you for your feedback!');
document.getElementById('feedbackInput').value = '';
// Reset stars
document.querySelectorAll('.feedback-star').forEach(star => {
star.innerHTML = '<i class="far fa-star text-2xl text-gray-400"></i>';
});
} else {
alert('Please provide feedback or a rating before submitting.');
}
}
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=frederic54/admagic" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |