-
Notifications
You must be signed in to change notification settings - Fork 1
/
pong_index.html
130 lines (124 loc) · 3.94 KB
/
pong_index.html
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
<!DOCTYPE html>
<html>
<head>
<title>Interactive Pong</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<style>
body {
font-family: Arial, sans-serif;
background-color: #f8f8f8;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
overflow: hidden; /*disable scrolling */
}
.container {
background-color: #ffffff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
max-width: 400px;
width: 90%;
text-align: center;
}
h1 {
margin-top: 0;
}
label {
display: block;
margin-bottom: 8px;
font-weight: bold;
}
input[type="range"] {
width: 100%;
transform: rotate(90deg);
transform-origin: right;
height: 30px; /* Adjust the height for touch-friendliness */
-webkit-appearance: none; /* Remove default styling */
background: #ddd;
border-radius: 10px;
outline: none;
opacity: 0.7;
transition: opacity 0.2s;
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none; /* Remove default styling */
appearance: none;
width: 20px;
height: 20px;
background: #007bff;
border-radius: 50%;
cursor: pointer;
}
input[type="range"]:focus {
opacity: 1;
}
p {
margin-top: 8px;
}
#slider-value {
font-weight: bold;
}
input[type="radio"] {
display: none;
}
label[for="radio_l"], label[for="radio_r"] {
display: inline-block;
cursor: pointer;
margin: 0 10px;
padding: 5px 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
input[type="radio"]:checked + label {
background-color: #007bff;
color: #fff;
border-color: #007bff;
}
</style>
</head>
<body>
<div class="container">
<h1>Interactive Pong</h1>
<hr>
<form id="slider-form">
<label for="slider">Slider:</label>
<input type="range" id="slider" name="slider" min="0" max="10" value="0">
<p>Value: <span id="slider-value">0</span></p>
<label>Radio:</label>
<input type="radio" id="radio_l" name="radio" value="L" checked>
<label for="radio_l">L</label>
<input type="radio" id="radio_r" name="radio" value="R">
<label for="radio_r">R</label>
</form>
</div>
<script>
var slider = document.getElementById('slider');
var sliderValueElement = document.getElementById('slider-value');
slider.addEventListener('input', function() {
var sliderValue = slider.value;
sliderValueElement.textContent = sliderValue;
sendDataToServer(sliderValue);
});
function sendDataToServer(sliderValue) {
var radioSelection = document.querySelector('input[name="radio"]:checked').value;
fetch('/', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: 'slider=' + sliderValue + '&radio=' + radioSelection
})
.then(function(response) {
console.log('Data sent successfully');
})
.catch(function(error) {
console.error('Error sending data:', error);
});
}
</script>
</body>
</html>