-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresume.html
More file actions
575 lines (515 loc) · 33.2 KB
/
resume.html
File metadata and controls
575 lines (515 loc) · 33.2 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
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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
<!DOCTYPE html>
<html lang="en" class="scroll-smooth">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Complete Your SpotOrigin Profile</title>
<link rel="icon" href="favicon.png" type="image/png">
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Inter', sans-serif;
background-color: #020617; /* Slate 950 */
color: #F8FAFC;
}
.calm-background {
position: absolute;
inset: 0;
background-image: radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.2) 0%, transparent 40%),
radial-gradient(circle at 80% 70%, rgba(139, 92, 246, 0.15) 0%, transparent 50%);
}
.drag-over {
border-color: #6366F1;
background-color: #1E293B;
}
.record-pulse {
animation: pulse 1.5s infinite;
}
@keyframes pulse {
0%, 100% {
transform: scale(1);
box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.7);
}
70% {
transform: scale(1.05);
box-shadow: 0 0 10px 15px rgba(236, 72, 153, 0);
}
}
</style>
</head>
<body class="antialiased">
<header class="absolute top-0 left-0 right-0 z-20">
<nav class="container mx-auto px-6 py-6">
<div class="text-2xl font-bold tracking-tighter">SpotOrigin</div>
</nav>
</header>
<main class="relative min-h-screen flex items-center justify-center py-24 px-4">
<div class="calm-background"></div>
<div class="relative z-10 w-full max-w-2xl">
<div class="bg-slate-900/70 backdrop-blur-xl border border-slate-700 rounded-2xl p-8 sm:p-12">
<div class="text-center mb-8">
<h1 class="text-3xl md:text-4xl font-extrabold tracking-tighter mb-2">Complete Your Private Profile</h1>
<p class="text-lg text-slate-400">Your information is confidential and only shared with vetted agents when a potential match is found.</p>
</div>
<form id="profile-form" action="https://formspree.io/f/xblzqllb" method="POST" novalidate class="space-y-4">
<input type="hidden" name="_autoresponse" value="Your SpotOrigin Application has been received!">
<input type="hidden" id="referrer-desktop" name="referrer_email">
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label for="name-desktop" class="block text-sm font-medium text-slate-300 mb-1">Full Name</label>
<input type="text" name="name" id="name-desktop" required class="w-full bg-slate-800 border border-slate-700 rounded-lg px-4 py-2 text-white placeholder-slate-500">
</div>
<div>
<label for="email-desktop" class="block text-sm font-medium text-slate-300 mb-1">Email Address</label>
<input type="email" name="email" id="email-desktop" required class="w-full bg-slate-800 border border-slate-700 rounded-lg px-4 py-2 text-white placeholder-slate-500">
</div>
</div>
<div>
<label for="experience-years" class="block text-sm font-medium text-slate-300 mb-1">Years of Professional Experience</label>
<select id="experience-years" name="experience_years" required class="w-full bg-slate-800 border border-slate-700 rounded-lg px-4 py-2 text-white appearance-none bg-no-repeat bg-right pr-8" style="background-image: url('data:image/svg+xml,%3csvg xmlns=%27http://www.w3.org/2000/svg%27 fill=%27none%27 viewBox=%270 0 20 20%27%3e%3cpath stroke=%27%2394a3b8%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 stroke-width=%271.5%27 d=%27M6 8l4 4 4-4%27/%3e%3c/svg%3e'); background-position: right 0.5rem center; background-size: 1.5em 1.5em;">
<option value="">Select a range</option>
<option value="0-2 years">0-2 years</option>
<option value="3-5 years">3-5 years</option>
<option value="6-10 years">6-10 years</option>
<option value="11-15 years">11-15 years</option>
<option value="15+ years">15+ years</option>
</select>
</div>
<div>
<label for="recruiter-specialty" class="block text-sm font-medium text-slate-300 mb-1">Primary Specialty</label>
<select id="recruiter-specialty" name="recruiter_specialty" required class="w-full bg-slate-800 border border-slate-700 rounded-lg px-4 py-2 text-white appearance-none bg-no-repeat bg-right pr-8" style="background-image: url('data:image/svg+xml,%3csvg xmlns=%27http://www.w3.org/2000/svg%27 fill=%27none%27 viewBox=%270 0 20 20%27%3e%3cpath stroke=%27%2394a3b8%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 stroke-width=%271.5%27 d=%27M6 8l4 4 4-4%27/%3e%3c/svg%3e'); background-position: right 0.5rem center; background-size: 1.5em 1.5em;">
<option value="">Select your main field</option>
<option value="Software Engineering">Software Engineering</option>
<option value="Product Management">Product Management</option>
<option value="Data Science & Analytics">Data Science & Analytics</option>
<option value="AI & Machine Learning">AI & Machine Learning</option>
<option value="Design & UX/UI">Design & UX/UI</option>
<option value="Sales & Business Development">Sales & Business Development</option>
<option value="Marketing & Communications">Marketing & Communications</option>
<option value="Finance & Accounting">Finance & Accounting</option>
<option value="Legal & Compliance">Legal & Compliance</option>
<option value="Human Resources & Talent">Human Resources & Talent</option>
<option value="Operations & Supply Chain">Operations & Supply Chain</option>
<option value="Cybersecurity">Cybersecurity</option>
<option value="Executive Leadership">Executive Leadership (C-Suite, VP)</option>
<option value="Other">Other</option>
</select>
</div>
<div>
<label for="location-input" class="block text-sm font-medium text-slate-300 mb-1">Desired Locations (e.g., Remote, New York, London)</label>
<input type="text" id="location-input" placeholder="Type a location and press Enter..." class="w-full bg-slate-800 border border-slate-700 rounded-lg px-4 py-2 text-white placeholder-slate-500">
<div id="locations-container" class="flex flex-wrap gap-2 mt-3"></div>
<input type="hidden" name="desired_locations" id="desired-locations-hidden">
</div>
<div>
<label for="last-compensation" class="block text-sm font-medium text-slate-300 mb-1">Last Compensation (Optional)</label>
<input type="text" name="last_compensation" id="last-compensation" placeholder="e.g., $120,000/year or $75/hour" class="w-full bg-slate-800 border border-slate-700 rounded-lg px-4 py-2 text-white placeholder-slate-500">
</div>
<div>
<label for="desired-compensation" class="block text-sm font-medium text-slate-300 mb-1">Desired Compensation (Optional)</label>
<input type="text" name="desired_compensation" id="desired-compensation" placeholder="e.g., $150,000/year or $90/hour" class="w-full bg-slate-800 border border-slate-700 rounded-lg px-4 py-2 text-white placeholder-slate-500">
</div>
<div>
<label class="block text-sm font-medium text-slate-300 mb-2">Upload Your Resume (Required)</label>
<div id="resume-dropzone" class="relative flex justify-center rounded-lg border-2 border-dashed border-slate-600 px-6 py-10 transition-colors">
<div class="text-center">
<svg class="mx-auto h-12 w-12 text-slate-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5" /></svg>
<div id="file-info" class="mt-4 text-sm leading-6 text-slate-400">
<label for="resume-input" class="relative cursor-pointer rounded-md font-semibold text-indigo-400 hover:text-indigo-300"><span>Upload a file</span><input id="resume-input" name="resume" type="file" class="sr-only"></label>
<p class="pl-1">or drag and drop</p>
</div>
<p class="text-xs leading-5 text-slate-500" id="file-constraints">PDF, DOC, DOCX up to 10MB</p>
</div>
</div>
</div>
<div class="pt-4">
<label class="block text-sm font-medium text-slate-300">Tell Us Your Story (Optional)</label>
<p class="text-sm text-slate-400 mb-4">In 90 seconds, tell us about the common thread in your career and what you're looking for next. If you don't record a note, every agent will have to get on a call with you.</p>
<div class="bg-slate-800 border border-slate-700 rounded-lg p-4">
<div class="flex items-center gap-4">
<button type="button" id="record-btn" class="flex-shrink-0 h-16 w-16 bg-pink-600 text-white rounded-full flex items-center justify-center hover:bg-pink-700 transition-all shadow-lg">
<svg id="record-icon" xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle></svg>
</button>
<div class="w-full">
<canvas id="audio-visualizer" class="w-full h-12"></canvas>
</div>
<div id="timer" class="text-xl font-mono text-slate-400 w-28 text-right">0:00 / 1:30</div>
</div>
<div id="audio-controls" class="flex items-center justify-center gap-4 mt-4 hidden">
<button type="button" id="listen-btn" class="bg-slate-700 text-white px-4 py-2 rounded-full text-sm font-semibold hover:bg-slate-600 disabled:opacity-50" disabled>Listen</button>
<button type="button" id="clear-btn" class="bg-slate-700 text-white px-4 py-2 rounded-full text-sm font-semibold hover:bg-slate-600">Clear & Re-record</button>
<audio id="audio-player" class="hidden"></audio>
</div>
<div id="mic-permission-msg" class="text-center text-yellow-400 text-sm mt-2 hidden">Waiting for microphone permission...</div>
</div>
</div>
<div class="pt-2 space-y-4">
<div class="flex items-start">
<div class="flex items-center h-5">
<input id="happy-checkbox" name="is_happy" type="checkbox" checked class="h-4 w-4 text-indigo-600 border-slate-600 bg-slate-700 rounded">
</div>
<div class="ml-3 text-sm">
<label for="happy-checkbox" class="text-slate-300">I'm happy in my current role and not actively looking.</label>
</div>
</div>
<div id="unhappy-details-container" class="hidden">
<label for="unhappy-details" class="block text-sm font-medium text-slate-300 mb-1">What's motivating you to look for a new role? (Optional)</label>
<textarea id="unhappy-details" name="unhappy_details" rows="3" placeholder="e.g., Seeking better compensation, looking for a leadership role, company culture..." class="w-full bg-slate-800 border border-slate-700 rounded-lg px-4 py-2 text-white placeholder-slate-500"></textarea>
</div>
</div>
<div class="flex items-start pt-2">
<div class="flex items-center h-5">
<input id="terms-desktop" name="terms-candidate" type="checkbox" required class="h-4 w-4 text-indigo-600 border-slate-600 bg-slate-700 rounded">
</div>
<div class="ml-3 text-sm">
<label for="terms-desktop" class="text-slate-400">I agree to the <a href="terms.html" target="_blank" class="font-medium text-indigo-400 hover:text-indigo-300 underline">Terms of Service</a> and <a href="privacy.html" target="_blank" class="font-medium text-indigo-400 hover:text-indigo-300 underline">Privacy Policy</a>.</label>
</div>
</div>
<div id="form-messages" class="text-center"></div>
<button type="submit" id="submit-button" class="w-full bg-indigo-600 text-white font-bold py-4 px-6 rounded-full !mt-8 text-lg hover:bg-indigo-700 hover:scale-105 transition-all duration-300 disabled:opacity-50 disabled:scale-100">Submit Application</button>
</form>
</div>
</div>
</main>
<script>
console.log("SpotOrigin Debug: resume.html SCRIPT BLOCK IS RUNNING.");
const runLogic = () => {
const form = document.getElementById('profile-form');
const submitButton = document.getElementById('submit-button');
const messagesDiv = document.getElementById('form-messages');
let uploadedFile = null;
let uploadedAudioFile = null;
const urlParams = new URLSearchParams(window.location.search);
console.log("SpotOrigin Debug: runLogic() fired. URL params are:", window.location.search);
const referrer = urlParams.get('ref');
if (referrer) {
const referrerDesktopInput = document.getElementById('referrer-desktop');
if (referrerDesktopInput) referrerDesktopInput.value = referrer;
}
const email = urlParams.get('email');
const emailDesktopInput = document.getElementById('email-desktop');
if (email && emailDesktopInput) {
emailDesktopInput.value = email;
}
const locationInput = document.getElementById('location-input');
const locationsContainer = document.getElementById('locations-container');
const hiddenLocationsInput = document.getElementById('desired-locations-hidden');
let locations = [];
const renderLocations = () => {
if (!locationsContainer) return;
locationsContainer.innerHTML = '';
locations.forEach(location => {
const tag = document.createElement('span');
tag.className = 'bg-slate-700 text-slate-200 text-sm font-medium px-3 py-1 rounded-full flex items-center gap-2';
tag.textContent = location;
const removeBtn = document.createElement('button');
removeBtn.type = 'button';
removeBtn.className = 'text-slate-400 hover:text-white font-bold pl-1';
removeBtn.innerHTML = '×';
removeBtn.onclick = () => {
locations = locations.filter(l => l !== location);
hiddenLocationsInput.value = locations.join(', ');
renderLocations();
};
tag.appendChild(removeBtn);
locationsContainer.appendChild(tag);
});
};
const addLocation = () => {
if (!locationInput) return;
const newLocation = locationInput.value.replace(/,/g, '').trim();
if (newLocation && !locations.includes(newLocation)) {
locations.push(newLocation);
hiddenLocationsInput.value = locations.join(', ');
renderLocations();
}
locationInput.value = '';
};
if (hiddenLocationsInput) {
locations = ['Remote'];
hiddenLocationsInput.value = locations.join(', ');
renderLocations();
}
if (locationInput) {
locationInput.addEventListener('keydown', (e) => {
if (e.key === 'Enter' || e.key === ',') {
e.preventDefault();
addLocation();
}
});
locationInput.addEventListener('blur', addLocation);
}
const happyCheckbox = document.getElementById('happy-checkbox');
const unhappyDetailsContainer = document.getElementById('unhappy-details-container');
if (happyCheckbox && unhappyDetailsContainer) {
happyCheckbox.addEventListener('change', () => {
unhappyDetailsContainer.classList.toggle('hidden', happyCheckbox.checked);
});
}
const dropzone = document.getElementById('resume-dropzone');
const fileInput = document.getElementById('resume-input');
const fileInfo = document.getElementById('file-info');
const fileConstraints = document.getElementById('file-constraints');
if (dropzone && fileInput && fileInfo) {
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => dropzone.addEventListener(eventName, e => { e.preventDefault(); e.stopPropagation(); }, false));
document.body.addEventListener('dragover', e => e.preventDefault());
document.body.addEventListener('drop', e => e.preventDefault());
dropzone.addEventListener('dragenter', () => dropzone.classList.add('drag-over'));
dropzone.addEventListener('dragover', () => dropzone.classList.add('drag-over'));
dropzone.addEventListener('dragleave', () => dropzone.classList.remove('drag-over'));
dropzone.addEventListener('drop', (e) => {
dropzone.classList.remove('drag-over');
const files = e.dataTransfer.files;
if (files.length > 0) handleFile(files[0]);
});
fileInput.addEventListener('change', e => {
const files = e.target.files;
if (files.length > 0) handleFile(files[0]);
});
const handleFile = (file) => {
const allowedTypes = ['application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'];
const maxSize = 10 * 1024 * 1024; // 10MB
if (!allowedTypes.includes(file.type)) {
fileInfo.innerHTML = `<span class="text-red-400">Invalid file type. Please use PDF, DOC, or DOCX.</span>`;
fileConstraints.classList.add('text-red-400');
uploadedFile = null; return;
}
if (file.size > maxSize) {
fileInfo.innerHTML = `<span class="text-red-400">File is too large. Max size is 10MB.</span>`;
fileConstraints.classList.add('text-red-400');
uploadedFile = null; return;
}
uploadedFile = file;
fileInfo.innerHTML = `<span class="text-slate-200">${file.name}</span>`;
fileConstraints.classList.remove('text-red-400');
messagesDiv.innerHTML = '';
};
}
// --- AUDIO RECORDING LOGIC (DEFINITIVE FIX v2) ---
const recordBtn = document.getElementById('record-btn');
const listenBtn = document.getElementById('listen-btn');
const clearBtn = document.getElementById('clear-btn');
const timerEl = document.getElementById('timer');
const visualizer = document.getElementById('audio-visualizer');
const audioControls = document.getElementById('audio-controls');
const audioPlayer = document.getElementById('audio-player');
const micPermissionMsg = document.getElementById('mic-permission-msg');
let mediaRecorder;
let audioChunks = [];
let timerInterval;
let audioContext, analyser, dataArray, source;
let animationFrameId;
let streamRef;
const recordSVG = `<svg id="record-icon" xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle></svg>`;
const stopSVG = `<svg id="record-icon" xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="6" y="6" width="12" height="12"></rect></svg>`;
const setupAudio = async () => {
if (streamRef) {
// Stop any existing tracks to ensure a fresh start
streamRef.getTracks().forEach(track => track.stop());
}
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
micPermissionMsg.textContent = 'Your browser does not support audio recording.';
micPermissionMsg.classList.remove('hidden');
return null;
}
try {
micPermissionMsg.classList.remove('hidden');
micPermissionMsg.textContent = 'Waiting for microphone permission...';
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
micPermissionMsg.classList.add('hidden');
streamRef = stream;
audioContext = new (window.AudioContext || window.webkitAudioContext)();
analyser = audioContext.createAnalyser();
source = audioContext.createMediaStreamSource(stream);
source.connect(analyser);
analyser.fftSize = 256;
const bufferLength = analyser.frequencyBinCount;
dataArray = new Uint8Array(bufferLength);
// Safari compatibility: Check for supported MIME types
const options = MediaRecorder.isTypeSupported('audio/mp4')
? { mimeType: 'audio/mp4' }
: {};
return new MediaRecorder(stream, options);
} catch (err) {
micPermissionMsg.innerHTML = 'Microphone access denied. Please enable it in browser settings.';
console.error("Mic access error:", err);
return null;
}
};
const startRecording = async () => {
clearRecording();
mediaRecorder = await setupAudio();
if (!mediaRecorder) return;
mediaRecorder.ondataavailable = event => {
if (event.data.size > 0) audioChunks.push(event.data);
};
mediaRecorder.onstop = () => {
if (audioChunks.length === 0) return;
const mimeType = mediaRecorder.mimeType || 'audio/webm';
const audioBlob = new Blob(audioChunks, { type: mimeType });
uploadedAudioFile = audioBlob;
const audioUrl = URL.createObjectURL(audioBlob);
audioControls.classList.remove('hidden');
audioPlayer.src = audioUrl;
audioPlayer.load();
const onCanPlay = () => {
listenBtn.disabled = false;
};
audioPlayer.addEventListener('canplaythrough', onCanPlay, { once: true });
audioPlayer.addEventListener('error', (e) => {
console.error("Audio Player Error:", e);
messagesDiv.innerHTML = `<p class="text-red-400">Error loading audio for playback. Please re-record.</p>`;
}, { once: true });
};
audioChunks = [];
mediaRecorder.start();
recordBtn.innerHTML = stopSVG;
recordBtn.classList.add('record-pulse');
let seconds = 0;
timerEl.textContent = `0:00 / 1:30`;
timerInterval = setInterval(() => {
seconds++;
const mins = Math.floor(seconds / 60);
const secs = seconds % 60;
timerEl.textContent = `${mins}:${secs.toString().padStart(2, '0')} / 1:30`;
if (seconds >= 90) stopRecording();
}, 1000);
visualize();
};
const stopRecording = () => {
if (mediaRecorder && mediaRecorder.state === 'recording') {
mediaRecorder.stop();
}
recordBtn.innerHTML = recordSVG;
recordBtn.classList.remove('record-pulse');
clearInterval(timerInterval);
if (animationFrameId) {
cancelAnimationFrame(animationFrameId);
animationFrameId = null;
}
};
const visualize = () => {
if (!analyser) return;
const canvasCtx = visualizer.getContext('2d');
const WIDTH = visualizer.width;
const HEIGHT = visualizer.height;
analyser.getByteTimeDomainData(dataArray);
canvasCtx.fillStyle = '#1e293b';
canvasCtx.fillRect(0, 0, WIDTH, HEIGHT);
canvasCtx.lineWidth = 2;
canvasCtx.strokeStyle = '#6366F1';
canvasCtx.beginPath();
const sliceWidth = WIDTH * 1.0 / analyser.frequencyBinCount;
let x = 0;
for (let i = 0; i < analyser.frequencyBinCount; i++) {
const v = dataArray[i] / 128.0;
const y = v * HEIGHT / 2;
if (i === 0) canvasCtx.moveTo(x, y);
else canvasCtx.lineTo(x, y);
x += sliceWidth;
}
canvasCtx.lineTo(WIDTH, HEIGHT / 2);
canvasCtx.stroke();
animationFrameId = requestAnimationFrame(visualize);
};
const clearRecording = () => {
uploadedAudioFile = null;
audioChunks = [];
audioControls.classList.add('hidden');
timerEl.textContent = '0:00 / 1:30';
listenBtn.disabled = true;
if (audioPlayer && audioPlayer.src && audioPlayer.src.startsWith('blob:')) {
URL.revokeObjectURL(audioPlayer.src);
}
if (audioPlayer) {
audioPlayer.removeAttribute('src');
audioPlayer.load();
}
if(visualizer){
const canvasCtx = visualizer.getContext('2d');
canvasCtx.fillStyle = '#1e293b';
canvasCtx.fillRect(0, 0, visualizer.width, visualizer.height);
}
};
if (recordBtn) {
recordBtn.addEventListener('click', () => {
if (mediaRecorder && mediaRecorder.state === "recording") {
stopRecording();
} else {
startRecording();
}
});
}
if(listenBtn) {
listenBtn.addEventListener('click', () => {
if (audioPlayer && audioPlayer.src) {
audioPlayer.currentTime = 0;
audioPlayer.play().catch(e => {
console.error("Playback failed:", e);
messagesDiv.innerHTML = `<p class="text-red-400">Could not play audio. Please try again.</p>`;
});
}
});
}
if(clearBtn) clearBtn.addEventListener('click', () => {
stopRecording();
clearRecording();
});
if (form) {
form.addEventListener('submit', async (e) => {
e.preventDefault();
if (!uploadedFile) {
messagesDiv.innerHTML = `<p class="text-red-400">Please upload your resume before submitting.</p>`; return;
}
if (!form.checkValidity()) {
messagesDiv.innerHTML = `<p class="text-red-400">Please fill out all required fields.</p>`; return;
}
submitButton.disabled = true;
submitButton.textContent = 'Submitting...';
messagesDiv.innerHTML = '';
const formData = new FormData(form);
formData.append('resume', uploadedFile, uploadedFile.name);
if (uploadedAudioFile) {
const fileExtension = mediaRecorder.mimeType && mediaRecorder.mimeType.includes('mp4') ? 'mp4' : 'webm';
formData.append('voicenote', uploadedAudioFile, `voicenote.${fileExtension}`);
}
try {
const response = await fetch(form.action, {
method: 'POST',
body: formData,
headers: { 'Accept': 'application/json' }
});
if (response.ok) {
messagesDiv.innerHTML = `<p class="text-green-400">Success! Your profile has been submitted. We'll be in touch.</p>`;
submitButton.textContent = 'Submitted!';
form.reset();
uploadedFile = null;
fileInfo.innerHTML = `<label for="resume-input" class="relative cursor-pointer rounded-md font-semibold text-indigo-400 hover:text-indigo-300"><span>Upload a file</span><input id="resume-input" name="resume" type="file" class="sr-only"></label><p class="pl-1">or drag and drop</p>`;
locations = ['Remote'];
if(hiddenLocationsInput) hiddenLocationsInput.value = locations.join(', ');
renderLocations();
clearRecording();
} else {
throw new Error('Submission failed. Please try again.');
}
} catch (error) {
messagesDiv.innerHTML = `<p class="text-red-400">${error.message || 'An unknown error occurred.'}</p>`;
submitButton.disabled = false;
submitButton.textContent = 'Submit Application';
}
});
}
};
if (document.readyState === 'loading') {
console.log("SpotOrigin Debug: DOM is loading, adding listener.");
document.addEventListener('DOMContentLoaded', runLogic);
} else {
console.log("SpotOrigin Debug: DOM is already ready, running logic now.");
runLogic();
}
</script>
</body>
</html>