کاری کن دکمه نمایشگر کد <p>&nbsp;</p>
<style>
    body {
        margin: 0;
        padding: 0;
        background-color: #f0f0f0;
        font-family: Arial, sans-serif;
    }
    
    .iframe-container {
        position: relative;
        width: 100%;
        height: 100vh;
        overflow: hidden;
    }
    
    iframe {
        width: 100%;
        height: calc(100% + 0.5cm); /* افزایش ارتفاع به اندازه ۰.۵ سانتیمتر */
        border: none;
        display: none;
        position: relative;
        top: -0.5cm; /* مخفی کردن ۰.۵ سانتیمتر از بالای آی‌فریم */
    }
    
    .loading {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        display: flex;
        flex-direction: column;
        align-items: center;
        z-index: 10000;
    }
    
    .loading-message {
        margin-bottom: 20px;
        font-size: 18px;
    }
    
    .progress {
        width: 80%;
        max-width: 400px;
        height: 20px;
        background-color: #ddd;
        border-radius: 5px;
        overflow: hidden;
    }
    
    .progress-bar {
        height: 100%;
        width: 0;
        background-color: #4caf50;
        transition: width 1s;
    }
    
    .error-message {
        display: none;
        color: red;
        margin-top: 20px;
        font-size: 16px;
        text-align: center;
    }
    
    #retryButton {
        display: none;
        margin-top: 10px;
        padding: 10px 20px;
        font-size: 16px;
        cursor: pointer;
        background-color: #4caf50;
        color: white;
        border: none;
        border-radius: 5px;
    }
    
    /* بهبود دکمه نمایشگر کد */
    .code-preview-button-top {
        display: block;
        width: 180px;
        color: white;
        text-align: center;
        padding: 10px;
        border-radius: 5px;
        cursor: pointer;
        font-size: 14px;
        transition: background-color 0.3s, transform 0.3s;
        position: fixed;
        top: 10px;
        right: 10px;
        z-index: 10001;
        text-decoration: none;
        background-color: #007BFF; /* رنگ جدید */
    }
    
    .code-preview-button-top::before {
        content: '💻 '; /* آیکون */
        font-size: 16px;
    }
    
    .code-preview-button-top:hover {
        background-color: #0056b3;
        transform: scale(1.05);
    }
    
    .modal {
        display: none;
        position: fixed;
        z-index: 10002;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        overflow: auto;
    }
    
    .modal-content {
        background-color: #fefefe;
        margin: 5% auto;
        padding: 20px;
        border: 1px solid #888;
        width: 90%;
        max-width: 900px;
        text-align: center;
        border-radius: 5px;
        position: relative;
    }
    
    .modal-content h2 {
        margin-top: 0;
    }
    
    .code-area {
        width: 100%;
        height: 300px;
        margin: 10px 0;
        padding: 10px;
        font-family: 'Courier New', Courier, monospace;
        direction: ltr;
        text-align: left;
        resize: vertical;
        font-size: 14px;
        background-color: #2d2d2d;
        color: #f8f8f2;
        border: 1px solid #444;
        border-radius: 5px;
        position: relative;
    }
    
    /* افزودن آیکون به کادر کد */
    .code-area::before {
        content: '💻';
        position: absolute;
        top: 10px;
        left: 10px;
        font-size: 20px;
    }
    
    .code-area::placeholder {
        color: #bbb;
        padding-left: 30px; /* فاصله برای آیکون */
    }
    
    .preview-area {
        width: 100%;
        height: 400px;
        margin: 10px 0;
        border: 1px solid #ccc;
        overflow: auto;
        background: white;
    }
    
    .modal-button {
        margin: 5px;
        padding: 10px 20px;
        border: none;
        border-radius: 5px;
        cursor: pointer;
        font-size: 14px;
        color: white;
    }
    
    .preview-btn {
        background-color: #2196F3;
    }
    
    .close-btn {
        background-color: #f44336;
    }
    
    @media (max-width: 768px) {
        .code-preview-button-top {
            width: 150px;
            padding: 8px;
            font-size: 12px;
        }
    
        .modal-content {
            width: 95%;
            margin: 10% auto;
        }
    }
    
    /* افزودن استایل دکمه اسکرول */
    .scroll-handle {
        position: fixed;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 9999;
        width: 45px;
        height: 45px;
        border-radius: 50%;
        background-color: rgba(0, 0, 0, 0.4);
        color: white;
        border: none;
        cursor: grab;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        transition: all 0.3s;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    }

    .scroll-handle:active {
        cursor: grabbing;
        background-color: rgba(0, 0, 0, 0.6);
        box-shadow: 0 3px 8px rgba(0,0,0,0.3);
    }

    @media (max-width: 768px) {
        .scroll-handle {
            right: 10px;
            width: 40px;
            height: 40px;
            font-size: 22px;
        }
    }

    @keyframes pulse {
        0% { transform: translateY(-50%) scale(1); }
        50% { transform: translateY(-50%) scale(1.1); }
        100% { transform: translateY(-50%) scale(1); }
    }

    .scroll-handle:hover {
        animation: pulse 1s infinite;
    }
    </style>
<!-- دکمه نمایشگر کد -->
<p><a href="#" class="code-preview-button-top" id="codePreviewButtonTop">نمایشگر کد</a></p>
<!-- مدال نمایش کد -->
<div id="codeModal" class="modal">
<div class="modal-content">
<h2>نمایشگر کد</h2>
<textarea id="codeArea" class="code-area" placeholder="کد تولید شده را برای نمایش اینجا قرار دهید"></textarea> <button class="modal-button close-btn" id="closeCodeBtn">بستن</button></div>
</div>
<!-- مدال پیش‌نمایش -->
<div id="previewModal" class="modal">
<div class="modal-content">
<h2>پیش&zwnj;نمایش صفحه</h2>
<div id="previewArea" class="preview-area"></div>
<button class="modal-button close-btn" id="closePreviewBtn">بستن</button></div>
</div>
<!-- کانتینر آی‌فریم و لودینگ -->
<div class="iframe-container">
<div class="loading" id="loadingContainer">
<div class="loading-message">لطفاً صبر کنید...</div>
<div class="progress">
<div class="progress-bar" id="progressBar"></div>
</div>
<div class="error-message" id="errorMessage">بارگیری زیاد طول کشید.<br />در صورت عدم بارگذاری، فیلترشکن خود را روشن کنید.</div>
<button id="retryButton">بارگذاری مجدد</button></div>
<iframe id="myIframe"></iframe></div>
<!-- دکمه اسکرول -->
<p><button class="scroll-handle" title="برای اسکرول بکشید" role="button" aria-label="دکمه اسکرول">👆</button></p>
<p>
<script>
    const siteURL = 'https://yasserrmd-webuigen.static.hf.space/index.html';
    let progress = 0;
    const progressBar = document.getElementById('progressBar');
    const retryButton = document.getElementById('retryButton');
    const errorMessage = document.getElementById('errorMessage');
    const loadingContainer = document.getElementById('loadingContainer');
    let interval;
    let iframeLoadedFlag = false;
    
    // عناصر مدال
    const codeModal = document.getElementById('codeModal');
    const previewModal = document.getElementById('previewModal');
    const codeArea = document.getElementById('codeArea');
    const previewArea = document.getElementById('previewArea');
    
    // دکمه‌ها
    const codePreviewButtonTop = document.getElementById('codePreviewButtonTop');
    const closeCodeBtn = document.getElementById('closeCodeBtn');
    const closePreviewBtn = document.getElementById('closePreviewBtn');
    
    function startProgress() {
        loadingContainer.style.display = 'flex';
        progressBar.style.width = '0%';
        progress = 0;
    
        interval = setInterval(() => {
            if (progress < 100) {
                progress += 10;
                progressBar.style.width = progress + '%';
            }
            if (progress === 100) {
                clearInterval(interval);
                if (!iframeLoadedFlag) {
                    retryButton.style.display = 'block';
                    errorMessage.style.display = 'block';
                }
            }
        }, 1000);
    }
    
    function iframeLoaded() {
        iframeLoadedFlag = true;
        clearInterval(interval);
        loadingContainer.style.display = 'none';
        document.getElementById('myIframe').style.display = 'block';
        setupScrollHandle();
    }
    
    function iframeError() {
        clearInterval(interval);
        loadingContainer.style.display = 'flex';
        retryButton.style.display = 'block';
        errorMessage.style.display = 'block';
    }
    
    function loadIframe() {
        fetch(siteURL, { method: 'HEAD', mode: 'no-cors' })
        .then(() => {
            const iframe = document.getElementById('myIframe');
            iframe.src = siteURL;
            iframe.onload = iframeLoaded;
            iframe.onerror = iframeError;
        })
        .catch(() => {
            iframeError();
        });
    }
    
    // لیسنرهای مدال‌ها
    codePreviewButtonTop.addEventListener('click', (e) => {
        e.preventDefault();
        const iframe = document.getElementById('myIframe');
        let doc = iframe.contentDocument || iframe.contentWindow.document;
        
        try {
            // دریافت کد HTML از آی‌فریم و نمایش در تکست اریا
            const htmlContent = doc.documentElement.outerHTML;
            codeArea.value = htmlContent;
        } catch (err) {
            alert('Cannot access iframe content due to cross-origin policy.');
            codeArea.value = '';
        }
        
        codeModal.style.display = 'block';
    });
    
    // دکمه‌های بستن مدال‌ها
    closeCodeBtn.addEventListener('click', () => {
        codeModal.style.display = 'none';
    });
    
    closePreviewBtn.addEventListener('click', () => {
        previewModal.style.display = 'none';
    });
    
    // بستن مدال با کلیک خارج از آن‌ها
    window.addEventListener('click', (event) => {
        if (event.target === codeModal) {
            codeModal.style.display = 'none';
        }
        if (event.target === previewModal) {
            previewModal.style.display = 'none';
        }
    });
    
    // دکمه بارگذاری مجدد
    retryButton.addEventListener('click', function() {
        progress = 0;
        progressBar.style.width = '0%';
        iframeLoadedFlag = false;
        retryButton.style.display = 'none';
        errorMessage.style.display = 'none';
        loadingContainer.style.display = 'flex';
        document.getElementById('myIframe').style.display = 'none';
        loadIframe();
        startProgress();
    });
    
    // بارگذاری اولیه
    loadIframe();
    startProgress();
    
    // عملکرد دکمه اسکرول
    let isDragging = false;
    let startY, startScrollY;
    
    function setupScrollHandle() {
        const scrollHandle = document.querySelector('.scroll-handle');
        const iframe = document.getElementById('myIframe');
    
        scrollHandle.addEventListener('mousedown', startDragging);
        scrollHandle.addEventListener('touchstart', startDragging);
    
        document.addEventListener('mousemove', drag);
        document.addEventListener('touchmove', drag);
    
        document.addEventListener('mouseup', stopDragging);
        document.addEventListener('touchend', stopDragging);
    
        function startDragging(e) {
            isDragging = true;
            startY = e.clientY || e.touches[0].clientY;
            if (iframe.contentWindow) {
                startScrollY = iframe.contentWindow.pageYOffset || iframe.contentWindow.scrollY;
            } else {
                startScrollY = 0;
            }
            scrollHandle.style.cursor = 'grabbing';
        }
    
        function drag(e) {
            if (!isDragging) return;
            e.preventDefault();
            const y = e.clientY || e.touches[0].clientY;
            const walk = (y - startY) * 2;
            if (iframe.contentWindow) {
                iframe.contentWindow.scrollTo(0, startScrollY - walk);
            }
        }
    
        function stopDragging() {
            isDragging = false;
            scrollHandle.style.cursor = 'grab';
        }
    }
    
    </script>
</p> کدی رو غیر از این نمایش بدهم یک دکمه کپی هم برای نمایشگر قرار بده <html><head><script>window.huggingface={variables:{"SPACE_CREATOR_USER_ID":"6397f4c8fec7b4ee64c47b0b"}};</script>


  <title>WebGenUI - Web Page UI Generator</title>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">
  <style>
/* Style the form container */
.form-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
  border: 1px solid #ccc;
  border-radius: 5px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

/* Style the form heading */
h1 {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 20px;
}

/* Style the form icon */
.form-icon {
  margin-right: 10px;
}

/* Style the group headings */
h2 {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
}

/* Style the group icon */
.group-icon {
  margin-right: 5px;
}

/* Style the form fields */
.form-field {
  margin-bottom: 10px;
}

/* Style the form field labels */
.form-field label {
  font-weight: bold;
}

/* Style the form field inputs */
.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
}

/* Style the form field checkboxes and radios */
.form-field input[type="checkbox"],
.form-field input[type="radio"] {
  margin-right: 5px;
}

/* Style the form field checkbox and radio labels */
.form-field label[for] {
  display: inline;
  font-weight: normal;
}

/* Style the form field error messages */
.form-field .error-message {
  color: red;
  font-size: 12px;
  margin-top: 5px;
}

/* Style the form submit and cancel buttons */
.form-buttons {
  margin-top: 20px;
}

.form-buttons button {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.form-buttons button[type="submit"] {
  background-color: #4CAF50;
  color: white;
  margin-right: 10px;
}

.form-buttons button[type="reset"] {
  background-color: #f44336;
  color: white;
}

/* Use Bootstrap classes to style the form and group headings */
.form-container {
  border: none;
  box-shadow: none;
  padding: 2rem;
  background-color: #f8f9fa;
  border-radius: 0.25rem;
}

h1 {
  font-size: 2.5rem;
  margin-bottom: 2rem;
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  padding: 0.5rem 1rem;
  background-color: #e9ecef;
  border-radius: 0.25rem;
  border: none;
}

.form-field {
  margin-bottom: 1rem;
}

.form-field label {
  font-weight: bold;
  margin-bottom: 0.25rem;
}

.form-field input,
.form-field textarea,
.form-field select {
  border-radius: 0.25rem;
}

.form-buttons button {
  padding: 0.5rem 1rem;
  border-radius: 0.25rem;
}

.form-buttons button[type="submit"] {
  background-color: #007bff;
  border-color: #007bff;
}

.form-buttons button[type="reset"] {
  background-color: #dc3545;
  border-color: #dc3545;
}


  </style>
</head>
<body>
    <div class="container" style="margin-top: 50px;">
        <form id="messageForm">
            <div class="input-group mb-3">
                <input type="text" class="form-control" id="messageInput" placeholder="Type your website details here...">
                 <!-- <textarea class="form-control" id="messageInput" placeholder="Type your message here..." rows="7"></textarea> -->
                <div class="input-group-append">
                    <button class="btn btn-outline-secondary" type="submit" id="sendButton">
                        <i id="buttonIcon" class="fas fa-paper-plane"></i>
                    </button>
                  <button id="downloadButton"><i class="fas fa-download"></i> Download HTML</button>
                </div>
            </div>
        </form>
    </div>

      <div class="container-fluid" id="htmlDiv">
        <div class=" embed-responsive-16by9">
    <iframe id="myIframe" class="embed-responsive-item" style="width: 100%;border: none;"></iframe>
  </div>
  </div>

      <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
      <script>
  //        document.getElementById('myIframe').onload = function() {
  //         document.getElementById('myIframe').style.height = document.getElementById('myIframe').contentWindow.document.body.scrollHeight + 'px';
  //         //document.getElementById('htmlDiv').style.height = document.getElementById('myIframe').contentWindow.document.body.scrollHeight  + 'px';
          
  // }

  var iframe = document.getElementById('myIframe');
  iframe.onload = function() {
    iframe.contentWindow.document.body.style.margin = '0';
    iframe.contentWindow.document.body.style.padding = '0';
    iframe.style.height = document.getElementById('myIframe').contentWindow.document.body.scrollHeight + 'px';
   
  }

document.getElementById('downloadButton').addEventListener('click', function() {
    var iframeDoc = document.getElementById('myIframe').contentWindow.document;
    if (iframeDoc.body.innerHTML.trim() !== '') {
        var html = iframeDoc.documentElement.outerHTML;
        var blob = new Blob([html], { type: 'text/html' });
        var url = URL.createObjectURL(blob);
        var a = document.createElement('a');
        a.href = url;
        a.download = 'output.html';
        document.body.appendChild(a);
        a.click();
        document.body.removeChild(a);
        URL.revokeObjectURL(url);
    } else {
        alert('No content to download.');
    }
});

          $(document).ready(function() {
              $('#messageForm').on('submit', function(e) {
                  e.preventDefault();
                  var message = $('#messageInput').val();
                  var buttonIcon = $('#buttonIcon');
                  //$("#htmlPreview").html('');
                  // Change icon to loading spinner
                  document.getElementById('myIframe').srcdoc = '';
                  buttonIcon.removeClass('fa-paper-plane').addClass('fa-spinner fa-spin');
                  
                  $.ajax({
                      url: 'https://nakheeltech.com:8030/api/v1/prediction/3845925d-d239-468c-a63f-b6948afd08fd',
                      type: 'POST',
                      data: JSON.stringify({"question":  message }),
                      contentType: 'application/json',
                      success: function(data) {
                          // Change icon back to paper plane
                          $('#messageInput').val('');
                          var text=data.text
                          var startIndex = text.indexOf("<");
                            var endIndex = text.lastIndexOf(">") + 1;
                            var htmlString = text.substring(startIndex, endIndex);
                            document.getElementById('myIframe').srcdoc = htmlString;
                            //$("#htmlPreview").html(htmlString);
                          buttonIcon.removeClass('fa-spinner fa-spin').addClass('fa-paper-plane');
                          // Handle success here
                      },
                      error: function(jqXHR, textStatus, errorThrown) {
                          // Change icon back to paper plane
                          buttonIcon.removeClass('fa-spinner fa-spin').addClass('fa-paper-plane');
                          // Handle error here
                      }
                  });
              });
          });
      </script>

<!-- <div class="container" id="htmlPreview">

</div> -->


</body></html>