annotate src/account.html.luan @ 34:62d04ca486dd

UI
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 12 Nov 2024 16:08:24 -0700
parents 5a56297713a3
children 7ea33179592a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local Io = require "luan:Io.luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local Http = require "luan:http/Http.luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local Shared = require "site:/lib/Shared.luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local head = Shared.head or error()
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local header = Shared.header or error()
5
a49866b52cc2 login to chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 4
diff changeset
8 local Utils = require "site:/lib/Utils.luan"
a49866b52cc2 login to chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 4
diff changeset
9 local base_url = Utils.base_url or error()
a49866b52cc2 login to chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 4
diff changeset
10 local User = require "site:/lib/User.luan"
a49866b52cc2 login to chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 4
diff changeset
11 local current_user = User.current_required or error()
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 return function()
5
a49866b52cc2 login to chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 4
diff changeset
15 local user = current_user()
a49866b52cc2 login to chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 4
diff changeset
16 if user == nil then return end
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 Io.stdout = Http.response.text_writer()
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 %>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 <!doctype html>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 <html>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 <head>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 <% head() %>
20
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
23 <script>
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
24 'use strict';
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
25
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
26 function deleteUser() {
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
27 let dialog = document.querySelector('dialog[delete_user]');
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
28 openModal(dialog);
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
29 }
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
30
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
31 function doDeleteUser(el) {
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
32 closeModal(el);
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
33 ajax('delete_user.js');
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
34 }
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
35 </script>
34
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
36 <style>
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
37 div[content] {
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
38 margin-left: auto;
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
39 margin-right: auto;
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
40 width: fit-content;
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
41 }
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
42 h1 {
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
43 text-align: center;
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
44 }
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
45 </style>
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 </head>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
47 <body>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48 <% header() %>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 <div content>
3
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
50 <h1>Your Account</h1>
21
5a56297713a3 move chat to home
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
51 <p><a href="about.html">About Web Chat</a></p>
5a56297713a3 move chat to home
Franklin Schmidt <fschmidt@gmail.com>
parents: 20
diff changeset
52 <p>Your URL: <%= base_url() %>/?with=<%=user.email%></p>
34
Franklin Schmidt <fschmidt@gmail.com>
parents: 21
diff changeset
53 <p><a href="javascript:logout()">Logout</a></p>
20
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
54 <p><a href="javascript:deleteUser()">Delete account</a></p>
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55 </div>
20
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
56 <dialog delete_user>
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
57 <h2>Delete Account</h2>
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
58 <p>Are you sure that you want to delete your account?</p>
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
59 <div buttons>
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
60 <button cancel onclick="closeModal(this)">Cancel</button>
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
61 <button go onclick="doDeleteUser(this)">Delete</button>
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
62 </div>
dade6a560494 add dialogs
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
63 </dialog>
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
64 </body>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
65 </html>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
66 <%
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
67 end