<!DOCTYPE html> <html lang="fa"> <head> <meta charset="UTF-8"> <meta name="viewport"…
- User
body, html { height: 100%; font-family: 'Tahoma', Arial, sans-serif; background-color: #f7f9fc; display: flex; justify-content: center; align-items: center; direction: rtl; text-align: right; color: #2c3e50; } /* کانتینر مترجم */ .translator-container { max-width: 600px; width: 90%; background: #fff; padding: 25px 35px; border-radius: 15px; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1); border: 1px solid #e0e0e0; text-align: center; } .translator-container h2 { margin-bottom: 20px; color: #34495e; font-size: 22px; } /* استایل کادر متن (متن ورودی) */ textarea { width: 100%; min-height: 40px; /* ارتفاع پیشفرض (اندازه یک خط) */ max-height: 200px; padding: 10px; border-radius: 8px; border: 1px solid #ccc; resize: none; /* جلوگیری از تغییر دستی اندازه توسط کاربر */ font-size: 16px; font-family: 'Tahoma', Arial, sans-serif; overflow: hidden; /* جلوگیری از اسکرول اولیه */ transition: border-color 0.3s, box-shadow 0.3s; } textarea:focus { border-color: #3498db; box-shadow: 0 0 5px rgba(52, 152, 219, 0.3); outline: none; } /* استایل اسپینر */ .spinner { border: 4px solid rgba(0, 0, 0, 0.1); border-top: 4px solid #3498db; border-radius: 50%; width: 20px; height: 20px; animation: spin 1s linear infinite; margin: 15px auto; display: none; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } /* نمایش نتیجه ترجمه */ .result { margin-top: 20px; padding: 15px; background: #f4f4f9; border-radius: 10px; min-height: 50px; font-size: 16px; color: #34495e; white-space: pre-wrap; word-wrap: break-word; } /* دکمه کپی */ .copy-button { margin-top: 15px; display: none; background-color: #3498db; border: none; color: #fff; padding: 10px 20px; border-radius: 5px; cursor: pointer; font-size: 15px; font-family: 'Tahoma', Arial, sans-serif; transition: background-color 0.3s; } .copy-button:hover { background-color: #2980b9; } /* استایل پیام موفقیت */ .success-message { display: none; margin-top: 15px; color: #2ecc71; font-size: 15px; font-weight: bold; } /* تنظیمات واکنشگرا */ @media (max-width: 480px) { .translator-container { padding: 15px 25px; } } </style><script> const inputText = document.getElementById('inputText'); const resultText = document.getElementById('resultText'); const spinner = document.getElementById('spinner'); const copyButton = document.getElementById('copyButton'); const successMessage = document.getElementById('successMessage'); let timeout; // تنظیم ارتفاع خودکار کادر متن inputText.addEventListener('input', function () { this.style.height = 'auto'; this.style.height = this.scrollHeight + 'px'; // محاسبه ارتفاع بر اساس محتوا const text = inputText.value.trim(); if (timeout) { clearTimeout(timeout); } // اگر ورودی خالی شد، نتیجه را پاک کن if (text === '') { resultText.textContent = 'ترجمه.'; copyButton.style.display = 'none'; spinner.style.display = 'none'; return; } // اجرا با تأخیر برای جلوگیری از درخواستهای زیاد timeout = setTimeout(() => translateText(text), 500); }); async function translateText(text) { const endpoint = 'https://api.mymemory.translated.net/get'; const params = new URLSearchParams({ q: text, langpair: 'fa|en' }); resultText.textContent = ''; spinner.style.display = 'block'; try { const response = await fetch(`${endpoint}?${params.toString()}`); if (!response.ok) { throw new Error('خطا در بارگیری'); } const data = await response.json(); spinner.style.display = 'none'; if (data.responseData && data.responseData.translatedText) { resultText.textContent = data.responseData.translatedText; copyButton.style.display = 'inline-block'; } else { resultText.textContent = 'ترجمه یافت نشد.'; } } catch (error) { spinner.style.display = 'none'; resultText.textContent = 'خطا در ترجمه.'; } } // مدیریت دکمه کپی copyButton.addEventListener('click', function () { const translatedText = resultText.textContent.trim(); if (translatedText === '' || translatedText === 'ترجمه.') { alert('هیچ متنی برای کپی کردن وجود ندارد.'); return; } navigator.clipboard.writeText(translatedText).then(() => { successMessage.style.display = 'block'; // مخفی کردن پیام بعد از 2 ثانیه setTimeout(() => { successMessage.style.display = 'none'; }, 2000); }).catch(err => { alert('کپی متن موفقیتآمیز نبود.'); }); }); </script> - Assistant
- User
دکمه کپی هم بالای متن انگلیسی باشه و اسم اش باشه کپی متن انگلیسی
- Assistant
- User
اسپینر هم بالای متن فارسی باشه بالای کادر
- Assistant
- User
اون متن که میگه با موفقیت کپی شد زیر همون دکمه نمایش بده
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.