forked from prepguides/prepguides.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-code-sync.html
More file actions
135 lines (127 loc) · 4.62 KB
/
test-code-sync.html
File metadata and controls
135 lines (127 loc) · 4.62 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Code Sync Test</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background: #f5f5f5;
}
.test-container {
background: white;
padding: 20px;
border-radius: 8px;
margin-bottom: 20px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.test-button {
background: #007bff;
color: white;
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
margin: 5px;
}
.test-button:hover {
background: #0056b3;
}
.test-result {
margin-top: 10px;
padding: 10px;
border-radius: 4px;
}
.success {
background: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
}
.error {
background: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
}
.info {
background: #d1ecf1;
color: #0c5460;
border: 1px solid #bee5eb;
}
</style>
</head>
<body>
<h1>Code Synchronization Test</h1>
<div class="test-container">
<h2>Test 1: BST Visualization</h2>
<button class="test-button" onclick="testBST()">Test BST</button>
<div id="bst-result" class="test-result" style="display: none;"></div>
</div>
<div class="test-container">
<h2>Test 2: Sorting Visualization</h2>
<button class="test-button" onclick="testSorting()">Test Sorting</button>
<div id="sorting-result" class="test-result" style="display: none;"></div>
</div>
<div class="test-container">
<h2>Test 3: Code Execution Sync</h2>
<button class="test-button" onclick="testCodeSync()">Test Code Sync</button>
<div id="codesync-result" class="test-result" style="display: none;"></div>
</div>
<script>
function showResult(elementId, message, type) {
const element = document.getElementById(elementId);
element.style.display = 'block';
element.className = `test-result ${type}`;
element.innerHTML = message;
}
function testBST() {
fetch('http://localhost:8000/algorithms/binary-search-tree.html')
.then(response => {
if (response.ok) {
showResult('bst-result', '✅ BST page loads successfully (HTTP 200)', 'success');
} else {
showResult('bst-result', `❌ BST page failed to load (HTTP ${response.status})`, 'error');
}
})
.catch(error => {
showResult('bst-result', `❌ BST page error: ${error.message}`, 'error');
});
}
function testSorting() {
fetch('http://localhost:8000/algorithms/sorting.html')
.then(response => {
if (response.ok) {
showResult('sorting-result', '✅ Sorting page loads successfully (HTTP 200)', 'success');
} else {
showResult('sorting-result', `❌ Sorting page failed to load (HTTP ${response.status})`, 'error');
}
})
.catch(error => {
showResult('sorting-result', `❌ Sorting page error: ${error.message}`, 'error');
});
}
function testCodeSync() {
fetch('http://localhost:8000/algorithms/code/code-execution-sync.js')
.then(response => {
if (response.ok) {
showResult('codesync-result', '✅ Code execution sync script loads successfully (HTTP 200)', 'success');
} else {
showResult('codesync-result', `❌ Code execution sync script failed to load (HTTP ${response.status})`, 'error');
}
})
.catch(error => {
showResult('codesync-result', `❌ Code execution sync script error: ${error.message}`, 'error');
});
}
// Auto-run tests on page load
window.addEventListener('load', () => {
setTimeout(() => {
testBST();
testSorting();
testCodeSync();
}, 1000);
});
</script>
</body>
</html>