File size: 14,798 Bytes
5f0e4fa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>FEI-Next - API Explorer</title>
    <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
    <script src="https://unpkg.com/feather-icons"></script>
    <script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.net.min.js"></script>
    <style>
        .api-endpoint {
            transition: all 0.3s ease;
            cursor: pointer;
        }
        .api-endpoint:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 16px -8px rgba(74, 144, 226, 0.3);
        }
        .response-area {
            font-family: 'Courier New', monospace;
            background: #1a202c;
            border: 1px solid #2d3748;
        }
        .method-get { border-left: 4px solid #10b981; }
        .method-post { border-left: 4px solid #3b82f6; }
        .method-put { border-left: 4px solid #f59e0b; }
        .method-delete { border-left: 4px solid #ef4444; }
    </style>
</head>
<body class="bg-gray-900 text-gray-100 font-sans overflow-x-hidden">
    <div id="vanta-bg" class="fixed inset-0 -z-10 opacity-20"></div>
    
    <header class="gradient-mask px-6 py-8">
        <div class="max-w-6xl mx-auto flex flex-col md:flex-row justify-between items-center">
            <div class="flex items-center mb-6 md:mb-0">
                <div class="relative">
                    <div class="absolute -inset-4 bg-blue-500 rounded-full opacity-20 blur-md"></div>
                    <div class="relative bg-gradient-to-br from-blue-600 to-indigo-800 w-12 h-12 rounded-2xl flex items-center justify-center">
                    <i data-feather="code" class="w-6 h-6"></i>
                </div>
                <h1 class="ml-4 text-2xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-blue-400 to-indigo-300">
                    API Explorer
                </h1>
            </div>
            <nav class="flex space-x-6">
                <a href="index.html" class="text-gray-400 hover:text-blue-300 transition-colors flex items-center">
                    <i data-feather="home" class="w-4 h-4 mr-2"></i>
                    Home
                </a>
                <a href="explore.html" class="text-gray-400 hover:text-blue-300 transition-colors flex items-center">
                    <i data-feather="compass" class="w-4 h-4 mr-2"></i>
                    Explore
                </a>
            </nav>
        </div>
    </header>

    <main class="max-w-6xl mx-auto px-6 pb-20">
        <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
            <!-- API Methods -->
            <div class="lg:col-span-2 space-y-6">
                <!-- GET Method -->
                <div class="api-endpoint bg-gray-800/30 backdrop-blur-md rounded-2xl p-6 border border-gray-700/50">
                    <div class="flex items-center mb-4">
                        <span class="px-3 py-1 rounded-full text-xs font-medium bg-green-900/50 text-green-300 border border-green-700/50 method-get p-4">
                            <div class="flex items-center">
                                <span class="px-2 py-1 rounded text-xs font-bold text-white bg-green-600 mr-3">
                            GET
                        </span>
                        <code class="text-blue-300">/api/cognitive-data</code>
                    </div>
                    <p class="text-gray-300 mb-4">Retrieve cognitive patterns and reasoning traces</p>
                        <div class="flex space-x-3">
                            <button onclick="testGetAPI()" class="px-4 py-2 bg-green-600 hover:bg-green-500 rounded-lg text-white text-sm transition-colors" id="get-button">
                            <span class="flex items-center">
                                <span>Test Endpoint</span>
                                <i data-feather="play" class="w-3 h-3 ml-2"></i>
                        </button>
                        <button onclick="showDocumentation('get')" class="px-4 py-2 bg-gray-600 hover:bg-gray-500 rounded-lg text-gray-300 text-sm transition-colors">
                            Documentation
                        </button>
                    </div>
                    <div class="response-area mt-4 p-4 rounded-lg text-sm hidden" id="get-response">
                        <div class="flex justify-between items-center mb-2">
                                    <span class="text-green-400">✓ Success</span>
                                    <span class="text-xs text-gray-400">Response will appear here</span>
                                </div>
                            </div>
                        </div>

            <!-- POST Method -->
            <div class="api-endpoint bg-gray-800/30 backdrop-blur-md rounded-2xl p-6 border border-gray-700/50">
                    <div class="flex items-center mb-4">
                        <span class="px-2 py-1 rounded text-xs font-bold text-white bg-blue-600 mr-3">
                            POST
                        </span>
                        <code class="text-blue-300">/api/cognitive-analysis</code>
                    </div>
                    <p class="text-gray-300 mb-4">Submit new cognitive data for analysis</p>
                    <div class="flex space-x-3">
                        <button onclick="testPostAPI()" class="px-4 py-2 bg-blue-600 hover:bg-blue-500 rounded-lg text-white text-sm transition-colors">
                            <span class="flex items-center">
                                <span>Test Endpoint</span>
                                <i data-feather="play" class="w-3 h-3 ml-2"></i>
                        </button>
                        <button onclick="showDocumentation('post')" class="px-4 py-2 bg-gray-600 hover:bg-gray-500 rounded-lg text-gray-300 text-sm transition-colors">
                            Documentation
                        </button>
                    </div>
                    <div class="response-area mt-4 p-4 rounded-lg text-sm hidden" id="post-response">
                            <div class="flex justify-between items-center mb-2">
                                <span class="text-blue-400">↗ Submit</span>
                            </div>
                        </div>

            <!-- Control Panel -->
            <div class="lg:col-span-1 bg-gray-800/30 backdrop-blur-md rounded-2xl p-6 border border-gray-700/50">
                <h3 class="text-lg font-bold mb-4">API Controls</h3>
                <div class="space-y-4">
                    <div>
                        <label class="block text-sm text-gray-400 mb-2">Environment</label>
                        <select class="w-full bg-gray-700/50 border border-gray-600/50 rounded-lg px-3 py-2 text-sm">
                            <option>Development</option>
                            <option>Staging</option>
                            <option>Production</option>
                        </select>
                    </div>
                    <div>
                        <label class="block text-sm text-gray-400 mb-2">Response Format</label>
                        <select class="w-full bg-gray-700/50 border border-gray-600/50 rounded-lg px-3 py-2 text-sm">
                            <option>JSON</option>
                            <option>XML</option>
                            <option>YAML</option>
                        </select>
                    </div>
                    <button onclick="clearAllResponses()" class="w-full px-4 py-2 bg-gray-600 hover:bg-gray-500 rounded-lg text-gray-300 text-sm transition-colors">
                            Clear All Responses
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </main>

    <footer class="border-t border-gray-800 py-8 mt-12">
        <div class="max-w-6xl mx-auto px-6">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="flex items-center mb-4 md:mb-0">
                    <i data-feather="activity" class="w-5 h-5 text-blue-400 mr-2"></i>
                    <span class="text-sm text-gray-400">FEI-Next API Explorer v1.0</span>
                </div>
                <div class="flex space-x-6">
                    <a href="index.html" class="text-gray-400 hover:text-blue-300 transition-colors">
                    <i data-feather="home"></i>
                    </a>
                    <a href="explore.html" class="text-gray-400 hover:text-blue-300 transition-colors">
                    <i data-feather="compass"></i>
                    </a>
                </div>
            </div>
        </div>
    </footer>

    <script>
        // Initialize Vanta.js background
        if (typeof VANTA !== 'undefined') {
            VANTA.NET({
                el: "#vanta-bg",
                mouseControls: true,
                touchControls: true,
                gyroControls: false,
                color: 0x3b82f6,
                backgroundColor: 0x111827,
                points: 12,
                maxDistance: 20,
                spacing: 18
            });
        }

        // Initialize feather icons
        feather.replace();

        // API testing functions
        window.testGetAPI = async () => {
            const button = document.getElementById('get-button');
            const responseArea = document.getElementById('get-response');
            
            // Show loading state
            responseArea.classList.remove('hidden');
            responseArea.innerHTML = `
                <div class="flex justify-between items-center mb-2">
                    <span class="text-blue-400">⏳ Loading...</span>
            `;
            
            try {
                const response = await fetch('https://jsonplaceholder.typicode.com/posts/1');
                const data = await response.json();
                
                responseArea.innerHTML = `
                    <div class="flex justify-between items-center mb-2">
                        <span class="text-green-400">✓ Success</span>
                        <span class="text-xs text-gray-400">Status: ${response.status}</span>
                    </div>
                    <pre class="text-green-300 overflow-auto">${JSON.stringify(data, null, 2)}</pre>
                `;
            } catch (error) {
                responseArea.innerHTML = `
                    <div class="flex justify-between items-center mb-2">
                        <span class="text-red-400">✗ Error</span>
                    </div>
                    <pre class="text-red-300">Request failed: ${error.message}</pre>
                `;
            }
        };

        window.testPostAPI = async () => {
            const responseArea = document.getElementById('post-response');
            
            // Show loading state
            responseArea.classList.remove('hidden');
            responseArea.innerHTML = `
                <div class="flex justify-between items-center mb-2">
                        <span class="text-blue-400">⏳ Processing...</span>
            `;
            
            try {
                const response = await fetch('https://jsonplaceholder.typicode.com/posts', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({
                    title: 'Cognitive Analysis Request',
                    body: 'Analyze this thought pattern for reasoning traces',
                    userId: 1
                })
            });
                const data = await response.json();
                
                responseArea.innerHTML = `
                    <div class="flex justify-between items-center mb-2">
                        <span class="text-green-400">✓ Success</span>
                        <span class="text-xs text-gray-400">Status: ${response.status}</span>
                </div>
                <pre class="text-green-300 overflow-auto">${JSON.stringify(data, null, 2)}</pre>
                `;
            } catch (error) {
                responseArea.innerHTML = `
                    <div class="flex justify-between items-center mb-2">
                        <span class="text-green-400">✓ Created</span>
                    </div>
                    <pre class="text-green-300">Request failed: ${error.message}</pre>
                `;
            }
        };

        window.showDocumentation = (method) => {
            const overlay = document.createElement('div');
            overlay.className = 'fixed inset-0 bg-gray-900/90 backdrop-blur-md z-50 flex items-center justify-center p-8';
            overlay.innerHTML = `
                <div class="relative max-w-4xl w-full bg-gray-800 rounded-2xl p-8 border border-gray-700 max-h-[90vh] overflow-auto">
                <button class="absolute top-4 right-4 text-gray-400 hover:text-white">
                    <i data-feather="x"></i>
                </button>
                <h3 class="text-xl font-bold mb-4">${method.toUpperCase()} API Documentation</h3>
                <div class="space-y-4">
                    <div class="p-4 bg-gray-700/50 rounded-lg">
                        <h4 class="font-medium mb-2">Endpoint</h4>
                        <code class="bg-gray-600 p-2 rounded text-sm block">
                        /api/cognitive-${method === 'get' ? 'data' : 'analysis'}</code>
                    <div class="p-4 bg-gray-700/50 rounded-lg">
                            <h4 class="font-medium mb-2">Description</h4>
                            <p class="text-gray-300">
                            ${method === 'get' ? 
                                'Retrieve cognitive patterns and reasoning traces from the system.' : 
                                'Submit new cognitive data for analysis and pattern recognition.'}
                        </p>
                    </div>
                </div>
            `;
            document.body.appendChild(overlay);
            feather.replace();
            
            // Add close handler
            overlay.querySelector('button').addEventListener('click', () => {
                overlay.remove();
            });
        };

        window.clearAllResponses = () => {
            document.querySelectorAll('.response-area').forEach(area => {
                area.classList.add('hidden');
                area.innerHTML = '';
            });
        };
    </script>
</body>
</html>