Mercurial Hosting > chat
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 40:7ea33179592a | 41:818697418dbe |
|---|---|
| 14 | 14 |
| 15 | 15 |
| 16 return function() | 16 return function() |
| 17 local user = current_user() | 17 local user = current_user() |
| 18 if user == nil then return end | 18 if user == nil then return end |
| 19 local notify_email = user.notify_email | |
| 20 Io.stdout = Http.response.text_writer() | 19 Io.stdout = Http.response.text_writer() |
| 21 %> | 20 %> |
| 22 <!doctype html> | 21 <!doctype html> |
| 23 <html> | 22 <html> |
| 24 <head> | 23 <head> |
| 25 <% head() %> | 24 <% head() %> |
| 26 <script> | 25 <script> |
| 27 'use strict'; | 26 'use strict'; |
| 28 | 27 |
| 29 let notifyEmail = <%= json_string(notify_email or "") %>; | 28 let notifyEmail = <%= json_string(user.notify_email or "") %>; |
| 30 let multiNotify = <%= user.multi_notify %>; | 29 let multiNotify = <%= user.multi_notify %>; |
| 30 let voice = <%= json_string(user.voice_url or "") %>; | |
| 31 | 31 |
| 32 function showNotify() { | 32 function showNotify() { |
| 33 let span = document.querySelector('span[notify]'); | 33 let span = document.querySelector('span[notify]'); |
| 34 span.textContent = notifyEmail ? `Send notifications to ${notifyEmail}` : 'No notifications' | 34 span.textContent = notifyEmail ? `Send notifications to ${notifyEmail}` : 'No notifications'; |
| 35 } | 35 } |
| 36 | 36 |
| 37 function editNotify() { | 37 function editNotify() { |
| 38 let dialog = document.querySelector('dialog[edit_notify]'); | 38 let dialog = document.querySelector('dialog[edit_notify]'); |
| 39 let input = dialog.querySelector('input[name=notify_email]'); | 39 let input = dialog.querySelector('input[name=notify_email]'); |
| 52 closeModal(input); | 52 closeModal(input); |
| 53 showNotify(); | 53 showNotify(); |
| 54 ajax(`save_notify.js?email=${encodeURIComponent(notifyEmail)}&multi=${multiNotify}`); | 54 ajax(`save_notify.js?email=${encodeURIComponent(notifyEmail)}&multi=${multiNotify}`); |
| 55 } | 55 } |
| 56 | 56 |
| 57 function showVoice() { | |
| 58 let span = document.querySelector('span[voice]'); | |
| 59 span.textContent = voice ? `Your voice URL: ${voice}` : 'No voice URL'; | |
| 60 } | |
| 61 | |
| 62 function editVoice() { | |
| 63 let dialog = document.querySelector('dialog[edit_voice]'); | |
| 64 let input = dialog.querySelector('input[name=voice]'); | |
| 65 input.value = voice; | |
| 66 openModal(dialog); | |
| 67 } | |
| 68 | |
| 69 function saveVoice() { | |
| 70 let dialog = document.querySelector('dialog[edit_voice]'); | |
| 71 let input = dialog.querySelector('input[name=voice]'); | |
| 72 voice = input.value; | |
| 73 closeModal(input); | |
| 74 showVoice(); | |
| 75 ajax(`save_voice.js?url=${encodeURIComponent(voice)}`); | |
| 76 } | |
| 77 | |
| 57 function deleteUser() { | 78 function deleteUser() { |
| 58 let dialog = document.querySelector('dialog[delete_user]'); | 79 let dialog = document.querySelector('dialog[delete_user]'); |
| 59 openModal(dialog); | 80 openModal(dialog); |
| 60 } | 81 } |
| 61 | 82 |
| 64 ajax('delete_user.js'); | 85 ajax('delete_user.js'); |
| 65 } | 86 } |
| 66 | 87 |
| 67 function init() { | 88 function init() { |
| 68 showNotify(); | 89 showNotify(); |
| 90 showVoice(); | |
| 69 } | 91 } |
| 70 </script> | 92 </script> |
| 71 <style> | 93 <style> |
| 72 div[content] { | 94 div[content] { |
| 73 margin-left: auto; | 95 margin-left: auto; |
| 77 h1 { | 99 h1 { |
| 78 text-align: center; | 100 text-align: center; |
| 79 } | 101 } |
| 80 input[name=notify_email] { | 102 input[name=notify_email] { |
| 81 width: 300px; | 103 width: 300px; |
| 104 max-width: 100%; | |
| 105 } | |
| 106 input[name=voice] { | |
| 107 width: 500px; | |
| 108 max-width: 100%; | |
| 82 } | 109 } |
| 83 span[note] { | 110 span[note] { |
| 84 font-size: small; | 111 font-size: small; |
| 85 } | 112 } |
| 86 </style> | 113 </style> |
| 90 <div content> | 117 <div content> |
| 91 <h1>Your Account</h1> | 118 <h1>Your Account</h1> |
| 92 <p><a href="about.html">About Web Chat</a></p> | 119 <p><a href="about.html">About Web Chat</a></p> |
| 93 <p>Your URL: <%= base_url() %>/?with=<%=user.email%></p> | 120 <p>Your URL: <%= base_url() %>/?with=<%=user.email%></p> |
| 94 <p><span notify></span> <a href="javascript:editNotify()">Edit</a></p> | 121 <p><span notify></span> <a href="javascript:editNotify()">Edit</a></p> |
| 122 <p><span voice></span> <a href="javascript:editVoice()">Edit</a></p> | |
| 95 <p><a href="javascript:logout()">Logout</a></p> | 123 <p><a href="javascript:logout()">Logout</a></p> |
| 96 <p><a href="javascript:deleteUser()">Delete account</a></p> | 124 <p><a href="javascript:deleteUser()">Delete account</a></p> |
| 97 </div> | 125 </div> |
| 98 <dialog edit_notify> | 126 <dialog edit_notify> |
| 99 <h2>Edit Notification</h2> | 127 <h2>Edit Notification</h2> |
| 117 <button type=button cancel onclick="closeModal(this)">Cancel</button> | 145 <button type=button cancel onclick="closeModal(this)">Cancel</button> |
| 118 <button type=submit go>Save</button> | 146 <button type=submit go>Save</button> |
| 119 </div> | 147 </div> |
| 120 </form> | 148 </form> |
| 121 </dialog> | 149 </dialog> |
| 150 <dialog edit_voice> | |
| 151 <h2>Edit Voice URL</h2> | |
| 152 <form action="javascript:saveVoice()"> | |
| 153 <p> | |
| 154 <label>URL for receiving voice calls</label><br> | |
| 155 <input type=url name=voice><br> | |
| 156 <span note>Leave blank for no voice URL</span> | |
| 157 </p> | |
| 158 <div buttons> | |
| 159 <button type=button cancel onclick="closeModal(this)">Cancel</button> | |
| 160 <button type=submit go>Save</button> | |
| 161 </div> | |
| 162 </form> | |
| 163 </dialog> | |
| 122 <dialog delete_user> | 164 <dialog delete_user> |
| 123 <h2>Delete Account</h2> | 165 <h2>Delete Account</h2> |
| 124 <p>Are you sure that you want to delete your account?</p> | 166 <p>Are you sure that you want to delete your account?</p> |
| 125 <div buttons> | 167 <div buttons> |
| 126 <button cancel onclick="closeModal(this)">Cancel</button> | 168 <button cancel onclick="closeModal(this)">Cancel</button> |
