File size: 7,185 Bytes
e9d94d1 | 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 | <!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The Third Voice AI</title>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&family=Playfair+Display:wght@700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Roboto', sans-serif;
background-color: #1a1a2e;
color: #e0e0e0;
margin: 0;
padding: 20px;
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
box-sizing: border-box;
}
.container {
background-color: #2a2a4a;
padding: 30px;
border-radius: 12px;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
width: 100%;
max-width: 800px;
margin-bottom: 20px;
}
h1 {
font-family: 'Playfair Display', serif;
color: #e94560;
text-align: center;
margin-bottom: 30px;
font-size: 2.5em;
}
label {
display: block;
margin-bottom: 8px;
font-weight: 700;
color: #a0a0a0;
}
textarea, select {
width: calc(100% - 20px);
padding: 12px;
margin-bottom: 20px;
border: 1px solid #3e3e5e;
border-radius: 8px;
background-color: #16213e;
color: #e0e0e0;
font-size: 1em;
box-sizing: border-box;
}
button {
background-color: #e94560;
color: white;
padding: 14px 25px;
border: none;
border-radius: 8px;
cursor: pointer;
font-size: 1.1em;
font-weight: 700;
transition: background-color 0.3s ease, transform 0.2s ease;
width: 100%;
box-sizing: border-box;
}
button:hover {
background-color: #ff6a80;
transform: translateY(-2px);
}
button:active {
transform: translateY(0);
}
.loading-spinner {
border: 4px solid #f3f3f3;
border-top: 4px solid #e94560;
border-radius: 50%;
width: 30px;
height: 30px;
animation: spin 1s linear infinite;
margin: 20px auto;
display: none;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.suggestion-box {
background-color: #3e3e5e;
padding: 15px;
border-radius: 8px;
margin-top: 20px;
border-left: 5px solid #e94560;
font-size: 0.95em;
color: #c0c0d0;
}
</style>
</head>
<body>
<div class="container">
<h1>The Third Voice AI</h1>
<p>Rewrite your messages for clarity, tone, and impact. Analyze what the other person might be feeling.</p><label for="messageInput">Your Message:</label>
<textarea id="messageInput" placeholder="Enter your message here..."></textarea>
<label for="toneSelect">Desired Tone:</label>
<select id="toneSelect">
<option value="professional">Professional</option>
<option value="friendly">Friendly</option>
<option value="assertive">Assertive</option>
<option value="empathetic">Empathetic</option>
<option value="concise">Concise</option>
<option value="neutral">Neutral</option>
</select>
<button id="rewriteButton">Rewrite Message</button>
<div class="loading-spinner" id="loadingSpinner"></div>
<div id="output">
<div class="suggestion-box" id="rewrittenBox" style="display:none;"></div>
</div>
<hr style="margin: 30px 0; border-color: #444;">
<label for="incomingMessage">Message You Received:</label>
<textarea id="incomingMessage" placeholder="Paste their message here..."></textarea>
<button id="analyzeButton">Analyze Tone and Feelings</button>
<div id="analysisOutput" class="suggestion-box" style="display:none;"></div>
</div>
<script>
const rewriteBtn = document.getElementById('rewriteButton');
const loadingSpinner = document.getElementById('loadingSpinner');
const rewrittenBox = document.getElementById('rewrittenBox');
rewriteBtn.addEventListener('click', async () => {
const message = document.getElementById('messageInput').value;
const tone = document.getElementById('toneSelect').value;
rewrittenBox.style.display = 'none';
rewrittenBox.textContent = '';
loadingSpinner.style.display = 'block';
try {
const response = await fetch('/rewrite', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ message, tone })
});
const data = await response.json();
if (response.ok) {
rewrittenBox.textContent = data.rewrittenText;
rewrittenBox.style.display = 'block';
} else {
rewrittenBox.textContent = `Error: ${data.error || 'Unknown error'}`;
rewrittenBox.style.display = 'block';
}
} catch (err) {
rewrittenBox.textContent = `Network error: ${err.message}`;
rewrittenBox.style.display = 'block';
} finally {
loadingSpinner.style.display = 'none';
}
});
const analyzeBtn = document.getElementById('analyzeButton');
const analysisOutput = document.getElementById('analysisOutput');
analyzeBtn.addEventListener('click', async () => {
const received = document.getElementById('incomingMessage').value;
analysisOutput.style.display = 'none';
analysisOutput.textContent = '';
try {
const response = await fetch('/analyze-tone', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ message: received })
});
const data = await response.json();
if (response.ok) {
analysisOutput.innerHTML = `<strong>How they might be feeling:</strong><br>${data.analysis}`;
analysisOutput.style.display = 'block';
} else {
analysisOutput.innerHTML = `<strong>Error:</strong> ${data.error || 'Unknown error'}`;
analysisOutput.style.display = 'block';
}
} catch (err) {
analysisOutput.innerHTML = `<strong>Network error:</strong> ${err.message}`;
analysisOutput.style.display = 'block';
}
});
</script>
</body>
</html>I |