-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
187 lines (164 loc) · 7 KB
/
Copy pathtest.html
File metadata and controls
187 lines (164 loc) · 7 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Numberly - 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: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.status {
padding: 10px;
border-radius: 4px;
margin: 10px 0;
}
.success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.warning { background: #fff3cd; color: #856404; border: 1px solid #ffeaa7; }
button {
background: #007bff;
color: white;
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
margin: 5px;
}
button:hover { background: #0056b3; }
#testResults { margin-top: 20px; }
</style>
</head>
<body>
<h1>Numberly - Application Test</h1>
<div class="test-section">
<h2>System Requirements Check</h2>
<div id="systemCheck">
<div class="status" id="canvasStatus">Checking Canvas support...</div>
<div class="status" id="tensorflowStatus">Checking TensorFlow.js...</div>
<div class="status" id="webglStatus">Checking WebGL support...</div>
<div class="status" id="localStorageStatus">Checking Local Storage...</div>
</div>
</div>
<div class="test-section">
<h2>Application Tests</h2>
<button onclick="testCanvas()">Test Canvas Drawing</button>
<button onclick="testMLModel()">Test ML Model</button>
<button onclick="testUI()">Test UI Components</button>
<button onclick="runAllTests()">Run All Tests</button>
<div id="testResults"></div>
</div>
<div class="test-section">
<h2>Quick Links</h2>
<p><a href="index.html">Go to Main Application</a></p>
<p><a href="plan.md">View Implementation Plan</a></p>
<p><a href="README.md">View README</a></p>
</div>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@4.10.0/dist/tf.min.js"></script>
<script>
// System requirements check
function checkSystemRequirements() {
// Canvas support
const canvas = document.createElement('canvas');
const canvasSupported = !!(canvas.getContext && canvas.getContext('2d'));
updateStatus('canvasStatus', canvasSupported,
'Canvas API supported', 'Canvas API not supported');
// TensorFlow.js
const tfSupported = typeof tf !== 'undefined';
updateStatus('tensorflowStatus', tfSupported,
'TensorFlow.js loaded', 'TensorFlow.js not available');
// WebGL support
const webglSupported = !!window.WebGLRenderingContext;
updateStatus('webglStatus', webglSupported,
'WebGL supported', 'WebGL not supported');
// Local Storage
const localStorageSupported = typeof(Storage) !== "undefined";
updateStatus('localStorageStatus', localStorageSupported,
'Local Storage supported', 'Local Storage not supported');
}
function updateStatus(elementId, success, successMsg, errorMsg) {
const element = document.getElementById(elementId);
element.className = `status ${success ? 'success' : 'error'}`;
element.textContent = success ? successMsg : errorMsg;
}
function addTestResult(test, success, message) {
const results = document.getElementById('testResults');
const div = document.createElement('div');
div.className = `status ${success ? 'success' : 'error'}`;
div.innerHTML = `<strong>${test}:</strong> ${message}`;
results.appendChild(div);
}
function testCanvas() {
try {
const canvas = document.createElement('canvas');
canvas.width = 200;
canvas.height = 200;
const ctx = canvas.getContext('2d');
// Test drawing
ctx.fillStyle = '#000000';
ctx.fillRect(10, 10, 20, 20);
// Test image data
const imageData = ctx.getImageData(0, 0, 200, 200);
addTestResult('Canvas Drawing', true, 'Canvas drawing and image data access working');
} catch (error) {
addTestResult('Canvas Drawing', false, `Error: ${error.message}`);
}
}
function testMLModel() {
try {
if (typeof tf === 'undefined') {
addTestResult('ML Model', false, 'TensorFlow.js not loaded');
return;
}
// Test tensor creation
const tensor = tf.tensor2d([[1, 2], [3, 4]]);
const result = tensor.mul(2);
const data = result.dataSync();
tensor.dispose();
result.dispose();
addTestResult('ML Model', true, 'TensorFlow.js operations working');
} catch (error) {
addTestResult('ML Model', false, `Error: ${error.message}`);
}
}
function testUI() {
try {
// Test if main app elements exist
const mainApp = document.createElement('div');
mainApp.innerHTML = `
<canvas id="testCanvas" width="200" height="200"></canvas>
<button id="testButton">Test Button</button>
`;
const canvas = mainApp.querySelector('#testCanvas');
const button = mainApp.querySelector('#testButton');
if (canvas && button) {
addTestResult('UI Components', true, 'Basic UI elements can be created');
} else {
addTestResult('UI Components', false, 'Failed to create UI elements');
}
} catch (error) {
addTestResult('UI Components', false, `Error: ${error.message}`);
}
}
function runAllTests() {
document.getElementById('testResults').innerHTML = '';
testCanvas();
testMLModel();
testUI();
}
// Run system check on load
window.addEventListener('load', checkSystemRequirements);
</script>
</body>
</html>