Update koleso.html
Browse files- 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 |
-
|
23 |
-
|
24 |
-
border-radius: 10px;
|
25 |
padding: 20px;
|
26 |
-
margin
|
|
|
27 |
}
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
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 |
-
|
71 |
-
border:
|
72 |
border-radius: 5px;
|
73 |
-
background-color: black;
|
74 |
-
color: lightgray; /* Светло-серый цвет текста в полях ввода */
|
75 |
}
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
79 |
}
|
80 |
-
|
81 |
-
|
82 |
-
|
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 |
-
|
|
|
|
|
|
|
91 |
}
|
92 |
-
|
93 |
-
|
94 |
-
background-color: #ff9900; /* Светло-оранжевый при наведении */
|
95 |
}
|
96 |
-
|
97 |
-
|
98 |
-
#
|
99 |
-
|
100 |
-
|
|
|
|
|
101 |
}
|
102 |
</style>
|
103 |
</head>
|
104 |
<body>
|
105 |
-
<
|
106 |
-
|
107 |
-
|
108 |
-
<
|
109 |
-
<
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
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 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
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 |
-
|
211 |
}
|
212 |
});
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
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>
|