Files
TimeTrack/templates/notes/share_password.html

194 lines
6.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Password Protected Note - {{ note_title }}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/fonts.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
<style>
body {
background: #f5f5f5;
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
margin: 0;
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
.password-container {
background: white;
border-radius: 16px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
padding: 3rem;
max-width: 400px;
width: 100%;
text-align: center;
}
.lock-icon {
font-size: 3rem;
margin-bottom: 1rem;
}
h1 {
font-size: 1.5rem;
margin-bottom: 0.5rem;
color: #1f2937;
}
.note-title {
color: #6b7280;
margin-bottom: 2rem;
font-size: 1rem;
}
.form-group {
margin-bottom: 1.5rem;
text-align: left;
}
.form-label {
display: block;
margin-bottom: 0.5rem;
font-weight: 600;
color: #374151;
}
.form-control {
width: 100%;
padding: 0.75rem;
border: 1px solid #e5e7eb;
border-radius: 8px;
font-size: 1rem;
transition: all 0.2s;
}
.form-control:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
.btn {
width: 100%;
padding: 0.75rem 1.5rem;
border-radius: 8px;
font-weight: 600;
transition: all 0.3s ease;
border: none;
cursor: pointer;
font-size: 1rem;
}
.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}
.error-message {
background: #fee;
color: #dc2626;
padding: 0.75rem;
border-radius: 8px;
margin-bottom: 1rem;
font-size: 0.875rem;
}
.spinner {
display: none;
width: 20px;
height: 20px;
border: 2px solid #f3f3f3;
border-top: 2px solid #667eea;
border-radius: 50%;
animation: spin 1s linear infinite;
margin: 0 auto;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body>
<div class="password-container">
<div class="lock-icon">🔒</div>
<h1>Password Protected Note</h1>
<p class="note-title">{{ note_title }}</p>
<form id="password-form">
<div id="error-container"></div>
<div class="form-group">
<label for="password" class="form-label">Enter Password</label>
<input type="password"
id="password"
name="password"
class="form-control"
required
autofocus
placeholder="Enter the password to view this note">
</div>
<button type="submit" class="btn btn-primary" id="submit-btn">
<span id="btn-text">Unlock Note</span>
<div class="spinner" id="spinner"></div>
</button>
</form>
</div>
<script>
document.getElementById('password-form').addEventListener('submit', async (e) => {
e.preventDefault();
const password = document.getElementById('password').value;
const submitBtn = document.getElementById('submit-btn');
const btnText = document.getElementById('btn-text');
const spinner = document.getElementById('spinner');
const errorContainer = document.getElementById('error-container');
// Clear previous errors
errorContainer.innerHTML = '';
// Show loading state
submitBtn.disabled = true;
btnText.style.display = 'none';
spinner.style.display = 'block';
try {
const response = await fetch(`/public/notes/{{ token }}/verify`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: `password=${encodeURIComponent(password)}`
});
const data = await response.json();
if (data.success) {
window.location.href = data.redirect;
} else {
errorContainer.innerHTML = '<div class="error-message">Invalid password. Please try again.</div>';
submitBtn.disabled = false;
btnText.style.display = 'inline';
spinner.style.display = 'none';
}
} catch (error) {
errorContainer.innerHTML = '<div class="error-message">An error occurred. Please try again.</div>';
submitBtn.disabled = false;
btnText.style.display = 'inline';
spinner.style.display = 'none';
}
});
</script>
</body>
</html>