-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
257 lines (227 loc) Β· 9.69 KB
/
Copy pathtest.html
File metadata and controls
257 lines (227 loc) Β· 9.69 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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Photobooth Test Page</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background: #f5f5f5;
}
.test-section {
background: white;
padding: 20px;
margin: 20px 0;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.test-button {
background: #007bff;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
margin: 5px;
}
.test-button:hover {
background: #0056b3;
}
.status {
padding: 10px;
margin: 10px 0;
border-radius: 5px;
}
.status.success {
background: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
}
.status.error {
background: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
}
.status.warning {
background: #fff3cd;
color: #856404;
border: 1px solid #ffeaa7;
}
</style>
</head>
<body>
<h1>WebCloudCam Photobooth - Test Page</h1>
<div class="test-section">
<h2>Browser Compatibility Test</h2>
<div id="browser-status"></div>
<button class="test-button" onclick="testBrowserFeatures()">Test Browser Features</button>
</div>
<div class="test-section">
<h2>Camera Access Test</h2>
<div id="camera-status"></div>
<button class="test-button" onclick="testCameraAccess()">Test Camera Access</button>
<video id="test-video" width="320" height="240" style="display: none;"></video>
</div>
<div class="test-section">
<h2>File System Access Test</h2>
<div id="file-status"></div>
<button class="test-button" onclick="testFileAccess()">Test File Access</button>
<input type="file" id="test-file" accept="image/*" style="display: none;">
</div>
<div class="test-section">
<h2>Canvas & Effects Test</h2>
<div id="canvas-status"></div>
<button class="test-button" onclick="testCanvas()">Test Canvas</button>
<canvas id="test-canvas" width="320" height="240" style="border: 1px solid #ccc; display: none;"></canvas>
</div>
<div class="test-section">
<h2>Print Test</h2>
<div id="print-status"></div>
<button class="test-button" onclick="testPrint()">Test Print Function</button>
</div>
<div class="test-section">
<h2>Launch Photobooth</h2>
<p>If all tests pass, you can launch the main photobooth application:</p>
<button class="test-button" onclick="launchPhotobooth()" style="background: #28a745; font-size: 16px; padding: 15px 30px;">
π Launch Photobooth
</button>
</div>
<script>
function addStatus(elementId, message, type = 'success') {
const element = document.getElementById(elementId);
element.innerHTML = `<div class="status ${type}">${message}</div>`;
}
function testBrowserFeatures() {
const features = {
'ES6 Classes': typeof class Test {} === 'function',
'Arrow Functions': typeof (() => {}) === 'function',
'Template Literals': typeof `test` === 'string',
'Local Storage': typeof localStorage !== 'undefined',
'Canvas API': typeof HTMLCanvasElement !== 'undefined',
'File API': typeof File !== 'undefined',
'FileReader': typeof FileReader !== 'undefined',
'MediaDevices': typeof navigator.mediaDevices !== 'undefined',
'getUserMedia': typeof navigator.mediaDevices?.getUserMedia === 'function'
};
let allPassed = true;
let statusHtml = '<div class="status success">Browser Features Test Results:</div>';
for (const [feature, supported] of Object.entries(features)) {
const status = supported ? 'β
' : 'β';
const color = supported ? 'success' : 'error';
statusHtml += `<div class="status ${color}">${status} ${feature}</div>`;
if (!supported) allPassed = false;
}
if (allPassed) {
statusHtml += '<div class="status success">π All browser features are supported!</div>';
} else {
statusHtml += '<div class="status error">β οΈ Some features are not supported. The photobooth may not work correctly.</div>';
}
document.getElementById('browser-status').innerHTML = statusHtml;
}
async function testCameraAccess() {
try {
addStatus('camera-status', 'Testing camera access...', 'warning');
const stream = await navigator.mediaDevices.getUserMedia({
video: { width: 320, height: 240 }
});
const video = document.getElementById('test-video');
video.srcObject = stream;
video.style.display = 'block';
addStatus('camera-status', 'β
Camera access successful! Video stream is active.', 'success');
} catch (error) {
addStatus('camera-status', `β Camera access failed: ${error.message}`, 'error');
}
}
function testFileAccess() {
const fileInput = document.getElementById('test-file');
fileInput.style.display = 'block';
fileInput.onchange = function(e) {
const file = e.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
addStatus('file-status', `β
File access successful! Loaded: ${file.name} (${file.size} bytes)`, 'success');
};
reader.onerror = function() {
addStatus('file-status', 'β File reading failed', 'error');
};
reader.readAsDataURL(file);
}
};
addStatus('file-status', 'π Click the file input below to test file access...', 'warning');
}
function testCanvas() {
try {
const canvas = document.getElementById('test-canvas');
const ctx = canvas.getContext('2d');
// Test basic drawing
ctx.fillStyle = '#ff6b6b';
ctx.fillRect(0, 0, 160, 120);
ctx.fillStyle = '#4ecdc4';
ctx.fillRect(160, 0, 160, 120);
ctx.fillStyle = '#45b7d1';
ctx.fillRect(0, 120, 160, 120);
ctx.fillStyle = '#96ceb4';
ctx.fillRect(160, 120, 160, 120);
// Test text
ctx.fillStyle = 'white';
ctx.font = '16px Arial';
ctx.textAlign = 'center';
ctx.fillText('Canvas Test', 160, 60);
ctx.fillText('β
Working!', 160, 180);
canvas.style.display = 'block';
addStatus('canvas-status', 'β
Canvas API working! Test pattern drawn.', 'success');
} catch (error) {
addStatus('canvas-status', `β Canvas test failed: ${error.message}`, 'error');
}
}
function testPrint() {
try {
const printWindow = window.open('', '_blank');
printWindow.document.write(`
<!DOCTYPE html>
<html>
<head>
<title>Print Test</title>
<style>
body { font-family: Arial, sans-serif; text-align: center; padding: 50px; }
.test-content { border: 2px solid #333; padding: 20px; margin: 20px; }
</style>
</head>
<body>
<h1>Print Test</h1>
<div class="test-content">
<p>If you can see this, print functionality is working!</p>
<p>Date: ${new Date().toLocaleString()}</p>
</div>
<script>
window.onload = function() {
setTimeout(() => {
window.print();
setTimeout(() => window.close(), 1000);
}, 500);
};
</script>
</body>
</html>
`);
printWindow.document.close();
addStatus('print-status', 'β
Print test initiated! Check if print dialog opens.', 'success');
} catch (error) {
addStatus('print-status', `β Print test failed: ${error.message}`, 'error');
}
}
function launchPhotobooth() {
window.open('index.html', '_blank');
}
// Auto-run browser test on page load
window.onload = function() {
testBrowserFeatures();
};
</script>
</body>
</html>