|
1
|
|
|
"use strict"; |
|
2
|
|
|
|
|
3
|
|
|
sodium.ready.then(function() { |
|
4
|
|
|
|
|
5
|
|
|
const ae = new AllEars(function(ok) { |
|
6
|
|
|
if (ok) { |
|
7
|
|
|
if (localStorage.greeting) { |
|
8
|
|
|
document.getElementById("greeting").textContent = localStorage.greeting; |
|
9
|
|
|
document.getElementById("txt_pg").value = localStorage.greeting; |
|
10
|
|
|
} else localStorage.greeting = document.getElementById("greeting").textContent; |
|
11
|
|
|
|
|
12
|
|
|
document.getElementById("txt_skey").style.background = "#466"; |
|
13
|
|
|
document.getElementById("txt_skey").maxLength = "64"; |
|
14
|
|
|
} else { |
|
15
|
|
|
console.log("Failed to load All-Ears"); |
|
|
|
|
|
|
16
|
|
|
} |
|
17
|
|
|
}); |
|
18
|
|
|
|
|
19
|
|
|
function TabState(cur, max, btnDele, btnUpdt) { |
|
20
|
|
|
this.cur = cur; |
|
21
|
|
|
this.max = max; |
|
22
|
|
|
this.btnDele = btnDele; |
|
23
|
|
|
this.btnUpdt = btnUpdt; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
const tabs = [ |
|
27
|
|
|
new TabState(0, 0, false, true), // Inbox |
|
28
|
|
|
new TabState(0, 0, false, true), // Outbx |
|
29
|
|
|
new TabState(0, 1, true, false), // Write |
|
30
|
|
|
new TabState(0, 2, false, false), // Notes |
|
31
|
|
|
new TabState(0, 2, false, true) // Tools |
|
32
|
|
|
]; |
|
33
|
|
|
|
|
34
|
|
|
let showHeaders = false; |
|
35
|
|
|
|
|
36
|
|
|
let tab = 0; |
|
37
|
|
|
const TAB_INBOX = 0; |
|
38
|
|
|
const TAB_DRBOX = 1; |
|
39
|
|
|
const TAB_WRITE = 2; |
|
40
|
|
|
const TAB_NOTES = 3; |
|
41
|
|
|
const TAB_TOOLS = 4; |
|
42
|
|
|
|
|
43
|
|
|
// Helper functions |
|
44
|
|
|
function getErrorMessage(err) { |
|
45
|
|
|
switch (err) { |
|
46
|
|
|
// 0x01-0x20 Client-side error codes |
|
47
|
|
|
case 0x01: return "Invalid input"; |
|
48
|
|
|
case 0x02: return "Only administrators can perform this action"; |
|
49
|
|
|
case 0x03: return "Failed connecting to server"; |
|
50
|
|
|
case 0x04: return "Invalid input to _FetchEncrypted"; |
|
51
|
|
|
case 0x05: return "Failed decrypting response from server"; |
|
52
|
|
|
case 0x06: return "Invalid response length"; |
|
53
|
|
|
case 0x07: return "Server responded with invalid data"; |
|
54
|
|
|
case 0x08: return "Addr32 encoding failed"; |
|
55
|
|
|
|
|
56
|
|
|
case 0x10: return "Message too short"; |
|
57
|
|
|
case 0x11: return "Name too long"; |
|
58
|
|
|
case 0x12: return "File too large"; |
|
59
|
|
|
|
|
60
|
|
|
case 0x17: return "Server failed decrypting the request"; // 400 |
|
61
|
|
|
case 0x18: return "Account does not exist"; // 403 |
|
62
|
|
|
case 0x19: return "Server failed checking account data"; // 500 |
|
63
|
|
|
case 0x20: return "Invalid status code in response"; |
|
64
|
|
|
|
|
65
|
|
|
// 0x21-0x2F Generic |
|
66
|
|
|
case 0x21: return ["FORMAT", "Invalid format"]; |
|
67
|
|
|
case 0x22: return ["ADMINONLY", "Only administrators can perform this action"]; |
|
68
|
|
|
case 0x23: return ["MISC", "Unknown error"]; |
|
69
|
|
|
case 0x24: return ["INTERNAL", "Internal server error"]; |
|
70
|
|
|
case 0x25: return ["TODO", "Functionality missing - in development"]; |
|
71
|
|
|
case 0x26: return ["FIXME", "Unexpected error encountered"]; |
|
72
|
|
|
case 0x2A: return ["NOTEXIST", "Item does not exist"]; |
|
73
|
|
|
|
|
74
|
|
|
// 0x30-0x3F Misc |
|
75
|
|
|
case 0x30: return ["ACCOUNT_DELETE_NOSTORAGE", "Account data was deleted, but deleting message data failed due to an internal error."]; |
|
76
|
|
|
|
|
77
|
|
|
// 0xDA-0xDF Address/Create|Delete|Update |
|
78
|
|
|
case 0xDA: return ["ADDRESS_CREATE_INUSE", "Address already taken"]; |
|
79
|
|
|
case 0xDB: return ["ADDRESS_CREATE_ATLIMIT", "Limit reached - unable to register additional addresses"]; |
|
80
|
|
|
case 0xDC: return ["ADDRESS_DELETE_SOMEFOUND", "Delete successful, but some addresses were not found"]; |
|
81
|
|
|
case 0xDD: return ["ADDRESS_DELETE_NONEFOUND", "No such address(es)"]; |
|
82
|
|
|
case 0xDE: return ["ADDRESS_UPDATE_SOMEFOUND", "Partial success - some addresses not found"]; |
|
83
|
|
|
case 0xDF: return ["ADDRESS_UPDATE_NONEFOUND", "No update performed - address(es) not found"]; |
|
84
|
|
|
|
|
85
|
|
|
// 0xE0-0xEF Message/Create |
|
86
|
|
|
case 0xE0: return ["MESSAGE_CREATE_EXT_MINLEVEL", "Account level too low"]; |
|
87
|
|
|
case 0xE1: return ["MESSAGE_CREATE_EXT_FORMAT_FROM", "Malformed from-address"]; |
|
88
|
|
|
case 0xE2: return ["MESSAGE_CREATE_EXT_FORMAT_TO", "Malformed to-address"]; |
|
89
|
|
|
case 0xE3: return ["MESSAGE_CREATE_EXT_FORMAT_REPLYID", "Malformed reply-id"]; |
|
90
|
|
|
case 0xE4: return ["MESSAGE_CREATE_EXT_FORMAT_SUBJECT", "Malformed subject"]; |
|
91
|
|
|
case 0xE5: return ["MESSAGE_CREATE_EXT_INVALID_REPLYID", "Invalid reply-id"]; |
|
92
|
|
|
case 0xE6: return ["MESSAGE_CREATE_EXT_INVALID_FROM", "Invalid from-address"]; |
|
93
|
|
|
case 0xE7: return ["MESSAGE_CREATE_EXT_INVALID_TO", "Invalid to-address"]; |
|
94
|
|
|
case 0xE8: return ["MESSAGE_CREATE_EXT_BODY_SIZE", "Body too long or short"]; |
|
95
|
|
|
case 0xE9: return ["MESSAGE_CREATE_EXT_BODY_UTF8", "Body not UTF-8"]; |
|
96
|
|
|
case 0xEA: return ["MESSAGE_CREATE_EXT_BODY_CONTROL", "Body contains control characters"]; |
|
97
|
|
|
case 0xEB: return ["MESSAGE_CREATE_EXT_LINE_TOOLONG", "Body exceeds line-length limit"]; |
|
98
|
|
|
case 0xEC: return ["MESSAGE_CREATE_EXT_BODY_FORMAT", "Malformed body"]; |
|
99
|
|
|
case 0xED: return ["MESSAGE_CREATE_EXT_BODY_TOOSHORT", "Body too short"]; |
|
100
|
|
|
case 0xEE: return ["MESSAGE_CREATE_EXT_TODOMAIN", "Invalid to-address domain"]; |
|
101
|
|
|
// case 0xEF: return ["", ""]; |
|
102
|
|
|
|
|
103
|
|
|
// 0xF0-0xF9 Message/Create sendMail() |
|
104
|
|
|
case 0xF0: return ["MESSAGE_CREATE_SENDMAIL_GREET", "Failed greeting receiver server"]; |
|
105
|
|
|
case 0xF1: return ["MESSAGE_CREATE_SENDMAIL_EHLO", "EHLO command failed"]; |
|
106
|
|
|
case 0xF2: return ["MESSAGE_CREATE_SENDMAIL_STLS", "STARTTLS command failed"]; |
|
107
|
|
|
case 0xF3: return ["MESSAGE_CREATE_SENDMAIL_SHAKE", "TLS handshake failed"]; |
|
108
|
|
|
case 0xF4: return ["MESSAGE_CREATE_SENDMAIL_NOTLS", "TLS not available"]; |
|
109
|
|
|
case 0xF5: return ["MESSAGE_CREATE_SENDMAIL_MAIL", "MAIL command failed"]; |
|
110
|
|
|
case 0xF6: return ["MESSAGE_CREATE_SENDMAIL_RCPT", "RCPT command failed"]; |
|
111
|
|
|
case 0xF7: return ["MESSAGE_CREATE_SENDMAIL_DATA", "DATA command failed"]; |
|
112
|
|
|
case 0xF8: return ["MESSAGE_CREATE_SENDMAIL_BODY", "Sending body failed"]; |
|
113
|
|
|
// case 0xF9: return ["", ""]; |
|
114
|
|
|
|
|
115
|
|
|
// 0xFA-0xFF Message/Create Int |
|
116
|
|
|
case 0xFA: return ["MESSAGE_CREATE_INT_TOOSHORT", "Message too short"]; |
|
117
|
|
|
case 0xFB: return ["MESSAGE_CREATE_INT_TS_INVALID", "Invalid timestamp"]; |
|
118
|
|
|
case 0xFC: return ["MESSAGE_CREATE_INT_SUBJECT_SIZE", "Subject too long or short"]; |
|
119
|
|
|
case 0xFD: return ["MESSAGE_CREATE_INT_ADDR_NOTOWN", "Sender address not owned"]; |
|
120
|
|
|
case 0xFE: return ["MESSAGE_CREATE_INT_TO_NOTACCEPT", "Receiver address does not accept messages"]; |
|
121
|
|
|
case 0xFF: return ["MESSAGE_CREATE_INT_TO_SELF", "Sending to own account not allowed"]; |
|
122
|
|
|
|
|
123
|
|
|
default: return ["???", "Unknown error"]; |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
function errorDialog(err) { |
|
128
|
|
|
if (typeof(err) !== "number" || err < 1) return; |
|
129
|
|
|
|
|
130
|
|
|
let btnDisable = []; |
|
131
|
|
|
const buttons = document.querySelectorAll("nav > button"); |
|
132
|
|
|
buttons.forEach(function(btn) { |
|
133
|
|
|
btnDisable.push(btn.disabled); |
|
134
|
|
|
btn.disabled = true; |
|
135
|
|
|
}); |
|
136
|
|
|
|
|
137
|
|
|
const errMsg = getErrorMessage(err); |
|
138
|
|
|
|
|
139
|
|
|
const dlg = document.querySelector("dialog"); |
|
140
|
|
|
dlg.children[0].style.height = getComputedStyle(document.querySelector("#main1 > div[class='mid']")).height; |
|
141
|
|
|
dlg.querySelector("h1").textContent = "ERROR 0x" + err.toString(16).padStart(2, "0").toUpperCase(); |
|
142
|
|
|
dlg.querySelector("p").textContent = (typeof(errMsg) === "string") ? errMsg : errMsg[1]; |
|
143
|
|
|
dlg.show(); |
|
144
|
|
|
|
|
145
|
|
|
document.querySelector("dialog > div").onclick = function() { |
|
146
|
|
|
buttons.forEach(function(btn, i) {btn.disabled = btnDisable[i];}); |
|
147
|
|
|
dlg.close(); |
|
148
|
|
|
}; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
function getCountryName(countryCode) { |
|
152
|
|
|
switch (countryCode) { |
|
153
|
|
|
case "??": return "Unknown"; |
|
154
|
|
|
case "DZ": return "Algeria"; |
|
155
|
|
|
case "AO": return "Angola"; |
|
156
|
|
|
case "BJ": return "Benin"; |
|
157
|
|
|
case "BW": return "Botswana"; |
|
158
|
|
|
case "BF": return "Burkina Faso"; |
|
159
|
|
|
case "BI": return "Burundi"; |
|
160
|
|
|
case "CV": return "Cabo Verde"; |
|
161
|
|
|
case "CM": return "Cameroon"; |
|
162
|
|
|
case "CF": return "Central African Republic"; |
|
163
|
|
|
case "TD": return "Chad"; |
|
164
|
|
|
case "KM": return "Comoros"; |
|
165
|
|
|
case "CD": return "Congo"; |
|
166
|
|
|
case "DJ": return "Djibouti"; |
|
167
|
|
|
case "EG": return "Egypt"; |
|
168
|
|
|
case "GQ": return "Equatorial Guinea"; |
|
169
|
|
|
case "ER": return "Eritrea"; |
|
170
|
|
|
case "SZ": return "Eswatini"; |
|
171
|
|
|
case "ET": return "Ethiopia"; |
|
172
|
|
|
case "GA": return "Gabon"; |
|
173
|
|
|
case "GM": return "Gambia"; |
|
174
|
|
|
case "GH": return "Ghana"; |
|
175
|
|
|
case "GW": return "Guinea-Bissau"; |
|
176
|
|
|
case "GN": return "Guinea"; |
|
177
|
|
|
case "CI": return "Ivory Coast"; |
|
178
|
|
|
case "KE": return "Kenya"; |
|
179
|
|
|
case "LS": return "Lesotho"; |
|
180
|
|
|
case "LR": return "Liberia"; |
|
181
|
|
|
case "LY": return "Libya"; |
|
182
|
|
|
case "MG": return "Madagascar"; |
|
183
|
|
|
case "MW": return "Malawi"; |
|
184
|
|
|
case "ML": return "Mali"; |
|
185
|
|
|
case "MR": return "Mauritania"; |
|
186
|
|
|
case "MU": return "Mauritius"; |
|
187
|
|
|
case "YT": return "Mayotte"; |
|
188
|
|
|
case "MA": return "Morocco"; |
|
189
|
|
|
case "MZ": return "Mozambique"; |
|
190
|
|
|
case "NA": return "Namibia"; |
|
191
|
|
|
case "NE": return "Niger"; |
|
192
|
|
|
case "NG": return "Nigeria"; |
|
193
|
|
|
case "CG": return "Republic of the Congo"; |
|
194
|
|
|
case "RW": return "Rwanda"; |
|
195
|
|
|
case "RE": return "Réunion"; |
|
196
|
|
|
case "SH": return "Saint Helena"; |
|
197
|
|
|
case "SN": return "Senegal"; |
|
198
|
|
|
case "SC": return "Seychelles"; |
|
199
|
|
|
case "SL": return "Sierra Leone"; |
|
200
|
|
|
case "SO": return "Somalia"; |
|
201
|
|
|
case "ZA": return "South Africa"; |
|
202
|
|
|
case "SS": return "South Sudan"; |
|
203
|
|
|
case "SD": return "Sudan"; |
|
204
|
|
|
case "ST": return "São Tomé and Príncipe"; |
|
205
|
|
|
case "TZ": return "Tanzania"; |
|
206
|
|
|
case "TG": return "Togo"; |
|
207
|
|
|
case "TN": return "Tunisia"; |
|
208
|
|
|
case "UG": return "Uganda"; |
|
209
|
|
|
case "EH": return "Western Sahara"; |
|
210
|
|
|
case "ZM": return "Zambia"; |
|
211
|
|
|
case "ZW": return "Zimbabwe"; |
|
212
|
|
|
case "AQ": return "Antarctica"; |
|
213
|
|
|
case "BV": return "Bouvet Island"; |
|
214
|
|
|
case "TF": return "French Southern Territories"; |
|
215
|
|
|
case "HM": return "Heard Island and McDonald Islands"; |
|
216
|
|
|
case "GS": return "South Georgia and the South Sandwich Islands"; |
|
217
|
|
|
case "AF": return "Afghanistan"; |
|
218
|
|
|
case "AM": return "Armenia"; |
|
219
|
|
|
case "AZ": return "Azerbaijan"; |
|
220
|
|
|
case "BH": return "Bahrain"; |
|
221
|
|
|
case "BD": return "Bangladesh"; |
|
222
|
|
|
case "BT": return "Bhutan"; |
|
223
|
|
|
case "IO": return "British Indian Ocean Territory"; |
|
224
|
|
|
case "BN": return "Brunei"; |
|
225
|
|
|
case "KH": return "Cambodia"; |
|
226
|
|
|
case "CN": return "China"; |
|
227
|
|
|
case "CC": return "Cocos [Keeling] Islands"; |
|
228
|
|
|
case "GE": return "Georgia"; |
|
229
|
|
|
case "JO": return "Hashemite Kingdom of Jordan"; |
|
230
|
|
|
case "HK": return "Hong Kong"; |
|
231
|
|
|
case "IN": return "India"; |
|
232
|
|
|
case "ID": return "Indonesia"; |
|
233
|
|
|
case "IR": return "Iran"; |
|
234
|
|
|
case "IQ": return "Iraq"; |
|
235
|
|
|
case "IL": return "Israel"; |
|
236
|
|
|
case "JP": return "Japan"; |
|
237
|
|
|
case "KZ": return "Kazakhstan"; |
|
238
|
|
|
case "KW": return "Kuwait"; |
|
239
|
|
|
case "KG": return "Kyrgyzstan"; |
|
240
|
|
|
case "LA": return "Laos"; |
|
241
|
|
|
case "LB": return "Lebanon"; |
|
242
|
|
|
case "MO": return "Macao"; |
|
243
|
|
|
case "MY": return "Malaysia"; |
|
244
|
|
|
case "MV": return "Maldives"; |
|
245
|
|
|
case "MN": return "Mongolia"; |
|
246
|
|
|
case "MM": return "Myanmar"; |
|
247
|
|
|
case "NP": return "Nepal"; |
|
248
|
|
|
case "KP": return "North Korea"; |
|
249
|
|
|
case "OM": return "Oman"; |
|
250
|
|
|
case "PK": return "Pakistan"; |
|
251
|
|
|
case "PS": return "Palestine"; |
|
252
|
|
|
case "PH": return "Philippines"; |
|
253
|
|
|
case "QA": return "Qatar"; |
|
254
|
|
|
case "SA": return "Saudi Arabia"; |
|
255
|
|
|
case "SG": return "Singapore"; |
|
256
|
|
|
case "KR": return "South Korea"; |
|
257
|
|
|
case "LK": return "Sri Lanka"; |
|
258
|
|
|
case "SY": return "Syria"; |
|
259
|
|
|
case "TW": return "Taiwan"; |
|
260
|
|
|
case "TJ": return "Tajikistan"; |
|
261
|
|
|
case "TH": return "Thailand"; |
|
262
|
|
|
case "TR": return "Turkey"; |
|
263
|
|
|
case "TM": return "Turkmenistan"; |
|
264
|
|
|
case "AE": return "United Arab Emirates"; |
|
265
|
|
|
case "UZ": return "Uzbekistan"; |
|
266
|
|
|
case "VN": return "Vietnam"; |
|
267
|
|
|
case "YE": return "Yemen"; |
|
268
|
|
|
case "AL": return "Albania"; |
|
269
|
|
|
case "AD": return "Andorra"; |
|
270
|
|
|
case "AT": return "Austria"; |
|
271
|
|
|
case "BY": return "Belarus"; |
|
272
|
|
|
case "BE": return "Belgium"; |
|
273
|
|
|
case "BA": return "Bosnia and Herzegovina"; |
|
274
|
|
|
case "BG": return "Bulgaria"; |
|
275
|
|
|
case "HR": return "Croatia"; |
|
276
|
|
|
case "CY": return "Cyprus"; |
|
277
|
|
|
case "CZ": return "Czechia"; |
|
278
|
|
|
case "DK": return "Denmark"; |
|
279
|
|
|
case "EE": return "Estonia"; |
|
280
|
|
|
case "FO": return "Faroe Islands"; |
|
281
|
|
|
case "FI": return "Finland"; |
|
282
|
|
|
case "FR": return "France"; |
|
283
|
|
|
case "DE": return "Germany"; |
|
284
|
|
|
case "GI": return "Gibraltar"; |
|
285
|
|
|
case "GR": return "Greece"; |
|
286
|
|
|
case "GG": return "Guernsey"; |
|
287
|
|
|
case "HU": return "Hungary"; |
|
288
|
|
|
case "IS": return "Iceland"; |
|
289
|
|
|
case "IE": return "Ireland"; |
|
290
|
|
|
case "IM": return "Isle of Man"; |
|
291
|
|
|
case "IT": return "Italy"; |
|
292
|
|
|
case "JE": return "Jersey"; |
|
293
|
|
|
case "XK": return "Kosovo"; |
|
294
|
|
|
case "LV": return "Latvia"; |
|
295
|
|
|
case "LI": return "Liechtenstein"; |
|
296
|
|
|
case "LU": return "Luxembourg"; |
|
297
|
|
|
case "MT": return "Malta"; |
|
298
|
|
|
case "MC": return "Monaco"; |
|
299
|
|
|
case "ME": return "Montenegro"; |
|
300
|
|
|
case "NL": return "Netherlands"; |
|
301
|
|
|
case "MK": return "North Macedonia"; |
|
302
|
|
|
case "NO": return "Norway"; |
|
303
|
|
|
case "PL": return "Poland"; |
|
304
|
|
|
case "PT": return "Portugal"; |
|
305
|
|
|
case "LT": return "Republic of Lithuania"; |
|
306
|
|
|
case "MD": return "Republic of Moldova"; |
|
307
|
|
|
case "RO": return "Romania"; |
|
308
|
|
|
case "RU": return "Russia"; |
|
309
|
|
|
case "SM": return "San Marino"; |
|
310
|
|
|
case "RS": return "Serbia"; |
|
311
|
|
|
case "SK": return "Slovakia"; |
|
312
|
|
|
case "SI": return "Slovenia"; |
|
313
|
|
|
case "ES": return "Spain"; |
|
314
|
|
|
case "SJ": return "Svalbard and Jan Mayen"; |
|
315
|
|
|
case "SE": return "Sweden"; |
|
316
|
|
|
case "CH": return "Switzerland"; |
|
317
|
|
|
case "UA": return "Ukraine"; |
|
318
|
|
|
case "GB": return "United Kingdom"; |
|
319
|
|
|
case "VA": return "Vatican City"; |
|
320
|
|
|
case "AX": return "Åland"; |
|
321
|
|
|
case "AI": return "Anguilla"; |
|
322
|
|
|
case "AG": return "Antigua and Barbuda"; |
|
323
|
|
|
case "AW": return "Aruba"; |
|
324
|
|
|
case "BS": return "Bahamas"; |
|
325
|
|
|
case "BB": return "Barbados"; |
|
326
|
|
|
case "BZ": return "Belize"; |
|
327
|
|
|
case "BM": return "Bermuda"; |
|
328
|
|
|
case "BQ": return "Bonaire, Sint Eustatius, and Saba"; |
|
329
|
|
|
case "VG": return "British Virgin Islands"; |
|
330
|
|
|
case "CA": return "Canada"; |
|
331
|
|
|
case "KY": return "Cayman Islands"; |
|
332
|
|
|
case "CR": return "Costa Rica"; |
|
333
|
|
|
case "CU": return "Cuba"; |
|
334
|
|
|
case "CW": return "Curaçao"; |
|
335
|
|
|
case "DM": return "Dominica"; |
|
336
|
|
|
case "DO": return "Dominican Republic"; |
|
337
|
|
|
case "SV": return "El Salvador"; |
|
338
|
|
|
case "GL": return "Greenland"; |
|
339
|
|
|
case "GD": return "Grenada"; |
|
340
|
|
|
case "GP": return "Guadeloupe"; |
|
341
|
|
|
case "GT": return "Guatemala"; |
|
342
|
|
|
case "HT": return "Haiti"; |
|
343
|
|
|
case "HN": return "Honduras"; |
|
344
|
|
|
case "JM": return "Jamaica"; |
|
345
|
|
|
case "MQ": return "Martinique"; |
|
346
|
|
|
case "MX": return "Mexico"; |
|
347
|
|
|
case "MS": return "Montserrat"; |
|
348
|
|
|
case "NI": return "Nicaragua"; |
|
349
|
|
|
case "PA": return "Panama"; |
|
350
|
|
|
case "PR": return "Puerto Rico"; |
|
351
|
|
|
case "BL": return "Saint Barthélemy"; |
|
352
|
|
|
case "LC": return "Saint Lucia"; |
|
353
|
|
|
case "MF": return "Saint Martin"; |
|
354
|
|
|
case "PM": return "Saint Pierre and Miquelon"; |
|
355
|
|
|
case "VC": return "Saint Vincent and the Grenadines"; |
|
356
|
|
|
case "SX": return "Sint Maarten"; |
|
357
|
|
|
case "KN": return "St Kitts and Nevis"; |
|
358
|
|
|
case "TT": return "Trinidad and Tobago"; |
|
359
|
|
|
case "TC": return "Turks and Caicos Islands"; |
|
360
|
|
|
case "VI": return "U.S. Virgin Islands"; |
|
361
|
|
|
case "US": return "United States"; |
|
362
|
|
|
case "AS": return "American Samoa"; |
|
363
|
|
|
case "AU": return "Australia"; |
|
364
|
|
|
case "CX": return "Christmas Island"; |
|
365
|
|
|
case "CK": return "Cook Islands"; |
|
366
|
|
|
case "TL": return "Democratic Republic of Timor-Leste"; |
|
367
|
|
|
case "FM": return "Federated States of Micronesia"; |
|
368
|
|
|
case "FJ": return "Fiji"; |
|
369
|
|
|
case "PF": return "French Polynesia"; |
|
370
|
|
|
case "GU": return "Guam"; |
|
371
|
|
|
case "KI": return "Kiribati"; |
|
372
|
|
|
case "MH": return "Marshall Islands"; |
|
373
|
|
|
case "NR": return "Nauru"; |
|
374
|
|
|
case "NC": return "New Caledonia"; |
|
375
|
|
|
case "NZ": return "New Zealand"; |
|
376
|
|
|
case "NU": return "Niue"; |
|
377
|
|
|
case "NF": return "Norfolk Island"; |
|
378
|
|
|
case "MP": return "Northern Mariana Islands"; |
|
379
|
|
|
case "PW": return "Palau"; |
|
380
|
|
|
case "PG": return "Papua New Guinea"; |
|
381
|
|
|
case "PN": return "Pitcairn Islands"; |
|
382
|
|
|
case "WS": return "Samoa"; |
|
383
|
|
|
case "SB": return "Solomon Islands"; |
|
384
|
|
|
case "TK": return "Tokelau"; |
|
385
|
|
|
case "TO": return "Tonga"; |
|
386
|
|
|
case "TV": return "Tuvalu"; |
|
387
|
|
|
case "UM": return "U.S. Minor Outlying Islands"; |
|
388
|
|
|
case "VU": return "Vanuatu"; |
|
389
|
|
|
case "WF": return "Wallis and Futuna"; |
|
390
|
|
|
case "AR": return "Argentina"; |
|
391
|
|
|
case "BO": return "Bolivia"; |
|
392
|
|
|
case "BR": return "Brazil"; |
|
393
|
|
|
case "CL": return "Chile"; |
|
394
|
|
|
case "CO": return "Colombia"; |
|
395
|
|
|
case "EC": return "Ecuador"; |
|
396
|
|
|
case "FK": return "Falkland Islands"; |
|
397
|
|
|
case "GF": return "French Guiana"; |
|
398
|
|
|
case "GY": return "Guyana"; |
|
399
|
|
|
case "PY": return "Paraguay"; |
|
400
|
|
|
case "PE": return "Peru"; |
|
401
|
|
|
case "SR": return "Suriname"; |
|
402
|
|
|
case "UY": return "Uruguay"; |
|
403
|
|
|
case "VE": return "Venezuela"; |
|
404
|
|
|
} |
|
405
|
|
|
|
|
406
|
|
|
return "Error"; |
|
407
|
|
|
} |
|
408
|
|
|
|
|
409
|
|
|
function getCountryFlag(countryCode) { |
|
410
|
|
|
return (!countryCode || countryCode.length !== 2 || countryCode == "??") ? "❔" : sodium.to_string(new Uint8Array([ |
|
411
|
|
|
240, 159, 135, 166 + countryCode.codePointAt(0) - 65, |
|
412
|
|
|
240, 159, 135, 166 + countryCode.codePointAt(1) - 65 |
|
413
|
|
|
])); |
|
414
|
|
|
} |
|
415
|
|
|
|
|
416
|
|
|
function getClockIcon(d) { |
|
417
|
|
|
const h24 = d.getUTCHours(); |
|
418
|
|
|
let h12 = (h24 === 0 ? 12 : ((h24 > 12) ? h24 - 12 : h24)); |
|
419
|
|
|
|
|
420
|
|
|
const m60 = (d.getUTCMinutes() * 60) + d.getUTCSeconds(); |
|
421
|
|
|
let m30 = 0; |
|
422
|
|
|
if (m60 <= 900) { // <= 15: round down to this hour |
|
423
|
|
|
m30 = 0; |
|
424
|
|
|
} else if (m60 > 900 && m60 < 2700) { // 15..45: round to half-past this hour |
|
425
|
|
|
m30 = 12; |
|
426
|
|
|
} else { // >= 45: round up to next hour |
|
427
|
|
|
h12++; |
|
428
|
|
|
m30 = 0; |
|
429
|
|
|
} |
|
430
|
|
|
|
|
431
|
|
|
return String.fromCodePoint((128335 + h12) + m30); |
|
432
|
|
|
} |
|
433
|
|
|
|
|
434
|
|
View Code Duplication |
function shieldMix(addr) { |
|
|
|
|
|
|
435
|
|
|
let newAddr = ""; |
|
436
|
|
|
|
|
437
|
|
|
for (let i = 0; i < 16; i++) { |
|
438
|
|
|
switch (addr.charAt(i)) { |
|
439
|
|
|
case '1': |
|
440
|
|
|
newAddr += "1iIlL".charAt(Math.floor(Math.random() * 5)); |
|
441
|
|
|
break; |
|
442
|
|
|
case '0': |
|
443
|
|
|
newAddr += "0oO".charAt(Math.floor(Math.random() * 3)); |
|
444
|
|
|
break; |
|
445
|
|
|
case 'w': |
|
446
|
|
|
newAddr += "VvWw".charAt(Math.floor(Math.random() * 4)); |
|
447
|
|
|
break; |
|
448
|
|
|
default: |
|
449
|
|
|
newAddr += (Math.random() > 0.5) ? addr.charAt(i) : addr.charAt(i).toUpperCase(); |
|
450
|
|
|
} |
|
451
|
|
|
} |
|
452
|
|
|
|
|
453
|
|
|
return newAddr; |
|
454
|
|
|
} |
|
455
|
|
|
|
|
456
|
|
|
function downloadFile(num) { |
|
457
|
|
|
const a = document.createElement("a"); |
|
458
|
|
|
a.href = URL.createObjectURL(new Blob([ae.GetUplMsgBody(num).buffer])); |
|
459
|
|
|
a.download = ae.GetUplMsgTitle(num); |
|
460
|
|
|
a.click(); |
|
461
|
|
|
|
|
462
|
|
|
URL.revokeObjectURL(a.href); |
|
463
|
|
|
a.href = ""; |
|
464
|
|
|
a.download = ""; |
|
465
|
|
|
} |
|
466
|
|
|
|
|
467
|
|
|
function clearDisplay() { |
|
468
|
|
|
const el = document.querySelector("article > img, article > audio, article > video, article > embed, article > iframe"); |
|
469
|
|
|
if (!el) return; |
|
470
|
|
|
if (el.src) URL.revokeObjectURL(el.src); |
|
471
|
|
|
el.remove(); |
|
472
|
|
|
} |
|
473
|
|
|
|
|
474
|
|
|
function clearMsgFlags() { |
|
475
|
|
|
document.getElementById("readmsg_flags").children[0].replaceChildren(); |
|
476
|
|
|
} |
|
477
|
|
|
|
|
478
|
|
|
function addMsgFlag(abbr, abbrTitle) { |
|
479
|
|
|
const parent = document.getElementById("readmsg_flags").children[0]; |
|
480
|
|
|
|
|
481
|
|
|
const el = document.createElement("abbr"); |
|
482
|
|
|
el.title = abbrTitle; |
|
483
|
|
|
el.textContent = abbr; |
|
484
|
|
|
|
|
485
|
|
|
parent.appendChild(document.createTextNode(" ")); |
|
486
|
|
|
parent.appendChild(el); |
|
487
|
|
|
} |
|
488
|
|
|
|
|
489
|
|
|
function displayFile(num) { |
|
490
|
|
|
const fileType = ae.GetUplMsgType(num); |
|
491
|
|
|
if (!fileType) {downloadFile(num); return;} |
|
492
|
|
|
|
|
493
|
|
|
clearDisplay(); |
|
494
|
|
|
document.querySelector("article").scroll(0, 0); |
|
495
|
|
|
document.querySelector("article").setAttribute("data-msgid", ae.GetUplMsgIdHex(num)); |
|
496
|
|
|
|
|
497
|
|
|
document.getElementById("btn_mdele").disabled = false; |
|
498
|
|
|
document.getElementById("btn_msave").disabled = false; |
|
499
|
|
|
document.getElementById("btn_reply").disabled = true; |
|
500
|
|
|
|
|
501
|
|
|
document.getElementById("btn_msave").onclick = function() {downloadFile(num);}; |
|
502
|
|
|
|
|
503
|
|
|
document.querySelector("article > table").hidden = true; |
|
504
|
|
|
document.querySelector("article > h1").textContent = ae.GetUplMsgTitle(num); |
|
505
|
|
|
|
|
506
|
|
|
if (fileType === "text") { |
|
507
|
|
|
document.querySelector("article > pre").hidden = false; |
|
508
|
|
|
document.querySelector("article > pre").textContent = sodium.to_string(ae.GetUplMsgBody(num)); |
|
509
|
|
|
return; |
|
510
|
|
|
} |
|
511
|
|
|
|
|
512
|
|
|
document.querySelector("article > pre").hidden = true; |
|
513
|
|
|
let el; |
|
514
|
|
|
|
|
515
|
|
|
switch (fileType) { |
|
516
|
|
|
case "image": { |
|
517
|
|
|
el = document.createElement("img"); |
|
518
|
|
|
el.src = URL.createObjectURL(new Blob([ae.GetUplMsgBody(num).buffer])); |
|
519
|
|
|
el.onclick = function() { |
|
520
|
|
|
if (!document.fullscreen) |
|
521
|
|
|
this.requestFullscreen(); |
|
522
|
|
|
else |
|
523
|
|
|
document.exitFullscreen(); |
|
524
|
|
|
}; |
|
525
|
|
|
break;} |
|
526
|
|
|
|
|
527
|
|
|
case "audio": |
|
528
|
|
|
case "video": { |
|
529
|
|
|
el = document.createElement(fileType); |
|
530
|
|
|
el.controls = "controls"; |
|
531
|
|
|
el.src = URL.createObjectURL(new Blob([ae.GetUplMsgBody(num).buffer])); |
|
532
|
|
|
break;} |
|
533
|
|
|
|
|
534
|
|
|
case "pdf": { |
|
535
|
|
|
el = document.createElement("embed"); |
|
536
|
|
|
el.type = "application/pdf"; |
|
537
|
|
|
el.src = URL.createObjectURL(new Blob([ae.GetUplMsgBody(num).buffer], {type: "application/pdf"})); |
|
538
|
|
|
break;} |
|
539
|
|
|
|
|
540
|
|
|
case "html": { |
|
541
|
|
|
el = document.createElement("iframe"); |
|
542
|
|
|
el.allow = ""; |
|
543
|
|
|
el.sandbox = ""; |
|
544
|
|
|
el.referrerPolicy = "no-referrer"; |
|
545
|
|
|
el.csp = "base-uri 'none'; child-src 'none'; connect-src 'none'; default-src 'none'; font-src 'none'; form-action 'none'; frame-ancestors 'none'; frame-src 'none'; img-src 'none'; manifest-src 'none'; media-src 'none'; object-src 'none'; script-src 'none'; style-src 'none'; worker-src 'none';"; |
|
546
|
|
|
el.srcdoc = sodium.to_string(ae.GetUplMsgBody(num).buffer); |
|
547
|
|
|
break;} |
|
548
|
|
|
|
|
549
|
|
|
default: return; |
|
550
|
|
|
} |
|
551
|
|
|
|
|
552
|
|
|
document.querySelector("article").appendChild(el); |
|
553
|
|
|
} |
|
554
|
|
|
|
|
555
|
|
|
function displayMsg(isInt, num) { |
|
556
|
|
|
clearDisplay(); |
|
557
|
|
|
|
|
558
|
|
|
document.getElementById("btn_mdele").disabled = false; |
|
559
|
|
|
document.getElementById("btn_msave").disabled = isInt; |
|
560
|
|
|
|
|
561
|
|
|
document.querySelector("article").scroll(0, 0); |
|
562
|
|
|
document.querySelector("article").setAttribute("data-msgid", isInt? ae.GetIntMsgIdHex(num) : ae.GetExtMsgIdHex(num)); |
|
563
|
|
|
|
|
564
|
|
|
const ts = isInt? ae.GetIntMsgTime(num) : ae.GetExtMsgTime(num); |
|
565
|
|
|
|
|
566
|
|
|
if (!isInt) { |
|
567
|
|
|
document.getElementById("btn_msave").onclick = function() { |
|
568
|
|
|
this.blur(); |
|
569
|
|
|
|
|
570
|
|
|
const a = document.createElement("a"); |
|
571
|
|
|
a.href = URL.createObjectURL(new Blob([ae.ExportExtMsg(num)])); |
|
572
|
|
|
a.download = ae.GetExtMsgTitle(num); |
|
573
|
|
|
a.click(); |
|
574
|
|
|
|
|
575
|
|
|
URL.revokeObjectURL(a.href); |
|
576
|
|
|
a.href = ""; |
|
577
|
|
|
a.download = ""; |
|
578
|
|
|
}; |
|
579
|
|
|
} |
|
580
|
|
|
|
|
581
|
|
|
if (!isInt || (ae.GetIntMsgFrom(num) !== "public" && ae.GetIntMsgFrom(num) !== "system")) { |
|
582
|
|
|
document.getElementById("btn_reply").disabled = false; |
|
583
|
|
|
|
|
584
|
|
|
document.getElementById("btn_reply").onclick = function() { |
|
585
|
|
|
document.getElementById("write_recv").value = isInt? ae.GetIntMsgFrom(num) : ae.GetExtMsgReplyAddress(num); |
|
586
|
|
|
document.getElementById("write_subj").value = isInt? ae.GetIntMsgTitle(num) : ae.GetExtMsgTitle(num); |
|
587
|
|
|
if (!document.getElementById("write_subj").value.startsWith("Re:")) document.getElementById("write_subj").value = "Re: " + document.getElementById("write_subj").value; |
|
588
|
|
|
document.querySelector("#write2_pkey > input").value = isInt? ae.GetIntMsgFromPk(num) : ""; |
|
589
|
|
|
|
|
590
|
|
|
document.getElementById("write_recv").readOnly = !isInt; |
|
591
|
|
|
document.getElementById("write_subj").readOnly = !isInt; |
|
592
|
|
|
document.getElementById("write_subj").setAttribute("data-replyid", isInt? "" : ae.GetExtMsgHdrId(num)); |
|
593
|
|
|
|
|
594
|
|
|
tabs[TAB_WRITE].cur = 0; |
|
595
|
|
|
document.getElementById("btn_write").disabled = false; |
|
596
|
|
|
document.getElementById("btn_write").click(); |
|
597
|
|
|
document.getElementById("write_body").focus(); |
|
598
|
|
|
|
|
599
|
|
|
for (const opt of document.getElementById("write_from").options) { |
|
600
|
|
|
if (opt.value === (isInt ? ae.GetIntMsgTo(num) : ae.GetExtMsgEnvTo(num).split("@")[0].toLowerCase())) { |
|
601
|
|
|
opt.selected = true; |
|
602
|
|
|
} |
|
603
|
|
|
} |
|
604
|
|
|
}; |
|
605
|
|
|
} else { |
|
606
|
|
|
document.getElementById("btn_reply").disabled = true; |
|
607
|
|
|
} |
|
608
|
|
|
|
|
609
|
|
|
document.querySelector("article > table").hidden = false; |
|
610
|
|
|
document.querySelector("article > pre").hidden = false; |
|
611
|
|
|
|
|
612
|
|
|
document.getElementById("readmsg_envto").textContent = isInt ? "" : ae.GetExtMsgEnvTo(num); |
|
613
|
|
|
document.getElementById("readmsg_hdrto").textContent = isInt ? ae.GetIntMsgTo(num) : (ae.GetExtMsgHdrTo(num) + (ae.GetExtMsgDnTo(num) ? " (" + ae.GetExtMsgDnTo(num) + ")" : "")); |
|
614
|
|
|
|
|
615
|
|
|
const tzOs = new Date().getTimezoneOffset(); |
|
616
|
|
|
const msgDate = new Date((ts * 1000) + (tzOs * -60000)); |
|
617
|
|
|
document.getElementById("readmsg_date").children[0].textContent = getClockIcon(msgDate); |
|
618
|
|
|
document.getElementById("readmsg_date").children[1].dateTime = new Date(ts * 1000).toISOString(); |
|
619
|
|
|
|
|
620
|
|
|
if (isInt) { |
|
621
|
|
|
document.querySelector("article > h1").textContent = ae.GetIntMsgTitle(num); |
|
622
|
|
|
document.querySelector("article > pre").textContent = ae.GetIntMsgBody(num); |
|
623
|
|
|
|
|
624
|
|
|
document.getElementById("readmsg_date").children[1].textContent = msgDate.toISOString().slice(0, 19).replace("T", " "); |
|
625
|
|
|
|
|
626
|
|
|
document.getElementById("readmsg_ip").style.visibility = "hidden"; |
|
627
|
|
|
document.getElementById("readmsg_rdns").style.visibility = "hidden"; |
|
628
|
|
|
document.getElementById("readmsg_dkim").style.visibility = "hidden"; |
|
629
|
|
|
document.getElementById("readmsg_greet").style.visibility = "hidden"; |
|
630
|
|
|
document.getElementById("readmsg_cert").style.visibility = "hidden"; |
|
631
|
|
|
document.getElementById("readmsg_envfrom").style.visibility = "hidden"; |
|
632
|
|
|
document.getElementById("readmsg_envto").style.visibility = "hidden"; |
|
633
|
|
|
|
|
634
|
|
|
if (ae.GetIntMsgFrom(num) !== "system" && ae.GetIntMsgFrom(num) !== "public") { |
|
635
|
|
|
document.getElementById("readmsg_tls").style.visibility = "visible"; |
|
636
|
|
|
document.getElementById("readmsg_tls").children[0].textContent = ae.GetIntMsgFromPk(num); |
|
637
|
|
|
} else document.getElementById("readmsg_tls").style.visibility = "hidden"; |
|
638
|
|
|
|
|
639
|
|
|
let symbol = document.createElement("span"); |
|
640
|
|
|
if (ae.GetIntMsgLevel(num) === 3 && ae.GetIntMsgFrom(num) === "system") {symbol.title = "System message"; symbol.textContent = "🅢";} |
|
641
|
|
|
else if (ae.GetIntMsgLevel(num) === 3 && ae.GetIntMsgFrom(num) === "public") {symbol.title = "Public announcement"; symbol.textContent = "🅟";} |
|
642
|
|
|
else if (ae.GetIntMsgLevel(num) === 3) {symbol.title = "Administrator"; symbol.textContent = "🅐";} |
|
643
|
|
|
else if (ae.GetIntMsgLevel(num) === 2) {symbol.title = "Level 2"; symbol.textContent = "➋";} |
|
644
|
|
|
else if (ae.GetIntMsgLevel(num) === 1) {symbol.title = "Level 1"; symbol.textContent = "➊";} |
|
645
|
|
|
else if (ae.GetIntMsgLevel(num) === 0) {symbol.title = "Level 0"; symbol.textContent = "🄌";} |
|
646
|
|
|
else {symbol.title = "Invalid level"; symbol.textContent = "⚠";} |
|
647
|
|
|
|
|
648
|
|
|
document.getElementById("readmsg_hdrfrom").replaceChildren(symbol, document.createTextNode(" " + ae.GetIntMsgFrom(num))); |
|
649
|
|
|
|
|
650
|
|
|
clearMsgFlags(); |
|
651
|
|
|
if (!ae.GetIntMsgFlagVPad(num)) addMsgFlag("PAD", "Invalid padding"); |
|
652
|
|
|
if (!ae.GetIntMsgFlagVSig(num)) addMsgFlag("SIG", "Invalid signature"); |
|
653
|
|
|
if ( ae.GetIntMsgFlagE2ee(num)) addMsgFlag("E2EE", "End-to-end encrypted"); |
|
654
|
|
|
} else { |
|
655
|
|
|
const headers = document.createElement("p"); |
|
656
|
|
|
headers.textContent = ae.GetExtMsgHeaders(num); |
|
657
|
|
|
headers.className = "mono"; |
|
658
|
|
|
headers.hidden = !showHeaders; |
|
659
|
|
|
|
|
660
|
|
|
const body = document.createElement("p"); |
|
661
|
|
|
body.innerHTML = ae.GetExtMsgBody(num); |
|
662
|
|
|
|
|
663
|
|
|
document.querySelector("article > pre").replaceChildren(headers, body); |
|
664
|
|
|
|
|
665
|
|
|
const h1 = document.querySelector("article > h1"); |
|
666
|
|
|
h1.textContent = ae.GetExtMsgTitle(num); |
|
667
|
|
|
h1.style.cursor = headers.textContent? "pointer" : ""; |
|
668
|
|
|
h1.onclick = function() { |
|
669
|
|
|
if (!headers.textContent) return; |
|
670
|
|
|
showHeaders = !showHeaders; |
|
671
|
|
|
headers.hidden = !showHeaders; |
|
672
|
|
|
}; |
|
673
|
|
|
|
|
674
|
|
|
let hdrSecs = Math.abs(ae.GetExtMsgHdrTime(num)); |
|
675
|
|
|
let hdrTime = ""; |
|
676
|
|
|
if (hdrSecs >= 3600) { |
|
677
|
|
|
const hdrHours = Math.floor(hdrSecs / 3600); |
|
678
|
|
|
hdrTime += hdrHours.toString() + "h "; |
|
679
|
|
|
hdrSecs -= hdrHours * 3600; |
|
680
|
|
|
} |
|
681
|
|
|
if (hdrSecs >= 60) { |
|
682
|
|
|
const hdrMins = Math.floor(hdrSecs / 60); |
|
683
|
|
|
hdrTime += hdrMins.toString() + "m "; |
|
684
|
|
|
hdrSecs -= hdrMins * 60; |
|
685
|
|
|
} |
|
686
|
|
|
hdrTime += hdrSecs + "s"; |
|
687
|
|
|
|
|
688
|
|
|
const hdrTz = (ae.GetExtMsgHdrTz(num) >= 0 ? "+" : "-") + Math.floor(Math.abs(ae.GetExtMsgHdrTz(num)) / 60).toString().padStart(2, "0") + (Math.abs(ae.GetExtMsgHdrTz(num)) % 60).toString().padStart(2, "0"); |
|
689
|
|
|
document.getElementById("readmsg_date").children[1].textContent = msgDate.toISOString().slice(0, 19).replace("T", " ") + "; " + hdrTz + " " + ((ae.GetExtMsgHdrTime(num) >= 0) ? "+" : "-") + hdrTime; |
|
690
|
|
|
|
|
691
|
|
|
document.getElementById("readmsg_ip").style.visibility = "visible"; |
|
692
|
|
|
document.getElementById("readmsg_rdns").style.visibility = "visible"; |
|
693
|
|
|
document.getElementById("readmsg_dkim").style.visibility = "visible"; |
|
694
|
|
|
document.getElementById("readmsg_greet").style.visibility = "visible"; |
|
695
|
|
|
document.getElementById("readmsg_tls").style.visibility = "visible"; |
|
696
|
|
|
document.getElementById("readmsg_cert").style.visibility = "visible"; |
|
697
|
|
|
document.getElementById("readmsg_envfrom").style.visibility = "visible"; |
|
698
|
|
|
document.getElementById("readmsg_envto").style.visibility = "visible"; |
|
699
|
|
|
|
|
700
|
|
|
const cc = ae.GetExtMsgCountry(num); |
|
701
|
|
|
|
|
702
|
|
|
// DKIM |
|
703
|
|
|
let dkim = ""; |
|
704
|
|
|
if (ae.GetExtMsgDkim(num)) { |
|
705
|
|
|
[ // Look for a matching domain in this order |
|
706
|
|
|
ae.GetExtMsgHdrFrom(num).split("@")[1], |
|
707
|
|
|
ae.GetExtMsgEnvFrom(num).split("@")[1], |
|
708
|
|
|
ae.GetExtMsgRdns(num), |
|
709
|
|
|
ae.GetExtMsgGreet(num), |
|
710
|
|
|
ae.GetExtMsgTlsDomain(num) |
|
711
|
|
|
].forEach(function(dom) { |
|
712
|
|
|
if (dkim) return; |
|
713
|
|
|
for (let i = 0; i < ae.GetExtMsgDkim(num).domain.length; i++) { |
|
714
|
|
|
if (ae.GetExtMsgDkim(num).domain[i] === dom) { |
|
715
|
|
|
dkim = dom + " ✓"; |
|
716
|
|
|
return; |
|
717
|
|
|
} |
|
718
|
|
|
} |
|
719
|
|
|
}); |
|
720
|
|
|
|
|
721
|
|
|
if (!dkim) dkim = ae.GetExtMsgDkim(num).domain[0]; // Default to first signature domain |
|
722
|
|
|
} |
|
723
|
|
|
|
|
724
|
|
|
if (ae.GetExtMsgFlagDkFl(num)) dkim += " (fail)"; |
|
725
|
|
|
|
|
726
|
|
|
// Left side |
|
727
|
|
|
document.getElementById("readmsg_country").textContent = getCountryFlag(cc); |
|
728
|
|
|
document.getElementById("readmsg_country").title = getCountryName(cc); |
|
729
|
|
|
document.getElementById("readmsg_ip").children[1].textContent = ae.GetExtMsgIp(num) + (ae.GetExtMsgFlagIpBl(num) ? " ❗" : ""); |
|
730
|
|
|
document.getElementById("readmsg_tls").children[0].textContent = ae.GetExtMsgTLS(num); |
|
731
|
|
|
|
|
732
|
|
|
// Right side |
|
733
|
|
|
document.getElementById("readmsg_greet").children[0].textContent = ae.GetExtMsgGreet(num) + (ae.GetExtMsgFlagGrDm(num) ? " ✓" : ""); |
|
734
|
|
|
document.getElementById("readmsg_rdns").children[0].textContent = ae.GetExtMsgRdns(num) + (ae.GetExtMsgGreet(num) === ae.GetExtMsgRdns(num) ? " ✓" : ""); |
|
735
|
|
|
document.getElementById("readmsg_cert").children[0].textContent = ae.GetExtMsgTlsDomain(num) ? (ae.GetExtMsgTlsDomain(num) + " ✓") : ""; |
|
736
|
|
|
document.getElementById("readmsg_dkim").children[0].textContent = dkim; |
|
737
|
|
|
document.getElementById("readmsg_envfrom").textContent = ae.GetExtMsgEnvFrom(num); |
|
738
|
|
|
document.getElementById("readmsg_hdrfrom").textContent = ae.GetExtMsgHdrFrom(num) + (ae.GetExtMsgDnFrom(num) ? " (" + ae.GetExtMsgDnFrom(num) + ")" : ""); |
|
739
|
|
|
|
|
740
|
|
|
clearMsgFlags(); |
|
741
|
|
|
if (!ae.GetExtMsgFlagVPad(num)) addMsgFlag("PAD", "Invalid padding"); |
|
742
|
|
|
if (!ae.GetExtMsgFlagVSig(num)) addMsgFlag("SIG", "Invalid signature"); |
|
743
|
|
|
if (!ae.GetExtMsgFlagPExt(num)) addMsgFlag("SMTP", "The sender did not use the Extended (ESMTP) protocol"); |
|
744
|
|
|
if (!ae.GetExtMsgFlagQuit(num)) addMsgFlag("QUIT", "The sender did not issue the required QUIT command"); |
|
745
|
|
|
if ( ae.GetExtMsgFlagRare(num)) addMsgFlag("RARE", "The sender issued unusual command(s)"); |
|
746
|
|
|
if ( ae.GetExtMsgFlagFail(num)) addMsgFlag("FAIL", "The sender issued invalid command(s)"); |
|
747
|
|
|
if ( ae.GetExtMsgFlagPErr(num)) addMsgFlag("PROT", "The sender violated the protocol"); |
|
748
|
|
|
} |
|
749
|
|
|
} |
|
750
|
|
|
|
|
751
|
|
|
function displayOutMsg(num) { |
|
752
|
|
|
clearDisplay(); |
|
753
|
|
|
document.querySelector("article").scroll(0, 0); |
|
754
|
|
|
document.querySelector("article").setAttribute("data-msgid", ae.GetOutMsgIdHex(num)); |
|
755
|
|
|
|
|
756
|
|
|
document.getElementById("btn_mdele").disabled = false; |
|
757
|
|
|
document.getElementById("btn_msave").disabled = true; |
|
758
|
|
|
document.getElementById("btn_reply").disabled = true; |
|
759
|
|
|
|
|
760
|
|
|
document.querySelector("article > table").hidden = false; |
|
761
|
|
|
document.querySelector("article > pre").hidden = false; |
|
762
|
|
|
|
|
763
|
|
|
document.querySelector("article > h1").textContent = ae.GetOutMsgSubj(num); |
|
764
|
|
|
document.querySelector("article > pre").textContent = ae.GetOutMsgBody(num); |
|
765
|
|
|
|
|
766
|
|
|
document.getElementById("readmsg_dkim").style.visibility = "hidden"; |
|
767
|
|
|
document.getElementById("readmsg_hdrto").style.visibility = "visible"; |
|
768
|
|
|
document.getElementById("readmsg_hdrfrom").style.visibility = "visible"; |
|
769
|
|
|
document.getElementById("readmsg_envto").style.visibility = "visible"; |
|
770
|
|
|
document.getElementById("readmsg_envfrom").style.visibility = "hidden"; |
|
771
|
|
|
|
|
772
|
|
|
document.getElementById("readmsg_hdrfrom").textContent = ae.GetOutMsgFrom(num); |
|
773
|
|
|
|
|
774
|
|
|
document.getElementById("readmsg_envto").textContent = ae.GetOutMsgMxDom(num); |
|
775
|
|
|
document.getElementById("readmsg_hdrto").textContent = ae.GetOutMsgTo(num); |
|
776
|
|
|
|
|
777
|
|
|
const ts = ae.GetOutMsgTime(num); |
|
778
|
|
|
const tzOs = new Date().getTimezoneOffset(); |
|
779
|
|
|
document.getElementById("readmsg_date").children[1].textContent = new Date((ts * 1000) + (tzOs * -60000)).toISOString().slice(0, 19).replace("T", " "); |
|
780
|
|
|
|
|
781
|
|
|
const isInt = ae.GetOutMsgIsInt(num); |
|
782
|
|
|
document.getElementById("readmsg_ip").style.visibility = isInt? "hidden" : "visible"; |
|
783
|
|
|
document.getElementById("readmsg_rdns").style.visibility = /*isInt?*/ "hidden" /*: "visible"*/; // TODO |
|
784
|
|
|
document.getElementById("readmsg_tls").style.visibility = /*isInt?*/ "hidden" /*: "visible"*/; // TODO |
|
785
|
|
|
document.getElementById("readmsg_cert").style.visibility = /*isInt?*/ "hidden" /*: "visible"*/; // TODO |
|
786
|
|
|
document.getElementById("readmsg_greet").style.visibility = isInt? "hidden" : "visible"; |
|
787
|
|
|
|
|
788
|
|
|
if (!isInt) { |
|
789
|
|
|
// const cc = ae.GetExtMsgCountry(num); |
|
790
|
|
|
|
|
791
|
|
|
document.getElementById("readmsg_ip").children[1].textContent = ae.GetOutMsgIp(num); |
|
792
|
|
|
// document.getElementById("readmsg_country").textContent = getCountryFlag(cc) + " " + getCountryName(cc); |
|
793
|
|
|
// document.getElementById("readmsg_tls").children[0].textContent = ae.GetOutMsgTLS(num); |
|
794
|
|
|
document.getElementById("readmsg_greet").children[0].textContent = ae.GetOutMsgGreet(num); |
|
795
|
|
|
} |
|
796
|
|
|
|
|
797
|
|
|
clearMsgFlags(); |
|
798
|
|
|
if (!ae.GetOutMsgFlagVPad(num)) addMsgFlag("PAD", "Invalid padding"); |
|
799
|
|
|
if (!ae.GetOutMsgFlagVSig(num)) addMsgFlag("SIG", "Invalid signature"); |
|
800
|
|
|
if ( ae.GetOutMsgFlagE2ee(num)) addMsgFlag("E2EE", "End-to-end encrypted"); |
|
801
|
|
|
} |
|
802
|
|
|
|
|
803
|
|
|
function addSent() { |
|
804
|
|
|
const tbl = document.getElementById("tbl_drbox"); |
|
805
|
|
|
tbl.replaceChildren(); |
|
806
|
|
|
|
|
807
|
|
|
for (let i = 0; i < ae.GetOutMsgCount(); i++) { |
|
808
|
|
|
const row = tbl.insertRow(-1); |
|
809
|
|
|
row.setAttribute("data-msgid", ae.GetOutMsgIdHex(i)); |
|
810
|
|
|
|
|
811
|
|
|
let cell; |
|
812
|
|
|
cell = row.insertCell(-1); cell.textContent = new Date(ae.GetOutMsgTime(i) * 1000).toISOString().slice(0, 10); |
|
813
|
|
|
cell = row.insertCell(-1); cell.textContent = ae.GetOutMsgSubj(i); |
|
814
|
|
|
row.onclick = function() {displayOutMsg(i);}; |
|
815
|
|
|
} |
|
816
|
|
|
} |
|
817
|
|
|
|
|
818
|
|
|
function updateAddressButtons() { |
|
819
|
|
|
const limitReached = (ae.GetAddressCountNormal() + ae.GetAddressCountShield() >= 31); |
|
820
|
|
|
document.getElementById("btn_address_create_normal").disabled = (limitReached || ae.GetAddressCountNormal() >= ae.GetLimitNormalA(ae.GetUserLevel())); |
|
821
|
|
|
document.getElementById("btn_address_create_shield").disabled = (limitReached || ae.GetAddressCountShield() >= ae.GetLimitShieldA(ae.GetUserLevel())); |
|
822
|
|
|
} |
|
823
|
|
|
|
|
824
|
|
|
function updateAddressCounts() { |
|
825
|
|
|
document.querySelector("#tbd_accs > tr > td:nth-child(3)").textContent = ae.GetAddressCountNormal(); |
|
826
|
|
|
document.querySelector("#tbd_accs > tr > td:nth-child(4)").textContent = ae.GetAddressCountShield(); |
|
827
|
|
|
|
|
828
|
|
|
document.getElementById("limit_normal").textContent = (ae.GetAddressCountNormal() + "/" + ae.GetLimitNormalA(ae.GetUserLevel())).padStart(ae.GetLimitNormalA(ae.GetUserLevel()) > 9 ? 5 : 1); |
|
829
|
|
|
document.getElementById("limit_shield").textContent = (ae.GetAddressCountShield() + "/" + ae.GetLimitShieldA(ae.GetUserLevel())).padStart(ae.GetLimitShieldA(ae.GetUserLevel()) > 9 ? 5 : 1); |
|
830
|
|
|
document.getElementById("limit_total").textContent = ((ae.GetAddressCountNormal() + ae.GetAddressCountShield()) + "/" + ae.GetAddrPerUser()).padStart(5); |
|
831
|
|
|
|
|
832
|
|
|
updateAddressButtons(); |
|
833
|
|
|
} |
|
834
|
|
|
|
|
835
|
|
|
function adjustLevel(pubkey, level, c) { |
|
836
|
|
|
const fs = document.getElementById("tbl_accs"); |
|
837
|
|
|
fs.disabled = true; |
|
838
|
|
|
|
|
839
|
|
|
ae.Account_Update(pubkey, level, function(error) { |
|
840
|
|
|
fs.disabled = false; |
|
841
|
|
|
|
|
842
|
|
|
if (error === 0) { |
|
843
|
|
|
c[4].textContent = level; |
|
844
|
|
|
c[5].children[0].disabled = (level === 3); |
|
845
|
|
|
c[6].children[0].disabled = (level === 0); |
|
846
|
|
|
} else errorDialog(error); |
|
847
|
|
|
}); |
|
848
|
|
|
} |
|
849
|
|
|
|
|
850
|
|
|
function addMsg(isInt, i) { |
|
851
|
|
|
const row = document.getElementById("tbl_inbox").insertRow(-1); |
|
852
|
|
|
row.setAttribute("data-msgid", isInt? ae.GetIntMsgIdHex(i) : ae.GetExtMsgIdHex(i)); |
|
853
|
|
|
|
|
854
|
|
|
const ts = isInt? ae.GetIntMsgTime(i) : ae.GetExtMsgTime(i); |
|
855
|
|
|
const el = document.createElement("time"); |
|
856
|
|
|
el.dateTime = new Date(ts * 1000).toISOString(); |
|
857
|
|
|
el.textContent = new Date((ts * 1000) + (new Date().getTimezoneOffset() * -60000)).toISOString().slice(0, 10); |
|
858
|
|
|
let cell = row.insertCell(-1); |
|
859
|
|
|
cell.appendChild(el); |
|
860
|
|
|
|
|
861
|
|
|
cell = row.insertCell(-1); |
|
862
|
|
|
cell.textContent = isInt? ae.GetIntMsgTitle(i) : ae.GetExtMsgTitle(i); |
|
863
|
|
|
|
|
864
|
|
|
if (isInt) { |
|
865
|
|
|
cell = row.insertCell(-1); |
|
866
|
|
|
cell.textContent = ae.GetIntMsgFrom(i); |
|
867
|
|
|
cell.className = (ae.GetIntMsgFrom(i).length === 16) ? "mono" : ""; |
|
868
|
|
|
} else { |
|
869
|
|
|
const from1 = ae.GetExtMsgHdrFrom(i); |
|
870
|
|
|
const from2 = from1.substring(from1.indexOf("@") + 1); |
|
871
|
|
|
cell = row.insertCell(-1); |
|
872
|
|
|
cell.textContent = from1.substring(0, from1.indexOf("@")); |
|
873
|
|
|
|
|
874
|
|
|
const flag = document.createElement("abbr"); |
|
875
|
|
|
const cc = ae.GetExtMsgCountry(i); |
|
876
|
|
|
flag.textContent = getCountryFlag(cc); |
|
877
|
|
|
flag.title = getCountryName(cc); |
|
878
|
|
|
|
|
879
|
|
|
const fromText = document.createElement("span"); |
|
880
|
|
|
fromText.textContent = " " + from2; |
|
881
|
|
|
|
|
882
|
|
|
cell = row.insertCell(-1); |
|
883
|
|
|
cell.appendChild(flag); |
|
884
|
|
|
cell.appendChild(fromText); |
|
885
|
|
|
} |
|
886
|
|
|
|
|
887
|
|
|
row.onclick = function() { |
|
888
|
|
|
displayMsg(isInt, i); |
|
889
|
|
|
}; |
|
890
|
|
|
} |
|
891
|
|
|
|
|
892
|
|
|
function getRowsPerPage() { |
|
893
|
|
|
const tbl = document.getElementById("tbl_inbox"); |
|
894
|
|
|
tbl.replaceChildren(); |
|
895
|
|
|
const row = tbl.insertRow(-1); |
|
896
|
|
|
const cell = row.insertCell(-1); |
|
897
|
|
|
cell.textContent = "0"; |
|
898
|
|
|
|
|
899
|
|
|
const rowsPerPage = Math.floor(getComputedStyle(document.getElementById("div_inbox")).height.replace("px", "") / getComputedStyle(document.querySelector("#tbl_inbox > tbody > tr:first-child")).height.replace("px", "")) - 1; // -1 allows space for 'load more' |
|
900
|
|
|
tbl.replaceChildren(); |
|
901
|
|
|
return rowsPerPage; |
|
902
|
|
|
} |
|
903
|
|
|
|
|
904
|
|
|
function addMessages() { |
|
905
|
|
|
const maxExt = ae.GetExtMsgCount(); |
|
906
|
|
|
const maxInt = ae.GetIntMsgCount(); |
|
907
|
|
|
|
|
908
|
|
|
if (maxExt + maxInt < 1) { |
|
909
|
|
|
tabs[TAB_INBOX].max = 0; |
|
910
|
|
|
return; |
|
911
|
|
|
} |
|
912
|
|
|
|
|
913
|
|
|
const rowsPerPage = getRowsPerPage(); |
|
914
|
|
|
let skipMsgs = rowsPerPage * tabs[TAB_INBOX].cur; |
|
915
|
|
|
|
|
916
|
|
|
tabs[TAB_INBOX].max = Math.floor((maxExt + maxInt - 1) / rowsPerPage); |
|
917
|
|
|
|
|
918
|
|
|
let numExt = 0; |
|
919
|
|
|
let numInt = 0; |
|
920
|
|
|
let numAdd = 0; |
|
921
|
|
|
|
|
922
|
|
|
while (numAdd < rowsPerPage) { |
|
923
|
|
|
const tsInt = (numInt < maxInt) ? ae.GetIntMsgTime(numInt) : -1; |
|
924
|
|
|
const tsExt = (numExt < maxExt) ? ae.GetExtMsgTime(numExt) : -1; |
|
925
|
|
|
if (tsInt === -1 && tsExt === -1) break; |
|
926
|
|
|
|
|
927
|
|
|
if (tsInt !== -1 && (tsExt === -1 || tsInt > tsExt)) { |
|
928
|
|
|
if (skipMsgs > 0) skipMsgs--; else {addMsg(true, numInt); numAdd++;} |
|
929
|
|
|
numInt++; |
|
930
|
|
|
} else if (tsExt !== -1) { |
|
931
|
|
|
if (skipMsgs > 0) skipMsgs--; else {addMsg(false, numExt); numAdd++;} |
|
932
|
|
|
numExt++; |
|
933
|
|
|
} |
|
934
|
|
|
} |
|
935
|
|
|
|
|
936
|
|
|
if (ae.GetReadyMsgBytes() < ae.GetTotalMsgBytes()) { |
|
937
|
|
|
const inbox = document.getElementById("tbl_inbox"); |
|
938
|
|
|
const row = inbox.insertRow(-1); |
|
939
|
|
|
const cell = row.insertCell(-1); |
|
940
|
|
|
cell.textContent = "Load more (" + Math.round((ae.GetTotalMsgBytes() - ae.GetReadyMsgBytes()) / 1024) + " KiB left)"; |
|
941
|
|
|
|
|
942
|
|
|
row.onclick = function() { |
|
943
|
|
|
this.onclick = ""; |
|
944
|
|
|
|
|
945
|
|
|
ae.Message_Browse(false, false, function(errorBrowse) { |
|
946
|
|
|
document.getElementById("tbl_inbox").style.opacity = 1; |
|
947
|
|
|
|
|
948
|
|
|
if (errorBrowse === 0) { |
|
949
|
|
|
addMessages(); |
|
950
|
|
|
addUploads(); |
|
951
|
|
|
addSent(); |
|
952
|
|
|
if (tabs[tab].cur < tabs[tab].max) document.getElementById("btn_rght").disabled = false; |
|
953
|
|
|
} // else TODO |
|
954
|
|
|
}); |
|
955
|
|
|
}; |
|
956
|
|
|
} |
|
957
|
|
|
} |
|
958
|
|
|
|
|
959
|
|
|
function addUploads() { |
|
960
|
|
|
const tbl = document.getElementById("tbd_uploads"); |
|
961
|
|
|
tbl.replaceChildren(); |
|
962
|
|
|
|
|
963
|
|
|
for (let i = 0; i < ae.GetUplMsgCount(); i++) { |
|
964
|
|
|
const row = tbl.insertRow(-1); |
|
965
|
|
|
row.setAttribute("data-msgid", ae.GetUplMsgIdHex(i)); |
|
966
|
|
|
|
|
967
|
|
|
let cell; |
|
968
|
|
|
cell = row.insertCell(-1); cell.textContent = new Date(ae.GetUplMsgTime(i) * 1000).toISOString().slice(0, 10); |
|
969
|
|
|
|
|
970
|
|
|
cell = row.insertCell(-1); cell.textContent = ae.GetUplMsgTitle(i); |
|
971
|
|
|
cell.onclick = function() {displayFile(this.parentElement.rowIndex - 1);}; |
|
972
|
|
|
|
|
973
|
|
|
cell = row.insertCell(-1); cell.textContent = (ae.GetUplMsgBytes(i) / 1024).toFixed(1); |
|
974
|
|
|
|
|
975
|
|
|
cell = row.insertCell(-1); |
|
976
|
|
|
if (ae.GetUplMsgIdHex(i)) { |
|
977
|
|
|
const btn = document.createElement("button"); |
|
978
|
|
|
btn.setAttribute("data-msgid", ae.GetUplMsgIdHex(i)); |
|
979
|
|
|
btn.type = "button"; |
|
980
|
|
|
btn.textContent = "X"; |
|
981
|
|
|
|
|
982
|
|
|
btn.onclick = function() { |
|
983
|
|
|
const tr = this.parentElement.parentElement; |
|
984
|
|
|
ae.Message_Delete(this.getAttribute("data-msgid"), function(error) { |
|
985
|
|
|
if (error === 0) tr.remove(); |
|
986
|
|
|
else errorDialog(error); |
|
987
|
|
|
}); |
|
988
|
|
|
}; |
|
989
|
|
|
|
|
990
|
|
|
cell.appendChild(btn); |
|
991
|
|
|
} |
|
992
|
|
|
} |
|
993
|
|
|
} |
|
994
|
|
|
|
|
995
|
|
|
function addAccountToTable(i) { |
|
996
|
|
|
const tblAccs = document.getElementById("tbd_accs"); |
|
997
|
|
|
const row = tblAccs.insertRow(-1); |
|
998
|
|
|
let cell; |
|
999
|
|
|
cell = row.insertCell(-1); cell.textContent = ae.Admin_GetUserPkHex(i); |
|
1000
|
|
|
cell = row.insertCell(-1); cell.textContent = ae.Admin_GetUserSpace(i); |
|
1001
|
|
|
cell = row.insertCell(-1); cell.textContent = ae.Admin_GetUserNAddr(i); |
|
1002
|
|
|
cell = row.insertCell(-1); cell.textContent = ae.Admin_GetUserSAddr(i); |
|
1003
|
|
|
cell = row.insertCell(-1); cell.textContent = ae.Admin_GetUserLevel(i); |
|
1004
|
|
|
|
|
1005
|
|
|
cell = row.insertCell(-1); |
|
1006
|
|
|
let btn = document.createElement("button"); |
|
1007
|
|
|
btn.type = "button"; |
|
1008
|
|
|
btn.textContent = "+"; |
|
1009
|
|
|
btn.disabled = (ae.Admin_GetUserLevel(i) === 3); |
|
1010
|
|
|
btn.onclick = function() {const c = this.parentElement.parentElement.cells; adjustLevel(c[0].textContent, parseInt(c[4].textContent, 10) + 1, c);}; |
|
1011
|
|
|
cell.appendChild(btn); |
|
1012
|
|
|
|
|
1013
|
|
|
cell = row.insertCell(-1); |
|
1014
|
|
|
btn = document.createElement("button"); |
|
1015
|
|
|
btn.type = "button"; |
|
1016
|
|
|
btn.textContent = "−"; |
|
1017
|
|
|
btn.disabled = (ae.Admin_GetUserLevel(i) === 0); |
|
1018
|
|
|
btn.onclick = function() {const c = this.parentElement.parentElement.cells; adjustLevel(c[0].textContent, parseInt(c[4].textContent, 10) - 1, c);}; |
|
1019
|
|
|
cell.appendChild(btn); |
|
1020
|
|
|
|
|
1021
|
|
|
cell = row.insertCell(-1); |
|
1022
|
|
|
btn = document.createElement("button"); |
|
1023
|
|
|
btn.type = "button"; |
|
1024
|
|
|
btn.textContent = "X"; |
|
1025
|
|
|
btn.onclick = function() { |
|
1026
|
|
|
const tr = this.parentElement.parentElement; |
|
1027
|
|
|
ae.Account_Delete(tr.cells[0].textContent, function(error) { |
|
1028
|
|
|
if (error === 0) tr.remove(); else errorDialog(error); |
|
1029
|
|
|
}); |
|
1030
|
|
|
}; |
|
1031
|
|
|
cell.appendChild(btn); |
|
1032
|
|
|
} |
|
1033
|
|
|
|
|
1034
|
|
|
function reloadAccount() { |
|
1035
|
|
|
// Limits |
|
1036
|
|
|
const tblLimits = document.getElementById("tbl_limits"); |
|
1037
|
|
|
if (ae.IsUserAdmin()) { |
|
1038
|
|
|
for (let i = 0; i < 4; i++) { |
|
1039
|
|
|
tblLimits.rows[i].cells[1].children[0].disabled = false; |
|
1040
|
|
|
tblLimits.rows[i].cells[2].children[0].disabled = false; |
|
1041
|
|
|
tblLimits.rows[i].cells[3].children[0].disabled = false; |
|
1042
|
|
|
|
|
1043
|
|
|
tblLimits.rows[i].cells[1].children[0].value = ae.GetLimitStorage(i) + 1; |
|
1044
|
|
|
tblLimits.rows[i].cells[2].children[0].value = ae.GetLimitNormalA(i); |
|
1045
|
|
|
tblLimits.rows[i].cells[3].children[0].value = ae.GetLimitShieldA(i); |
|
1046
|
|
|
} |
|
1047
|
|
|
} else { |
|
1048
|
|
|
const lvl = ae.GetUserLevel(); |
|
1049
|
|
|
tblLimits.rows[lvl].cells[1].children[0].value = ae.GetLimitStorage(lvl) + 1; |
|
1050
|
|
|
tblLimits.rows[lvl].cells[2].children[0].value = ae.GetLimitNormalA(lvl); |
|
1051
|
|
|
tblLimits.rows[lvl].cells[3].children[0].value = ae.GetLimitShieldA(lvl); |
|
1052
|
|
|
} |
|
1053
|
|
|
|
|
1054
|
|
|
// Accounts |
|
1055
|
|
|
const tblAccs = document.getElementById("tbd_accs"); |
|
1056
|
|
|
|
|
1057
|
|
|
// All: Our account |
|
1058
|
|
|
const row = tblAccs.insertRow(-1); |
|
1059
|
|
|
let cell; |
|
1060
|
|
|
cell = row.insertCell(-1); cell.textContent = ae.GetUserPkHex(); |
|
1061
|
|
|
cell = row.insertCell(-1); cell.textContent = Math.round(ae.GetTotalMsgBytes() / 1048576); // MiB |
|
1062
|
|
|
cell = row.insertCell(-1); cell.textContent = ae.GetAddressCountNormal(); |
|
1063
|
|
|
cell = row.insertCell(-1); cell.textContent = ae.GetAddressCountShield(); |
|
1064
|
|
|
cell = row.insertCell(-1); cell.textContent = ae.GetUserLevel(); |
|
1065
|
|
|
|
|
1066
|
|
|
cell = row.insertCell(-1); |
|
1067
|
|
|
let btn = document.createElement("button"); |
|
1068
|
|
|
btn.type = "button"; |
|
1069
|
|
|
btn.textContent = "+"; |
|
1070
|
|
|
btn.disabled = true; |
|
1071
|
|
|
cell.appendChild(btn); |
|
1072
|
|
|
|
|
1073
|
|
|
cell = row.insertCell(-1); |
|
1074
|
|
|
btn = document.createElement("button"); |
|
1075
|
|
|
btn.type = "button"; |
|
1076
|
|
|
btn.textContent = "−"; |
|
1077
|
|
|
btn.disabled = true; |
|
1078
|
|
|
btn.id = "btn_lowme"; |
|
1079
|
|
|
btn.onclick = function() { |
|
1080
|
|
|
const newLevel = parseInt(row.cells[4].textContent, 10) - 1; |
|
1081
|
|
|
ae.Account_Update(ae.GetUserPkHex(), newLevel, function(error) { |
|
1082
|
|
|
if (error === 0) { |
|
1083
|
|
|
row.cells[4].textContent = newLevel; |
|
1084
|
|
|
if (newLevel === 0) { |
|
1085
|
|
|
document.getElementById("btn_lowme").disabled = true; |
|
1086
|
|
|
document.getElementById("chk_lowme").disabled = true; |
|
1087
|
|
|
} |
|
1088
|
|
|
} else errorDialog(error); |
|
1089
|
|
|
}); |
|
1090
|
|
|
}; |
|
1091
|
|
|
cell.appendChild(btn); |
|
1092
|
|
|
|
|
1093
|
|
|
cell = row.insertCell(-1); |
|
1094
|
|
|
btn = document.createElement("button"); |
|
1095
|
|
|
btn.type = "button"; |
|
1096
|
|
|
btn.textContent = "X"; |
|
1097
|
|
|
btn.disabled = true; |
|
1098
|
|
|
btn.id = "btn_delme"; |
|
1099
|
|
|
btn.onclick = function() { |
|
1100
|
|
|
ae.Account_Delete(ae.GetUserPkHex(), function(error) { |
|
1101
|
|
|
if (error === 0) { |
|
1102
|
|
|
row.remove(); |
|
1103
|
|
|
document.getElementById("chk_delme").disabled = true; |
|
1104
|
|
|
} else errorDialog(error); |
|
1105
|
|
|
}); |
|
1106
|
|
|
}; |
|
1107
|
|
|
cell.appendChild(btn); |
|
1108
|
|
|
|
|
1109
|
|
|
document.getElementById("txt_reg").disabled = !ae.IsUserAdmin(); |
|
1110
|
|
|
document.getElementById("btn_reg").disabled = !ae.IsUserAdmin(); |
|
1111
|
|
|
document.getElementById("chk_lowme").disabled = (ae.GetUserLevel() === 0); |
|
1112
|
|
|
|
|
1113
|
|
|
// Contacts |
|
1114
|
|
|
for (let i = 0; i < ae.GetContactCount(); i++) { |
|
1115
|
|
|
addContact( |
|
1116
|
|
|
ae.GetContactMail(i), |
|
1117
|
|
|
ae.GetContactName(i), |
|
1118
|
|
|
ae.GetContactNote(i) |
|
1119
|
|
|
); |
|
1120
|
|
|
} |
|
1121
|
|
|
|
|
1122
|
|
|
refreshContactList(); |
|
1123
|
|
|
|
|
1124
|
|
|
// Addresses |
|
1125
|
|
|
for (let i = 0; i < ae.GetAddressCount(); i++) { |
|
1126
|
|
|
addAddress(i); |
|
1127
|
|
|
} |
|
1128
|
|
|
|
|
1129
|
|
|
updateAddressCounts(); |
|
1130
|
|
|
addMessages(); |
|
1131
|
|
|
addUploads(); |
|
1132
|
|
|
addSent(); |
|
1133
|
|
|
|
|
1134
|
|
|
document.getElementById("btn_rght").disabled = (tabs[tab].cur === tabs[tab].max); |
|
1135
|
|
|
} |
|
1136
|
|
|
|
|
1137
|
|
|
function deleteAddress(addr) { |
|
1138
|
|
|
const buttons = document.querySelectorAll("#tbl_addrs button"); |
|
1139
|
|
|
buttons.forEach(function(btn) {btn.disabled = true;}); |
|
1140
|
|
|
|
|
1141
|
|
|
let addressToDelete = -1; |
|
1142
|
|
|
for (let i = 0; i < ae.GetAddressCount(); i++) { |
|
1143
|
|
|
if (addr === ae.GetAddress(i)) { |
|
1144
|
|
|
addressToDelete = i; |
|
1145
|
|
|
break; |
|
1146
|
|
|
} |
|
1147
|
|
|
} |
|
1148
|
|
|
|
|
1149
|
|
|
if (addressToDelete === -1) return; |
|
1150
|
|
|
|
|
1151
|
|
|
ae.Address_Delete(addressToDelete, function(error1) { |
|
1152
|
|
|
if (error1 !== 0) { |
|
1153
|
|
|
buttons.forEach(function(btn) {btn.disabled = false;}); |
|
1154
|
|
|
errorDialog(error1); |
|
1155
|
|
|
return; |
|
1156
|
|
|
} |
|
1157
|
|
|
|
|
1158
|
|
|
document.getElementById("tbl_addrs").deleteRow(addressToDelete); |
|
1159
|
|
|
document.getElementById("write_from").remove(addressToDelete); |
|
1160
|
|
|
updateAddressCounts(); |
|
1161
|
|
|
|
|
1162
|
|
|
ae.Private_Update(function(error2) { |
|
1163
|
|
|
buttons.forEach(function(btn) {btn.disabled = false;}); |
|
1164
|
|
|
if (error2) errorDialog(error2); |
|
1165
|
|
|
}); |
|
1166
|
|
|
}); |
|
1167
|
|
|
} |
|
1168
|
|
|
|
|
1169
|
|
|
function addAddress(num) { |
|
1170
|
|
|
const addrTable = document.getElementById("tbl_addrs"); |
|
1171
|
|
|
const row = addrTable.insertRow(-1); |
|
1172
|
|
|
const addr = ae.GetAddress(num); |
|
1173
|
|
|
|
|
1174
|
|
|
let cell = row.insertCell(-1); |
|
1175
|
|
|
cell.textContent = addr; |
|
1176
|
|
|
cell.onclick = function() {navigator.clipboard.writeText(((this.textContent.length === 16) ? shieldMix(this.textContent) : this.textContent) + "@" + ae.GetDomainEml());}; |
|
1177
|
|
|
|
|
1178
|
|
|
cell = row.insertCell(-1); |
|
1179
|
|
|
let el = document.createElement("input"); |
|
1180
|
|
|
el.type = "checkbox"; |
|
1181
|
|
|
el.checked = ae.GetAddressAccExt(num); |
|
1182
|
|
|
cell.appendChild(el); |
|
1183
|
|
|
|
|
1184
|
|
|
cell = row.insertCell(-1); |
|
1185
|
|
|
el = document.createElement("input"); |
|
1186
|
|
|
el.type = "checkbox"; |
|
1187
|
|
|
el.checked = ae.GetAddressAccInt(num); |
|
1188
|
|
|
cell.appendChild(el); |
|
1189
|
|
|
|
|
1190
|
|
|
cell = row.insertCell(-1); |
|
1191
|
|
|
el = document.createElement("button"); |
|
1192
|
|
|
el.type = "button"; |
|
1193
|
|
|
el.textContent = "X"; |
|
1194
|
|
|
el.onclick = function() {deleteAddress(addr);}; |
|
1195
|
|
|
cell.appendChild(el); |
|
1196
|
|
|
|
|
1197
|
|
|
el = document.createElement("option"); |
|
1198
|
|
|
el.value = addr; |
|
1199
|
|
|
el.textContent = addr + "@" + ae.GetDomainEml(); |
|
1200
|
|
|
document.getElementById("write_from").appendChild(el); |
|
1201
|
|
|
} |
|
1202
|
|
|
|
|
1203
|
|
|
// Interface |
|
1204
|
|
|
document.getElementById("btn_dele").onclick = function() { |
|
1205
|
|
|
this.blur(); |
|
1206
|
|
|
|
|
1207
|
|
|
if (tab === TAB_WRITE) { |
|
1208
|
|
|
tabs[tab].cur = 0; |
|
1209
|
|
|
updateTab(); |
|
1210
|
|
|
|
|
1211
|
|
|
document.querySelector("#write2_pkey > input").value = ""; |
|
1212
|
|
|
|
|
1213
|
|
|
document.getElementById("write_recv").value = ""; |
|
1214
|
|
|
document.getElementById("write_subj").value = ""; |
|
1215
|
|
|
document.getElementById("write_body").value = ""; |
|
1216
|
|
|
|
|
1217
|
|
|
document.getElementById("write_recv").readOnly = false; |
|
1218
|
|
|
document.getElementById("write_subj").readOnly = false; |
|
1219
|
|
|
document.getElementById("write_subj").setAttribute("data-replyid", ""); |
|
1220
|
|
|
|
|
1221
|
|
|
document.getElementById("write_recv").focus(); |
|
1222
|
|
|
} |
|
1223
|
|
|
}; |
|
1224
|
|
|
|
|
1225
|
|
|
document.getElementById("btn_updt").onclick = function() { |
|
1226
|
|
|
const btn = this; |
|
1227
|
|
|
btn.disabled = true; |
|
1228
|
|
|
btn.blur(); |
|
1229
|
|
|
|
|
1230
|
|
|
if (tab === TAB_INBOX) { |
|
1231
|
|
|
document.getElementById("tbl_inbox").style.opacity = 0.5; |
|
1232
|
|
|
|
|
1233
|
|
|
ae.Message_Browse(true, false, function(error) { |
|
1234
|
|
|
if (error === 0) { |
|
1235
|
|
|
addMessages(); |
|
1236
|
|
|
addUploads(); |
|
1237
|
|
|
} else { |
|
1238
|
|
|
errorDialog(error); |
|
1239
|
|
|
} |
|
1240
|
|
|
|
|
1241
|
|
|
document.getElementById("tbl_inbox").style.opacity = 1; |
|
1242
|
|
|
btn.disabled = false; |
|
1243
|
|
|
}); |
|
1244
|
|
|
} |
|
1245
|
|
|
}; |
|
1246
|
|
|
|
|
1247
|
|
|
document.getElementById("btn_mdele").onclick = function() { |
|
1248
|
|
|
const delId = document.querySelector("article").getAttribute("data-msgid"); |
|
1249
|
|
|
if (!delId) return; |
|
1250
|
|
|
|
|
1251
|
|
|
const btn = this; |
|
1252
|
|
|
btn.blur(); |
|
1253
|
|
|
btn.disabled = true; |
|
1254
|
|
|
|
|
1255
|
|
|
ae.Message_Delete(delId, function(error) { |
|
1256
|
|
|
if (error !== 0) { |
|
1257
|
|
|
btn.disabled = false; |
|
1258
|
|
|
errorDialog(error); |
|
1259
|
|
|
return; |
|
1260
|
|
|
} |
|
1261
|
|
|
|
|
1262
|
|
|
switch (tab) { |
|
1263
|
|
|
case TAB_INBOX: addMessages(); break; |
|
1264
|
|
|
case TAB_DRBOX: addSent(); break; |
|
1265
|
|
|
case TAB_NOTES: addUploads(); break; |
|
1266
|
|
|
} |
|
1267
|
|
|
}); |
|
1268
|
|
|
}; |
|
1269
|
|
|
|
|
1270
|
|
|
function refreshContactList() { |
|
1271
|
|
|
let opts = []; |
|
1272
|
|
|
|
|
1273
|
|
|
for (let i = 0; i < ae.GetContactCount(); i++) { |
|
1274
|
|
|
const el = document.createElement("option"); |
|
1275
|
|
|
el.value = ae.GetContactMail(i); |
|
1276
|
|
|
opts.push(el); |
|
1277
|
|
|
} |
|
1278
|
|
|
|
|
1279
|
|
|
if (ae.IsUserAdmin()) { |
|
1280
|
|
|
const el = document.createElement("option"); |
|
1281
|
|
|
el.value = "public"; |
|
1282
|
|
|
opts.push(el); |
|
1283
|
|
|
} |
|
1284
|
|
|
|
|
1285
|
|
|
document.getElementById("contact_emails").replaceChildren(...opts); |
|
1286
|
|
|
} |
|
1287
|
|
|
|
|
1288
|
|
|
function addContact(mail, name, note) { |
|
1289
|
|
|
const tbl = document.getElementById("tbl_ctact"); |
|
1290
|
|
|
const row = tbl.insertRow(-1); |
|
1291
|
|
|
|
|
1292
|
|
|
let cell = row.insertCell(-1); |
|
1293
|
|
|
cell.autocapitalize = "off"; |
|
1294
|
|
|
cell.contentEditable = true; |
|
1295
|
|
|
cell.inputMode = "email"; |
|
1296
|
|
|
cell.spellcheck = false; |
|
1297
|
|
|
cell.textContent = mail; |
|
1298
|
|
|
|
|
1299
|
|
|
cell = row.insertCell(-1); |
|
1300
|
|
|
cell.autocapitalize = "words"; |
|
1301
|
|
|
cell.contentEditable = true; |
|
1302
|
|
|
cell.spellcheck = false; |
|
1303
|
|
|
cell.textContent = name; |
|
1304
|
|
|
|
|
1305
|
|
|
cell = row.insertCell(-1); |
|
1306
|
|
|
cell.autocapitalize = "off"; |
|
1307
|
|
|
cell.contentEditable = true; |
|
1308
|
|
|
cell.spellcheck = false; |
|
1309
|
|
|
cell.textContent = note; |
|
1310
|
|
|
|
|
1311
|
|
|
cell = row.insertCell(-1); |
|
1312
|
|
|
const el = document.createElement("button"); |
|
1313
|
|
|
el.type = "button"; |
|
1314
|
|
|
el.textContent = "X"; |
|
1315
|
|
|
el.onclick = function() {row.remove();}; |
|
1316
|
|
|
cell.appendChild(el); |
|
1317
|
|
|
} |
|
1318
|
|
|
|
|
1319
|
|
|
document.getElementById("btn_newcontact").onclick = function() { |
|
1320
|
|
|
addContact("", "", ""); |
|
1321
|
|
|
}; |
|
1322
|
|
|
|
|
1323
|
|
|
document.getElementById("btn_savecontacts").onclick = function() { |
|
1324
|
|
|
while (ae.GetContactCount() > 0) { |
|
1325
|
|
|
ae.DeleteContact(0); |
|
1326
|
|
|
} |
|
1327
|
|
|
|
|
1328
|
|
|
for (const row of document.getElementById("tbl_ctact").rows) { |
|
1329
|
|
|
ae.AddContact(row.cells[0].textContent, row.cells[1].textContent, row.cells[2].textContent); |
|
1330
|
|
|
} |
|
1331
|
|
|
|
|
1332
|
|
|
refreshContactList(); |
|
1333
|
|
|
|
|
1334
|
|
|
const btn = this; |
|
1335
|
|
|
btn.disabled = true; |
|
1336
|
|
|
|
|
1337
|
|
|
ae.Private_Update(function(error) { |
|
1338
|
|
|
btn.disabled = false; |
|
1339
|
|
|
if (error) errorDialog(error); |
|
1340
|
|
|
}); |
|
1341
|
|
|
}; |
|
1342
|
|
|
|
|
1343
|
|
|
function writeVerify() { |
|
1344
|
|
|
if ( |
|
1345
|
|
|
!document.getElementById("write_recv").reportValidity() |
|
1346
|
|
|
|| !document.getElementById("write_subj").reportValidity() |
|
1347
|
|
|
|| !document.getElementById("write_body").reportValidity() |
|
1348
|
|
|
) {tabs[TAB_WRITE].cur = 0; return;} |
|
1349
|
|
|
|
|
1350
|
|
|
document.getElementById("div_write_1").hidden = true; |
|
1351
|
|
|
document.getElementById("div_write_2").hidden = false; |
|
1352
|
|
|
|
|
1353
|
|
|
document.getElementById("write2_recv").textContent = document.getElementById("write_recv").value; |
|
1354
|
|
|
document.getElementById("write2_subj").textContent = document.getElementById("write_subj").value; |
|
1355
|
|
|
document.getElementById("write2_rply").textContent = document.getElementById("write_subj").getAttribute("data-replyid"); |
|
1356
|
|
|
document.getElementById("write2_body").textContent = document.getElementById("write_body").value; |
|
1357
|
|
|
|
|
1358
|
|
|
if (document.getElementById("write_recv").value.indexOf("@") >= 0) { |
|
1359
|
|
|
document.getElementById("write2_from").textContent = document.getElementById("write_from").value + "@" + ae.GetDomainEml(); |
|
1360
|
|
|
document.getElementById("write2_pkey").hidden = true; |
|
1361
|
|
|
} else { |
|
1362
|
|
|
document.getElementById("write2_from").textContent = document.getElementById("write_from").value; |
|
1363
|
|
|
document.getElementById("write2_pkey").hidden = (document.getElementById("write_recv").value === "public"); |
|
1364
|
|
|
} |
|
1365
|
|
|
|
|
1366
|
|
|
document.querySelector("#write2_send > button").disabled = false; |
|
1367
|
|
|
document.getElementById("write2_btntxt").textContent = (document.getElementById("write_recv").value === "public") ? "Make" : "Send to"; |
|
1368
|
|
|
} |
|
1369
|
|
|
|
|
1370
|
|
|
function updateTab() { |
|
1371
|
|
|
switch (tab) { |
|
1372
|
|
|
case TAB_INBOX: |
|
1373
|
|
|
addMessages(); |
|
1374
|
|
|
break; |
|
1375
|
|
|
|
|
1376
|
|
|
case TAB_DRBOX: |
|
1377
|
|
|
addSent(); |
|
1378
|
|
|
break; |
|
1379
|
|
|
|
|
1380
|
|
|
case TAB_WRITE: |
|
1381
|
|
|
if (tabs[tab].cur === 0) { |
|
1382
|
|
|
document.getElementById("div_write_1").hidden = false; |
|
1383
|
|
|
document.getElementById("div_write_2").hidden = true; |
|
1384
|
|
|
document.getElementById("write_body").focus(); |
|
1385
|
|
|
} else { |
|
1386
|
|
|
writeVerify(); |
|
1387
|
|
|
} |
|
1388
|
|
|
break; |
|
1389
|
|
|
|
|
1390
|
|
|
case TAB_NOTES: |
|
1391
|
|
|
for (let i = 0; i <= tabs[tab].max; i++) { |
|
1392
|
|
|
document.getElementById("div_notes").children[i].hidden = (i !== tabs[tab].cur); |
|
1393
|
|
|
} |
|
1394
|
|
|
break; |
|
1395
|
|
|
|
|
1396
|
|
|
case TAB_TOOLS: |
|
1397
|
|
|
for (let i = 0; i <= tabs[tab].max; i++) { |
|
1398
|
|
|
document.getElementById("div_tools").children[i].hidden = (i !== tabs[tab].cur); |
|
1399
|
|
|
} |
|
1400
|
|
|
break; |
|
1401
|
|
|
} |
|
1402
|
|
|
|
|
1403
|
|
|
document.getElementById("btn_left").disabled = (tabs[tab].cur === 0); |
|
1404
|
|
|
document.getElementById("btn_rght").disabled = (tabs[tab].cur === tabs[tab].max); |
|
1405
|
|
|
} |
|
1406
|
|
|
|
|
1407
|
|
|
document.getElementById("btn_left").onclick = function() { |
|
1408
|
|
|
tabs[tab].cur--; |
|
1409
|
|
|
if (tabs[tab].cur === 0) this.disabled = true; |
|
1410
|
|
|
if (tabs[tab].cur < tabs[tab].max) document.getElementById("btn_rght").disabled = false; |
|
1411
|
|
|
updateTab(); |
|
1412
|
|
|
this.blur(); |
|
1413
|
|
|
}; |
|
1414
|
|
|
|
|
1415
|
|
|
document.getElementById("btn_rght").onclick = function() { |
|
1416
|
|
|
tabs[tab].cur++; |
|
1417
|
|
|
if (tabs[tab].cur === tabs[tab].max) this.disabled = true; |
|
1418
|
|
|
document.getElementById("btn_left").disabled = false; |
|
1419
|
|
|
updateTab(); |
|
1420
|
|
|
this.blur(); |
|
1421
|
|
|
}; |
|
1422
|
|
|
|
|
1423
|
|
|
const buttons = document.querySelectorAll("#main1 > .top > button"); |
|
1424
|
|
|
for (let i = 0; i < buttons.length; i++) { |
|
1425
|
|
|
buttons[i].onclick = function() { |
|
1426
|
|
|
tab = i; |
|
1427
|
|
|
|
|
1428
|
|
|
for (let j = 0; j < buttons.length; j++) { |
|
1429
|
|
|
document.querySelectorAll("#main1 > .mid > div")[j].hidden = (tab !== j); |
|
1430
|
|
|
buttons[j].disabled = (tab === j); |
|
1431
|
|
|
} |
|
1432
|
|
|
|
|
1433
|
|
|
document.getElementById("btn_left").disabled = (tabs[tab].cur === 0); |
|
|
|
|
|
|
1434
|
|
|
document.getElementById("btn_rght").disabled = (tabs[tab].cur === tabs[tab].max); |
|
1435
|
|
|
document.getElementById("btn_dele").disabled = !tabs[tab].btnDele; |
|
1436
|
|
|
document.getElementById("btn_updt").disabled = !tabs[tab].btnUpdt; |
|
1437
|
|
|
|
|
1438
|
|
|
updateTab(); |
|
1439
|
|
|
}; |
|
1440
|
|
|
} |
|
1441
|
|
|
|
|
1442
|
|
|
function addressCreate(addr) { |
|
1443
|
|
|
document.getElementById("btn_address_create_normal").disabled = true; |
|
1444
|
|
|
document.getElementById("btn_address_create_shield").disabled = true; |
|
1445
|
|
|
|
|
1446
|
|
|
ae.Address_Create(addr, function(error1) { |
|
1447
|
|
|
if (error1 !== 0) { |
|
1448
|
|
|
updateAddressButtons(); |
|
1449
|
|
|
errorDialog(error1); |
|
1450
|
|
|
return; |
|
1451
|
|
|
} |
|
1452
|
|
|
|
|
1453
|
|
|
ae.Private_Update(function(error2) { |
|
1454
|
|
|
updateAddressCounts(); |
|
1455
|
|
|
|
|
1456
|
|
|
addAddress(ae.GetAddressCount() - 1); |
|
1457
|
|
|
if (addr !== "SHIELD") { |
|
1458
|
|
|
document.getElementById("txt_address_create_normal").value = ""; |
|
1459
|
|
|
document.getElementById("txt_address_create_normal").focus(); |
|
1460
|
|
|
} |
|
1461
|
|
|
|
|
1462
|
|
|
if (error2 !== 0) errorDialog(error2); |
|
1463
|
|
|
}); |
|
1464
|
|
|
}); |
|
1465
|
|
|
} |
|
1466
|
|
|
|
|
1467
|
|
|
document.getElementById("btn_address_create_normal").onclick = function() { |
|
1468
|
|
|
if (ae.GetAddressCountNormal() >= ae.GetLimitNormalA(ae.GetUserLevel()) || ae.GetAddressCountNormal() + ae.GetAddressCountShield() >= 31) return; |
|
1469
|
|
|
|
|
1470
|
|
|
const txtNewAddr = document.getElementById("txt_address_create_normal"); |
|
1471
|
|
|
if (!txtNewAddr.reportValidity()) return; |
|
1472
|
|
|
|
|
1473
|
|
|
addressCreate(txtNewAddr.value); |
|
1474
|
|
|
}; |
|
1475
|
|
|
|
|
1476
|
|
|
document.getElementById("btn_address_create_shield").onclick = function() { |
|
1477
|
|
|
if (ae.GetAddressCountShield() >= ae.GetLimitShieldA(ae.GetUserLevel()) || ae.GetAddressCountNormal() + ae.GetAddressCountShield() >= 31) return; |
|
1478
|
|
|
|
|
1479
|
|
|
addressCreate("SHIELD"); |
|
1480
|
|
|
}; |
|
1481
|
|
|
|
|
1482
|
|
|
document.getElementById("btn_address_update").onclick = function() { |
|
1483
|
|
|
const btn = this; |
|
1484
|
|
|
btn.disabled = true; |
|
1485
|
|
|
|
|
1486
|
|
|
const rows = document.getElementById("tbl_addrs").rows; |
|
1487
|
|
|
|
|
1488
|
|
|
for (let i = 0; i < rows.length; i++) { |
|
1489
|
|
|
ae.SetAddressAccExt(i, rows[i].getElementsByTagName("input")[0].checked); |
|
1490
|
|
|
ae.SetAddressAccInt(i, rows[i].getElementsByTagName("input")[1].checked); |
|
1491
|
|
|
} |
|
1492
|
|
|
|
|
1493
|
|
|
ae.Address_Update(function(error) { |
|
1494
|
|
|
btn.disabled = false; |
|
1495
|
|
|
if (error) errorDialog(error); |
|
1496
|
|
|
}); |
|
1497
|
|
|
}; |
|
1498
|
|
|
|
|
1499
|
|
|
|
|
1500
|
|
|
document.getElementById("txt_reg").onkeyup = function(event) { |
|
1501
|
|
|
if (event.key === "Enter") { |
|
1502
|
|
|
event.preventDefault(); |
|
1503
|
|
|
document.getElementById("btn_reg").click(); |
|
1504
|
|
|
} |
|
1505
|
|
|
}; |
|
1506
|
|
|
|
|
1507
|
|
|
document.getElementById("btn_reg").onclick = function() { |
|
1508
|
|
|
const btn = document.getElementById("btn_reg"); |
|
1509
|
|
|
const txt = document.getElementById("txt_reg"); |
|
1510
|
|
|
if (!txt.reportValidity()) return; |
|
1511
|
|
|
btn.disabled = true; |
|
1512
|
|
|
|
|
1513
|
|
|
ae.Account_Create(txt.value, function(error) { |
|
1514
|
|
|
if (error === 0) { |
|
1515
|
|
|
addAccountToTable(ae.Admin_GetUserCount() - 1); |
|
1516
|
|
|
txt.value = ""; |
|
1517
|
|
|
} else errorDialog(error); |
|
1518
|
|
|
|
|
1519
|
|
|
btn.disabled = false; |
|
1520
|
|
|
}); |
|
1521
|
|
|
}; |
|
1522
|
|
|
|
|
1523
|
|
|
document.getElementById("chk_delme").onclick = function() {document.getElementById("btn_delme").disabled = !this.checked;}; |
|
1524
|
|
|
document.getElementById("chk_lowme").onclick = function() {document.getElementById("btn_lowme").disabled = !this.checked;}; |
|
1525
|
|
|
|
|
1526
|
|
|
document.getElementById("btn_notepad_saveupl").onclick = function() { |
|
1527
|
|
|
const np = document.getElementById("txt_notepad"); |
|
1528
|
|
|
np.disabled = true; |
|
1529
|
|
|
|
|
1530
|
|
|
let fname = prompt("Save as...", "Untitled"); |
|
|
|
|
|
|
1531
|
|
|
if (!fname.endsWith(".txt")) fname += ".txt"; |
|
1532
|
|
|
|
|
1533
|
|
|
ae.Message_Upload(fname, np.value, function(error) { |
|
1534
|
|
|
if (error === 0) { |
|
1535
|
|
|
np.value = ""; |
|
1536
|
|
|
addUploads(); |
|
1537
|
|
|
document.getElementById("tbd_accs").children[0].children[1].textContent = Math.round(ae.GetTotalMsgBytes() / 1024 / 1024); |
|
1538
|
|
|
} else errorDialog(error); |
|
1539
|
|
|
|
|
1540
|
|
|
np.disabled = false; |
|
1541
|
|
|
}); |
|
1542
|
|
|
}; |
|
1543
|
|
|
|
|
1544
|
|
|
document.getElementById("btn_upload").onclick = function() { |
|
1545
|
|
|
const btn = this; |
|
1546
|
|
|
const fileSelector = document.createElement("input"); |
|
1547
|
|
|
fileSelector.type = "file"; |
|
1548
|
|
|
fileSelector.click(); |
|
1549
|
|
|
|
|
1550
|
|
|
fileSelector.onchange = function() { |
|
1551
|
|
|
btn.disabled = true; |
|
1552
|
|
|
|
|
1553
|
|
|
const reader = new FileReader(); |
|
1554
|
|
|
reader.onload = function() { |
|
1555
|
|
|
ae.Message_Upload(fileSelector.files[0].name, new Uint8Array(reader.result), function(error) { |
|
1556
|
|
|
if (error === 0) { |
|
1557
|
|
|
addUploads(); |
|
1558
|
|
|
document.getElementById("tbd_accs").children[0].children[1].textContent = Math.round(ae.GetTotalMsgBytes() / 1024 / 1024); |
|
1559
|
|
|
} else errorDialog(error); |
|
1560
|
|
|
|
|
1561
|
|
|
btn.disabled = false; |
|
1562
|
|
|
}); |
|
1563
|
|
|
}; |
|
1564
|
|
|
|
|
1565
|
|
|
reader.readAsArrayBuffer(fileSelector.files[0]); |
|
1566
|
|
|
}; |
|
1567
|
|
|
}; |
|
1568
|
|
|
|
|
1569
|
|
|
document.getElementById("btn_pg").onclick = function() { |
|
1570
|
|
|
localStorage.greeting = document.getElementById("txt_pg").value; |
|
1571
|
|
|
}; |
|
1572
|
|
|
|
|
1573
|
|
|
document.querySelector("#write2_send > button").onclick = function() { |
|
1574
|
|
|
const btn = this; |
|
1575
|
|
|
btn.disabled = true; |
|
1576
|
|
|
|
|
1577
|
|
|
// Public announcement |
|
1578
|
|
|
if (document.getElementById("write2_recv").textContent === "public") { |
|
1579
|
|
|
ae.Message_Public(document.getElementById("write_subj").value, document.getElementById("write_body").value, function(error) { |
|
1580
|
|
|
if (error === 0) { |
|
1581
|
|
|
document.getElementById("write2_btntxt").textContent = "Announced to"; |
|
1582
|
|
|
document.getElementById("write_recv").value = ""; |
|
1583
|
|
|
document.getElementById("write_subj").value = ""; |
|
1584
|
|
|
document.getElementById("write_body").value = ""; |
|
1585
|
|
|
} else { |
|
1586
|
|
|
// TODO display error |
|
1587
|
|
|
document.getElementById("write2_btntxt").textContent = "Retry making"; |
|
1588
|
|
|
btn.disabled = false; |
|
1589
|
|
|
} |
|
1590
|
|
|
}); |
|
1591
|
|
|
|
|
1592
|
|
|
return; |
|
1593
|
|
|
} |
|
1594
|
|
|
|
|
1595
|
|
|
// Email or internal message |
|
1596
|
|
|
document.getElementById("write2_btntxt").textContent = "Sending to"; |
|
1597
|
|
|
|
|
1598
|
|
|
ae.Message_Create( |
|
1599
|
|
|
document.getElementById("write_subj").value, |
|
1600
|
|
|
document.getElementById("write_body").value, |
|
1601
|
|
|
document.getElementById("write_from").value, |
|
1602
|
|
|
document.getElementById("write_recv").value, |
|
1603
|
|
|
document.getElementById("write_subj").getAttribute("data-replyid"), |
|
1604
|
|
|
(document.getElementById("write2_recv").textContent.indexOf("@") > 0) ? null : sodium.from_base64(document.querySelector("#write2_pkey > input").value, sodium.base64_variants.ORIGINAL_NO_PADDING), |
|
1605
|
|
|
function(error) { |
|
1606
|
|
|
if (error === 0) { |
|
1607
|
|
|
document.getElementById("write2_btntxt").textContent = "Delivered to"; |
|
1608
|
|
|
document.getElementById("write_recv").value = ""; |
|
1609
|
|
|
document.getElementById("write_subj").value = ""; |
|
1610
|
|
|
document.getElementById("write_body").value = ""; |
|
1611
|
|
|
} else { |
|
1612
|
|
|
errorDialog(error); |
|
1613
|
|
|
|
|
1614
|
|
|
document.getElementById("write2_btntxt").textContent = "Retry sending to"; |
|
1615
|
|
|
btn.disabled = false; |
|
1616
|
|
|
} |
|
1617
|
|
|
} |
|
1618
|
|
|
); |
|
1619
|
|
|
}; |
|
1620
|
|
|
|
|
1621
|
|
|
document.getElementById("txt_skey").onfocus = function() { |
|
1622
|
|
|
document.getElementById("greeting").textContent = localStorage.greeting; |
|
1623
|
|
|
}; |
|
1624
|
|
|
|
|
1625
|
|
|
document.getElementById("txt_skey").onkeyup = function(event) { |
|
1626
|
|
|
if (event.key === "Enter") { |
|
1627
|
|
|
event.preventDefault(); |
|
1628
|
|
|
document.getElementById("btn_enter").click(); |
|
1629
|
|
|
} |
|
1630
|
|
|
}; |
|
1631
|
|
|
|
|
1632
|
|
|
document.getElementById("btn_enter").onclick = function() { |
|
1633
|
|
|
const txtSkey = document.getElementById("txt_skey"); |
|
1634
|
|
|
|
|
1635
|
|
|
if (txtSkey.value === "") { |
|
1636
|
|
|
ae.Reset(); |
|
1637
|
|
|
document.getElementById("greeting").textContent = "Data cleared"; |
|
1638
|
|
|
return; |
|
1639
|
|
|
} |
|
1640
|
|
|
|
|
1641
|
|
|
if (!txtSkey.reportValidity()) return; |
|
1642
|
|
|
|
|
1643
|
|
|
const btn = this; |
|
1644
|
|
|
btn.disabled = true; |
|
1645
|
|
|
|
|
1646
|
|
|
document.getElementById("txt_skey").disabled = true; |
|
1647
|
|
|
document.getElementById("txt_skey").style.background = "#233"; |
|
1648
|
|
|
|
|
1649
|
|
|
ae.SetKeys(txtSkey.value, function(successSetKeys) { |
|
1650
|
|
|
if (successSetKeys) { |
|
1651
|
|
|
document.body.style.cursor = "wait"; |
|
1652
|
|
|
|
|
1653
|
|
|
ae.Message_Browse(false, true, function(statusBrowse) { |
|
1654
|
|
|
document.body.style.cursor = "auto"; |
|
1655
|
|
|
|
|
1656
|
|
|
if (statusBrowse === 0) { |
|
1657
|
|
|
txtSkey.value = ""; |
|
1658
|
|
|
document.getElementById("div_begin").hidden = true; |
|
1659
|
|
|
document.getElementById("div_main").hidden = false; |
|
1660
|
|
|
reloadAccount(); |
|
1661
|
|
|
|
|
1662
|
|
|
if (ae.IsUserAdmin()) { |
|
1663
|
|
|
ae.Account_Browse(function(statusAcc) { |
|
1664
|
|
|
if (statusAcc === 0) { |
|
1665
|
|
|
for (let i = 0; i < ae.Admin_GetUserCount(); i++) {addAccountToTable(i);} |
|
1666
|
|
|
} else { |
|
1667
|
|
|
errorDialog(statusAcc); |
|
1668
|
|
|
} |
|
1669
|
|
|
}); |
|
1670
|
|
|
} |
|
1671
|
|
|
} else { |
|
1672
|
|
|
document.getElementById("txt_skey").disabled = false; |
|
1673
|
|
|
document.getElementById("txt_skey").style.background = "#466"; |
|
1674
|
|
|
btn.focus(); |
|
1675
|
|
|
|
|
1676
|
|
|
document.getElementById("greeting").textContent = getErrorMessage(statusBrowse) + " (0x" + statusBrowse.toString(16).padStart(2, "0").toUpperCase() + ")"; |
|
1677
|
|
|
btn.disabled = false; |
|
1678
|
|
|
} |
|
1679
|
|
|
}); |
|
1680
|
|
|
} else { |
|
1681
|
|
|
document.getElementById("txt_skey").disabled = false; |
|
1682
|
|
|
document.getElementById("txt_skey").style.background = "#466"; |
|
1683
|
|
|
txtSkey.focus(); |
|
1684
|
|
|
|
|
1685
|
|
|
document.getElementById("greeting").textContent = "SetKeys failed"; |
|
1686
|
|
|
btn.disabled = false; |
|
1687
|
|
|
} |
|
1688
|
|
|
}); |
|
1689
|
|
|
}; |
|
1690
|
|
|
|
|
1691
|
|
|
}); |
|
1692
|
|
|
|