Mercurial Hosting > chat
diff src/account.html.luan @ 41:818697418dbe
add voice link
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 27 Feb 2025 19:05:57 -0700 |
parents | 7ea33179592a |
children | 89d3ddd302c7 |
line wrap: on
line diff
--- a/src/account.html.luan Thu Feb 27 16:44:20 2025 -0700 +++ b/src/account.html.luan Thu Feb 27 19:05:57 2025 -0700 @@ -16,7 +16,6 @@ return function() local user = current_user() if user == nil then return end - local notify_email = user.notify_email Io.stdout = Http.response.text_writer() %> <!doctype html> @@ -26,12 +25,13 @@ <script> 'use strict'; - let notifyEmail = <%= json_string(notify_email or "") %>; + let notifyEmail = <%= json_string(user.notify_email or "") %>; let multiNotify = <%= user.multi_notify %>; + let voice = <%= json_string(user.voice_url or "") %>; function showNotify() { let span = document.querySelector('span[notify]'); - span.textContent = notifyEmail ? `Send notifications to ${notifyEmail}` : 'No notifications' + span.textContent = notifyEmail ? `Send notifications to ${notifyEmail}` : 'No notifications'; } function editNotify() { @@ -54,6 +54,27 @@ ajax(`save_notify.js?email=${encodeURIComponent(notifyEmail)}&multi=${multiNotify}`); } + function showVoice() { + let span = document.querySelector('span[voice]'); + span.textContent = voice ? `Your voice URL: ${voice}` : 'No voice URL'; + } + + function editVoice() { + let dialog = document.querySelector('dialog[edit_voice]'); + let input = dialog.querySelector('input[name=voice]'); + input.value = voice; + openModal(dialog); + } + + function saveVoice() { + let dialog = document.querySelector('dialog[edit_voice]'); + let input = dialog.querySelector('input[name=voice]'); + voice = input.value; + closeModal(input); + showVoice(); + ajax(`save_voice.js?url=${encodeURIComponent(voice)}`); + } + function deleteUser() { let dialog = document.querySelector('dialog[delete_user]'); openModal(dialog); @@ -66,6 +87,7 @@ function init() { showNotify(); + showVoice(); } </script> <style> @@ -79,6 +101,11 @@ } input[name=notify_email] { width: 300px; + max-width: 100%; + } + input[name=voice] { + width: 500px; + max-width: 100%; } span[note] { font-size: small; @@ -92,6 +119,7 @@ <p><a href="about.html">About Web Chat</a></p> <p>Your URL: <%= base_url() %>/?with=<%=user.email%></p> <p><span notify></span> <a href="javascript:editNotify()">Edit</a></p> + <p><span voice></span> <a href="javascript:editVoice()">Edit</a></p> <p><a href="javascript:logout()">Logout</a></p> <p><a href="javascript:deleteUser()">Delete account</a></p> </div> @@ -119,6 +147,20 @@ </div> </form> </dialog> + <dialog edit_voice> + <h2>Edit Voice URL</h2> + <form action="javascript:saveVoice()"> + <p> + <label>URL for receiving voice calls</label><br> + <input type=url name=voice><br> + <span note>Leave blank for no voice URL</span> + </p> + <div buttons> + <button type=button cancel onclick="closeModal(this)">Cancel</button> + <button type=submit go>Save</button> + </div> + </form> + </dialog> <dialog delete_user> <h2>Delete Account</h2> <p>Are you sure that you want to delete your account?</p>