DmitrMakeev commited on
Commit
5f320dc
·
verified ·
1 Parent(s): 4f47adf

Update koleso.html

Browse files
Files changed (1) hide show
  1. koleso.html +104 -201
koleso.html CHANGED
@@ -3,234 +3,137 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Wheel of Fortune</title>
 
 
7
  <style>
8
  body {
9
- display: flex;
10
- justify-content: center;
11
- align-items: center;
12
- height: 100vh;
13
- background-color: black;
14
- color: white;
15
  font-family: Arial, sans-serif;
16
- }
17
-
18
- .container {
19
  text-align: center;
 
 
 
20
  }
21
-
22
- #wheelOfFortune {
23
- border: 2px solid #f82; /* Оранжевая окантовка для колеса */
24
- border-radius: 10px;
25
  padding: 20px;
26
- margin-bottom: 20px;
 
27
  }
28
-
29
- #wheel {
30
- border: 2px solid #f82; /* Оранжевая окантовка для колеса */
31
- border-radius: 50%;
32
- }
33
-
34
- #spin {
35
  margin-top: 20px;
36
- padding: 10px 20px;
37
- border: 2px solid #f82; /* Оранжевая окантовка для кнопки Пуск */
38
- border-radius: 5px;
39
- background-color: black;
40
- color: white;
41
- cursor: pointer;
42
- transition: background-color 0.3s;
43
- }
44
-
45
- #spin:hover {
46
- background-color: #f82; /* Оранжевый фон при наведении на кнопку Пуск */
47
- }
48
-
49
- #registrationForm {
50
- display: none;
51
- background-color: black;
52
- padding: 30px; /* Увеличенный padding для формы */
53
- border: 2px solid #f82; /* Оранжевая окантовка для формы */
54
- border-radius: 10px;
55
- text-align: center;
56
- width: 90%;
57
- max-width: 400px;
58
- }
59
-
60
- #registrationForm h1 {
61
- color: #f82; /* Оранжевый цвет для заголовка */
62
- margin-bottom: 20px;
63
  }
64
-
65
- #registrationForm input[type="text"],
66
- #registrationForm input[type="email"],
67
- #registrationForm input[type="tel"] {
68
- width: calc(100% - 22px);
69
  padding: 10px;
70
- margin-bottom: 10px;
71
- border: 2px solid #f82; /* Оранжевая окантовка для полей ввода */
72
  border-radius: 5px;
73
- background-color: black;
74
- color: lightgray; /* Светло-серый цвет текста в полях ввода */
75
  }
76
-
77
- #registrationForm input[type="checkbox"] {
78
- margin-right: 5px;
 
79
  }
80
-
81
- #registrationForm button {
82
- width: 100%;
83
- padding: 15px; /* Увеличенная высота кнопки */
84
  border: none;
85
- border-radius: 5px;
86
- background-color: #f82; /* Оранжевая кнопка */
87
- color: black;
88
- font-weight: bold;
89
  cursor: pointer;
90
- transition: background-color 0.3s;
 
 
 
91
  }
92
-
93
- #registrationForm button:hover {
94
- background-color: #ff9900; /* Светло-оранжевый при наведении */
95
  }
96
-
97
- @media (max-width: 600px) {
98
- #registrationForm {
99
- width: 95%;
100
- }
 
 
101
  }
102
  </style>
103
  </head>
104
  <body>
105
- <div class="container">
106
- <div id="wheelOfFortune">
107
- <h1>Ирина Дель Соль</h1>
108
- <canvas id="wheel" width="300" height="300"></canvas>
109
- <div id="spin">Пуск</div>
110
- <p>Текст под колесом</p>
111
- <a href="#">Ссылка под колесом</a>
112
- </div>
113
-
114
- <!-- Форма ввода данных -->
115
- <div id="registrationForm" style="display: none;">
116
- <h1>Ирина Дель Соль</h1>
117
- <form id="registration">
118
- <input type="text" id="name" name="name" placeholder="Ваше имя" required><br>
119
- <input type="email" id="email" name="email" placeholder="Ваш email" required><br>
120
- <input type="tel" id="phone" name="phone" placeholder="Ваш телефон" required><br>
121
- <label><input type="checkbox" id="newsletter" name="newsletter"> Согласен на рассылку</label><br>
122
- <label><input type="checkbox" id="privacyPolicy" name="privacyPolicy" required> Знаком с политикой конфиденциальности</label><br>
123
- <button type="submit">Зарегистрироваться</button>
124
- </form>
125
- <p>Текст под формой</p>
126
- <a href="#">Ссылка под формой</a>
127
  </div>
 
 
128
  </div>
129
-
 
 
 
130
  <script>
131
- const sectors = [
132
- { color: '#f82', label: 'VIP', probability: 94 },
133
- { color: '#0bf', label: '10', probability: 1 },
134
- { color: '#fb0', label: '200', probability: 1 },
135
- { color: '#0fb', label: '50', probability: 1 },
136
- { color: '#b0f', label: '100', probability: 1 },
137
- { color: '#f0b', label: '5', probability: 1 },
138
- { color: '#bf0', label: '500', probability: 1 }
139
- ];
140
- const rand = (m, M) => Math.random() * (M - m) + m;
141
- const tot = sectors.length;
142
- const spinEl = document.querySelector('#spin');
143
- const ctx = document.querySelector('#wheel').getContext('2d');
144
- const dia = ctx.canvas.width;
145
- const rad = dia / 2;
146
- const PI = Math.PI;
147
- const TAU = 2 * PI;
148
- const arc = TAU / sectors.length;
149
- const friction = 0.991; // 0.995=soft, 0.99=mid, 0.98=hard
150
- let angVel = 0; // Angular velocity
151
- let ang = 0; // Angle in radians
152
- const getIndex = () => Math.floor(tot - (ang / TAU) * tot) % tot;
153
- function drawSector(sector, i) {
154
- const ang = arc * i;
155
- ctx.save();
156
- // COLOR
157
- ctx.beginPath();
158
- ctx.fillStyle = sector.color;
159
- ctx.moveTo(rad, rad);
160
- ctx.arc(rad, rad, rad, ang, ang + arc);
161
- ctx.lineTo(rad, rad);
162
- ctx.fill();
163
- // TEXT
164
- ctx.translate(rad, rad);
165
- ctx.rotate(ang + arc / 2);
166
- ctx.textAlign = 'right';
167
- ctx.fillStyle = '#fff';
168
- ctx.font = 'bold 21px sans-serif'; // Уменьшенный размер шрифта на 30%
169
- ctx.fillText(sector.label, rad - 10, 10);
170
- //
171
- ctx.restore();
172
- }
173
- function rotate() {
174
- const sector = sectors[getIndex()];
175
- ctx.canvas.style.transform = `rotate(${ang - PI / 2}rad)`;
176
- spinEl.textContent = !angVel ? 'Удача!' : sector.label;
177
- spinEl.style.background = sector.color;
178
- }
179
- function frame() {
180
- if (!angVel) return;
181
- angVel *= friction; // Decrement velocity by friction
182
- if (angVel < 0.002) {
183
- angVel = 0; // Bring to stop
184
- const sector = sectors[getIndex()];
185
- localStorage.setItem('hasSpun', 'true');
186
- console.log('Result:', sector.label); // Вывод значения в консоль
187
- showRegistrationForm(); // Показать форму после остановки колеса
188
- }
189
- ang += angVel; // Update angle
190
- ang %= TAU; // Normalize angle
191
- rotate();
192
- }
193
- function engine() {
194
- frame();
195
- requestAnimationFrame(engine);
196
- }
197
- function init() {
198
- if (!localStorage.getItem('hasSpun')) {
199
- localStorage.setItem('hasSpun', 'false');
200
- }
201
- sectors.forEach(drawSector);
202
- rotate(); // Initial rotation
203
- engine(); // Start engine
204
- spinEl.addEventListener('click', () => {
205
- if (localStorage.getItem('hasSpun') === 'false') {
206
- localStorage.setItem('hasSpun', 'true');
207
- angVel = rand(0.25, 0.45);
208
- spinWheel();
209
  } else {
210
- console.log('You have already spun the wheel.');
211
  }
212
  });
213
- }
214
- function spinWheel() {
215
- const probabilities = sectors.map(sector => sector.probability);
216
- const totalProbability = probabilities.reduce((a, b) => a + b, 0);
217
- const random = Math.random() * totalProbability;
218
- let cumulativeProbability = 0;
219
- for (let i = 0; i < sectors.length; i++) {
220
- cumulativeProbability += sectors[i].probability;
221
- if (random < cumulativeProbability) {
222
- ang = (i + 0.5) * arc;
223
- break;
224
- }
225
- }
226
- }
227
- function showRegistrationForm() {
228
- const wheelOfFortune = document.getElementById('wheelOfFortune');
229
- const registrationForm = document.getElementById('registrationForm');
230
- wheelOfFortune.style.display = 'none'; // Скрыть колесо
231
- registrationForm.style.display = 'block'; // Показать форму
232
- }
233
- window.onload = init;
234
  </script>
235
  </body>
236
  </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Wheel of Fortune Sectors Editor</title>
7
+ <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css">
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/9.9.2/jsoneditor.min.css" />
9
  <style>
10
  body {
 
 
 
 
 
 
11
  font-family: Arial, sans-serif;
 
 
 
12
  text-align: center;
13
+ background-color: #f0f0f0;
14
+ margin: 0;
15
+ padding: 0;
16
  }
17
+ h1 {
18
+ background-color: #4CAF50;
19
+ color: white;
 
20
  padding: 20px;
21
+ margin: 0;
22
+ border-bottom: 2px solid #388E3C;
23
  }
24
+ .input-row {
25
+ display: flex;
26
+ justify-content: center;
27
+ gap: 10px;
 
 
 
28
  margin-top: 20px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  }
30
+ .input-row input, .input-row select {
 
 
 
 
31
  padding: 10px;
32
+ font-size: 16px;
33
+ border: 1px solid #ccc;
34
  border-radius: 5px;
 
 
35
  }
36
+ #jsoneditor {
37
+ width: 50%;
38
+ height: 300px;
39
+ margin: 20px auto;
40
  }
41
+ #addSector, #saveToClipboard {
42
+ color: white;
43
+ background-color: #4CAF50;
 
44
  border: none;
 
 
 
 
45
  cursor: pointer;
46
+ padding: 10px 20px;
47
+ font-size: 16px;
48
+ border-radius: 5px;
49
+ margin-top: 20px;
50
  }
51
+ #addSector:hover, #saveToClipboard:hover {
52
+ background-color: #388E3C;
 
53
  }
54
+ .jsoneditor-menu {
55
+ background-color: #4CAF50 !important;
56
+ border-bottom: 1px solid #388E3C !important;
57
+ }
58
+ .jsoneditor {
59
+ border: 1px #4CAF50 !important;
60
+ border-bottom: 2px solid #388E3C !important;
61
  }
62
  </style>
63
  </head>
64
  <body>
65
+ <h1>Редактор секторов колеса фортуны</h1>
66
+ <div>
67
+ <div class="input-row">
68
+ <label for="color">Цвет:</label>
69
+ <select id="color">
70
+ <option value="#f82">Красный</option>
71
+ <option value="#0bf">Голубой</option>
72
+ <option value="#fb0">Желтый</option>
73
+ <option value="#0fb">Зеленый</option>
74
+ <option value="#b0f">Фиолетовый</option>
75
+ <option value="#f0b">Розовый</option>
76
+ <option value="#bf0">Зеленый</option>
77
+ </select>
78
+ <label for="label">Лейбл:</label>
79
+ <input type="text" id="label" placeholder="Введите лейбл">
80
+ <label for="probability">Вероятность:</label>
81
+ <input type="number" id="probability" placeholder="Введите вероятность">
 
 
 
 
 
82
  </div>
83
+ <button id="addSector">Добавить сектор</button>
84
+ <button id="saveToClipboard">Сохранить в буфер обмена</button>
85
  </div>
86
+ <div id="jsoneditor"></div>
87
+
88
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/9.9.2/jsoneditor.min.js"></script>
89
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
90
  <script>
91
+ document.addEventListener('DOMContentLoaded', function() {
92
+ const container = document.getElementById('jsoneditor');
93
+ const options = {
94
+ mode: 'code',
95
+ modes: ['code', 'tree'],
96
+ onError: function(err) {
97
+ alert(err.toString());
98
+ }
99
+ };
100
+ const editor = new JSONEditor(container, options);
101
+ let sectorsList = [];
102
+ editor.set(sectorsList);
103
+
104
+ document.getElementById('addSector').addEventListener('click', function() {
105
+ const color = document.getElementById('color').value;
106
+ const label = document.getElementById('label').value;
107
+ const probability = document.getElementById('probability').value;
108
+ if (label && probability) {
109
+ sectorsList.push({ color, label, probability: parseInt(probability, 10) });
110
+ editor.set(sectorsList);
111
+ document.getElementById('label').value = '';
112
+ document.getElementById('probability').value = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  } else {
114
+ alert('Please fill in both label and probability.');
115
  }
116
  });
117
+
118
+ document.getElementById('saveToClipboard').addEventListener('click', function() {
119
+ const json = editor.get();
120
+ const jsonString = JSON.stringify(json, null, 0); // Добавляем в одну строку без отступов
121
+ navigator.clipboard.writeText(jsonString).then(function() {
122
+ Toastify({
123
+ text: "Сектора скопированы!",
124
+ duration: 3000, // Показывать 3 секунды
125
+ newWindow: true,
126
+ close: true,
127
+ gravity: "top", // Показывать сверху
128
+ position: "center", // Позиционировать по центру
129
+ backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)",
130
+ stopOnFocus: true // Останавливать таймер при фокусе на сообщении
131
+ }).showToast();
132
+ }, function(err) {
133
+ console.error('Could not copy text: ', err);
134
+ });
135
+ });
136
+ });
 
137
  </script>
138
  </body>
139
  </html>