File size: 12,626 Bytes
594af2b | 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 | <!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>مولد الأرقام العشوائية</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>
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700&display=swap');
body {
font-family: 'Tajawal', sans-serif;
}
.number-display {
transition: all 0.3s ease;
}
.glow {
animation: glow 1s ease-in-out infinite alternate;
}
@keyframes glow {
from {
box-shadow: 0 0 5px rgba(59, 130, 246, 0.5);
}
to {
box-shadow: 0 0 20px rgba(59, 130, 246, 0.8);
}
}
</style>
</head>
<body class="bg-gradient-to-br from-blue-50 to-indigo-100 min-h-screen">
<div class="container mx-auto px-4 py-8">
<div class="max-w-md mx-auto bg-white rounded-xl shadow-md overflow-hidden md:max-w-2xl">
<div class="p-8">
<div class="flex items-center justify-center mb-6">
<i class="fas fa-random text-blue-500 text-3xl mr-2"></i>
<h1 class="text-2xl font-bold text-gray-800">مولد الأرقام العشوائية</h1>
</div>
<div class="mb-6">
<label for="quantity" class="block text-sm font-medium text-gray-700 mb-2">عدد الأرقام المطلوبة</label>
<div class="flex">
<input type="number" id="quantity" min="1" max="20" value="1"
class="flex-1 px-4 py-2 border border-gray-300 rounded-l-md focus:ring-blue-500 focus:border-blue-500">
<button id="generateBtn" class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-r-md transition duration-300">
<i class="fas fa-bolt mr-1"></i> توليد
</button>
</div>
</div>
<div class="mb-6">
<label class="block text-sm font-medium text-gray-700 mb-2">النطاق</label>
<div class="grid grid-cols-2 gap-4">
<div>
<label for="min" class="block text-xs text-gray-500 mb-1">الحد الأدنى</label>
<input type="number" id="min" min="0" max="9999" value="0"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500">
</div>
<div>
<label for="max" class="block text-xs text-gray-500 mb-1">الحد الأعلى</label>
<input type="number" id="max" min="1" max="10000" value="10000"
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500">
</div>
</div>
</div>
<div class="flex items-center mb-6">
<input type="checkbox" id="unique" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
<label for="unique" class="mr-2 block text-sm text-gray-700">أرقام فريدة (بدون تكرار)</label>
</div>
<div id="resultContainer" class="hidden">
<h2 class="text-lg font-semibold text-gray-800 mb-3 flex items-center">
<i class="fas fa-list-ol text-blue-500 mr-2"></i> النتائج
</h2>
<div id="results" class="space-y-3"></div>
<div class="mt-4 flex justify-between">
<button id="copyBtn" class="bg-gray-200 hover:bg-gray-300 text-gray-800 px-4 py-2 rounded-md text-sm transition duration-300">
<i class="fas fa-copy mr-1"></i> نسخ النتائج
</button>
<button id="clearBtn" class="text-red-500 hover:text-red-700 text-sm transition duration-300">
<i class="fas fa-trash-alt mr-1"></i> مسح الكل
</button>
</div>
</div>
</div>
</div>
<div class="mt-8 text-center text-sm text-gray-500">
<p>تم التطوير بواسطة مولد الأرقام العشوائية | النطاق من 0 إلى 10000</p>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const generateBtn = document.getElementById('generateBtn');
const quantityInput = document.getElementById('quantity');
const minInput = document.getElementById('min');
const maxInput = document.getElementById('max');
const uniqueCheckbox = document.getElementById('unique');
const resultContainer = document.getElementById('resultContainer');
const resultsDiv = document.getElementById('results');
const copyBtn = document.getElementById('copyBtn');
const clearBtn = document.getElementById('clearBtn');
// Validate inputs
minInput.addEventListener('change', function() {
if (parseInt(this.value) < 0) this.value = 0;
if (parseInt(this.value) > 9999) this.value = 9999;
if (parseInt(this.value) >= parseInt(maxInput.value)) {
maxInput.value = parseInt(this.value) + 1;
}
});
maxInput.addEventListener('change', function() {
if (parseInt(this.value) > 10000) this.value = 10000;
if (parseInt(this.value) < 1) this.value = 1;
if (parseInt(this.value) <= parseInt(minInput.value)) {
minInput.value = parseInt(this.value) - 1;
}
});
quantityInput.addEventListener('change', function() {
if (parseInt(this.value) < 1) this.value = 1;
if (parseInt(this.value) > 20) this.value = 20;
});
// Generate random numbers
generateBtn.addEventListener('click', function() {
const quantity = parseInt(quantityInput.value);
const min = parseInt(minInput.value);
const max = parseInt(maxInput.value);
const unique = uniqueCheckbox.checked;
if (min >= max) {
alert('الحد الأدنى يجب أن يكون أقل من الحد الأعلى');
return;
}
if (unique && (max - min + 1) < quantity) {
alert('لا يمكن توليد أرقام فريدة أكثر من النطاق المحدد');
return;
}
const numbers = generateRandomNumbers(quantity, min, max, unique);
displayResults(numbers);
resultContainer.classList.remove('hidden');
});
function generateRandomNumbers(quantity, min, max, unique) {
const numbers = [];
if (unique) {
// Generate unique numbers
const possibleNumbers = Array.from({length: max - min + 1}, (_, i) => min + i);
for (let i = 0; i < quantity && possibleNumbers.length > 0; i++) {
const randomIndex = Math.floor(Math.random() * possibleNumbers.length);
numbers.push(possibleNumbers[randomIndex]);
possibleNumbers.splice(randomIndex, 1);
}
} else {
// Generate numbers with possible duplicates
for (let i = 0; i < quantity; i++) {
numbers.push(Math.floor(Math.random() * (max - min + 1)) + min);
}
}
return numbers;
}
function displayResults(numbers) {
resultsDiv.innerHTML = '';
numbers.forEach((num, index) => {
const numberDiv = document.createElement('div');
numberDiv.className = 'flex items-center justify-between bg-blue-50 p-3 rounded-lg number-display hover:bg-blue-100';
const numberInfo = document.createElement('div');
numberInfo.className = 'flex items-center';
const numberIndex = document.createElement('span');
numberIndex.className = 'bg-blue-500 text-white text-xs font-bold px-2 py-1 rounded-full mr-2';
numberIndex.textContent = index + 1;
const numberValue = document.createElement('span');
numberValue.className = 'text-gray-800 font-medium';
numberValue.textContent = num.toLocaleString();
numberInfo.appendChild(numberIndex);
numberInfo.appendChild(numberValue);
const copyIcon = document.createElement('button');
copyIcon.className = 'text-blue-500 hover:text-blue-700';
copyIcon.innerHTML = '<i class="fas fa-copy"></i>';
copyIcon.title = 'نسخ الرقم';
copyIcon.addEventListener('click', () => {
navigator.clipboard.writeText(num.toString());
copyIcon.innerHTML = '<i class="fas fa-check text-green-500"></i>';
setTimeout(() => {
copyIcon.innerHTML = '<i class="fas fa-copy"></i>';
}, 1000);
});
numberDiv.appendChild(numberInfo);
numberDiv.appendChild(copyIcon);
resultsDiv.appendChild(numberDiv);
});
}
// Copy all results
copyBtn.addEventListener('click', function() {
const numbers = Array.from(resultsDiv.querySelectorAll('div > div > span:nth-child(2)'))
.map(span => span.textContent.replace(/,/g, ''));
navigator.clipboard.writeText(numbers.join('\n'));
const originalText = copyBtn.innerHTML;
copyBtn.innerHTML = '<i class="fas fa-check mr-1"></i> تم النسخ!';
copyBtn.classList.remove('bg-gray-200', 'hover:bg-gray-300');
copyBtn.classList.add('bg-green-100', 'text-green-800');
setTimeout(() => {
copyBtn.innerHTML = originalText;
copyBtn.classList.remove('bg-green-100', 'text-green-800');
copyBtn.classList.add('bg-gray-200', 'hover:bg-gray-300');
}, 2000);
});
// Clear results
clearBtn.addEventListener('click', function() {
resultsDiv.innerHTML = '';
resultContainer.classList.add('hidden');
});
});
</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=hader1890/aas" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |