lattmamb commited on
Commit
a897abd
·
1 Parent(s): 8beb2b1

Delete main.js

Browse files
Files changed (1) hide show
  1. main.js +0 -269
main.js DELETED
@@ -1,269 +0,0 @@
1
- // Main JavaScript file for the Quantum NLP Framework
2
-
3
- document.addEventListener('DOMContentLoaded', function() {
4
- // Show loading state on form submission
5
- const form = document.getElementById('process-form');
6
- const analyzeBtn = document.getElementById('analyze-btn');
7
-
8
- if (form) {
9
- form.addEventListener('submit', function() {
10
- if (analyzeBtn) {
11
- // Disable button and show loading state
12
- analyzeBtn.disabled = true;
13
- analyzeBtn.innerHTML = '<i class="fas fa-atom fa-spin me-2"></i> Processing...';
14
-
15
- // Trigger quantum transition animation if available
16
- if (typeof showQuantumTransition === 'function') {
17
- showQuantumTransition();
18
- }
19
- }
20
- });
21
- }
22
-
23
- // Add hover effects to analyze button if present
24
- if (analyzeBtn) {
25
- analyzeBtn.addEventListener('mouseover', function() {
26
- // Add hover class for CSS effects
27
- this.classList.add('quantum-btn-hover');
28
-
29
- // Trigger particle effect if available
30
- if (typeof triggerSmallParticleEffect === 'function') {
31
- triggerSmallParticleEffect(this);
32
- }
33
- });
34
-
35
- analyzeBtn.addEventListener('mouseout', function() {
36
- this.classList.remove('quantum-btn-hover');
37
- });
38
- }
39
-
40
- // Initialize tooltips
41
- const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
42
- tooltipTriggerList.map(function(tooltipTriggerEl) {
43
- return new bootstrap.Tooltip(tooltipTriggerEl);
44
- });
45
-
46
- // Initialize text-to-vision transitions
47
- initTextToVisionTransitions();
48
-
49
- // Check for results container and apply entrance animations
50
- const resultsContainer = document.getElementById('results-container');
51
- if (resultsContainer && resultsContainer.children.length > 0) {
52
- applyResultsAnimations(resultsContainer);
53
- }
54
-
55
- // Highlight entities in text (if applicable)
56
- highlightEntities();
57
-
58
- // Check if OpenAI key is available for contextual hints
59
- const hasOpenaiKey = document.body.classList.contains('has-openai-key');
60
- if (!hasOpenaiKey && typeof window.contextualHintSystem !== 'undefined') {
61
- setTimeout(() => {
62
- const settingsLink = document.querySelector('a[href="/settings"]');
63
- if (settingsLink) {
64
- window.contextualHintSystem.registerHint('openai-key-needed', {
65
- title: 'OpenAI API Key Needed',
66
- content: 'For enhanced AI-powered analysis, add your OpenAI API key in Settings. Without it, the system uses local fallback processing.',
67
- position: 'bottom',
68
- selector: 'a[href="/settings"]',
69
- icon: 'fas fa-key',
70
- important: true,
71
- maxShows: 2,
72
- buttonText: 'Go to Settings'
73
- });
74
- window.contextualHintSystem.considerShowingHint('openai-key-needed', settingsLink);
75
- }
76
- }, 2000);
77
- }
78
- });
79
-
80
- /**
81
- * Initialize text-to-vision transitions with staggered timing
82
- */
83
- function initTextToVisionTransitions() {
84
- const visionElements = document.querySelectorAll('.text-to-vision');
85
- visionElements.forEach((elem, index) => {
86
- // Add a staggered delay for smoother visual effect
87
- const delay = 300 + (index * 150);
88
- setTimeout(() => {
89
- elem.classList.add('text-to-vision-active');
90
-
91
- // Reset the animation after it completes to allow replaying
92
- setTimeout(() => {
93
- elem.classList.remove('text-to-vision-active');
94
- }, 1500);
95
- }, delay);
96
- });
97
- }
98
-
99
- /**
100
- * Apply animations to results container
101
- */
102
- function applyResultsAnimations(container) {
103
- // Add entrance animation
104
- container.style.opacity = '0';
105
- container.style.transform = 'translateY(20px)';
106
-
107
- setTimeout(() => {
108
- container.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
109
- container.style.opacity = '1';
110
- container.style.transform = 'translateY(0)';
111
-
112
- // Apply the quantum-reveal class to each card with staggered timing
113
- const cards = container.querySelectorAll('.quantum-card');
114
- cards.forEach((card, index) => {
115
- setTimeout(() => {
116
- card.classList.add('quantum-reveal');
117
- }, 300 + (index * 150));
118
- });
119
- }, 200);
120
- }
121
-
122
- /**
123
- * Highlight named entities in the displayed text
124
- */
125
- function highlightEntities() {
126
- // First try the data-entities method
127
- const entityContainers = document.querySelectorAll('.highlight-entities');
128
-
129
- entityContainers.forEach(function(element) {
130
- let html = element.innerHTML;
131
- const entities = JSON.parse(element.dataset.entities || '[]');
132
-
133
- // Sort entities by start position in descending order
134
- // to avoid offset issues when replacing text
135
- entities.sort((a, b) => b.start - a.start);
136
-
137
- // Replace each entity with highlighted version
138
- entities.forEach(function(entity) {
139
- const entityText = html.substring(entity.start, entity.end);
140
- const replacement = `<span class="entity entity-${entity.label.toLowerCase()}"
141
- title="${entity.label}">${entityText}</span>`;
142
-
143
- html = html.substring(0, entity.start) + replacement + html.substring(entity.end);
144
- });
145
-
146
- element.innerHTML = html;
147
- });
148
-
149
- // Add special effects to entity items in lists
150
- const entityItems = document.querySelectorAll('.list-group-item:has(.badge.bg-success)');
151
-
152
- entityItems.forEach(item => {
153
- // Extract entity text from the item
154
- const entityText = item.textContent.split(/\s+/)[0].trim();
155
- const entityType = item.querySelector('.badge')?.textContent || '';
156
-
157
- // Add quantum hover effects
158
- item.classList.add('quantum-entity-item');
159
-
160
- // Handle hover effects
161
- item.addEventListener('mouseover', function() {
162
- this.style.backgroundColor = 'rgba(66, 133, 244, 0.1)';
163
- this.style.boxShadow = '0 0 10px rgba(66, 133, 244, 0.3)';
164
- this.style.transform = 'translateX(5px)';
165
-
166
- // Create particle effect if the function is available
167
- if (typeof triggerSmallParticleEffect === 'function') {
168
- triggerSmallParticleEffect(this, 3, 0.3);
169
- }
170
- });
171
-
172
- item.addEventListener('mouseout', function() {
173
- this.style.backgroundColor = '';
174
- this.style.boxShadow = '';
175
- this.style.transform = '';
176
- });
177
-
178
- // Try to find and highlight the entity in the original text
179
- highlightEntityInInput(entityText);
180
- });
181
- }
182
-
183
- /**
184
- * Highlight an entity in the input text area
185
- */
186
- function highlightEntityInInput(entityText) {
187
- const textArea = document.getElementById('input_text');
188
- if (!textArea || !entityText) return;
189
-
190
- const text = textArea.value;
191
- if (!text) return;
192
-
193
- // Check if the entity is in the text
194
- const regex = new RegExp(`\\b${entityText}\\b`, 'gi');
195
- if (!regex.test(text)) return;
196
-
197
- // We can't highlight directly in textarea, so we can add a custom tooltip
198
- // or create a special view mode that shows the marked-up text
199
-
200
- // For now, we'll just add a subtle animation to the textarea
201
- textArea.classList.add('has-entities');
202
-
203
- // Create a glowing effect in the textarea
204
- const glowEffect = document.createElement('div');
205
- glowEffect.className = 'textarea-glow';
206
- glowEffect.style.position = 'absolute';
207
- glowEffect.style.top = '0';
208
- glowEffect.style.left = '0';
209
- glowEffect.style.width = '100%';
210
- glowEffect.style.height = '100%';
211
- glowEffect.style.pointerEvents = 'none';
212
- glowEffect.style.boxShadow = 'inset 0 0 15px rgba(66, 133, 244, 0.3)';
213
- glowEffect.style.opacity = '0';
214
- glowEffect.style.transition = 'opacity 0.5s ease';
215
-
216
- // Add glow effect as sibling to textarea with relative positioning
217
- const parent = textArea.parentElement;
218
- parent.style.position = 'relative';
219
- parent.appendChild(glowEffect);
220
-
221
- // Show the glow effect
222
- setTimeout(() => {
223
- glowEffect.style.opacity = '1';
224
- }, 300);
225
-
226
- // Hide after 2 seconds
227
- setTimeout(() => {
228
- glowEffect.style.opacity = '0';
229
-
230
- // Remove after fade out
231
- setTimeout(() => {
232
- glowEffect.remove();
233
- }, 500);
234
- }, 2000);
235
- }
236
-
237
- /**
238
- * Create a basic visualization of quantum score
239
- */
240
- function visualizeQuantumScore(elementId, score) {
241
- if (!elementId) return;
242
-
243
- const element = document.getElementById(elementId);
244
- if (!element) return;
245
-
246
- // Create a simple bar visualization
247
- const width = score * 100;
248
- const color = getColorForScore(score);
249
-
250
- element.innerHTML = `
251
- <div class="progress">
252
- <div class="progress-bar" role="progressbar"
253
- style="width: ${width}%; background-color: ${color};"
254
- aria-valuenow="${score * 100}" aria-valuemin="0" aria-valuemax="100">
255
- ${(score * 100).toFixed(0)}%
256
- </div>
257
- </div>
258
- `;
259
- }
260
-
261
- /**
262
- * Get color based on score value
263
- */
264
- function getColorForScore(score) {
265
- if (score < 0.3) return '#dc3545'; // Low - red
266
- if (score < 0.6) return '#ffc107'; // Medium - yellow
267
- if (score < 0.8) return '#0dcaf0'; // Good - cyan
268
- return '#198754'; // High - green
269
- }