I'll create a comprehensive EMDR (Eye Movement Desensitization and Reprocessing) app in a single HTML file. This will include bilateral stimulation through visual, audio, and tactile options, along with session management features.
html Copy code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>EMDR Therapy Assistant</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: #f0f4f8;
color: #2d3748;
min-height: 100vh;
display: flex;
flex-direction: column;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
width: 100%;
}
header {
text-align: center;
margin-bottom: 30px;
padding: 20px;
background: white;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
h1 {
color: #4a5568;
margin-bottom: 10px;
}
.disclaimer {
font-size: 14px;
color: #718096;
margin-top: 10px;
padding: 10px;
background: #e2e8f0;
border-radius: 5px;
}
.main-content {
background: white;
border-radius: 10px;
padding: 30px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.tabs {
display: flex;
gap: 10px;
margin-bottom: 30px;
flex-wrap: wrap;
}
.tab {
padding: 10px 20px;
background: #e2e8f0;
border: none;
border-radius: 5px;
cursor: pointer;
transition: all 0.3s;
font-size: 16px;
}
.tab.active {
background: #4299e1;
color: white;
}
.tab:hover {
background: #cbd5e0;
}
.tab.active:hover {
background: #3182ce;
}
.tab-content {
display: none;
}
.tab-content.active {
display: block;
}
.visual-container {
height: 200px;
background: #1a202c;
border-radius: 10px;
position: relative;
overflow: hidden;
margin-bottom: 30px;
}
.ball {
width: 40px;
height: 40px;
background: #4299e1;
border-radius: 50%;
position: absolute;
top: 50%;
transform: translateY(-50%);
transition: none;
box-shadow: 0 0 20px rgba(66, 153, 225, 0.5);
}
.controls {
display: grid;
gap: 20px;
}
.control-group {
display: flex;
flex-direction: column;
gap: 10px;
}
label {
font-weight: 600;
color: #4a5568;
}
input[type="range"] {
width: 100%;
height: 8px;
border-radius: 4px;
background: #e2e8f0;
outline: none;
-webkit-appearance: none;
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
width: 20px;
height: 20px;
border-radius: 50%;
background: #4299e1;
cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
width: 20px;
height: 20px;
border-radius: 50%;
background: #4299e1;
cursor: pointer;
border: none;
}
.value-display {
text-align: center;
color: #718096;
font-size: 14px;
}
.button-group {
display: flex;
gap: 10px;
margin-top: 20px;
}
button {
flex: 1;
padding: 12px 24px;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
transition: all 0.3s;
font-weight: 600;
}
.btn-primary {
background: #4299e1;
color: white;
}
.btn-primary:hover {
background: #3182ce;
}
.btn-secondary {
background: #e2e8f0;
color: #4a5568;
}
.btn-secondary:hover {
background: #cbd5e0;
}
.session-info {
margin-top: 30px;
padding: 20px;
background: #f7fafc;
border-radius: 10px;
display: none;
}
.session-info.active {
display: block;
}
.timer {
font-size: 24px;
font-weight: bold;
text-align: center;
color: #4a5568;
margin-bottom: 10px;
}
.audio-controls {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 10px;
margin-bottom: 20px;
}
.audio-option {
padding: 10px;
background: #e2e8f0;
border-radius: 5px;
cursor: pointer;
text-align: center;
transition: all 0.3s;
}
.audio-option.active {
background: #4299e1;
color: white;
}
.tactile-indicator {
display: flex;
justify-content: space-between;
align-items: center;
height: 100px;
margin-bottom: 20px;
}
.tactile-side {
width: 45%;
height: 100%;
background: #e2e8f0;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
font-size: 24px;
font-weight: bold;
transition: all 0.3s;
}
.tactile-side.active {
background: #4299e1;
color: white;
transform: scale(1.05);
}
.breathing-guide {
text-align: center;
padding: 40px;
background: #e6fffa;
border-radius: 10px;
margin-bottom: 20px;
}
.breathing-circle {
width: 150px;
height: 150px;
background: #4299e1;
border-radius: 50%;
margin: 0 auto 20px;
transition: transform 4s ease-in-out;
}
.breathing-circle.inhale {
transform: scale(1.3);
}
.breathing-text {
font-size: 24px;
color: #4a5568;
font-weight: 600;
}
@media (max-width: 600px) {
.container {
padding: 10px;
}
.main-content {
padding: 20px;
}
.tabs {
justify-content: center;
}
.tab {
font-size: 14px;
padding: 8px 16px;
}
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>EMDR Therapy Assistant</h1>
<div class="disclaimer">
This tool is designed to support EMDR therapy sessions. Please use under the guidance of a qualified EMDR therapist.
</div>
</header>
<div class="main-content">
<div class="tabs">
<button class="tab active" onclick="switchTab('visual')">Visual</button>
<button class="tab" onclick="switchTab('audio')">Audio</button>
<button class="tab" onclick="switchTab('tactile')">Tactile</button>
<button class="tab" onclick="switchTab('breathing')">Breathing</button>
</div>
<div id="visual" class="tab-content active">
<div class="visual-container">
<div class="ball" id="visualBall"></div>
</div>
<div class="controls">
<div class="control-group">
<label for="speedSlider">Speed</label>
<input type="range" id="speedSlider" min="0.5" max="3" step="0.1" value="1">
<div class="value-display">Speed: <span id="speedValue">1</span> seconds</div>
</div>
<div class="control-group">
<label for="colorPicker">Ball Color</label>
<input type="color" id="colorPicker" value="#4299e1">
</div>
</div>
</div>
<div id="audio" class="tab-content">
<div class="audio-controls">
<div class="audio-option active" onclick="selectAudioType('tone')">Tone</div>
<div class="audio-option" onclick="selectAudioType('click')">Click</div>
<div class="audio-option" onclick="selectAudioType('nature')">Nature</div>
</div>
<div class="controls">
<div class="control-group">
<label for="audioSpeedSlider">Speed</label>
<input type="range" id="audioSpeedSlider" min="0.5" max="3" step="0.1" value="1">
<div class="value-display">Speed: <span id="audioSpeedValue">1</span> seconds</div>
</div>
<div class="control-group">
<label for="volumeSlider">Volume</label>
<input type="range" id="volumeSlider" min="0" max="100" step="5" value="50">
<div class="value-display">Volume: <span id="volumeValue">50</span>%</div>
</div>
</div>
</div>
<div id="tactile" class="tab-content">
<div class="tactile-indicator">
<div class="tactile-side" id="leftTactile">LEFT</div>
<div class="tactile-side" id="rightTactile">RIGHT</div>
</div>
<div class="controls">
<div class="control-group">
<label for="tactileSpeedSlider">Speed</label>
<input type="range" id="tactileSpeedSlider" min="0.5" max="3" step="0.1" value="1">
<div class="value-display">Speed: <span id="tactileSpeedValue">1</span> seconds</div>
</div>
<div class="control-group">
<label>Instructions</label>
<p style="color: #718096; font-size: 14px;">
Place your hands on your knees or thighs. Tap alternately with the highlighted side.
You can also cross your arms and tap your shoulders alternately.
</p>
</div>
</div>
</div>
<div id="breathing" class="tab-content">
<div class="breathing-guide">
<div class="breathing-circle" id="breathingCircle"></div>
<div class="breathing-text" id="breathingText">Click Start to begin</div>
</div>
<div class="controls">
<div class="control-group">
<label>Breathing Pattern</label>
<p style="color: #718096; font-size: 14px;">
4-7-8 breathing: Inhale for 4 seconds, hold for 7 seconds, exhale for 8 seconds.
This technique helps activate the parasympathetic nervous system.
</p>
</div>
</div>
</div>
<div class="button-group">
<button class="btn-primary" id="startBtn" onclick="toggleSession()">Start Session</button>
<button class="btn-secondary" onclick="resetSession()">Reset</button>
</div>
<div class="session-info" id="sessionInfo">
<div class="timer" id="timer">00:00</div>
<div style="text-align: center; color: #718096;">
Session in progress...
</div>
</div>
</div>
</div>
<script>
let isRunning = false;
let currentTab = 'visual';
let animationId = null;
let audioContext = null;
let oscillator = null;
let gainNode = null;
let startTime = null;
let timerInterval = null;
let audioType = 'tone';
// Initialize audio context
function initAudio() {
if (!audioContext) {
audioContext = new (window.AudioContext || window.webkitAudioContext)();
}
}
// Tab switching
function switchTab(tab) {
currentTab = tab;
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
document.querySelectorAll('.tab-content').forEach(c => c.classList.remove('active'));
event.target.classList.add('active');
document.getElementById(tab).classList.add('active');
if (isRunning) {
stopSession();
startSession();
}
}
// Visual animation
function animateVisual() {
const ball = document.getElementById('visualBall');
const container = document.querySelector('.visual-container');
const speed = parseFloat(document.getElementById('speedSlider').value) * 1000;
let direction = 1;
let position = 0;
function move() {
if (!isRunning || currentTab !== 'visual') return;
const maxPosition = container.offsetWidth - ball.offsetWidth;
position += (maxPosition / (speed / 16)) * direction;
if (position >= maxPosition || position <= 0) {
direction *= -1;
position = Math.max(0, Math.min(position, maxPosition));
}
ball.style.left = position + 'px';
animationId = requestAnimationFrame(move);
}
move();
}
// Audio generation
function playAudio() {
initAudio();
const speed = parseFloat(document.getElementById('audioSpeedSlider').value) * 1000;
const volume = parseFloat(document.getElementById('volumeSlider').