fixed indents
This commit is contained in:
+244
-244
@@ -335,115 +335,115 @@ data:
|
||||
</div>'''
|
||||
|
||||
html = f"""<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
:root {{
|
||||
--accent: #{safe_accent};
|
||||
--accent-20: #{safe_accent}33;
|
||||
--accent-40: #{safe_accent}66;
|
||||
--accent-60: #{safe_accent}99;
|
||||
--bgcolor: #{safe_bgcolor};
|
||||
}}
|
||||
* {{ margin: 0; padding: 0; box-sizing: border-box; }}
|
||||
html, body {{ background: var(--bgcolor); height: 100%; }}
|
||||
body {{ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: rgba(255,255,255,0.9); }}
|
||||
.container {{ display: flex; flex-direction: column; height: 100%; padding: 8px; gap: 8px; }}
|
||||
.todo-list {{ flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }}
|
||||
.todo-item {{
|
||||
display: flex; align-items: center; gap: 8px; padding: 8px 10px;
|
||||
background: rgba(255,255,255,0.04); border-radius: 6px;
|
||||
transition: background 0.15s;
|
||||
}}
|
||||
.todo-item:hover {{ background: rgba(255,255,255,0.08); }}
|
||||
.todo-item:hover .todo-delete {{ opacity: 1; }}
|
||||
.todo-item.done .todo-text {{ opacity: 0.5; text-decoration: line-through; }}
|
||||
.todo-check {{
|
||||
width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent);
|
||||
flex-shrink: 0;
|
||||
}}
|
||||
.todo-text {{ flex: 1; font-size: 14px; line-height: 1.4; word-break: break-word; }}
|
||||
.todo-delete {{
|
||||
opacity: 0; background: none; border: none; cursor: pointer;
|
||||
font-size: 14px; padding: 4px; transition: opacity 0.15s;
|
||||
}}
|
||||
.todo-delete:hover {{ transform: scale(1.1); }}
|
||||
.add-form {{ display: flex; gap: 8px; }}
|
||||
.add-input {{
|
||||
flex: 1; padding: 10px 12px; border: 1px solid var(--accent-20);
|
||||
background: rgba(255,255,255,0.06); border-radius: 6px;
|
||||
color: rgba(255,255,255,0.9); font-size: 14px; outline: none;
|
||||
}}
|
||||
.add-input:focus {{ border-color: var(--accent-40); background: rgba(255,255,255,0.1); }}
|
||||
.add-input::placeholder {{ color: var(--accent-40); }}
|
||||
.add-btn {{
|
||||
padding: 10px 16px; background: var(--accent-20); border: none;
|
||||
border-radius: 6px; color: var(--accent); font-size: 14px; cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
}}
|
||||
.add-btn:hover {{ background: var(--accent-40); }}
|
||||
.status {{ font-size: 11px; text-align: center; min-height: 16px; opacity: 0.6; }}
|
||||
.status.error {{ color: #f87171; opacity: 1; }}
|
||||
.todo-list::-webkit-scrollbar {{ width: 6px; }}
|
||||
.todo-list::-webkit-scrollbar-track {{ background: transparent; }}
|
||||
.todo-list::-webkit-scrollbar-thumb {{ background: var(--accent-40); border-radius: 3px; }}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="add-form">
|
||||
<input type="text" class="add-input" id="newTodo" placeholder="+ Add a task" onkeypress="if(event.key==='Enter')addTodo()">
|
||||
<button class="add-btn" onclick="addTodo()">Add</button>
|
||||
</div>
|
||||
<div class="todo-list" id="todoList">{todo_html if todo_html else '<div style="opacity:0.5;text-align:center;padding:20px;">No tasks yet</div>'}</div>
|
||||
<div class="status" id="status"></div>
|
||||
</div>
|
||||
<script>
|
||||
const apiKey = '{expected_key}';
|
||||
const user = '{safe_user}';
|
||||
const baseUrl = '/userdata/todo';
|
||||
|
||||
function showStatus(msg, isError) {{
|
||||
const s = document.getElementById('status');
|
||||
s.textContent = msg;
|
||||
s.className = 'status' + (isError ? ' error' : '');
|
||||
if (!isError) setTimeout(() => s.textContent = '', 2000);
|
||||
}}
|
||||
|
||||
async function addTodo() {{
|
||||
const input = document.getElementById('newTodo');
|
||||
const text = input.value.trim();
|
||||
if (!text) return;
|
||||
try {{
|
||||
const r = await fetch(baseUrl + '/add?key=' + apiKey + '&user=' + user, {{
|
||||
method: 'POST',
|
||||
headers: {{ 'Content-Type': 'application/json' }},
|
||||
body: JSON.stringify({{ text: text }})
|
||||
}});
|
||||
if (r.ok) {{ input.value = ''; location.reload(); }}
|
||||
else showStatus('Failed to add', true);
|
||||
}} catch(e) {{ showStatus('Error: ' + e.message, true); }}
|
||||
}}
|
||||
|
||||
async function toggleTodo(index) {{
|
||||
try {{
|
||||
const r = await fetch(baseUrl + '/toggle?key=' + apiKey + '&user=' + user + '&index=' + index, {{ method: 'POST' }});
|
||||
if (!r.ok) showStatus('Failed to update', true);
|
||||
}} catch(e) {{ showStatus('Error: ' + e.message, true); }}
|
||||
}}
|
||||
|
||||
async function deleteTodo(index) {{
|
||||
try {{
|
||||
const r = await fetch(baseUrl + '/delete?key=' + apiKey + '&user=' + user + '&index=' + index, {{ method: 'POST' }});
|
||||
if (r.ok) location.reload();
|
||||
else showStatus('Failed to delete', true);
|
||||
}} catch(e) {{ showStatus('Error: ' + e.message, true); }}
|
||||
}}
|
||||
</script>
|
||||
</body>
|
||||
</html>"""
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
:root {{
|
||||
--accent: #{safe_accent};
|
||||
--accent-20: #{safe_accent}33;
|
||||
--accent-40: #{safe_accent}66;
|
||||
--accent-60: #{safe_accent}99;
|
||||
--bgcolor: #{safe_bgcolor};
|
||||
}}
|
||||
* {{ margin: 0; padding: 0; box-sizing: border-box; }}
|
||||
html, body {{ background: var(--bgcolor); height: 100%; }}
|
||||
body {{ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: rgba(255,255,255,0.9); }}
|
||||
.container {{ display: flex; flex-direction: column; height: 100%; padding: 8px; gap: 8px; }}
|
||||
.todo-list {{ flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }}
|
||||
.todo-item {{
|
||||
display: flex; align-items: center; gap: 8px; padding: 8px 10px;
|
||||
background: rgba(255,255,255,0.04); border-radius: 6px;
|
||||
transition: background 0.15s;
|
||||
}}
|
||||
.todo-item:hover {{ background: rgba(255,255,255,0.08); }}
|
||||
.todo-item:hover .todo-delete {{ opacity: 1; }}
|
||||
.todo-item.done .todo-text {{ opacity: 0.5; text-decoration: line-through; }}
|
||||
.todo-check {{
|
||||
width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent);
|
||||
flex-shrink: 0;
|
||||
}}
|
||||
.todo-text {{ flex: 1; font-size: 14px; line-height: 1.4; word-break: break-word; }}
|
||||
.todo-delete {{
|
||||
opacity: 0; background: none; border: none; cursor: pointer;
|
||||
font-size: 14px; padding: 4px; transition: opacity 0.15s;
|
||||
}}
|
||||
.todo-delete:hover {{ transform: scale(1.1); }}
|
||||
.add-form {{ display: flex; gap: 8px; }}
|
||||
.add-input {{
|
||||
flex: 1; padding: 10px 12px; border: 1px solid var(--accent-20);
|
||||
background: rgba(255,255,255,0.06); border-radius: 6px;
|
||||
color: rgba(255,255,255,0.9); font-size: 14px; outline: none;
|
||||
}}
|
||||
.add-input:focus {{ border-color: var(--accent-40); background: rgba(255,255,255,0.1); }}
|
||||
.add-input::placeholder {{ color: var(--accent-40); }}
|
||||
.add-btn {{
|
||||
padding: 10px 16px; background: var(--accent-20); border: none;
|
||||
border-radius: 6px; color: var(--accent); font-size: 14px; cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
}}
|
||||
.add-btn:hover {{ background: var(--accent-40); }}
|
||||
.status {{ font-size: 11px; text-align: center; min-height: 16px; opacity: 0.6; }}
|
||||
.status.error {{ color: #f87171; opacity: 1; }}
|
||||
.todo-list::-webkit-scrollbar {{ width: 6px; }}
|
||||
.todo-list::-webkit-scrollbar-track {{ background: transparent; }}
|
||||
.todo-list::-webkit-scrollbar-thumb {{ background: var(--accent-40); border-radius: 3px; }}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="add-form">
|
||||
<input type="text" class="add-input" id="newTodo" placeholder="+ Add a task" onkeypress="if(event.key==='Enter')addTodo()">
|
||||
<button class="add-btn" onclick="addTodo()">Add</button>
|
||||
</div>
|
||||
<div class="todo-list" id="todoList">{todo_html if todo_html else '<div style="opacity:0.5;text-align:center;padding:20px;">No tasks yet</div>'}</div>
|
||||
<div class="status" id="status"></div>
|
||||
</div>
|
||||
<script>
|
||||
const apiKey = '{expected_key}';
|
||||
const user = '{safe_user}';
|
||||
const baseUrl = '/userdata/todo';
|
||||
|
||||
function showStatus(msg, isError) {{
|
||||
const s = document.getElementById('status');
|
||||
s.textContent = msg;
|
||||
s.className = 'status' + (isError ? ' error' : '');
|
||||
if (!isError) setTimeout(() => s.textContent = '', 2000);
|
||||
}}
|
||||
|
||||
async function addTodo() {{
|
||||
const input = document.getElementById('newTodo');
|
||||
const text = input.value.trim();
|
||||
if (!text) return;
|
||||
try {{
|
||||
const r = await fetch(baseUrl + '/add?key=' + apiKey + '&user=' + user, {{
|
||||
method: 'POST',
|
||||
headers: {{ 'Content-Type': 'application/json' }},
|
||||
body: JSON.stringify({{ text: text }})
|
||||
}});
|
||||
if (r.ok) {{ input.value = ''; location.reload(); }}
|
||||
else showStatus('Failed to add', true);
|
||||
}} catch(e) {{ showStatus('Error: ' + e.message, true); }}
|
||||
}}
|
||||
|
||||
async function toggleTodo(index) {{
|
||||
try {{
|
||||
const r = await fetch(baseUrl + '/toggle?key=' + apiKey + '&user=' + user + '&index=' + index, {{ method: 'POST' }});
|
||||
if (!r.ok) showStatus('Failed to update', true);
|
||||
}} catch(e) {{ showStatus('Error: ' + e.message, true); }}
|
||||
}}
|
||||
|
||||
async function deleteTodo(index) {{
|
||||
try {{
|
||||
const r = await fetch(baseUrl + '/delete?key=' + apiKey + '&user=' + user + '&index=' + index, {{ method: 'POST' }});
|
||||
if (r.ok) location.reload();
|
||||
else showStatus('Failed to delete', true);
|
||||
}} catch(e) {{ showStatus('Error: ' + e.message, true); }}
|
||||
}}
|
||||
</script>
|
||||
</body>
|
||||
</html>"""
|
||||
return Response(content=html, media_type="text/html")
|
||||
|
||||
@APP.post("/userdata/todo/add")
|
||||
@@ -515,144 +515,144 @@ data:
|
||||
quotes_html += f'<div class="quote-item" data-index="{i}"><span class="quote-text">{q_escaped}</span><button class="quote-delete" onclick="deleteQuote({i})">×</button></div>'
|
||||
|
||||
html = f"""<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
:root {{
|
||||
--accent: #{safe_accent};
|
||||
--accent-20: #{safe_accent}33;
|
||||
--accent-40: #{safe_accent}66;
|
||||
--accent-60: #{safe_accent}99;
|
||||
--bgcolor: #{safe_bgcolor};
|
||||
}}
|
||||
* {{ margin: 0; padding: 0; box-sizing: border-box; }}
|
||||
html, body {{ background: var(--bgcolor); height: 100%; }}
|
||||
body {{ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: rgba(255,255,255,0.9); }}
|
||||
.container {{ display: flex; flex-direction: column; height: 100%; padding: 12px; position: relative; }}
|
||||
.settings-btn {{
|
||||
position: absolute; top: 8px; right: 8px;
|
||||
background: none; border: none; cursor: pointer;
|
||||
font-size: 16px; opacity: 0.4; transition: opacity 0.15s;
|
||||
}}
|
||||
.settings-btn:hover {{ opacity: 0.8; }}
|
||||
.quote-display {{
|
||||
flex: 1; display: flex; align-items: center; justify-content: center;
|
||||
text-align: center; padding: 8px 28px;
|
||||
}}
|
||||
.quote-text-main {{
|
||||
font-size: 15px; line-height: 1.5; font-style: italic;
|
||||
color: var(--accent); opacity: 0.9;
|
||||
}}
|
||||
.quote-count {{
|
||||
font-size: 11px; opacity: 0.4; text-align: center; padding-bottom: 4px;
|
||||
}}
|
||||
/* Modal */
|
||||
.modal-overlay {{
|
||||
display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7);
|
||||
align-items: center; justify-content: center; z-index: 1000;
|
||||
}}
|
||||
.modal-overlay.open {{ display: flex; }}
|
||||
.modal {{
|
||||
background: #1a1a2e; border-radius: 12px; width: 90%; max-width: 400px;
|
||||
max-height: 80%; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,0.5);
|
||||
}}
|
||||
.modal-header {{
|
||||
display: flex; justify-content: space-between; align-items: center;
|
||||
padding: 16px; border-bottom: 1px solid rgba(255,255,255,0.1);
|
||||
}}
|
||||
.modal-title {{ font-size: 16px; font-weight: 600; }}
|
||||
.modal-close {{
|
||||
background: none; border: none; font-size: 24px; cursor: pointer;
|
||||
color: rgba(255,255,255,0.6); line-height: 1;
|
||||
}}
|
||||
.modal-close:hover {{ color: rgba(255,255,255,0.9); }}
|
||||
.modal-body {{ flex: 1; overflow-y: auto; padding: 12px; }}
|
||||
.quote-item {{
|
||||
display: flex; align-items: flex-start; gap: 8px; padding: 10px;
|
||||
background: rgba(255,255,255,0.04); border-radius: 6px; margin-bottom: 8px;
|
||||
}}
|
||||
.quote-item .quote-text {{ flex: 1; font-size: 13px; line-height: 1.4; word-break: break-word; }}
|
||||
.quote-delete {{
|
||||
background: none; border: none; cursor: pointer; font-size: 18px;
|
||||
color: rgba(255,255,255,0.4); padding: 0 4px; line-height: 1;
|
||||
}}
|
||||
.quote-delete:hover {{ color: #f87171; }}
|
||||
.modal-footer {{ padding: 12px; border-top: 1px solid rgba(255,255,255,0.1); }}
|
||||
.add-form {{ display: flex; gap: 8px; }}
|
||||
.add-input {{
|
||||
flex: 1; padding: 10px 12px; border: 1px solid var(--accent-20);
|
||||
background: rgba(255,255,255,0.06); border-radius: 6px;
|
||||
color: rgba(255,255,255,0.9); font-size: 14px; outline: none;
|
||||
}}
|
||||
.add-input:focus {{ border-color: var(--accent-40); }}
|
||||
.add-btn {{
|
||||
padding: 10px 16px; background: var(--accent-20); border: none;
|
||||
border-radius: 6px; color: var(--accent); font-size: 14px; cursor: pointer;
|
||||
}}
|
||||
.add-btn:hover {{ background: var(--accent-40); }}
|
||||
.empty-state {{ text-align: center; padding: 20px; opacity: 0.5; font-size: 13px; }}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<button class="settings-btn" onclick="openModal()" title="Manage quotes">⚙️</button>
|
||||
<div class="quote-display">
|
||||
<div class="quote-text-main">"{current_quote_escaped}"</div>
|
||||
</div>
|
||||
<div class="quote-count">{len(quotes)} quote{'s' if len(quotes) != 1 else ''}</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-overlay" id="modal" onclick="if(event.target===this)closeModal()">
|
||||
<div class="modal">
|
||||
<div class="modal-header">
|
||||
<div class="modal-title">Manage Quotes</div>
|
||||
<button class="modal-close" onclick="closeModal()">×</button>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
:root {{
|
||||
--accent: #{safe_accent};
|
||||
--accent-20: #{safe_accent}33;
|
||||
--accent-40: #{safe_accent}66;
|
||||
--accent-60: #{safe_accent}99;
|
||||
--bgcolor: #{safe_bgcolor};
|
||||
}}
|
||||
* {{ margin: 0; padding: 0; box-sizing: border-box; }}
|
||||
html, body {{ background: var(--bgcolor); height: 100%; }}
|
||||
body {{ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: rgba(255,255,255,0.9); }}
|
||||
.container {{ display: flex; flex-direction: column; height: 100%; padding: 12px; position: relative; }}
|
||||
.settings-btn {{
|
||||
position: absolute; top: 8px; right: 8px;
|
||||
background: none; border: none; cursor: pointer;
|
||||
font-size: 16px; opacity: 0.4; transition: opacity 0.15s;
|
||||
}}
|
||||
.settings-btn:hover {{ opacity: 0.8; }}
|
||||
.quote-display {{
|
||||
flex: 1; display: flex; align-items: center; justify-content: center;
|
||||
text-align: center; padding: 8px 28px;
|
||||
}}
|
||||
.quote-text-main {{
|
||||
font-size: 15px; line-height: 1.5; font-style: italic;
|
||||
color: var(--accent); opacity: 0.9;
|
||||
}}
|
||||
.quote-count {{
|
||||
font-size: 11px; opacity: 0.4; text-align: center; padding-bottom: 4px;
|
||||
}}
|
||||
/* Modal */
|
||||
.modal-overlay {{
|
||||
display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7);
|
||||
align-items: center; justify-content: center; z-index: 1000;
|
||||
}}
|
||||
.modal-overlay.open {{ display: flex; }}
|
||||
.modal {{
|
||||
background: #1a1a2e; border-radius: 12px; width: 90%; max-width: 400px;
|
||||
max-height: 80%; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,0.5);
|
||||
}}
|
||||
.modal-header {{
|
||||
display: flex; justify-content: space-between; align-items: center;
|
||||
padding: 16px; border-bottom: 1px solid rgba(255,255,255,0.1);
|
||||
}}
|
||||
.modal-title {{ font-size: 16px; font-weight: 600; }}
|
||||
.modal-close {{
|
||||
background: none; border: none; font-size: 24px; cursor: pointer;
|
||||
color: rgba(255,255,255,0.6); line-height: 1;
|
||||
}}
|
||||
.modal-close:hover {{ color: rgba(255,255,255,0.9); }}
|
||||
.modal-body {{ flex: 1; overflow-y: auto; padding: 12px; }}
|
||||
.quote-item {{
|
||||
display: flex; align-items: flex-start; gap: 8px; padding: 10px;
|
||||
background: rgba(255,255,255,0.04); border-radius: 6px; margin-bottom: 8px;
|
||||
}}
|
||||
.quote-item .quote-text {{ flex: 1; font-size: 13px; line-height: 1.4; word-break: break-word; }}
|
||||
.quote-delete {{
|
||||
background: none; border: none; cursor: pointer; font-size: 18px;
|
||||
color: rgba(255,255,255,0.4); padding: 0 4px; line-height: 1;
|
||||
}}
|
||||
.quote-delete:hover {{ color: #f87171; }}
|
||||
.modal-footer {{ padding: 12px; border-top: 1px solid rgba(255,255,255,0.1); }}
|
||||
.add-form {{ display: flex; gap: 8px; }}
|
||||
.add-input {{
|
||||
flex: 1; padding: 10px 12px; border: 1px solid var(--accent-20);
|
||||
background: rgba(255,255,255,0.06); border-radius: 6px;
|
||||
color: rgba(255,255,255,0.9); font-size: 14px; outline: none;
|
||||
}}
|
||||
.add-input:focus {{ border-color: var(--accent-40); }}
|
||||
.add-btn {{
|
||||
padding: 10px 16px; background: var(--accent-20); border: none;
|
||||
border-radius: 6px; color: var(--accent); font-size: 14px; cursor: pointer;
|
||||
}}
|
||||
.add-btn:hover {{ background: var(--accent-40); }}
|
||||
.empty-state {{ text-align: center; padding: 20px; opacity: 0.5; font-size: 13px; }}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<button class="settings-btn" onclick="openModal()" title="Manage quotes">⚙️</button>
|
||||
<div class="quote-display">
|
||||
<div class="quote-text-main">"{current_quote_escaped}"</div>
|
||||
</div>
|
||||
<div class="quote-count">{len(quotes)} quote{'s' if len(quotes) != 1 else ''}</div>
|
||||
</div>
|
||||
<div class="modal-body" id="quotesList">
|
||||
{quotes_html if quotes_html else '<div class="empty-state">No quotes yet. Add your first one below!</div>'}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="add-form">
|
||||
<input type="text" class="add-input" id="newQuote" placeholder="Add a new quote..." onkeypress="if(event.key==='Enter')addQuote()">
|
||||
<button class="add-btn" onclick="addQuote()">Add</button>
|
||||
|
||||
<div class="modal-overlay" id="modal" onclick="if(event.target===this)closeModal()">
|
||||
<div class="modal">
|
||||
<div class="modal-header">
|
||||
<div class="modal-title">Manage Quotes</div>
|
||||
<button class="modal-close" onclick="closeModal()">×</button>
|
||||
</div>
|
||||
<div class="modal-body" id="quotesList">
|
||||
{quotes_html if quotes_html else '<div class="empty-state">No quotes yet. Add your first one below!</div>'}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="add-form">
|
||||
<input type="text" class="add-input" id="newQuote" placeholder="Add a new quote..." onkeypress="if(event.key==='Enter')addQuote()">
|
||||
<button class="add-btn" onclick="addQuote()">Add</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const apiKey = '{expected_key}';
|
||||
const user = '{safe_user}';
|
||||
const baseUrl = '/userdata/motivation';
|
||||
|
||||
function openModal() {{ document.getElementById('modal').classList.add('open'); }}
|
||||
function closeModal() {{ document.getElementById('modal').classList.remove('open'); }}
|
||||
|
||||
async function addQuote() {{
|
||||
const input = document.getElementById('newQuote');
|
||||
const text = input.value.trim();
|
||||
if (!text) return;
|
||||
try {{
|
||||
const r = await fetch(baseUrl + '/add?key=' + apiKey + '&user=' + user, {{
|
||||
method: 'POST',
|
||||
headers: {{ 'Content-Type': 'application/json' }},
|
||||
body: JSON.stringify({{ text: text }})
|
||||
}});
|
||||
if (r.ok) {{ input.value = ''; location.reload(); }}
|
||||
}} catch(e) {{ console.error(e); }}
|
||||
}}
|
||||
|
||||
async function deleteQuote(index) {{
|
||||
try {{
|
||||
const r = await fetch(baseUrl + '/delete?key=' + apiKey + '&user=' + user + '&index=' + index, {{ method: 'POST' }});
|
||||
if (r.ok) location.reload();
|
||||
}} catch(e) {{ console.error(e); }}
|
||||
}}
|
||||
</script>
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
<script>
|
||||
const apiKey = '{expected_key}';
|
||||
const user = '{safe_user}';
|
||||
const baseUrl = '/userdata/motivation';
|
||||
|
||||
function openModal() {{ document.getElementById('modal').classList.add('open'); }}
|
||||
function closeModal() {{ document.getElementById('modal').classList.remove('open'); }}
|
||||
|
||||
async function addQuote() {{
|
||||
const input = document.getElementById('newQuote');
|
||||
const text = input.value.trim();
|
||||
if (!text) return;
|
||||
try {{
|
||||
const r = await fetch(baseUrl + '/add?key=' + apiKey + '&user=' + user, {{
|
||||
method: 'POST',
|
||||
headers: {{ 'Content-Type': 'application/json' }},
|
||||
body: JSON.stringify({{ text: text }})
|
||||
}});
|
||||
if (r.ok) {{ input.value = ''; location.reload(); }}
|
||||
}} catch(e) {{ console.error(e); }}
|
||||
}}
|
||||
|
||||
async function deleteQuote(index) {{
|
||||
try {{
|
||||
const r = await fetch(baseUrl + '/delete?key=' + apiKey + '&user=' + user + '&index=' + index, {{ method: 'POST' }});
|
||||
if (r.ok) location.reload();
|
||||
}} catch(e) {{ console.error(e); }}
|
||||
}}
|
||||
</script>
|
||||
</body>
|
||||
</html>"""
|
||||
return Response(content=html, media_type="text/html")
|
||||
|
||||
@APP.post("/userdata/motivation/add")
|
||||
|
||||
Reference in New Issue
Block a user