<textarea id="htmlInput" placeholder="أدخل كود HTML هنا"></textarea>
<textarea id="cssInput" placeholder="أدخل كود CSS هنا"></textarea>
<textarea id="jsInput" placeholder="أدخل كود JavaScript هنا"></textarea>
<textarea id="pythonInput" placeholder="أدخل كود Python هنا"></textarea>
عرض الأكواد
رجوع
<iframe id="resultFrame"></iframe>
<script>
async function renderCode() {
const htmlCode = document.getElementById('htmlInput').value;
const cssCode = document.getElementById('cssInput').value;
const jsCode = document.getElementById('jsInput').value;
const pythonCode = document.getElementById('pythonInput').value;
if (!htmlCode && !cssCode && !jsCode && !pythonCode) {
alert("الرجاء إدخال كود على الأقل في أحد الحقول.");
return;
}
// عرض HTML, CSS, JS
const combinedCode = `
<style>${cssCode}</style>
${htmlCode}
<script>${jsCode}<\/script>
`;
const iframe = document.getElementById('resultFrame');
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
iframeDoc.open();
iframeDoc.write(combinedCode);
iframeDoc.close();
// تنفيذ كود Python باستخدام Pyodide
if (pythonCode) {
await loadPyodide();
let output = "";
try {
const result = await pyodide.runPythonAsync(pythonCode);
output = result !== undefined ? result.toString() : "تم التنفيذ بنجاح بدون إخراج.";
} catch (error) {
output = `خطأ: ${error.message}`;
}
document.getElementById('pythonResult').innerText = output;
} else {
document.getElementById('pythonResult').innerText = "";
}
document.querySelector('.container').style.display = 'none';
document.querySelector('.output').style.display = 'block';
}
function goBack() {
document.querySelector('.container').style.display = 'block';
document.querySelector('.output').style.display = 'none';
}
// تحميل Pyodide عند بدء التطبيق
let pyodide;
async function loadPyodide() {
if (!pyodide) {
pyodide = await loadPyodide({ indexURL: "https://cdn.jsdelivr.net/pyodide/v0.23.4/full/" });
}
}
</script>