-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatistical.html
More file actions
214 lines (188 loc) · 6.58 KB
/
statistical.html
File metadata and controls
214 lines (188 loc) · 6.58 KB
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
<!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>
<link rel="manifest" href="/manifest.json" />
<script src="https://cdn.jsdelivr.net/npm/mathjs@10.0.1/lib/browser/math.js"></script>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet"/>
<style>
body {
font-family: 'Cairo', sans-serif;
transition: background-color 0.3s ease, color 0.3s ease;
}
.dark-mode {
background-color: #1f2937;
color: #f9fafb;
}
.dark-mode .bg-white {
background-color: #374151 !important;
}
.dark-mode .text-blue-700 {
color: #60a5fa !important;
}
.dark-mode .text-gray-500 {
color: #d1d5db;
}
.dark-mode textarea,
.dark-mode .border {
background-color: #4b5563;
color: white;
}
.header-button {
font-size: 1rem;
color: #1f2937;
padding: 0.75rem 1.5rem;
background-color: #e5e7eb;
border: none;
border-radius: 6px;
transition: all 0.3s ease;
}
.header-button:hover {
background-color: #60a5fa;
color: white;
}
.header-button:active {
background-color: #2563eb;
}
.input-field {
background-color: #f9fafb;
border: 1px solid #e5e7eb;
font-size: 1.25rem;
padding: 1rem;
width: 100%;
text-align: right;
border-radius: 12px;
margin-bottom: 1rem;
color: #1f2937;
}
.result {
background-color: #e5e7eb;
border-radius: 12px;
padding: 1.5rem;
margin-top: 2rem;
font-size: 1.5rem;
color: #1f2937;
}
</style>
</head>
<body class="text-right p-6 bg-gray-50" id="body">
<div class="max-w-3xl mx-auto bg-white rounded-2xl shadow-lg p-6 space-y-6">
<div class="flex justify-between items-center">
<h1 class="text-3xl font-bold text-blue-700">الإحصائيات</h1>
<button onclick="toggleDarkMode()" class="header-button">
🌓 وضع الليل
</button>
</div>
<div>
<h2 class="text-xl font-semibold text-blue-700 mb-4">أدخل البيانات:</h2>
<input id="dataInput" class="input-field" type="text" placeholder="أدخل الأرقام مفصولة بفواصل" />
<button onclick="calculateStatistics()" class="header-button w-full">
حساب الإحصائيات
</button>
<button onclick="startVoiceInput()" class="header-button w-full mt-4">
🎤 استخدم الصوت
</button>
</div>
<div class="result" id="meanResult">
المتوسط الحسابي: <span id="mean">0</span>
</div>
<div class="result" id="medianResult">
الوسيط: <span id="median">0</span>
</div>
<div class="result" id="stdDevResult">
الانحراف المعياري: <span id="stdDev">0</span>
</div>
<div class="result" id="sumResult">
المجموع: <span id="sum">0</span>
</div>
<div class="result" id="countResult">
عدد البيانات: <span id="count">0</span>
</div>
<div class="result" id="rangeResult">
النطاق: <span id="range">0</span>
</div>
<div class="result" id="modeResult">
المنوال: <span id="mode">0</span>
</div>
<div class="result" id="minResult">
الحد الأدنى: <span id="min">0</span>
</div>
<div class="result" id="maxResult">
الحد الأقصى: <span id="max">0</span>
</div>
</div>
<footer class="mt-10 text-center text-xs text-gray-400">
موقع إحصائيات من الطالب عمر أبو بكر
</footer>
<script>
function calculateStatistics() {
const input = document.getElementById('dataInput').value;
const data = input.split(',').map(num => parseFloat(num.trim())).filter(num => !isNaN(num));
if (data.length === 0) {
alert("من فضلك أدخل بيانات صحيحة.");
return;
}
const mean = math.mean(data);
const median = math.median(data);
const stdDev = math.std(data);
const sum = math.sum(data);
const count = data.length;
const range = math.max(data) - math.min(data);
const mode = math.mode(data);
const min = math.min(data);
const max = math.max(data);
document.getElementById('mean').textContent = mean.toFixed(2);
document.getElementById('median').textContent = median.toFixed(2);
document.getElementById('stdDev').textContent = stdDev.toFixed(2);
document.getElementById('sum').textContent = sum.toFixed(2);
document.getElementById('count').textContent = count;
document.getElementById('range').textContent = range.toFixed(2);
document.getElementById('mode').textContent = Array.isArray(mode) ? mode.join(', ') : mode;
document.getElementById('min').textContent = min.toFixed(2);
document.getElementById('max').textContent = max.toFixed(2);
}
let speechInput = '';
let recognitionTimeout;
let recognition;
let isSpeaking = false;
function startVoiceInput() {
if (isSpeaking) {
recognition.stop();
isSpeaking = false;
document.getElementById('dataInput').value = speechInput;
} else {
if (recognition) {
recognition.abort();
}
recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
recognition.lang = 'ar-SA';
recognition.continuous = true;
recognition.interimResults = true;
recognition.start();
isSpeaking = true;
recognition.onresult = function(event) {
const transcript = event.results[event.results.length - 1][0].transcript.trim();
if (/^\d+$/.test(transcript)) {
if (speechInput === '') {
speechInput = transcript;
} else if (!speechInput.split(',').includes(transcript)) {
speechInput += ',' + transcript;
}
document.getElementById('dataInput').value = speechInput;
}
clearTimeout(recognitionTimeout);
recognitionTimeout = setTimeout(() => {
calculateStatistics();
}, 1000);
};
recognition.onerror = function(event) {
alert("حدث خطأ أثناء استخدام الصوت: " + event.error);
};
recognition.onend = function() {};
}
}
</script>
</body>
</html>