Repository navigation
Expand file tree
/
Copy pathhamming.html
More file actions
134 lines (129 loc) · 4.59 KB
/
Copy pathhamming.html
File metadata and controls
134 lines (129 loc) · 4.59 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
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Код Хэмминга</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 20px auto;
padding: 20px;
}
.container {
display: flex;
flex-direction: column;
gap: 20px;
}
.input-group {
display: flex;
flex-direction: column;
gap: 10px;
padding: 15px;
border: 1px solid #ddd;
border-radius: 5px;
}
input[type="text"] {
padding: 8px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 3px;
}
button {
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 3px;
cursor: pointer;
font-size: 16px;
width: 200px;
}
button:hover {
background-color: #45a049;
}
.error {
color: red;
font-weight: bold;
margin-top: 5px;
}
.success {
color: green;
margin-top: 5px;
}
.bits-display {
display: flex;
flex-wrap: wrap;
gap: 2px;
margin-top: 10px;
}
.bit {
width: 30px;
height: 30px;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid #ccc;
font-family: monospace;
font-weight: bold;
}
.control-bit {
background-color: #e0f7fa;
}
.error-bit {
background-color: #ffcdd2;
color: #d32f2f;
}
.corrected-bit {
background-color: #c8e6c9;
color: #388e3c;
}
.info {
font-size: 14px;
color: #666;
margin-top: 5px;
}
</style>
</head>
<body>
<h1>Кодирование и декодирование Хэмминга</h1>
<div class="container">
<!-- Шаг 1: Ввод данных -->
<div class="input-group">
<h3>1. Введите двоичную последовательность:</h3>
<input type="text" id="inputData" placeholder="Например: 1011"
onkeypress="checkBinary(event)">
<button onclick="encodeHamming()">Закодировать</button>
<div class="info">Разрешены только символы 0 и 1</div>
</div>
<!-- Шаг 2: Закодированные данные -->
<div class="input-group">
<h3>2. Закодированная последовательность:</h3>
<input type="text" id="encodedData"
placeholder="Здесь появится результат кодирования"
onkeypress="checkBinary(event)">
<div id="bitsVisualization" class="bits-display"></div>
<div class="info">Можно изменить биты для проверки исправления ошибок</div>
</div>
<!-- Шаг 3: Декодирование -->
<div class="input-group">
<h3>3. Декодированная последовательность:</h3>
<input type="text" id="decodedData" readonly
placeholder="Здесь появится результат декодирования">
<button onclick="decodeHamming()">Декодировать</button>
<div id="resultMessage"></div>
</div>
<!-- Информация о контрольных битах -->
<div class="input-group">
<h3>Информация:</h3>
<div id="infoContent">
<p>Контрольные биты находятся на позициях: <span id="controlBitsPositions">-</span></p>
<p>Длина исходных данных: <span id="originalLength">0</span> бит</p>
<p>Длина с контрольными битами: <span id="encodedLength">0</span> бит</p>
</div>
</div>
</div>
<script src="hamming.js"></script>
</body>
</html>