copious-mail 0.0.0-stage → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/LICENSE +504 -0
  2. package/README.md +143 -2
  3. package/bin/index.js +345 -0
  4. package/client/copiousLogo.svg +123 -0
  5. package/client/hosted.html +5259 -0
  6. package/client/mail_styles.css +40 -0
  7. package/client/mikado.bundle.debug.js +1406 -0
  8. package/client/mikado.bundle.min.js +68 -0
  9. package/client/mikado.bundle.module.debug.js +1401 -0
  10. package/client/mikado.bundle.module.min.js +67 -0
  11. package/client/mikado.bundle.profiler.debug.js +1490 -0
  12. package/client/mikado.es5.debug.js +1995 -0
  13. package/client/mikado.es5.min.js +85 -0
  14. package/client/mikado.light.debug.js +535 -0
  15. package/client/mikado.light.min.js +29 -0
  16. package/client/mikado.light.module.debug.js +530 -0
  17. package/data/user_list.db +14 -0
  18. package/index.html +7242 -0
  19. package/index.js +5 -0
  20. package/jsconfig.json +32 -0
  21. package/lib/mail_repo_bridge_ops.js +1177 -0
  22. package/lib/utils.js +70 -0
  23. package/lib/websocket_con.js +249 -0
  24. package/mail_bridge.conf +10 -0
  25. package/package.json +41 -5
  26. package/svelte-src/App.svelte +2513 -0
  27. package/svelte-src/ContactGrid.svelte +98 -0
  28. package/svelte-src/FloatWindow.svelte +181 -0
  29. package/svelte-src/MessageDisplay.svelte +230 -0
  30. package/svelte-src/MessageEditor.svelte +664 -0
  31. package/svelte-src/MessageListEditor.svelte +133 -0
  32. package/svelte-src/Thing.svelte +190 -0
  33. package/svelte-src/ThingFull.svelte +117 -0
  34. package/svelte-src/ipfs_profile_proxy.js +923 -0
  35. package/svelte-src/main.js +10 -0
  36. package/svelte-src/search_box.js +69 -0
  37. package/svelte-src/utilities.js +180 -0
  38. package/test/c +28 -0
  39. package/test/copiousLogo.svg +123 -0
  40. package/test/index.html +4408 -0
  41. package/test/index.js +244 -0
  42. package/test/mail_styles.css +40 -0
  43. package/test/mikado.bundle.debug.js +1406 -0
  44. package/test/mikado.bundle.min.js +68 -0
  45. package/test/mikado.bundle.module.debug.js +1401 -0
  46. package/test/mikado.bundle.module.min.js +67 -0
  47. package/test/mikado.bundle.profiler.debug.js +1490 -0
  48. package/test/mikado.es5.debug.js +1995 -0
  49. package/test/mikado.es5.min.js +85 -0
  50. package/test/mikado.light.debug.js +535 -0
  51. package/test/mikado.light.min.js +29 -0
  52. package/test/mikado.light.module.debug.js +530 -0
  53. package/test/tpl/partial/attachment_edit.es5.js +1 -0
  54. package/test/tpl/partial/attachment_edit.html +5 -0
  55. package/test/tpl/partial/attachment_edit.js +1 -0
  56. package/test/tpl/partial/attachment_view.es5.js +1 -0
  57. package/test/tpl/partial/attachment_view.html +1 -0
  58. package/test/tpl/partial/attachment_view.js +1 -0
  59. package/test/tpl/partial/contact_list.es5.js +1 -0
  60. package/test/tpl/partial/contact_list.html +9 -0
  61. package/test/tpl/partial/contact_list.js +1 -0
  62. package/test/tpl/partial/draft_list.es5.js +1 -0
  63. package/test/tpl/partial/draft_list.html +8 -0
  64. package/test/tpl/partial/draft_list.js +1 -0
  65. package/test/tpl/partial/inbox_list.es5.js +1 -0
  66. package/test/tpl/partial/inbox_list.html +7 -0
  67. package/test/tpl/partial/inbox_list.js +1 -0
  68. package/test/tpl/partial/notify_list.es5.js +1 -0
  69. package/test/tpl/partial/notify_list.html +8 -0
  70. package/test/tpl/partial/notify_list.js +1 -0
  71. package/test/tpl/partial/sent_list.es5.js +1 -0
  72. package/test/tpl/partial/sent_list.html +7 -0
  73. package/test/tpl/partial/sent_list.js +1 -0
  74. package/test/tpl/partial/spam_list.es5.js +1 -0
  75. package/test/tpl/partial/spam_list.html +8 -0
  76. package/test/tpl/partial/spam_list.js +1 -0
  77. package/test/tpl/partial/trash_list.es5.js +1 -0
  78. package/test/tpl/partial/trash_list.html +7 -0
  79. package/test/tpl/partial/trash_list.js +1 -0
  80. package/test/tpl/partial/user.es5.js +1 -0
  81. package/test/tpl/partial/user.html +18 -0
  82. package/test/tpl/partial/user.js +1 -0
  83. package/tools/jsdoc.conf +47 -0
  84. package/tools/templates/docdash/publish.js +843 -0
  85. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  86. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  87. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  88. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  89. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  90. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  91. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  92. package/tools/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  93. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  94. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  95. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  96. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  97. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  98. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  99. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  100. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  101. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  102. package/tools/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  103. package/tools/templates/docdash/static/scripts/collapse.js +67 -0
  104. package/tools/templates/docdash/static/scripts/commonNav.js +28 -0
  105. package/tools/templates/docdash/static/scripts/linenumber.js +25 -0
  106. package/tools/templates/docdash/static/scripts/nav.js +12 -0
  107. package/tools/templates/docdash/static/scripts/polyfill.js +4 -0
  108. package/tools/templates/docdash/static/scripts/prettify/Apache-License-2.0.txt +202 -0
  109. package/tools/templates/docdash/static/scripts/prettify/lang-css.js +2 -0
  110. package/tools/templates/docdash/static/scripts/prettify/prettify.js +28 -0
  111. package/tools/templates/docdash/static/scripts/search.js +99 -0
  112. package/tools/templates/docdash/static/styles/jsdoc.css +803 -0
  113. package/tools/templates/docdash/static/styles/prettify.css +80 -0
  114. package/tools/templates/docdash/tmpl/augments.tmpl +10 -0
  115. package/tools/templates/docdash/tmpl/container.tmpl +203 -0
  116. package/tools/templates/docdash/tmpl/details.tmpl +152 -0
  117. package/tools/templates/docdash/tmpl/example.tmpl +2 -0
  118. package/tools/templates/docdash/tmpl/examples.tmpl +13 -0
  119. package/tools/templates/docdash/tmpl/exceptions.tmpl +32 -0
  120. package/tools/templates/docdash/tmpl/layout.tmpl +102 -0
  121. package/tools/templates/docdash/tmpl/mainpage.tmpl +15 -0
  122. package/tools/templates/docdash/tmpl/members.tmpl +38 -0
  123. package/tools/templates/docdash/tmpl/method.tmpl +132 -0
  124. package/tools/templates/docdash/tmpl/modifies.tmpl +14 -0
  125. package/tools/templates/docdash/tmpl/namespace.tmpl +133 -0
  126. package/tools/templates/docdash/tmpl/params.tmpl +132 -0
  127. package/tools/templates/docdash/tmpl/properties.tmpl +107 -0
  128. package/tools/templates/docdash/tmpl/returns.tmpl +19 -0
  129. package/tools/templates/docdash/tmpl/source.tmpl +8 -0
  130. package/tools/templates/docdash/tmpl/tutorial.tmpl +19 -0
  131. package/tools/templates/docdash/tmpl/type.tmpl +26 -0
  132. package/tools/templates/templates/docdash/publish.js +843 -0
  133. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  134. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  135. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  136. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  137. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  138. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  139. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  140. package/tools/templates/templates/docdash/static/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  141. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  142. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  143. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  144. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  145. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  146. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  147. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  148. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  149. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  150. package/tools/templates/templates/docdash/static/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  151. package/tools/templates/templates/docdash/static/scripts/collapse.js +67 -0
  152. package/tools/templates/templates/docdash/static/scripts/commonNav.js +28 -0
  153. package/tools/templates/templates/docdash/static/scripts/linenumber.js +25 -0
  154. package/tools/templates/templates/docdash/static/scripts/nav.js +12 -0
  155. package/tools/templates/templates/docdash/static/scripts/polyfill.js +4 -0
  156. package/tools/templates/templates/docdash/static/scripts/prettify/Apache-License-2.0.txt +202 -0
  157. package/tools/templates/templates/docdash/static/scripts/prettify/lang-css.js +2 -0
  158. package/tools/templates/templates/docdash/static/scripts/prettify/prettify.js +28 -0
  159. package/tools/templates/templates/docdash/static/scripts/search.js +99 -0
  160. package/tools/templates/templates/docdash/static/styles/jsdoc.css +803 -0
  161. package/tools/templates/templates/docdash/static/styles/prettify.css +80 -0
  162. package/tools/templates/templates/docdash/tmpl/augments.tmpl +10 -0
  163. package/tools/templates/templates/docdash/tmpl/container.tmpl +203 -0
  164. package/tools/templates/templates/docdash/tmpl/details.tmpl +152 -0
  165. package/tools/templates/templates/docdash/tmpl/example.tmpl +2 -0
  166. package/tools/templates/templates/docdash/tmpl/examples.tmpl +13 -0
  167. package/tools/templates/templates/docdash/tmpl/exceptions.tmpl +32 -0
  168. package/tools/templates/templates/docdash/tmpl/layout.tmpl +102 -0
  169. package/tools/templates/templates/docdash/tmpl/mainpage.tmpl +15 -0
  170. package/tools/templates/templates/docdash/tmpl/members.tmpl +38 -0
  171. package/tools/templates/templates/docdash/tmpl/method.tmpl +132 -0
  172. package/tools/templates/templates/docdash/tmpl/modifies.tmpl +14 -0
  173. package/tools/templates/templates/docdash/tmpl/namespace.tmpl +133 -0
  174. package/tools/templates/templates/docdash/tmpl/params.tmpl +132 -0
  175. package/tools/templates/templates/docdash/tmpl/properties.tmpl +107 -0
  176. package/tools/templates/templates/docdash/tmpl/returns.tmpl +19 -0
  177. package/tools/templates/templates/docdash/tmpl/source.tmpl +8 -0
  178. package/tools/templates/templates/docdash/tmpl/tutorial.tmpl +19 -0
  179. package/tools/templates/templates/docdash/tmpl/type.tmpl +26 -0
  180. package/tpl/partial/user.es5.js +1 -0
  181. package/tpl/partial/user.html +10 -0
  182. package/tpl/partial/user.js +1 -0
@@ -0,0 +1,4408 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+
5
+ <meta charset="utf-8">
6
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
7
+ <meta name="author" content="Richard Leddy" />
8
+ <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
9
+ <meta id="theme-color" name="theme-color" content="#452770">
10
+
11
+ <link rel="canonical" href="http://www.copious.world">
12
+
13
+ <title>Copious World</title>
14
+ <meta name="description" content="An entry point into the our world of AI, IoT, and Communities built around songs, etc.">
15
+ <link rel="icon" type="image/svg+xml" href="/copiousLogo.svg" />
16
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700" />
17
+
18
+ <link rel="stylesheet" href="./mail_styles.css" />
19
+
20
+ <style>
21
+
22
+ .fade_able {
23
+ position:absolute;
24
+ visibility:hidden;
25
+ top : 10px; left : 10px;
26
+ height:80%;
27
+ width: 40%;
28
+ z-index:101;
29
+ border: rgba(252, 190, 190, 0.4) 2px solid;
30
+ background-color: white;
31
+ overflow:hidden;
32
+ box-shadow: 8px 8px 2px 1px rgb(0 0 255 / 0.2);
33
+ }
34
+
35
+ @media screen and (max-width: 1100px) {
36
+ .right_fade_able {
37
+ position:absolute;
38
+ visibility:hidden;
39
+ top : 10px; left : 10px;
40
+ height:80%;
41
+ width: 90%;
42
+ z-index:101;
43
+ border: rgba(252, 190, 190, 0.4) 2px solid;
44
+ background-color: white;
45
+ overflow:hidden;
46
+ box-shadow: 8px 8px 2px 1px rgb(0 0 255 / 0.2);
47
+ }
48
+ }
49
+ @media screen and (min-width: 1100px) {
50
+ .right_fade_able {
51
+ position:absolute;
52
+ visibility:hidden;
53
+ top : 10px; left : 20%;
54
+ height:80%;
55
+ width: 60%;
56
+ z-index:101;
57
+ border: rgba(252, 190, 190, 0.4) 2px solid;
58
+ background-color: white;
59
+ overflow:hidden;
60
+ box-shadow: 8px 8px 2px 1px rgb(0 0 255 / 0.2);
61
+ }
62
+ }
63
+
64
+
65
+ .fadeable-wide {
66
+ width: 60%;
67
+ }
68
+
69
+ @media screen and (max-width: 1040px) {
70
+ .fade_able {
71
+ width: 60%;
72
+ }
73
+ .fadeable-wide {
74
+ width: 60%;
75
+ }
76
+ }
77
+
78
+ @media screen and (max-width: 600px) {
79
+ .fade_able {
80
+ width: 90%;
81
+ }
82
+ .fadeable-wide {
83
+ width: 90%;
84
+ }
85
+ }
86
+
87
+
88
+ .fade_able_content {
89
+ height:100%;
90
+ width: 100%;
91
+ overflow:auto;
92
+ cursor: pointer;
93
+ }
94
+
95
+
96
+
97
+ .togglebar {
98
+ height: fit-content;
99
+ visibility:inherit;
100
+ background-color: navy;
101
+ text-align:right;
102
+ cursor: move;
103
+ }
104
+
105
+ .togglebar:hover {
106
+ background-color: darkgreen;
107
+ }
108
+
109
+
110
+ .togglebar-sect {
111
+ height:16px;
112
+ visibility:inherit;
113
+ background-color: navy;
114
+ text-align:center;
115
+ vertical-align:middle;
116
+ cursor: pointer;
117
+ font-weight: bold;
118
+ font-size:200%;
119
+ color: navy;
120
+ padding-bottom: 3px;
121
+ padding-top:0;
122
+ }
123
+
124
+ .togglebar-sect:hover {
125
+ background-color: darkgreen;
126
+ color: orange;
127
+ }
128
+
129
+
130
+ .closer_x {
131
+ padding-left:2px;
132
+ padding-right:2px;
133
+ color:rgb(216, 159, 37);
134
+ font-weight:bolder;
135
+ font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
136
+ border: solid 1px rgb(255, 102, 0);
137
+ cursor:pointer;
138
+ height: 24px;
139
+ min-height: 24px;
140
+ max-height: 24px;
141
+ font-weight: bolder;
142
+ background-color: rgba(92, 92, 117, 0.815);
143
+ }
144
+
145
+ .closer_x:hover {
146
+ padding-left:2px;
147
+ padding-right:2px;
148
+ color:purple;
149
+ font-weight:bolder;
150
+ font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
151
+ border: solid 1px rgb(44, 129, 44);
152
+ cursor:pointer;
153
+ height: inherit;
154
+ font-weight: bolder;
155
+ background-color: rgb(248, 245, 219);
156
+ }
157
+
158
+
159
+ .sizerbar {
160
+ position: absolute;
161
+ bottom: 0;
162
+ right: 0;
163
+ z-index: 1000; /* Adjust as needed to be above other content */
164
+ height:10px;
165
+ width: 10px;
166
+ visibility:inherit;
167
+ background-color: navy;
168
+ text-align:center;
169
+ cursor: nesw-resize;
170
+ font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
171
+ border: solid 1px rgb(44, 129, 44);
172
+ cursor:pointer;
173
+ font-weight: bolder;
174
+ }
175
+
176
+ .sizerbar:hover {
177
+ padding-left:2px;
178
+ padding-right:2px;
179
+ color:purple;
180
+ cursor: nesw-resize;
181
+ background-color: rgb(248, 245, 219);
182
+ }
183
+
184
+ .op-button {
185
+ padding:2px;
186
+ width:fit-content;
187
+ font-size: small;
188
+ border-color: rgb(248, 245, 219);
189
+ }
190
+
191
+ .flows-bash-cmd {
192
+ background-color:rgb(255, 255, 234);
193
+ border:1px solid rgb(51, 25, 51);
194
+ padding:2px;
195
+ color:rgb(53, 15, 15);
196
+ font-weight: 550;
197
+ }
198
+
199
+ .flows-bash-cmd-the-cmd {
200
+ color:rgb(9, 39, 9);
201
+ font-weight: 600;
202
+ }
203
+
204
+
205
+ .report-window-styles {
206
+ border : solid 1px rgb(43, 11, 43);
207
+ padding : 3px;
208
+ background-color: rgb(255, 253, 225);
209
+ }
210
+
211
+ </style>
212
+
213
+ <style>
214
+
215
+ html {
216
+ interpolate-size: allow-keywords;
217
+ }
218
+
219
+ summary {
220
+ list-style: none; /* Modern standard way */
221
+ }
222
+ summary::-webkit-details-marker {
223
+ display: none; /* Safari and older Chrome support */
224
+ }
225
+
226
+ /*
227
+ details[open] summary::after {
228
+ background-color: rgba(235, 235, 187, 1);
229
+ } */
230
+
231
+ /* 1. Target the wrapper element containing the content inside <details> */
232
+ details::details-content {
233
+ width: 0;
234
+ overflow: hidden;
235
+ }
236
+
237
+ /* 2. Target the content when the parent <details> is open */
238
+ details[open]::details-content {
239
+ width: auto;
240
+ }
241
+
242
+
243
+ .mail-go-container {
244
+ padding: 6px;
245
+ padding-right: 16px;
246
+ /* -- */
247
+ }
248
+
249
+ .mail-go-container > blockquote {
250
+ border: solid 1px rgb(8, 22, 8);
251
+ background-color: white;
252
+ box-shadow: 3px 3px rgba(128, 128, 128, 0.377);
253
+ margin: 0; /* Prevents default browser spacing */
254
+ position: absolute;
255
+ top: 0;
256
+ left:0;
257
+ height: calc(100vh - 40px);
258
+ overflow-y: auto;
259
+ transition: width 0.3s ease-out, content-visibility 0.3s allow-discrete;
260
+ display: none;
261
+ }
262
+
263
+ details[open] .mail-go-container > blockquote {
264
+ display: block;
265
+ width: 200px;
266
+ @starting-style { width: 0; }
267
+ }
268
+
269
+
270
+ .mail-go-container ul {
271
+ width: calc(100% - 24px);
272
+ list-style-type: none; /* Removes the dots */
273
+ padding-left: 10px;
274
+ padding-right: 10px;
275
+ margin: 0; /* Prevents default browser spacing */
276
+ }
277
+
278
+ .mail-go-container ul > li {
279
+ border-bottom: 1px solid rgb(5, 36, 5);
280
+ }
281
+
282
+ .mail-go-container ul > li > button {
283
+ width: 100%;
284
+ background-color: white;
285
+ border:none;
286
+ margin-bottom: 2%;
287
+ font-weight: bold;
288
+ font-size: 105%;
289
+ text-wrap: nowrap;
290
+ }
291
+
292
+ .mail-go-container ul > li > button:hover {
293
+ background-color: rgba(221, 255, 177, 0.57);
294
+ color: rgba(255, 123, 0, 0.86)
295
+ }
296
+
297
+
298
+ .follow-menu {
299
+ float: inline-end;
300
+ padding-right:20%;
301
+ font-weight: bold;
302
+ font-size: 1.15em;
303
+ width: 50%;
304
+ }
305
+
306
+ .search-band {
307
+ padding:4px;
308
+ text-align: center;
309
+ background-color: rgba(255, 255, 225, 1);
310
+ border-bottom: solid 1px rgb(7, 7, 39);
311
+ }
312
+ .search-band > span {
313
+ font-weight: bolder;
314
+ }
315
+ .search-band > input {
316
+ font-weight: normal;
317
+ width: 20%;
318
+ }
319
+ .search-band > button {
320
+ font-weight: normal;
321
+ width: fit-content;
322
+ text-wrap: nowrap;
323
+ border:none;
324
+ border-bottom: 1px dotted rgba(102, 102, 95, 0.356);
325
+ background-color: transparent;
326
+ box-shadow: 2px 2px rgba(186, 186, 201, 0.31);
327
+ }
328
+
329
+ h4 {
330
+ padding-left: 8%;
331
+ font-style: italic;
332
+ color: rgb(50, 88, 40);
333
+ width: calc(100% - 20px);
334
+ background-color: rgba(250, 250, 179, 0.84);
335
+ }
336
+
337
+ h4 > button {
338
+ border: none;
339
+ background-color: transparent;
340
+ cursor: pointer;
341
+ font: inherit;
342
+ text-wrap: nowrap;
343
+ }
344
+
345
+
346
+
347
+ /** list styling **/
348
+
349
+
350
+ .inbox_check_select {
351
+ border:solid 1px rgba(255, 0, 0, 0.438);
352
+ }
353
+ .sent_check_select {
354
+ border:solid 1px rgba(255, 0, 0, 0.438);
355
+ }
356
+ .spam_check_select {
357
+ border:solid 1px rgba(255, 0, 0, 0.438);
358
+ }
359
+ .notify_check_select {
360
+ border:solid 1px rgba(255, 0, 0, 0.438);
361
+ }
362
+ .drafts_check_select {
363
+ border:solid 1px rgba(255, 0, 0, 0.438);
364
+ }
365
+ .trash_check_select {
366
+ border:solid 1px rgba(255, 0, 0, 0.438);
367
+ }
368
+
369
+ /* drafts list */
370
+ .email-drafts {
371
+ background-color: white;
372
+ }
373
+ .email-drafts tr:hover td, tr:hover th {
374
+ background-color: #e0e0e0;
375
+ }
376
+ .email-drafts > thead th {
377
+ background-color: #e6f0d4ff;
378
+ }
379
+ .drafts-checkbox-th { background-color: white; cursor: pointer; width: 5%;}
380
+ .drafts-recipient-th { background-color: white; cursor: pointer; width: 25%; }
381
+ .drafts-subject-th { background-color: white; cursor: pointer; width: 33%; }
382
+ .drafts-date-th { background-color: white; cursor: pointer; width: 33%; }
383
+ /* ---- */
384
+ .ed-checkbox-cell { background-color: white; cursor: pointer; width: 5%; }
385
+ .ed-recipient-cell { background-color: white; cursor: pointer; width: 25%; padding-left: 4%; }
386
+ .ed-subject-cell { background-color: white; cursor: pointer; width: 33%; padding-left: 4%; }
387
+ .ed-date-cell { background-color: white; cursor: pointer; width: 33%; padding-left: 4%; }
388
+
389
+ .email-drafts th > button {
390
+ color: navy;
391
+ }
392
+ .email-drafts th > button:hover {
393
+ color: green;
394
+ background-color: #f7fddcff;
395
+ }
396
+
397
+ /* sent list */
398
+ .email-sent {
399
+ background-color: white;
400
+ }
401
+ .email-sent tr:hover td, tr:hover th {
402
+ background-color: #e0e0e0;
403
+ }
404
+ .email-sent > thead th {
405
+ background-color: #e6f0d4ff;
406
+ }
407
+ .sent-checkbox-th { background-color: white; cursor: pointer; width: 5%;}
408
+ .sent-recipient-th { background-color: white; cursor: pointer; width: 25%; }
409
+ .sent-subject-th { background-color: white; cursor: pointer; width: 33%; }
410
+ .sent-date-th { background-color: white; cursor: pointer; width: 33%; }
411
+ /* ---- */
412
+ .sent-checkbox-cell { background-color: white; cursor: pointer; width: 5%; }
413
+ .sent-recipient-cell { background-color: white; cursor: pointer; width: 25%; padding-left: 4%; }
414
+ .sent-subject-cell { background-color: white; cursor: pointer; width: 33%; padding-left: 4%; }
415
+ .sent-date-cell { background-color: white; cursor: pointer; width: 33%; padding-left: 4%; }
416
+
417
+ .email-sent th > button {
418
+ color: navy;
419
+ }
420
+ .email-sent th > button:hover {
421
+ color: green;
422
+ background-color: #f7fddcff;
423
+ }
424
+
425
+
426
+ /* inbox list */
427
+ .email-inbox {
428
+ background-color: white;
429
+ }
430
+ .email-inbox tr:hover td, tr:hover th {
431
+ background-color: #e0e0e0;
432
+ }
433
+ .email-inbox > thead th {
434
+ background-color: #e6f0d4ff;
435
+ }
436
+ .in-checkbox-th { background-color: white; cursor: pointer; width: 5%;}
437
+ .in-recipient-th { background-color: white; cursor: pointer; width: 25%; }
438
+ .in-subject-th { background-color: white; cursor: pointer; width: 33%; }
439
+ .in-date-th { background-color: white; cursor: pointer; width: 33%; }
440
+ /* ---- */
441
+ .in-checkbox-cell { background-color: white; cursor: pointer; width: 5%; }
442
+ .in-recipient-cell { background-color: white; cursor: pointer; width: 25%; padding-left: 4%; }
443
+ .in-subject-cell { background-color: white; cursor: pointer; width: 33%; padding-left: 4%; }
444
+ .in-date-cell { background-color: white; cursor: pointer; width: 33%; padding-left: 4%; }
445
+
446
+ .email-inbox th > button {
447
+ color: navy;
448
+ }
449
+ .email-inbox th > button:hover {
450
+ color: green;
451
+ background-color: #f7fddcff;
452
+ }
453
+
454
+
455
+ /* notify list */
456
+ .email-notify {
457
+ background-color: white;
458
+ }
459
+ .email-notify tr:hover td, tr:hover th {
460
+ background-color: #e0e0e0;
461
+ }
462
+ .email-notify > thead th {
463
+ background-color: #e6f0d4ff;
464
+ }
465
+ .notify-checkbox-th { background-color: white; cursor: pointer; width: 5%;}
466
+ .notify-recipient-th { background-color: white; cursor: pointer; width: 25%; }
467
+ .notify-subject-th { background-color: white; cursor: pointer; width: 33%; }
468
+ .notify-date-th { background-color: white; cursor: pointer; width: 33%; }
469
+ /* ---- */
470
+ .notify-checkbox-cell { background-color: white; cursor: pointer; width: 5%; }
471
+ .notify-recipient-cell { background-color: white; cursor: pointer; width: 25%; padding-left: 4%; }
472
+ .notify-subject-cell { background-color: white; cursor: pointer; width: 33%; padding-left: 4%; }
473
+ .notify-date-cell { background-color: white; cursor: pointer; width: 33%; padding-left: 4%; }
474
+
475
+ .email-notify th > button {
476
+ color: navy;
477
+ }
478
+ .email-notify th > button:hover {
479
+ color: green;
480
+ background-color: #f7fddcff;
481
+ }
482
+
483
+ /* spam list */
484
+ .email-spam {
485
+ background-color: white;
486
+ }
487
+ .email-spam tr:hover td, tr:hover th {
488
+ background-color: #e0e0e0;
489
+ }
490
+ .email-spam > thead th {
491
+ background-color: #e6f0d4ff;
492
+ }
493
+ .spam-checkbox-th { background-color: white; cursor: pointer; width: 5%;}
494
+ .spam-recipient-th { background-color: white; cursor: pointer; width: 25%; }
495
+ .spam-subject-th { background-color: white; cursor: pointer; width: 33%; }
496
+ .spam-date-th { background-color: white; cursor: pointer; width: 33%; }
497
+ /* ---- */
498
+ .spam-checkbox-cell { background-color: white; cursor: pointer; width: 5%; }
499
+ .spam-recipient-cell { background-color: white; cursor: pointer; width: 25%; padding-left: 4%; }
500
+ .spam-subject-cell { background-color: white; cursor: pointer; width: 33%; padding-left: 4%; }
501
+ .spam-date-cell { background-color: white; cursor: pointer; width: 33%; padding-left: 4%; }
502
+
503
+ .email-spam th > button {
504
+ color: navy;
505
+ }
506
+ .email-spam th > button:hover {
507
+ color: green;
508
+ background-color: #f7fddcff;
509
+ }
510
+
511
+ /* trash list */
512
+ .email-trash {
513
+ background-color: white;
514
+ }
515
+ .email-trash tr:hover td, tr:hover th {
516
+ background-color: #e0e0e0;
517
+ }
518
+ .email-trash > thead th {
519
+ background-color: #e6f0d4ff;
520
+ }
521
+ .trash-checkbox-th { background-color: white; cursor: pointer; width: 5%;}
522
+ .trash-recipient-th { background-color: white; cursor: pointer; width: 25%; }
523
+ .trash-subject-th { background-color: white; cursor: pointer; width: 33%; }
524
+ .trash-date-th { background-color: white; cursor: pointer; width: 33%; }
525
+ /* ---- */
526
+ .trash-checkbox-cell { background-color: white; cursor: pointer; width: 5%; }
527
+ .trash-recipient-cell { background-color: white; cursor: pointer; width: 25%; padding-left: 4%; }
528
+ .trash-subject-cell { background-color: white; cursor: pointer; width: 33%; padding-left: 4%; }
529
+ .trash-date-cell { background-color: white; cursor: pointer; width: 33%; padding-left: 4%; }
530
+
531
+
532
+ .email-trash th > button {
533
+ color: navy;
534
+ }
535
+ .email-trash th > button:hover {
536
+ color: green;
537
+ background-color: #f7fddcff;
538
+ }
539
+
540
+ .email-editor-body {
541
+ border: solid 1px rgb(13, 43, 13);
542
+ }
543
+
544
+ .mail-properties {
545
+ display: grid;
546
+ grid-template-columns: 20% 1fr;
547
+ gap: 12px 16px;
548
+ align-items: center;
549
+ padding: 16px;
550
+ background: #f9f9f9;
551
+ /* border-radius: 8px; */
552
+ /* max-width: 600px; */
553
+ }
554
+
555
+ .edit-mail-properties {
556
+ display: grid;
557
+ grid-template-columns: 20% 1fr;
558
+ gap: 12px 16px;
559
+ align-items: center;
560
+ padding: 16px;
561
+ background: #f9f9f9;
562
+ }
563
+
564
+
565
+ .contact-properties {
566
+ display: grid;
567
+ grid-template-columns: 20% 1fr;
568
+ gap: 12px 16px;
569
+ align-items: center;
570
+ padding: 16px;
571
+ background: #f9f9f9;
572
+ /* border-radius: 8px; */
573
+ /* max-width: 600px; */
574
+ }
575
+
576
+ .select-all-ops-properties {
577
+ display: grid;
578
+ grid-template-columns: 50% 1fr;
579
+ gap: 12px 16px;
580
+ align-items: center;
581
+ padding: 16px;
582
+ background: #f9f9f9;
583
+ /* border-radius: 8px;
584
+ max-width: 600px; */
585
+ }
586
+
587
+ .select-all-ops-properties-on-ops {
588
+ display: grid;
589
+ grid-template-columns: 50% 1fr;
590
+ gap: 12px 16px;
591
+ align-items: center;
592
+ padding: 2px;
593
+ border-top:solid 1px rgb(9, 37, 9);
594
+ border-bottom:solid 1px rgb(9, 37, 9);
595
+ background: #fffef7ff;
596
+ margin-top: 6px;
597
+ }
598
+
599
+ .style-confirm-properties {
600
+ display: grid;
601
+ grid-template-columns: 50% 1fr;
602
+ gap: 6px 66px;
603
+ align-items: center;
604
+ padding: 4px;
605
+ background: #fff6d9ff;
606
+ }
607
+
608
+ .attachments-controls {
609
+ background-color: rgb(243, 239, 219);
610
+ border-bottom: 1px solid rgb(9, 54, 9);
611
+ border-top: 1px solid rgb(9, 54, 9);
612
+ padding:4px;
613
+ font-style: italic;
614
+ color: rgb(50, 88, 40);
615
+ user-select: none;
616
+ cursor: arrow;
617
+ }
618
+
619
+ .attachments-controls > button {
620
+ border: none;
621
+ background-color: transparent;
622
+ cursor: pointer;
623
+ font: inherit;
624
+ text-wrap: nowrap;
625
+ }
626
+
627
+ .attachments-controls a:hover {
628
+ color:rgb(168, 53, 0);
629
+ font-weight: 600;
630
+ }
631
+
632
+ .file-dropper-handler.drag-over {
633
+ cursor: grab;
634
+ border: solid 1px rgb(255, 94, 0);
635
+ background-color: rgb(248, 255, 230);
636
+ }
637
+
638
+
639
+ .ops-button-containers {
640
+ background: #e9ebf0ff;
641
+ width: 100%;
642
+ border-bottom: 1px solid black;
643
+ margin-bottom: 8px;
644
+ }
645
+
646
+ .field-label {
647
+ font-weight: bold;
648
+ color: #555;
649
+ text-align: right;
650
+ }
651
+
652
+ .select-all-ops-properties-on-ops .field-label {
653
+ font-size:smaller;
654
+ color: #1f1c2eff;
655
+ }
656
+
657
+ .style-confirm-properties .field-label {
658
+ font-size:smaller;
659
+ color: #1f1c2eff;
660
+ }
661
+
662
+
663
+ .field-value {
664
+ color: #222;
665
+ word-break: break-word;
666
+ }
667
+
668
+ /** contact list **/
669
+
670
+ .contact-list {
671
+ background-color: white;
672
+ }
673
+ .contact-list tr:hover td, tr:hover th {
674
+ background-color: #e0e0e0;
675
+ }
676
+ .contact-list > thead th {
677
+ background-color: #e6f0d4ff;
678
+ }
679
+ .contact-checkbox-th { background-color: white; cursor: pointer; width: 5%;}
680
+ .contact-name-th { background-color: white; cursor: pointer; width: 25%; }
681
+ .contact-email-th { background-color: white; cursor: pointer; width: 33%; }
682
+ .contact-date-th { background-color: white; cursor: pointer; width: 33%; }
683
+ /* ---- */
684
+ .contact-checkbox-cell { background-color: white; cursor: pointer; width: 5%; }
685
+ .contact-name-cell { background-color: white; cursor: pointer; width: 25%; padding-left: 4%; }
686
+ .contact-email-cell { background-color: white; cursor: pointer; width: 33%; padding-left: 4%; }
687
+ .contact-date-cell { background-color: white; cursor: pointer; width: 33%; padding-left: 4%; }
688
+
689
+ .contact-list th > button {
690
+ color: navy;
691
+ }
692
+ .contact-list th > button:hover {
693
+ color: green;
694
+ background-color: #f7fddcff;
695
+ }
696
+
697
+ /* attachments */
698
+
699
+ .ul-attachments-list > li {
700
+ border-bottom: 1px solid rgba(228, 227, 219, 0.445);
701
+ }
702
+
703
+ .ul-attachments-list > li > button {
704
+ border: none;
705
+ border-bottom: 1px solid transparent;
706
+ font-weight: bold;
707
+ }
708
+ .ul-attachments-list > li > button:hover {
709
+ border-bottom: 1px solid navy;
710
+ }
711
+
712
+ .edit-attachments-cell-2 > button {
713
+ cursor: pointer;
714
+ border: none;
715
+ border-bottom: 1px dotted rgba(246, 255, 116, 1);
716
+ font-weight: bold;
717
+ }
718
+
719
+ .edit-attachments-cell-2 > button:hover {
720
+ color: rgba(87, 26, 26, 1);
721
+ background-color: rgb(251, 255, 242);
722
+ }
723
+
724
+ .edit-attachments-cell-3 > button {
725
+ cursor: pointer;
726
+ border: none;
727
+ border-bottom: 1px dotted rgba(255, 230, 116, 1);
728
+ font-weight: bold;
729
+ }
730
+
731
+ .edit-attachments-cell-3 > button:hover {
732
+ color: rgba(194, 0, 0, 1);
733
+ background-color: rgba(254, 255, 191, 1);
734
+ }
735
+
736
+ .show-cat {
737
+ font-weight: bold;
738
+ color: rgb(9, 9, 59);
739
+ }
740
+
741
+ </style>
742
+
743
+ <script type="module">
744
+
745
+ import Mikado from "./mikado.bundle.module.min.js";
746
+
747
+ //
748
+ // import tweet_template from "./tpl/partial/user.js";
749
+ // const tweet_view = new Mikado(tweet_template, {/* options */});
750
+ // window._x_share_tweet_view = tweet_view
751
+
752
+ //
753
+ import inbox_template from "./tpl/partial/inbox_list.js";
754
+ import sent_template from "./tpl/partial/sent_list.js";
755
+ import draft_template from "./tpl/partial/draft_list.js";
756
+ import spam_template from "./tpl/partial/spam_list.js";
757
+ import notify_template from "./tpl/partial/notify_list.js";
758
+ import trash_template from "./tpl/partial/trash_list.js";
759
+ import contacts_template from "./tpl/partial/contact_list.js";
760
+ import attachment_view_template from "./tpl/partial/attachment_view.js"
761
+ import attachment_edit_template from "./tpl/partial/attachment_edit.js"
762
+
763
+
764
+ let mail_imports = {
765
+ "inbox" : inbox_template,
766
+ 'sent' : sent_template,
767
+ 'drafts' : draft_template,
768
+ 'spam' : spam_template,
769
+ 'notify' : notify_template,
770
+ 'trash' : trash_template,
771
+ 'contacts' : contacts_template
772
+ }
773
+
774
+ let attachment_imports = {
775
+ 'view' : attachment_view_template,
776
+ 'edit' : attachment_edit_template
777
+ }
778
+
779
+ //
780
+ let mail_classes = ['inbox','sent','drafts','spam','notify','trash', 'contacts']
781
+ let mail_management = {}
782
+
783
+ for ( let mtype of mail_classes ) {
784
+ let store = new Mikado.Array();
785
+ let mail_template = mail_imports[mtype]
786
+ let view = new Mikado(mail_template, { observe: store });
787
+ mail_management[mtype] = {
788
+ "view" : view,
789
+ "store" : store,
790
+ "root" : null,
791
+ "container_el" : null
792
+ }
793
+ }
794
+
795
+ let attachment_classes = ['view','edit']
796
+ let attachment_management = {}
797
+
798
+ for ( let mtype of attachment_classes ) {
799
+ let store = new Mikado.Array();
800
+ let attachment_template = attachment_imports[mtype]
801
+ let view = new Mikado(attachment_template, { observe: store });
802
+ attachment_management[mtype] = {
803
+ "view" : view,
804
+ "store" : store,
805
+ "root" : null,
806
+ "container_el" : null
807
+ }
808
+ }
809
+
810
+ window._x_share_mail_managers = mail_management
811
+ window._x_share_mail_classes = ['inbox','sent','drafts','spam','notify','trash', 'contacts']
812
+
813
+ window._x_share_attachment_managers = attachment_management
814
+ window._x_share_attachment_classes = ['view','edit']
815
+
816
+ </script>
817
+ </head>
818
+ <body>
819
+ <nav id="mainNav" >
820
+
821
+ <div class="follow-menu">
822
+ <span id="mail-type-title">inbox</span>
823
+ </div>
824
+
825
+
826
+ <details id="squash_container" class="squash_m" >
827
+ <summary>
828
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" >
829
+ <path class="heroicon-ui" d="M4 5h16a1 1 0 0 1 0 2H4a1 1 0 1 1 0-2zm0 6h16a1 1 0 0 1 0 2H4a1 1 0 0 1 0-2zm0 6h16a1 1 0 0 1 0 2H4a1 1 0 0 1 0-2z"/>
830
+ </svg>
831
+ </summary>
832
+ <!-- MAIL MENU CONTROL -->
833
+ <div class="mail-go-container" >
834
+ <blockquote id="expanded-menu" onclick="close_if_open()">
835
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" >
836
+ <path class="heroicon-ui" d="M4 5h16a1 1 0 0 1 0 2H4a1 1 0 1 1 0-2zm0 6h16a1 1 0 0 1 0 2H4a1 1 0 0 1 0-2zm0 6h16a1 1 0 0 1 0 2H4a1 1 0 0 1 0-2z"/>
837
+ </svg>
838
+ <h4><button onclick="toggle_ul(event,'messages')">messages <span id="ardn-messages" style="display:inline-block">&#x25BC;</span><span id="arrt-messages" style="display:none">&#x25BA;</span></button></h4>
839
+ <ul id="ul-messages">
840
+ <li><button onclick="mail_create()" >write new</button></li>
841
+ <li><button onclick="mail_switch_to('drafts')" >drafts</button></li>
842
+ <li><button onclick="mail_switch_to('sent')" >sent</button></li>
843
+ </ul>
844
+ <h4><button onclick="toggle_ul(event,'received')">received <span id="ardn-received" style="display:inline-block">&#x25BC;</span><span id="arrt-received" style="display:none">&#x25BA;</span></button></h4>
845
+ <ul id="ul-received">
846
+ <li><button onclick="mail_switch_to('inbox')" >inbox</button></li>
847
+ <li><button onclick="mail_switch_to('notify')" >notfication</button></li>
848
+ </ul>
849
+ <h4><button onclick="toggle_ul(event,'filtered')">filtered <span id="ardn-filtered" style="display:inline-block">&#x25BC;</span><span id="arrt-filtered" style="display:none">&#x25BA;</span></button></h4>
850
+ <ul id="ul-filtered">
851
+ <li><button onclick="mail_switch_to('spam')" >spam</button></li>
852
+ <li><button onclick="mail_switch_to('trash')" >trash</button></li>
853
+ </ul>
854
+ <h4><button onclick="toggle_ul(event,'manage')">manage <span id="ardn-manage" style="display:inline-block">&#x25BC;</span><span id="arrt-manage" style="display:none">&#x25BA;</span></button></h4>
855
+ <ul id="ul-manage">
856
+ <li><button onclick="contacts_ui()" >contacts</button></li>
857
+ <li><button onclick="contact_create()" >add_contact</button></li>
858
+ <li><button onclick="search_ui('contacts')" >search contacts</button></li>
859
+ <li><button onclick="search_ui('messages')" >search messages</button></li>
860
+ <li><button onclick="manage_prefs()" >preferences</button></li>
861
+ </ul>
862
+ </blockquote>
863
+ </div>
864
+ </details>
865
+
866
+ <!--
867
+ /*
868
+ Source - https://stackoverflow.com/a/71646714
869
+ Posted by TrojanName
870
+ Retrieved 2026-09-09, License - CC BY-SA 4.0
871
+ */ -->
872
+
873
+ </nav>
874
+
875
+ <div class="search-band">
876
+ <span id="mail-search-title" >search</span>
877
+ <span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
878
+ <input id="search-filter" type="text" value="" />
879
+ <span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
880
+ <select id="banner_mail_type_selector" onchange="mail_switch_to_event(event)" >
881
+ <option value="all-messages">all messages</option>
882
+ <optgroup label="received">
883
+ <option value="inbox">inbox</option>
884
+ <option value="notify">notify</option>
885
+ </optgroup>
886
+ <optgroup label="composed">
887
+ <option value="drafts">drafts</option>
888
+ <option value="sent">sent</option>
889
+ </optgroup>
890
+ <optgroup label="no interest">
891
+ <option value="spam">spam</option>
892
+ <option value="trash">trash</option>
893
+ </optgroup>
894
+ </select>
895
+ <span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
896
+ <button onclick="detailed_search(event)">detailed search</button>
897
+ </div>
898
+
899
+
900
+ <!-- MAIL DISPLAY -->
901
+ <main id="mail-main" >
902
+ <div id="inbox-mail" style="display:block" >
903
+ <div>
904
+ <table class="email-inbox" style="width:100%" >
905
+ <thead>
906
+ <th class="in-checkbox-th"><button onclick="do_op_modal('inbox')">ops</button></th>
907
+ <th class="in-recipient-th">sender</th>
908
+ <th class="in-subject-th">subject</th>
909
+ <th class="in-date-th">time</th>
910
+ </thead>
911
+ </table>
912
+ <table id="list-mail-inbox" class="email-inbox" style="width:100%" >
913
+
914
+ </table>
915
+ </div>
916
+ </div>
917
+ <div id="notify-mail" style="display:none" >
918
+ <div>
919
+ <table class="email-notify" style="width:100%" >
920
+ <thead>
921
+ <th class="notify-checkbox-th"><button onclick="do_op_modal('notify')">ops</button></th>
922
+ <th class="notify-recipient-th">sender</th>
923
+ <th class="notify-subject-th">subject</th>
924
+ <th class="notify-date-th">time</th>
925
+ </thead>
926
+ </table>
927
+ <table id="list-mail-notify" class="email-notify" style="width:100%" >
928
+
929
+ </table>
930
+ </div>
931
+ </div>
932
+ <div id="sent-mail" style="display:none" >
933
+ <div>
934
+ <table class="email-sent" style="width:100%" >
935
+ <thead>
936
+ <th class="sent-checkbox-th"><button onclick="do_op_modal('sent')">ops</button></th>
937
+ <th class="sent-recipient-th">sender</th>
938
+ <th class="sent-subject-th">subject</th>
939
+ <th class="sent-date-th">time</th>
940
+ </thead>
941
+ </table>
942
+ <table id="list-mail-sent" class="email-sent" style="width:100%" >
943
+
944
+ </table>
945
+ </div>
946
+ </div>
947
+ <div id="drafts-mail" style="display:none" >
948
+ <div>
949
+ <table class="email-drafts" style="width:100%" >
950
+ <thead>
951
+ <th class="drafts-checkbox-th"><button onclick="do_op_modal('drafts')">ops</button></th>
952
+ <th class="drafts-recipient-th">recipient</th>
953
+ <th class="drafts-subject-th">subject</th>
954
+ <th class="drafts-date-th">time</th>
955
+ </thead>
956
+ </table>
957
+ <table id="list-mail-drafts" class="email-drafts" style="width:100%" >
958
+
959
+ </table>
960
+ </div>
961
+ </div>
962
+ <div id="spam-mail" style="display:none" >
963
+ <div>
964
+ <table class="email-spam" style="width:100%" >
965
+ <thead>
966
+ <th class="spam-checkbox-th"><button onclick="do_op_modal('spam')">ops</button></th>
967
+ <th class="spam-recipient-th">sender</th>
968
+ <th class="spam-subject-th">subject</th>
969
+ <th class="spam-date-th">time</th>
970
+ </thead>
971
+ </table>
972
+ <table id="list-mail-spam" class="email-spam" style="width:100%" >
973
+
974
+ </table>
975
+ </div>
976
+ </div>
977
+ <div id="trash-mail" style="display:none" >
978
+ <div>
979
+ <table class="email-trash" style="width:100%" >
980
+ <thead>
981
+ <th class="trash-checkbox-th"><button onclick="do_op_modal('trash')">ops</button></th>
982
+ <th class="trash-recipient-th">sender</th>
983
+ <th class="trash-subject-th">subject</th>
984
+ <th class="trash-date-th">time</th>
985
+ </thead>
986
+ </table>
987
+ <table id="list-mail-trash" class="email-trash" style="width:100%" >
988
+
989
+ </table>
990
+ </div>
991
+ </div>
992
+
993
+ <div id="human-contacts" style="display:none" >
994
+ <div>
995
+ <table class="contact-list" style="width:100%" >
996
+ <thead>
997
+ <th class="contact-checkbox-th"><button onclick="do_contact_op_modal()">ops</button></th>
998
+ <th class="contact-name-th">name</th>
999
+ <th class="contact-email-th">email</th>
1000
+ <th class="contact-date-th">time</th>
1001
+ </thead>
1002
+ </table>
1003
+ <table id="list-contacts" class="contact-list" style="width:100%" >
1004
+
1005
+ </table>
1006
+ </div>
1007
+ </div>
1008
+
1009
+ </main>
1010
+
1011
+
1012
+ <div id="email_view" class="right_fade_able" style="z-index:124" >
1013
+ <div class="togglebar" >
1014
+ <span class="closer_x" onmousedown="closefader(event,'email_view');void_current_edit_email()">X</span>
1015
+ </div>
1016
+ <div class="sizerbar" > S </div>
1017
+ <div class="fade_able_content" >
1018
+ <div class="ops-button-containers">
1019
+ <span id="mail_view_category" class="show-cat" >inbox: </span>&nbsp;&nbsp;
1020
+ <button id="mail_view_move" onclick="single_mail_ops(event);">ops</button>
1021
+ </div>
1022
+ <div class="mail-properties">
1023
+ <div class="field-label">From:</div>
1024
+ <div id="view-email-sender" class="field-value">sender@example.com</div>
1025
+
1026
+ <div class="field-label">To:</div>
1027
+ <div id="view-email-recipient" class="field-value">recipient@example.com</div>
1028
+
1029
+ <div class="field-label">cc:</div>
1030
+ <div id="view-email-cc" class="field-value"></div>
1031
+
1032
+ <div class="field-label">Subject:</div>
1033
+ <div id="view-email-subject" class="field-value">Project Update &amp; Next Steps</div>
1034
+
1035
+ <div class="field-label">Date:</div>
1036
+ <div id="view-email-date" class="field-value">September 14, 2026, 12:51 PM</div>
1037
+ </div>
1038
+ <div class="attachments-controls">
1039
+ <button onclick="toggle_ul(event,'attachments')">attachments <span id="ardn-attachments" style="display:none">&#x25BC;</span><span id="arrt-attachments" style="display:inline-block">&#x25BA;</span></button>
1040
+ <ul id="ul-attachments" class="ul-attachments-list" style="display:none" >
1041
+ <li><button id="attach-128" onclick="show_attachment(128)">first attachment</button></li>
1042
+ <li><button id="attach-129" onclick="show_attachment(129)">second attachment</button></li>
1043
+ <li><button id="attach-130" onclick="show_attachment(130)">third attachment</button></li>
1044
+ </ul>
1045
+ </div>
1046
+ <div class="message-box" style="min-width: 400px;min-height: 300px;">
1047
+ <div id="email_message_contents" >
1048
+ This is the email to view
1049
+ </div>
1050
+ </div>
1051
+ </div>
1052
+ </div>
1053
+
1054
+
1055
+ <!-- Style the label to look exactly like a button using CSS -->
1056
+ <style>
1057
+ .custom-button {
1058
+ display: inline-block;
1059
+ padding: 2px 4px;
1060
+ border-radius: 2px;
1061
+ cursor: pointer;
1062
+ font-family: sans-serif;
1063
+ border:solid 1px transparent;
1064
+ }
1065
+ .custom-button:hover {
1066
+ color: rgb(94, 5, 5);
1067
+ background-color: #e9fff8ff;
1068
+ border:dotted 1px rgb(255, 169, 57);
1069
+ }
1070
+ </style>
1071
+
1072
+
1073
+ <div id="email_edit" class="right_fade_able" style="z-index:124" >
1074
+ <div class="togglebar" >
1075
+ <span class="closer_x" onmousedown="closefader(event,'email_edit');mail_edit_mode_reset(event);void_current_edit_email();">X</span>
1076
+ </div>
1077
+ <div class="sizerbar" > S </div>
1078
+ <div class="fade_able_content" >
1079
+ <div class="ops-button-containers">
1080
+ <span id="drafts_view_category" class="show-cat">drafts: </span>&nbsp;&nbsp;
1081
+ <button id="mail_edit_mode_send" onclick="do_send_mail_closefader(event)">send</button>
1082
+ <span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
1083
+ <button id="mail_edit_mode_save" onclick="edit_mail_save(event);" >save</button>
1084
+ <button id="mail_edit_mode_cancel" onclick="mail_edit_mode_reset(event);closefader(event,'email_edit');" >cancel</button>
1085
+ <span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
1086
+ <button id="mail_ops" onclick="single_mail_ops(event);">ops</button>
1087
+ </div>
1088
+ <div class="edit-mail-properties">
1089
+ <div class="field-label">From:</div>
1090
+ <div class="field-value"><input id="edit-email-sender" type="email" /></div>
1091
+
1092
+ <div class="field-label">To:</div>
1093
+ <div class="field-value"><input id="edit-email-recipient" type="email" /></div>
1094
+
1095
+ <div class="field-label">cc:</div>
1096
+ <div id="view-email-cc" class="field-value"><input id="edit-email-cc" type="email" /></div>
1097
+
1098
+ <div class="field-label">bcc:</div>
1099
+ <div id="view-email-bcc" class="field-value"><input id="edit-email-bcc" type="email" /></div>
1100
+
1101
+ <div class="field-label">Subject:</div>
1102
+ <div class="field-value"></label><input id="edit-email-subject" type="text" /></div>
1103
+
1104
+ <div class="field-label">Last edit:</div>
1105
+ <div id="edit-email-date" class="field-value">September 14, 2026, 12:51 PM</div>
1106
+ </div>
1107
+ <div id="edit-email-attachments" class="attachments-controls file-dropper-handler" dropzone="true" >
1108
+ <label for="fileInput" class="custom-button">
1109
+ add &#128206;
1110
+ </label>
1111
+ <input type="file" id="fileInput" style="display: none;" onchange="onFileSelected(event)" />
1112
+
1113
+ <button onclick="toggle_table(event,'edit-attachments')">attachments <span id="ardn-edit-attachments" style="display:none">&#x25BC;</span><span id="arrt-edit-attachments" style="display:inline-block">&#x25BA;</span></button>
1114
+ <table id="table-edit-attachments" style="display:none" >
1115
+ <tr><td class="edit-attachments-cell-1">first attachment</td> <td class="edit-attachments-cell-2">view</td><td class="edit-attachments-cell-3">delete</td></tr>
1116
+ <tr><td class="edit-attachments-cell-1">second attachment</td> <td class="edit-attachments-cell-2">view</td><td class="edit-attachments-cell-3">delete</td></tr>
1117
+ <tr><td class="edit-attachments-cell-1">third attachment</td> <td class="edit-attachments-cell-2">view</td><td class="edit-attachments-cell-3">delete</td></tr>
1118
+ </table>
1119
+ </div>
1120
+ <div class="message-box" style="min-width: 400px;min-height: 300px;">
1121
+ <div class="email-editor-body" id="email_message_contents_edit" contenteditable="true" >
1122
+ This is the email to view
1123
+ </div>
1124
+ </div>
1125
+ </div>
1126
+ </div>
1127
+
1128
+
1129
+ <div id="contact_view" class="right_fade_able" style="z-index:124" >
1130
+ <div class="togglebar" >
1131
+ <span class="closer_x" onmousedown="closefader(event,'contact_view');contact_edit_mode_reset(event)">X</span>
1132
+ </div>
1133
+ <div class="sizerbar" > S </div>
1134
+ <div class="fade_able_content" >
1135
+ <div class="ops-button-containers" >
1136
+ <button id="contact_edit_mode_select" onclick="contact_edit_mode_toggle(event)">edit</button>
1137
+ <button id="contact_edit_mode_cancel" onclick="contact_edit_mode_reset(event)" style="display: none;">cancel</button>
1138
+ <button id="contact_launch_compose" onclick="contact_launch_compose(event)">compose message</button>
1139
+ <button id="contact_remove" onclick="remove_one_contact(event);closefader(event,'contact_view')">remove contact</button>
1140
+ </div>
1141
+ <div id="contact-properties-view" class="contact-properties" style="display: grid;">
1142
+ <div class="field-label">Name:</div>
1143
+ <div id="view-contact-name" class="field-value">Sender Upper</div>
1144
+
1145
+ <div class="field-label">Email:</div>
1146
+ <div id="view-contact-email" class="field-value">contact@example.com</div>
1147
+
1148
+ <div class="field-label">Date:</div>
1149
+ <div id="view-contact-date" class="field-value">September 14, 2026, 12:51 PM</div>
1150
+ </div>
1151
+ <div id="contact-properties-edit" class="contact-properties" style="display: none;">
1152
+ <div class="field-label">Name:</div>
1153
+ <div class="field-value"><input id="edit-contact-name" type="text" /></div>
1154
+
1155
+ <div class="field-label">Email:</div>
1156
+ <div class="field-value"><input id="edit-contact-email" type="email" /></div>
1157
+
1158
+ <div class="field-label">Date:</div>
1159
+ <div id="edit-contact-date" class="field-value">September 14, 2026, 12:51 PM</div>
1160
+ </div>
1161
+ <div class="message-box" style="min-width: 400px;min-height: 300px;">
1162
+ <div class="email-editor-body" id="contact_contents_edit" contenteditable="true" >
1163
+ Contact record info
1164
+ </div>
1165
+ </div>
1166
+ </div>
1167
+ </div>
1168
+
1169
+
1170
+
1171
+ <div id="preferences" class="right_fade_able" style="z-index:124" >
1172
+ <div class="togglebar" >
1173
+ <span class="closer_x" onmousedown="closefader(event,'preferences')">X</span>
1174
+ </div>
1175
+ <div class="sizerbar" > S </div>
1176
+ <div class="fade_able_content" >
1177
+ update a user's preferences
1178
+ </div>
1179
+ </div>
1180
+
1181
+ <!--
1182
+ * Drafts can delete, move to trash, or be sent (sending moves to sent).
1183
+ * Sent can move to archive, or copy to drafts.
1184
+ * Inbox can move to trash, to spam, or notify
1185
+ * Spam can move to trash, to inbox, or notify
1186
+ * Notify can move to trash, to inbox, or to spam
1187
+ * Trash can permanently delete a message, or move to inbox, or notify
1188
+ -->
1189
+ <dialog id="email-ops-modal" style="min-width: 300px;">
1190
+ <div id="email-ops-drafts" style="display: none;" >
1191
+ <button onclick="prep_send_email_list('drafts')">send</button>
1192
+ <button onclick="prep_email_list_move_to('drafts','trash')">move to trash</button>
1193
+ </div>
1194
+ <div id="email-ops-sent" style="display: none;" >
1195
+ <button onclick="prep_email_list_move_to('sent','archive')">archive</button>
1196
+ <button onclick="prep_email_list_copy_to('sent','drafts')">copy to drafts</button>
1197
+ </div>
1198
+ <div id="email-ops-inbox" style="display: none;" >
1199
+ <button onclick="prep_email_list_reply_to('inbox')">reply</button>
1200
+ <button onclick="prep_email_list_reply_all('inbox')">reply all</button>
1201
+ &nbsp;|&nbsp;
1202
+ <button onclick="prep_email_list_move_to('inbox','trash')">move to trash</button>
1203
+ <button onclick="prep_email_list_move_to('inbox','spam')">move to spam</button>
1204
+ <button onclick="prep_email_list_move_to('inbox','notfify')">move to notify</button>
1205
+ </div>
1206
+ <div id="email-ops-spam" style="display: none;" >
1207
+ <button onclick="prep_email_list_move_to('spam','trash')">move to trash</button>
1208
+ <button onclick="prep_email_list_move_to('spam','inbox')">move to inbox</button>
1209
+ <button onclick="prep_email_list_move_to('spam','notfify')">move to notify</button>
1210
+ </div>
1211
+ <div id="email-ops-notify" style="display: none;" >
1212
+ <button onclick="prep_email_list_move_to('notify','trash')">move to trash</button>
1213
+ <button onclick="prep_email_list_move_to('notify','inbox')">move to inbox</button>
1214
+ <button onclick="prep_email_list_move_to('notify','spam')">move to spam</button>
1215
+ </div>
1216
+ <div id="email-ops-trash" style="display: none;" >
1217
+ <button onclick="prep_email_list_delete('trash')">delete</button>
1218
+ <button onclick="prep_email_list_move_to('trash','inbox')">move to inbox</button>
1219
+ <button onclick="prep_email_list_move_to('trash','notfify')">move to notify</button>
1220
+ </div>
1221
+ <div class="select-all-ops-properties-on-ops">
1222
+ <div class="field-label">Select All:</div>
1223
+ <div class="field-value"><input id="select-all-op-on-ops" type="checkbox" onchange="toggle_current_select_all(event)" value="inbox" /></div>
1224
+ </div>
1225
+ <form method="dialog">
1226
+ <p id="chosen_operation"><u>Please select an action to perform.</u></p>
1227
+ <!-- Cancel button: closes modal, returnValue is "cancel" -->
1228
+ <button type="submit" formmethod="dialog" value="cancel">Cancel</button>
1229
+ <!-- Close/Confirm button: closes modal, returnValue is "confirm" or selected value -->
1230
+ <button id="email-ops-modal-ok" type="submit" value="confirm" disabled>OK</button>
1231
+ </form>
1232
+ </dialog>
1233
+
1234
+ <dialog id="contact-ops-modal" style="min-width: 300px;">
1235
+ <div id="email-ops-drafts" style="display: block;" >
1236
+ <button onclick="prep_compose_for_contacts()">compose a message</button>
1237
+ <!-- <button onclick="prep_instant_message_contacts()">instant message</button> -->
1238
+ <button onclick="prep_edit_contacts()">edit contacts</button>
1239
+ <button onclick="prep_contact_delete()">delete contacts</button>
1240
+ </div>
1241
+ <form method="dialog">
1242
+ <p id="chosen_contact_operation"><u>Please select an action to perform.</u></p>
1243
+ <!-- Cancel button: closes modal, returnValue is "cancel" -->
1244
+ <button type="submit" formmethod="dialog" value="cancel">Cancel</button>
1245
+ <!-- Close/Confirm button: closes modal, returnValue is "confirm" or selected value -->
1246
+ <button type="submit" value="confirm" >OK</button>
1247
+ </form>
1248
+ </dialog>
1249
+
1250
+ <dialog id="search-ops-modal" style="min-width: 300px;">
1251
+ <div class="mail-properties" >
1252
+ <div class="field-label">search:</div>
1253
+ <div class="field-value"><input id="search-list-patterns" type="text" /></div>
1254
+
1255
+ <div id="mail_type_select_label" class="field-label" style="display: none;">mail type:</div>
1256
+ <div id="mail_type_select" class="field-value" style="display: none;">
1257
+ <select id="mail_type_selector" onchange="mail_switch_to_event(event)" >
1258
+ <option value="all-messages">all messages</option>
1259
+ <optgroup label="received">
1260
+ <option value="inbox">inbox</option>
1261
+ <option value="notify">notify</option>
1262
+ </optgroup>
1263
+ <optgroup label="composed">
1264
+ <option value="drafts">drafts</option>
1265
+ <option value="sent">sent</option>
1266
+ </optgroup>
1267
+ <optgroup label="no interest">
1268
+ <option value="spam">spam</option>
1269
+ <option value="trash">trash</option>
1270
+ </optgroup>
1271
+ </select>
1272
+ </div>
1273
+ </div>
1274
+ <div>
1275
+ testing...
1276
+ <button onclick="add_mails()">add mails</button>
1277
+ <button onclick="sort_mail()">sort mails</button>
1278
+ <button onclick="reverse_mail()">reverse mails</button>
1279
+ <button onclick="add_contacts()">add contacts</button>
1280
+ </div>
1281
+ <form method="dialog">
1282
+ <!-- Cancel button: closes modal, returnValue is "cancel" -->
1283
+ <button type="submit" formmethod="dialog" value="cancel">Cancel</button>
1284
+ <!-- Close/Confirm button: closes modal, returnValue is "confirm" or selected value -->
1285
+ <button type="submit" value="confirm">search</button>
1286
+ </form>
1287
+ </dialog>
1288
+
1289
+
1290
+ <dialog id="select-all-ops-modal" style="min-width: 300px;">
1291
+ <form method="dialog">
1292
+ <p id="chosen_contact_operation"><u>Would you like to select all messages?</u></p>
1293
+ <div class="select-all-ops-properties">
1294
+ <div class="field-label">Select All:</div>
1295
+ <div class="field-value"><input id="select-all-op" type="checkbox" onchange="toggle_current_select_all(event)" value="inbox" /></div>
1296
+ </div>
1297
+ <!-- Cancel button: closes modal, returnValue is "cancel" -->
1298
+ <button type="submit" formmethod="dialog" value="cancel">Cancel</button>
1299
+ <!-- Close/Confirm button: closes modal, returnValue is "confirm" or selected value -->
1300
+ <button id="sel-all-ops-modal-ok" type="submit" value="confirm" disabled>OK</button>
1301
+ </form>
1302
+ </dialog>
1303
+
1304
+
1305
+ <dialog id="style-confirm-modal" style="min-width: 300px;">
1306
+ <form method="dialog">
1307
+ <div id="blocking-confirmation" >
1308
+ <h5>error: empty fields not allowed</h5>
1309
+ <div id="list-blocking-confirmation" class="style-confirm-properties">
1310
+
1311
+ </div>
1312
+ </div>
1313
+ <h5></h5>
1314
+ <div id="warn-confirmation">
1315
+ <h5>warning: empty fields may be awkward</h5>
1316
+ <div id="list-warn-confirmation" class="style-confirm-properties">
1317
+
1318
+ </div>
1319
+ </div>
1320
+ <!-- Cancel button: closes modal, returnValue is "cancel" -->
1321
+ <button type="submit" formmethod="dialog" value="cancel">Cancel</button>
1322
+ <!-- Close/Confirm button: closes modal, returnValue is "confirm" or selected value -->
1323
+ <button id="style-confirm-modal-ok" type="submit" value="confirm" disabled>Continue</button>
1324
+ </form>
1325
+ </dialog>
1326
+
1327
+
1328
+ </body>
1329
+ </html>
1330
+ <script>
1331
+ function noop(event) {
1332
+ console.log(event?.target?.id)
1333
+ }
1334
+
1335
+
1336
+ class Attachment {
1337
+ constructor(id,title,data) {
1338
+ this.id = id
1339
+ this.title = title
1340
+ this.data = data
1341
+ }
1342
+ }
1343
+ </script>
1344
+ <script type="module">
1345
+
1346
+ const mail_managers = window._x_share_mail_managers
1347
+ //
1348
+ let mail_main = document.getElementById("mail-main")
1349
+
1350
+
1351
+ for ( let mtype in mail_managers ) {
1352
+ let a_manager = mail_managers[mtype]
1353
+ a_manager.root = ('contacts' === mtype) ? document.getElementById(`list-contacts`) : document.getElementById(`list-mail-${mtype}`)
1354
+ //
1355
+ a_manager.container_el = ('contacts' === mtype) ? document.getElementById(`human-contacts`) : document.getElementById(`${mtype}-mail`)
1356
+ if ( a_manager.root ) {
1357
+ a_manager?.view?.mount(a_manager.root)
1358
+ }
1359
+ }
1360
+
1361
+ // attachments
1362
+
1363
+ const view_ul_attachments = document.getElementById("ul-attachments")
1364
+ const edit_attachments_el = document.getElementById("table-edit-attachments")
1365
+
1366
+ const attachment_managers = window._x_share_attachment_managers
1367
+ const attach_types = window._x_share_attachment_classes
1368
+
1369
+ // ['view','edit']
1370
+ for ( let atype in attachment_managers ) {
1371
+ let a_manager = attachment_managers[atype]
1372
+ a_manager.root = (atype === 'view') ? view_ul_attachments : edit_attachments_el
1373
+ //
1374
+ if ( a_manager.root ) {
1375
+ a_manager?.view?.mount(a_manager.root)
1376
+ }
1377
+ }
1378
+
1379
+
1380
+ /**
1381
+ *
1382
+ */
1383
+ function store_of_mail_manager(mtype) {
1384
+ let mobj = mail_managers[mtype]
1385
+ if ( mobj ) {
1386
+ if ( mobj.store ){
1387
+ return mobj.store
1388
+ }
1389
+ }
1390
+ return false
1391
+ }
1392
+
1393
+ window.store_of_mail_manager = store_of_mail_manager
1394
+
1395
+
1396
+
1397
+ function store_of_attachment_manager(atype) {
1398
+ let aobj = attachment_managers[atype]
1399
+ if ( aobj ) {
1400
+ if ( aobj.store ){
1401
+ return aobj.store
1402
+ }
1403
+ }
1404
+ return false
1405
+ }
1406
+
1407
+ window.store_of_attachment_manager = store_of_attachment_manager
1408
+
1409
+
1410
+ /** --------------------------- */
1411
+ let g_current_mtype = "inbox"
1412
+ window._current_mtype = "inbox"
1413
+
1414
+ // MAIL IDENTIFIER -- need something better
1415
+ window.largest_id = 20
1416
+
1417
+ window.get_next_id = () => {
1418
+ window.largest_id++
1419
+ return window.largest_id
1420
+ }
1421
+
1422
+ let date = new Date()
1423
+
1424
+ //
1425
+ let mail_proto = { "id" : 1,
1426
+ "sender" : "richard@myhost.local",
1427
+ "category" : "",
1428
+ "subject" : "",
1429
+ "recipient" : "",
1430
+ "cc" : "", "bcc" : "",
1431
+ "date" : date.toLocaleString(),
1432
+ "timestamp" : date.getTime(),
1433
+ "text" : "edit this message",
1434
+ "_count_edits" : 0, "_saved_updates" : []
1435
+ }
1436
+
1437
+ let contact_proto = { "id" : 1, "email" : "", "name" : "", "date" : date.toLocaleString(), "timestamp" : date.getTime(),
1438
+ "text" : "", "_count_edits" : 0, "_saved_updates" : [] }
1439
+
1440
+ //
1441
+ // testing
1442
+ window.add_mails = async (mtype) => {
1443
+ //
1444
+ if ( mtype === undefined ) mtype = g_current_mtype
1445
+ if ( mtype === "contacts" ) {
1446
+ add_contacts()
1447
+ return
1448
+ }
1449
+ let mail_store = store_of_mail_manager(mtype)
1450
+ //
1451
+ if ( mail_store ) {
1452
+ let new_mail_bunch = await load_a_bunch_of_emails(mtype)
1453
+ if ( new_mail_bunch && new_mail_bunch.length ) {
1454
+ for ( let m of new_mail_bunch ) {
1455
+ mail_store.unshift(m)
1456
+ }
1457
+ } else {
1458
+ if ( new_mail_bunch ) {
1459
+ mail_store.set(new_mail_bunch)
1460
+ }
1461
+ }
1462
+ }
1463
+
1464
+ sort_mail(mtype)
1465
+ }
1466
+
1467
+
1468
+ // useful
1469
+ window.add_contacts = async () => {
1470
+ let contact_store = store_of_mail_manager('contacts')
1471
+ if ( contact_store ) {
1472
+ let new_contact_bunch = await load_a_bunch_of_contacts()
1473
+ if ( new_contact_bunch && new_contact_bunch.length ) {
1474
+ for ( let c of new_contact_bunch ) {
1475
+ contact_store.unshift(c)
1476
+ }
1477
+ } else {
1478
+ if ( new_contact_bunch ) {
1479
+ contact_store.set(new_contact_bunch)
1480
+ }
1481
+ }
1482
+ }
1483
+ sort_mail('contacts')
1484
+ return true
1485
+ }
1486
+
1487
+
1488
+
1489
+ // useful (mail and contacts)
1490
+ window.add_emails_to_list = (mtype,email_list) => {
1491
+ if ( mtype === undefined ) return false
1492
+ let mail_store = store_of_mail_manager(mtype)
1493
+ if ( mail_store ) {
1494
+ if ( mail_store.length ) {
1495
+ for ( let m of email_list ) {
1496
+ mail_store.unshift(m)
1497
+ m.category = mtype
1498
+ }
1499
+ } else {
1500
+ mail_store.set(email_list)
1501
+ for ( let m of email_list ) {
1502
+ m.category = mtype
1503
+ }
1504
+ }
1505
+ }
1506
+ sort_mail(mtype)
1507
+ return true
1508
+ }
1509
+
1510
+
1511
+ window.delete_emails_from_list = (mtype,email_ids_list) => {
1512
+ if ( mtype === undefined ) return false
1513
+ let mail_store = store_of_mail_manager(mtype)
1514
+ if ( mail_store ) {
1515
+ mail_store.filter((email)=>{
1516
+ let mid = email.id
1517
+ if ( email_ids_list.indexOf(mid) >= 0 ) {
1518
+ return false
1519
+ }
1520
+ return true
1521
+ })
1522
+ }
1523
+ return true
1524
+ }
1525
+
1526
+ //
1527
+ window.get_list_of_objects = (mtype,id_list) => {
1528
+ if ( mtype === undefined ) return false
1529
+ let mail_store = store_of_mail_manager(mtype)
1530
+ if ( mail_store ) {
1531
+ let obj_list = []
1532
+ mail_store.forEach((obj) => {
1533
+ if ( id_list.includes(obj.id) ) {
1534
+ obj_list.push(obj)
1535
+ }
1536
+ })
1537
+ if ( !(obj_list.length) ) return false
1538
+ return obj_list
1539
+ }
1540
+ return false
1541
+ }
1542
+
1543
+
1544
+ window.add_empty_draft = (id) => {
1545
+ let mtype = "drafts"
1546
+ let mail_store = store_of_mail_manager(mtype)
1547
+ let new_mail = structuredClone(mail_proto)
1548
+ new_mail.id = id
1549
+ new_mail._count_edits = 0
1550
+ new_mail._saved_updates = []
1551
+ //
1552
+ if ( mail_store ) {
1553
+ mail_store.unshift(new_mail)
1554
+ return new_mail
1555
+ }
1556
+ return false
1557
+ }
1558
+
1559
+ window.add_empty_contact = (id) => {
1560
+ let mtype = "contacts"
1561
+ let mail_store = store_of_mail_manager(mtype)
1562
+ let new_contact = structuredClone(contact_proto)
1563
+ new_contact.id = id
1564
+ new_contact._count_edits = 0
1565
+ new_contact._saved_updates = []
1566
+ //
1567
+ if ( mail_store ) {
1568
+ mail_store.unshift(new_contact)
1569
+ return new_contact
1570
+ }
1571
+ return false
1572
+ }
1573
+
1574
+
1575
+ window.swap_two = (mtype) => {
1576
+ if ( mtype === undefined ) mtype = g_current_mtype
1577
+ let mail_store = store_of_mail_manager(mtype)
1578
+ if ( mail_store ) mail_store.swap(2,5)
1579
+ }
1580
+
1581
+ window.delete_two = (mtype) => {
1582
+ if ( mtype === undefined ) mtype = g_current_mtype
1583
+ let mail_store = store_of_mail_manager(mtype)
1584
+ if ( mail_store ) mail_store.splice(3,2)
1585
+ }
1586
+
1587
+ window.sort_mail = (mtype) => {
1588
+ if ( mtype === undefined ) mtype = g_current_mtype
1589
+ let mail_store = store_of_mail_manager(mtype)
1590
+ if ( mail_store ) mail_store.sort((a,b) => {
1591
+ if ( a.timestamp < b.timestamp ) return 1
1592
+ if ( a.timestamp > b.timestamp ) return -1
1593
+ return 0
1594
+ })
1595
+ }
1596
+
1597
+ window.sort_one_or_more = (mtype) => {
1598
+ if ( mtype === undefined ) mtype = g_current_mtype
1599
+ let mail_store = store_of_mail_manager(mtype)
1600
+ if ( mail_store ) {
1601
+ if ( mail_store.length === 1 ) {
1602
+ let obj = mail_store.pop()
1603
+ mail_store.push(obj)
1604
+ } else {
1605
+ sort_mail(mtype)
1606
+ }
1607
+ }
1608
+ }
1609
+
1610
+ window.reverse_mail = (mtype) => {
1611
+ if ( mtype === undefined ) mtype = g_current_mtype
1612
+ let mail_store = store_of_mail_manager(mtype)
1613
+ if ( mail_store ) mail_store.reverse()
1614
+ }
1615
+
1616
+ let mtype_title = document.getElementById("mail-type-title")
1617
+
1618
+ window.mail_switch_to = (mtype) => {
1619
+ if ( mtype === undefined ) mtype = g_current_mtype
1620
+ for ( let one_mtype in mail_managers ) {
1621
+ let mobj = mail_managers[one_mtype]
1622
+ if ( mobj.container_el ) {
1623
+ mobj.container_el.style.display = "none"
1624
+ }
1625
+ }
1626
+ let mobj = mail_managers[mtype]
1627
+ if ( mobj ) {
1628
+ if ( mobj.container_el ) {
1629
+ mobj.container_el.style.display = "block"
1630
+ //
1631
+ mtype_title.innerText = mtype
1632
+ g_current_mtype = mtype
1633
+ window._current_mtype = mtype
1634
+ set_banner_search_selector(mtype)
1635
+ }
1636
+ }
1637
+ }
1638
+
1639
+ window.mail_switch_to_event = (event) => {
1640
+ let sel_el = event.target
1641
+ if ( sel_el ) {
1642
+ if ( sel_el.value === "all-messages") return
1643
+ mail_switch_to(sel_el.value)
1644
+ }
1645
+ }
1646
+
1647
+ window.contacts_ui = () => {
1648
+ for ( let one_mtype in mail_managers ) {
1649
+ let mobj = mail_managers[one_mtype]
1650
+ if ( mobj.container_el ) {
1651
+ mobj.container_el.style.display = "none"
1652
+ }
1653
+ }
1654
+ let mtype = "contacts"
1655
+ let mobj = mail_managers[mtype]
1656
+ if ( mobj ) {
1657
+ if ( mobj.container_el ) {
1658
+ mobj.container_el.style.display = "block"
1659
+ //
1660
+ mtype_title.innerText = mtype
1661
+ g_current_mtype = mtype
1662
+ window._current_mtype = g_current_mtype
1663
+ set_banner_search_selector(mtype)
1664
+ }
1665
+ }
1666
+ }
1667
+
1668
+ // attachments -------------------
1669
+
1670
+ // useful (mail and contacts)
1671
+ window.add_atts_to_list = (atype,att_list) => {
1672
+ if ( atype === undefined ) return false
1673
+ let atts_store = store_of_attachment_manager(atype)
1674
+ if ( atts_store ) {
1675
+ if ( atts_store.length ) {
1676
+ for ( let a of att_list ) {
1677
+ atts_store.unshift(a)
1678
+ }
1679
+ } else {
1680
+ atts_store.set(att_list)
1681
+ }
1682
+ }
1683
+ // sort_attachments(atype)
1684
+ return true
1685
+ }
1686
+
1687
+
1688
+ window.delete_atts_from_list = (atype,atts_ids_list) => {
1689
+ if ( atype === undefined ) return false
1690
+ let atts_store = store_of_attachment_manager(atype)
1691
+ if ( atts_store ) {
1692
+ atts_store.filter((attachment)=>{
1693
+ let aid = attachment.id
1694
+ if ( atts_ids_list.indexOf(aid) >= 0 ) {
1695
+ return false
1696
+ }
1697
+ return true
1698
+ })
1699
+ }
1700
+ return true
1701
+ }
1702
+
1703
+ window.clear_atts_list = (atype) => {
1704
+ if ( atype === undefined ) return false
1705
+ let atts_store = store_of_attachment_manager(atype)
1706
+ if ( atts_store ) {
1707
+ atts_store.set([])
1708
+ }
1709
+ }
1710
+
1711
+
1712
+
1713
+ window.indicate_page_on_window_banner = (mtype) => {
1714
+ if ( mtype !== 'drafts' ) {
1715
+ let wb_var = document.getElementById("mail_view_category")
1716
+ if ( wb_var ) {
1717
+ wb_var.innerText = `${mtype}: `
1718
+ }
1719
+ }
1720
+ }
1721
+
1722
+
1723
+
1724
+ </script>
1725
+ <script>
1726
+ const squash_container = document.getElementById("squash_container")
1727
+ const expanded = document.getElementById("expanded-menu")
1728
+ window.addEventListener("click",(event) => {
1729
+ close_if_open()
1730
+ })
1731
+
1732
+ function close_if_open() {
1733
+ if ( squash_container.hasAttribute("open" ) ) {
1734
+ squash_container.removeAttribute("open")
1735
+
1736
+ // 1. Kill the transition and snap back to the start
1737
+ expanded.style.transition = 'none';
1738
+
1739
+ // 2. Force reflow
1740
+ void expanded.offsetWidth;
1741
+
1742
+ // 3. Turn the transition back on and start the move
1743
+ expanded.style.transition = 'width 0.3s ease-out, content-visibility 0.3s allow-discrete';
1744
+
1745
+ }
1746
+ }
1747
+
1748
+ // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
1749
+ // open windows
1750
+
1751
+
1752
+ function get_text_from_store(mtype,msg_id) {
1753
+ let mail_store = store_of_mail_manager(mtype)
1754
+ let clear_text = "message not found"
1755
+ if ( mail_store ) {
1756
+ let the_msg = false
1757
+ mail_store.forEach(msg => {
1758
+ if ( msg.id === msg_id ) {
1759
+ the_msg = msg
1760
+ }
1761
+ })
1762
+ if ( the_msg ) {
1763
+ clear_text = the_msg.text
1764
+ }
1765
+ }
1766
+ return clear_text
1767
+ }
1768
+
1769
+
1770
+ function get_message_from_store(mtype,msg_id) {
1771
+ let mail_store = store_of_mail_manager(mtype)
1772
+ //
1773
+ if ( mail_store ) {
1774
+ let the_msg = false
1775
+ mail_store.forEach(msg => {
1776
+ if ( msg.id === msg_id ) {
1777
+ the_msg = msg
1778
+ }
1779
+ })
1780
+ if ( the_msg ) {
1781
+ return the_msg
1782
+ }
1783
+ }
1784
+ //
1785
+ return false
1786
+ }
1787
+
1788
+ // ---- ---- ---- ---- ---- ---- ---- ---- ----
1789
+ //
1790
+ // ['inbox','sent','spam','notify','trash'], ['drafts']
1791
+ //
1792
+ /*
1793
+ // inbox_check_select
1794
+ // sent_check_select
1795
+ // spam_check_select
1796
+ // notify_check_select
1797
+ // drafts_check_select
1798
+ // trash_check_select
1799
+ */
1800
+
1801
+ function setup_modal_response(dialog_id) {
1802
+ const dialog = document.getElementById(dialog_id);
1803
+ dialog._acceptance_action = false
1804
+ dialog._cancel_action = false
1805
+ let self = dialog
1806
+ dialog.addEventListener('close', () => {
1807
+ const action = dialog.returnValue;
1808
+ switch (action) {
1809
+ case "confirm" : {
1810
+ if ( dialog._acceptance_action ) {
1811
+ dialog._acceptance_action()
1812
+ dialog._acceptance_action = false
1813
+ }
1814
+ break;
1815
+ }
1816
+ case "cancel" : {
1817
+ if ( dialog._cancel_action ) {
1818
+ dialog._cancel_action()
1819
+ dialog._cancel_action = false
1820
+ }
1821
+ break
1822
+ }
1823
+ }
1824
+ restore_check_box_selections(self,action) // if the dialog was used for a single email in view or drafts
1825
+ });
1826
+ disable_ok_button()
1827
+ return dialog
1828
+ }
1829
+
1830
+ function setup_email_ops_dialog() {
1831
+ let diag = setup_modal_response('email-ops-modal')
1832
+ diag._cancel_action = () => {
1833
+ disable_ok_button()
1834
+ disable_selall_ok_button()
1835
+ }
1836
+ }
1837
+
1838
+ function setup_contacts_ops_dialog() {
1839
+ setup_modal_response('contact-ops-modal')
1840
+ }
1841
+
1842
+ function setup_search_ops_dialog() {
1843
+ let search_d = setup_modal_response('search-ops-modal')
1844
+ search_d._acceptance_action = () => {
1845
+ // final search update -- otherwise the fields are reactive
1846
+ }
1847
+ }
1848
+
1849
+
1850
+ // checkbox patterns
1851
+
1852
+ // for saving a pattern to be restored (handle indecision about checkboxes)
1853
+ class CheckBoxPatternEntry {
1854
+ constructor(id,cb_el) {
1855
+ this.data_id = id
1856
+ this.checkbox_element = cb_el
1857
+ this.state = cb_el.checked
1858
+ }
1859
+
1860
+ set_state(state) {
1861
+ this.state = state
1862
+ }
1863
+
1864
+ sync_state_view() {
1865
+ this.checkbox_element.checked = this.state
1866
+ }
1867
+ }
1868
+
1869
+ let g_all_list_view_check_box_patterns = {}
1870
+ function setup_checkbox_pattern_tracking() {
1871
+ let mtypes = window._x_share_mail_classes
1872
+ for ( let mtype of mtypes ) {
1873
+ g_all_list_view_check_box_patterns[mtype] = []
1874
+ }
1875
+ }
1876
+
1877
+ function update_check_box_pattern(ev) {
1878
+ store_current_check_box_pattern()
1879
+ }
1880
+
1881
+ function store_current_check_box_pattern() {
1882
+ const mtype = window._current_mtype
1883
+ let result_pattern = []
1884
+ g_all_list_view_check_box_patterns[mtype] = result_pattern
1885
+ const checkedBoxes = document.querySelectorAll(`.${mtype}_check_select`);
1886
+ for ( let cb of checkedBoxes ) {
1887
+ let id = cb.value
1888
+ let cb_entry = new CheckBoxPatternEntry(id,cb)
1889
+ result_pattern.push(cb_entry)
1890
+ }
1891
+ }
1892
+
1893
+ function restore_checkbox_pattern(mtype) {
1894
+ let saved_pattern = g_all_list_view_check_box_patterns[mtype]
1895
+ if ( saved_pattern.length ) {
1896
+ for ( let p_entry of saved_pattern ) {
1897
+ p_entry.sync_state_view()
1898
+ }
1899
+ } else {
1900
+ clear_check_boxes(mtype)
1901
+ }
1902
+ }
1903
+
1904
+
1905
+
1906
+ // --------
1907
+
1908
+
1909
+ let g_select_all_response_promise = {
1910
+ resolver : false,
1911
+ rejector : false
1912
+ }
1913
+
1914
+ function prep_select_all_modal_response() {
1915
+ let sel_d = select_all_op_dialog
1916
+ sel_d._acceptance_action = () => {
1917
+ if ( g_select_all_response_promise.resolver ) {
1918
+ g_select_all_response_promise.resolver()
1919
+ g_select_all_response_promise = { resolver : false, rejector : false }
1920
+ }
1921
+ }
1922
+ sel_d._cancel_action = () => {
1923
+ if ( g_select_all_response_promise.rejector ) {
1924
+ g_select_all_response_promise.rejector()
1925
+ g_select_all_response_promise = { resolver : false, rejector : false }
1926
+ }
1927
+ }
1928
+ }
1929
+
1930
+
1931
+ function setup_select_all_ops_dialog() {
1932
+ setup_modal_response('select-all-ops-modal')
1933
+ }
1934
+
1935
+
1936
+
1937
+ async function check_all_decision(mtype) {
1938
+ const dialog = select_all_op_dialog
1939
+ if ( dialog ) {
1940
+ // -- responses set to false after call
1941
+ prep_select_all_modal_response()
1942
+ //
1943
+ let p = new Promise((resolve,reject) => {
1944
+ g_select_all_response_promise.resolver = () => {
1945
+ resolve(true)
1946
+ }
1947
+ g_select_all_response_promise.rejector = () => {
1948
+ reject(false)
1949
+ }
1950
+ })
1951
+ dialog.showModal()
1952
+ try {
1953
+ let decision = await p
1954
+ if ( decision ) {
1955
+ let checkedBoxes = document.querySelectorAll(`.${mtype}_check_select:checked`);
1956
+ if ( checkedBoxes.length === 0 ) {
1957
+ checkedBoxes = document.querySelectorAll(`.${mtype}_check_select`)
1958
+ set_check_boxes(mtype)
1959
+ }
1960
+ const collectedIds = Array.from(checkedBoxes).map(cb => cb.value);
1961
+ disable_selall_ok_button()
1962
+ return collectedIds
1963
+ }
1964
+ } catch (e) {
1965
+ clear_check_boxes(mtype)
1966
+ disable_selall_ok_button()
1967
+ return false
1968
+ }
1969
+ }
1970
+ return false
1971
+ }
1972
+
1973
+ function clear_check_boxes(mtype) {
1974
+ const checkedBoxes = document.querySelectorAll(`.${mtype}_check_select`);
1975
+ for ( let cb of checkedBoxes ) {
1976
+ cb.checked = false
1977
+ }
1978
+ }
1979
+
1980
+ function set_check_boxes(mtype) {
1981
+ const checkedBoxes = document.querySelectorAll(`.${mtype}_check_select`);
1982
+ for ( let cb of checkedBoxes ) {
1983
+ cb.checked = true
1984
+ }
1985
+ }
1986
+
1987
+ // select_all_op_dialog_on_ops
1988
+ // const select_all_op_cb
1989
+ // const select_all_op_cb_on_ops
1990
+
1991
+ // SELECT ALL
1992
+
1993
+ function toggle_current_select_all(ev) {
1994
+ let check_master = ev.target
1995
+ let mtype = check_master.value
1996
+ let checked = check_master.checked
1997
+ //
1998
+ select_all_op_cb_on_ops.checked = checked
1999
+ select_all_op_cb.checked = checked
2000
+ if ( checked ) {
2001
+ enable_selall_ok_button()
2002
+ } else {
2003
+ disable_selall_ok_button()
2004
+ }
2005
+ //
2006
+ if ( checked ) {
2007
+ set_check_boxes(mtype)
2008
+ } else {
2009
+ restore_checkbox_pattern(mtype)
2010
+ if ( check_master === select_all_op_cb_on_ops ) {
2011
+ disable_ok_button_if_no_selection(mtype)
2012
+ }
2013
+ }
2014
+ collect_emails_list_for_op(mtype)
2015
+ }
2016
+
2017
+
2018
+ function get_checked_messages(mtype) {
2019
+ const checkedBoxes = document.querySelectorAll(`.${mtype}_check_select:checked`);
2020
+ const collectedIds = Array.from(checkedBoxes).map(cb => cb.value);
2021
+ return collectedIds
2022
+ }
2023
+
2024
+
2025
+ async function get_checked_messages_or_ask_for_all(mtype) {
2026
+ const check_master = document.getElementById("select-all-op")
2027
+ if ( select_all_op_cb && select_all_op_cb_on_ops ) {
2028
+ select_all_op_cb.value = mtype;
2029
+ select_all_op_cb.checked = false
2030
+ select_all_op_cb_on_ops.value = mtype;
2031
+ select_all_op_cb_on_ops.checked = false
2032
+ }
2033
+ const collectedIds = get_checked_messages(mtype)
2034
+ if (collectedIds.length ) {
2035
+ return collectedIds
2036
+ } else { // alternate with promise
2037
+ let all_collected_ids = await check_all_decision(mtype)
2038
+ if ( all_collected_ids && all_collected_ids.length ) return all_collected_ids
2039
+ return false
2040
+ }
2041
+ }
2042
+
2043
+ // EDIT WINDOW ['drafts'] and create
2044
+
2045
+ // change support
2046
+ function update_mail_properties_edit(mtype,msg_id) {
2047
+ //
2048
+ let message = get_message_from_store(mtype,msg_id)
2049
+ if ( message ) {
2050
+ g_current_edit_email = message
2051
+ //
2052
+ let m_prop_el = document.getElementById("edit-email-sender")
2053
+ if ( m_prop_el ) { m_prop_el.value = message.sender }
2054
+ m_prop_el = document.getElementById("edit-email-recipient")
2055
+ if ( m_prop_el ) { m_prop_el.value = message.recipient }
2056
+ //
2057
+ m_prop_el = document.getElementById("edit-email-cc")
2058
+ if ( m_prop_el ) { m_prop_el.value = message.cc }
2059
+ //
2060
+ m_prop_el = document.getElementById("edit-email-subject")
2061
+ if ( m_prop_el ) { m_prop_el.value = message.subject }
2062
+ m_prop_el = document.getElementById("edit-email-date")
2063
+ if ( m_prop_el ) { m_prop_el.innerHTML = message.date }
2064
+ //
2065
+ store_current_email_undo_stack()
2066
+ if ( message.attachments ) {
2067
+ clear_atts_list('edit')
2068
+ add_atts_to_list('edit',message.attachments)
2069
+ }
2070
+ } else {
2071
+ alert("no message")
2072
+ }
2073
+ //
2074
+ }
2075
+
2076
+
2077
+ function unload_email_for_undo(email) {
2078
+ if ( email ) {
2079
+ let id = email.id
2080
+ let sender = email.sender
2081
+ let recipient = email.recipient
2082
+ let cc = email.cc
2083
+ let subject = email.subject
2084
+ let text = email.text
2085
+ let date = email.date
2086
+ let timestamp = email.timestamp
2087
+ email.dirty = false
2088
+ return { id, sender, recipient, cc, subject, text, date, timestamp }
2089
+ }
2090
+ }
2091
+
2092
+
2093
+ function reload_email_by_undo(email,old_values) {
2094
+ if ( email ) {
2095
+ email.id = old_values.id
2096
+ email.sender = old_values.sender
2097
+ email.recipient = old_values.recipient
2098
+ email.cc = old_values.cc
2099
+ email.subject = old_values.subject
2100
+ email.text = old_values.text
2101
+ email.date = old_values.date
2102
+ email.timestamp = old_values.timestamp
2103
+ email.dirty = false
2104
+ }
2105
+ }
2106
+
2107
+ function unequal_objects(save_email,stored_email) {
2108
+ if ( save_email && stored_email ) {
2109
+ if ( save_email.id !== stored_email.id ) return true
2110
+ if ( save_email.sender !== stored_email.sender ) return true
2111
+ if ( save_email.recipient !== stored_email.recipient ) return true
2112
+ if ( save_email.cc !== stored_email.cc ) return true
2113
+ if ( save_email.subject !== stored_email.subject ) return true
2114
+ if ( save_email.text !== stored_email.text ) return true
2115
+ if ( save_email.date !== stored_email.date ) return true
2116
+ if ( save_email.timestamp !== stored_email.timestamp ) return true
2117
+ }
2118
+ return true
2119
+ }
2120
+
2121
+ function store_current_email_undo_stack() {
2122
+ if ( g_current_edit_email ) {
2123
+ const email = g_current_edit_email
2124
+ let save_email = unload_email_for_undo(g_current_edit_email)
2125
+ if ( unequal_objects(save_email,email._saved_updates[0]) ) {
2126
+ email._saved_updates.unshift(save_email)
2127
+ }
2128
+ }
2129
+ }
2130
+
2131
+ function update_contact_properties_view(cid) {
2132
+ let contact = get_message_from_store('contacts',cid)
2133
+ if ( contact ) {
2134
+ g_current_edit_contact = contact
2135
+ //
2136
+ let m_prop_el = document.getElementById("view-contact-name")
2137
+ if ( m_prop_el ) { m_prop_el.innerHTML = contact.name }
2138
+ m_prop_el = document.getElementById("view-contact-email")
2139
+ if ( m_prop_el ) { m_prop_el.innerHTML = contact.email }
2140
+ //
2141
+ m_prop_el = document.getElementById("edit-contact-name")
2142
+ if ( m_prop_el ) { m_prop_el.value = contact.name }
2143
+ m_prop_el = document.getElementById("edit-contact-email")
2144
+ if ( m_prop_el ) { m_prop_el.value = contact.email }
2145
+ //
2146
+ m_prop_el = document.getElementById("view-contact-date")
2147
+ if ( m_prop_el ) { m_prop_el.innerHTML = contact.date }
2148
+ m_prop_el = document.getElementById("edit-contact-date")
2149
+ if ( m_prop_el ) { m_prop_el.innerHTML = contact.date }
2150
+ //
2151
+ } else {
2152
+ alert("no message")
2153
+ }
2154
+ }
2155
+
2156
+
2157
+ function unload_contact_for_undo(contact) {
2158
+ if ( contact ) {
2159
+ let name = contact.name
2160
+ let email = contact.email
2161
+ let date = contact.date
2162
+ let text = contact.text
2163
+ let id = contact.id
2164
+ let timestamp = contact.timestamp
2165
+ contact.dirty = false
2166
+ return { id, name, email, text, date, timestamp }
2167
+ }
2168
+ }
2169
+
2170
+
2171
+ function reload_contact_by_undo(contact,old_values) {
2172
+ if ( contact ) {
2173
+ contact.name = old_values.name
2174
+ contact.email = old_values.email
2175
+ contact.date = old_values.date
2176
+ contact.text = old_values.text
2177
+ contact.id = old_values.id
2178
+ contact.imestamp = old_values.timestamp
2179
+ }
2180
+ }
2181
+
2182
+
2183
+
2184
+
2185
+ function update_just_date(message,date_el_id) {
2186
+ let date = new Date()
2187
+ if ( message ) {
2188
+ message.date = date.toLocaleString()
2189
+ message.timestamp = date.getTime()
2190
+ } else return
2191
+ let m_prop_el = document.getElementById(date_el_id)
2192
+ if ( m_prop_el ) { m_prop_el.innerHTML = message.date }
2193
+ if ( date_el_id === "edit-email-date" ) {
2194
+ sort_one_or_more('drafts')
2195
+ } else {
2196
+ sort_one_or_more('contacts')
2197
+ }
2198
+ }
2199
+
2200
+
2201
+
2202
+ let g_current_edit_email = false
2203
+ let g_current_edit_contact = false
2204
+ function setup_edit_response() {
2205
+ //
2206
+ let msg_editor = document.getElementById("email_message_contents_edit")
2207
+ if ( msg_editor ) {
2208
+ msg_editor.addEventListener('input', (event) => {
2209
+ if ( g_current_edit_email ) {
2210
+ g_current_edit_email.text = event.target.innerHTML
2211
+ update_just_date(g_current_edit_email,"edit-email-date")
2212
+ g_current_edit_email.dirty = true
2213
+ }
2214
+ });
2215
+ }
2216
+ //
2217
+ let m_prop_el = document.getElementById("edit-email-sender")
2218
+ if ( m_prop_el ) {
2219
+ m_prop_el.addEventListener('change', (event) => {
2220
+ if ( g_current_edit_email ) {
2221
+ g_current_edit_email.sender = event.target.value
2222
+ update_just_date(g_current_edit_email,"edit-email-date")
2223
+ g_current_edit_email.dirty = true
2224
+ }
2225
+ });
2226
+ }
2227
+ //
2228
+ m_prop_el = document.getElementById("edit-email-recipient")
2229
+ if ( m_prop_el ) {
2230
+ m_prop_el.addEventListener('change', (event) => {
2231
+ if ( g_current_edit_email ) {
2232
+ g_current_edit_email.recipient = event.target.value
2233
+ update_just_date(g_current_edit_email,"edit-email-date")
2234
+ g_current_edit_email.dirty = true
2235
+ }
2236
+ });
2237
+ }
2238
+ //
2239
+ m_prop_el = document.getElementById("edit-email-cc")
2240
+ if ( m_prop_el ) {
2241
+ m_prop_el.addEventListener('change', (event) => {
2242
+ if ( g_current_edit_email ) {
2243
+ g_current_edit_email.cc = event.target.value
2244
+ update_just_date(g_current_edit_email,"edit-email-date")
2245
+ g_current_edit_email.dirty = true
2246
+ }
2247
+ });
2248
+ }
2249
+ //
2250
+ m_prop_el = document.getElementById("edit-email-bcc")
2251
+ if ( m_prop_el ) {
2252
+ m_prop_el.addEventListener('change', (event) => {
2253
+ if ( g_current_edit_email ) {
2254
+ g_current_edit_email.bcc = event.target.value
2255
+ update_just_date(g_current_edit_email,"edit-email-date")
2256
+ g_current_edit_email.dirty = true
2257
+ }
2258
+ });
2259
+ }
2260
+ //
2261
+ m_prop_el = document.getElementById("edit-email-subject")
2262
+ if ( m_prop_el ) {
2263
+ m_prop_el.addEventListener('change', (event) => {
2264
+ if ( g_current_edit_email ) {
2265
+ g_current_edit_email.subject = event.target.value
2266
+ update_just_date(g_current_edit_email,"edit-email-date")
2267
+ g_current_edit_email.dirty = true
2268
+ }
2269
+ });
2270
+ }
2271
+
2272
+ // contacts
2273
+ //
2274
+ let contact_editor = document.getElementById("contact_contents_edit")
2275
+ if ( contact_editor ) {
2276
+ contact_editor.addEventListener('input', (event) => {
2277
+ if ( g_current_edit_contact ) {
2278
+ g_current_edit_contact.text = event.target.innerHTML
2279
+ update_just_date(g_current_edit_contact,"edit-contact-date")
2280
+ update_just_date(g_current_edit_contact,"view-contact-date")
2281
+ g_current_edit_contact.dirty = true
2282
+ }
2283
+ });
2284
+ }
2285
+ //
2286
+ let c_prop_el = document.getElementById("edit-contact-name")
2287
+ if ( c_prop_el ) {
2288
+ c_prop_el.addEventListener('change', (event) => {
2289
+ if ( g_current_edit_contact ) {
2290
+ g_current_edit_contact.name = event.target.value
2291
+ update_just_date(g_current_edit_contact,"edit-contact-date")
2292
+ update_just_date(g_current_edit_contact,"view-contact-date")
2293
+ g_current_edit_contact.dirty = true
2294
+ }
2295
+ });
2296
+ }
2297
+ //
2298
+ c_prop_el = document.getElementById("edit-contact-email")
2299
+ if ( c_prop_el ) {
2300
+ c_prop_el.addEventListener('change', (event) => {
2301
+ if ( g_current_edit_contact ) {
2302
+ g_current_edit_contact.email = event.target.value
2303
+ update_just_date(g_current_edit_contact,"edit-contact-date")
2304
+ update_just_date(g_current_edit_contact,"view-contact-date")
2305
+ g_current_edit_contact.dirty = true
2306
+ }
2307
+ });
2308
+ }
2309
+ }
2310
+
2311
+
2312
+ function mail_create() {
2313
+ mail_switch_to('drafts')
2314
+ let sect_box = `#email_edit`
2315
+ let msg_view = document.getElementById("email_message_contents_edit")
2316
+ if ( msg_view ) {
2317
+ let id = get_next_id()
2318
+ let draft = add_empty_draft(id)
2319
+ if ( draft ) {
2320
+ let msg_id = draft.id
2321
+ draft.text = ""
2322
+ let clear_text = draft.text
2323
+ msg_view.innerHTML = `adding message id = ${msg_id}
2324
+ <br> ${clear_text}
2325
+ <br> will be adding text here`
2326
+ //
2327
+ g_current_edit_email = draft
2328
+ update_mail_properties_edit("drafts",msg_id)
2329
+ }
2330
+ }
2331
+ pinBox(sect_box)
2332
+ }
2333
+
2334
+ function contact_create() {
2335
+ mail_switch_to('contacts')
2336
+ let sect_box = `#contact_view`
2337
+ let msg_view = document.getElementById("contact_contents_edit")
2338
+ if ( msg_view ) {
2339
+ let id = get_next_id()
2340
+ let contact = add_empty_contact(id)
2341
+ if ( contact ) {
2342
+ let c_id = contact.id
2343
+ contact.text = ""
2344
+ let clear_text = contact.text
2345
+ msg_view.innerHTML = `adding message id = ${c_id}
2346
+ <br> ${clear_text}
2347
+ <br> will be adding text here`
2348
+ //
2349
+ g_current_edit_contact = contact
2350
+ update_contact_properties_view(c_id)
2351
+ contact_edit_mode_toggle(true)
2352
+ }
2353
+ }
2354
+ pinBox(sect_box)
2355
+ }
2356
+
2357
+
2358
+ function edit_from_draft(msg_id) {
2359
+ let sect_box = `#email_edit`
2360
+ let msg_view = document.getElementById("email_message_contents_edit")
2361
+ if ( msg_view ) {
2362
+ update_mail_properties_edit("drafts",msg_id)
2363
+ let clear_text = get_text_from_store("drafts",msg_id)
2364
+ msg_view.innerHTML = clear_text
2365
+ }
2366
+ pinBox(sect_box)
2367
+ }
2368
+
2369
+
2370
+ //
2371
+ // VIEW WINDOW ['inbox','sent','spam','notify','trash']
2372
+ //
2373
+
2374
+ // item view support
2375
+ function update_mail_properties_view(mtype,msg_id) {
2376
+ //
2377
+ let message = get_message_from_store(mtype,msg_id)
2378
+ if ( message ) {
2379
+ g_current_edit_email = message
2380
+ let m_prop_el = document.getElementById("view-email-sender")
2381
+ if ( m_prop_el ) { m_prop_el.innerHTML = message.sender }
2382
+ m_prop_el = document.getElementById("view-email-recipient")
2383
+ if ( m_prop_el ) { m_prop_el.innerHTML = message.recipient }
2384
+ m_prop_el = document.getElementById("view-email-subject")
2385
+ if ( m_prop_el ) { m_prop_el.innerHTML = message.subject }
2386
+ m_prop_el = document.getElementById("view-email-date")
2387
+ if ( m_prop_el ) { m_prop_el.innerHTML = message.date }
2388
+ if ( message.attachments ) {
2389
+ clear_atts_list('view')
2390
+ add_atts_to_list('view',message.attachments)
2391
+ }
2392
+ indicate_page_on_window_banner(mtype)
2393
+ }
2394
+ //
2395
+ }
2396
+
2397
+ //
2398
+
2399
+ function view_from_inbox(msg_id) {
2400
+ let sect_box = `#email_view`
2401
+ let msg_view = document.getElementById("email_message_contents")
2402
+ if ( msg_view ) {
2403
+ update_mail_properties_view("inbox",msg_id)
2404
+ let clear_text = get_text_from_store("inbox",msg_id)
2405
+ msg_view.innerHTML = `picked message id = ${msg_id} <br> ${clear_text}`
2406
+ }
2407
+ pinBox(sect_box)
2408
+ }
2409
+ //
2410
+ function view_from_notify(msg_id) {
2411
+ let sect_box = `#email_view`
2412
+ let msg_view = document.getElementById("email_message_contents")
2413
+ if ( msg_view ) {
2414
+ update_mail_properties_view("notify",msg_id)
2415
+ let clear_text = get_text_from_store("notify",msg_id)
2416
+ msg_view.innerHTML = `picked message id = ${msg_id} <br> ${clear_text}`
2417
+ }
2418
+ pinBox(sect_box)
2419
+ }
2420
+ //
2421
+ function view_from_sent(msg_id) {
2422
+ let sect_box = `#email_view`
2423
+ let msg_view = document.getElementById("email_message_contents")
2424
+ if ( msg_view ) {
2425
+ update_mail_properties_view("sent",msg_id)
2426
+ let clear_text = get_text_from_store("sent",msg_id)
2427
+ msg_view.innerHTML = `picked message id = ${msg_id} <br> ${clear_text}`
2428
+ }
2429
+ pinBox(sect_box)
2430
+ }
2431
+ //
2432
+ function view_from_spam(msg_id) {
2433
+ let sect_box = `#email_view`
2434
+ let msg_view = document.getElementById("email_message_contents")
2435
+ if ( msg_view ) {
2436
+ update_mail_properties_view("spam",msg_id)
2437
+ let clear_text = get_text_from_store("spam",msg_id)
2438
+ msg_view.innerHTML = `picked message id = ${msg_id} <br> ${clear_text}`
2439
+ }
2440
+ pinBox(sect_box)
2441
+ }
2442
+ //
2443
+ function view_from_trash(msg_id) {
2444
+ let sect_box = `#email_view`
2445
+ let msg_view = document.getElementById("email_message_contents")
2446
+ if ( msg_view ) {
2447
+ update_mail_properties_view("trash",msg_id)
2448
+ let clear_text = get_text_from_store("trash",msg_id)
2449
+ msg_view.innerHTML = `picked message id = ${msg_id} <br> ${clear_text}`
2450
+ }
2451
+ pinBox(sect_box)
2452
+ }
2453
+
2454
+
2455
+ function toggle_ul(ev,category) {
2456
+ ev.preventDefault = true
2457
+ ev.cancelBubble = true
2458
+
2459
+ let dn_ar = document.getElementById(`ardn-${category}`)
2460
+ let rt_ar = document.getElementById(`arrt-${category}`)
2461
+ let mul = document.getElementById(`ul-${category}`)
2462
+ if ( dn_ar && rt_ar && mul ) {
2463
+ if ( rt_ar.style.display === "none" ) {
2464
+ rt_ar.style.display = "inline-block"
2465
+ dn_ar.style.display = "none"
2466
+ mul.style.display = "none"
2467
+ } else {
2468
+ rt_ar.style.display = "none"
2469
+ dn_ar.style.display = "inline-block"
2470
+ mul.style.display = "block"
2471
+ }
2472
+ }
2473
+ }
2474
+
2475
+
2476
+ function toggle_table(ev,category) {
2477
+ ev.preventDefault = true
2478
+ ev.cancelBubble = true
2479
+
2480
+ let dn_ar = document.getElementById(`ardn-${category}`)
2481
+ let rt_ar = document.getElementById(`arrt-${category}`)
2482
+ let mul = document.getElementById(`table-${category}`)
2483
+ if ( dn_ar && rt_ar && mul ) {
2484
+ if ( rt_ar.style.display === "none" ) {
2485
+ rt_ar.style.display = "inline-block"
2486
+ dn_ar.style.display = "none"
2487
+ mul.style.display = "none"
2488
+ } else {
2489
+ rt_ar.style.display = "none"
2490
+ dn_ar.style.display = "inline-block"
2491
+ mul.style.display = "block"
2492
+ }
2493
+ }
2494
+ }
2495
+ /**
2496
+ *
2497
+ */
2498
+ function view_from_contacts(cid) {
2499
+ let sect_box = `#contact_view`
2500
+ let msg_view = document.getElementById("contact_contents_edit")
2501
+ if ( msg_view ) {
2502
+ update_contact_properties_view(cid)
2503
+ let clear_text = get_text_from_store("contacts",cid)
2504
+ msg_view.innerHTML = `picked contact id = ${cid} <br> ${clear_text}`
2505
+ }
2506
+ pinBox(sect_box)
2507
+ }
2508
+
2509
+
2510
+ /**
2511
+ *
2512
+ */
2513
+ function manage_prefs() {
2514
+ let sect_box = `#preferences`
2515
+ pinBox(sect_box)
2516
+ }
2517
+
2518
+
2519
+ function detailed_search(ev) {
2520
+ let mtype = window._current_mtype
2521
+ if ( mtype === 'contacts' ) {
2522
+ search_ui(mtype)
2523
+ } else {
2524
+ search_ui('messages')
2525
+ }
2526
+ }
2527
+
2528
+
2529
+ function set_banner_search_selector(mtype) {
2530
+ let ts_banner_selector = document.getElementById("banner_mail_type_selector")
2531
+ if ( ts_banner_selector ) {
2532
+ if ( mtype === 'contacts' ) {
2533
+ ts_banner_selector.style.display = 'none'
2534
+ } else {
2535
+ ts_banner_selector.style.display = 'inline'
2536
+ ts_banner_selector.value = mtype
2537
+ }
2538
+ }
2539
+ }
2540
+
2541
+
2542
+ function search_ui(mtype) {
2543
+ //
2544
+ let type_select = document.getElementById("mail_type_select")
2545
+ let ts_label = document.getElementById("mail_type_select_label")
2546
+ let ts_selector = document.getElementById("mail_type_selector")
2547
+ let ts_banner_selector = document.getElementById("banner_mail_type_selector")
2548
+
2549
+ if ( mtype === 'contacts' ) {
2550
+ mail_switch_to('contacts')
2551
+ if ( type_select && ts_label ) {
2552
+ type_select.style.display = "none"
2553
+ ts_label.style.display = "none"
2554
+ }
2555
+ } else if ( mtype === 'messages' ) {
2556
+ let mtype = window._current_mtype
2557
+ if ( mtype === 'contacts' ) mtype = 'inbox'
2558
+ if ( type_select && ts_label ) {
2559
+ type_select.style.display = "inline"
2560
+ ts_label.style.display = "inline"
2561
+ if ( mtype && mtype.length ) {
2562
+ ts_selector.value = mtype
2563
+ ts_banner_selector.value = mtype
2564
+ }
2565
+ }
2566
+ mail_switch_to(mtype)
2567
+ }
2568
+ //
2569
+ open_search_box()
2570
+ }
2571
+
2572
+
2573
+ /**
2574
+ * Perform operations on a list.
2575
+ *
2576
+ * ['inbox','sent','drafts','spam','notify','trash']
2577
+ *
2578
+ * Some lists may allow movement to another list.
2579
+ *
2580
+ * Drafts can delete, move to trash, or be sent (sending moves to sent).
2581
+ * Sent can move to archive, or copy to drafts.
2582
+ * Spam can move to trash, to inbox, or notify
2583
+ * Notify can move to trash, to inbox, or to spam
2584
+ * Trash can permanently delete a message.
2585
+ *
2586
+ *
2587
+ */
2588
+
2589
+ async function add_objects_to_list(to,object_list) {
2590
+ add_emails_to_list(to,object_list)
2591
+ add_emails_to_server(to,object_list)
2592
+ }
2593
+
2594
+ async function delete_objects_from_list(from,id_list) {
2595
+ delete_emails_from_list(from,id_list)
2596
+ delete_emails_from_server(from,id_list)
2597
+ }
2598
+
2599
+ const email_op_message_el = document.getElementById("chosen_operation")
2600
+ const contact_op_message_el = document.getElementById("chosen_contact_operation")
2601
+ //
2602
+ const email_op_dialog = document.getElementById('email-ops-modal');
2603
+ const contact_op_dialog = document.getElementById('contact-ops-modal');
2604
+ const search_op_dialog = document.getElementById('search-ops-modal');
2605
+ const select_all_op_dialog = document.getElementById('select-all-ops-modal');
2606
+ //
2607
+ const select_all_op_cb = document.getElementById('select-all-op');
2608
+ const select_all_op_cb_on_ops = document.getElementById('select-all-op-on-ops');
2609
+
2610
+ function reset_op_starter_message(category,msg) {
2611
+ if ( category === "contacts" ) {
2612
+ contact_op_message_el.innerHTML = msg
2613
+ } else {
2614
+ email_op_message_el.innerHTML = msg
2615
+ }
2616
+ }
2617
+
2618
+ function show_op_buttons(display_this_one) {
2619
+ let mtypes = window._x_share_mail_classes
2620
+ for ( let mtype of mtypes ) {
2621
+ let mops = document.getElementById(`email-ops-${mtype}`)
2622
+ if ( mops ) {
2623
+ mops.style.display = "none"
2624
+ }
2625
+ }
2626
+ let mops = document.getElementById(display_this_one)
2627
+ if ( mops ) {
2628
+ mops.style.display = "block"
2629
+ }
2630
+ }
2631
+
2632
+ function reset_select_all_op_cb() {
2633
+ select_all_op_cb.checked = false
2634
+ select_all_op_cb_on_ops.checked = false
2635
+ }
2636
+
2637
+ let g_current_email_list_for_op = []
2638
+
2639
+ async function collect_emails_list_for_op(mtype) {
2640
+ let m_list = await get_checked_messages(mtype)
2641
+ if ( m_list) {
2642
+ g_current_email_list_for_op = m_list.map(id => parseInt(id))
2643
+ }
2644
+ }
2645
+
2646
+ async function do_op_modal(mtype,mail_id_list_set = false) {
2647
+ disable_ok_button()
2648
+ disable_selall_ok_button()
2649
+ let m_list = mail_id_list_set ? false : await get_checked_messages_or_ask_for_all(mtype)
2650
+ if ( m_list || mail_id_list_set ) {
2651
+ if ( !(mail_id_list_set) ) {
2652
+ g_current_email_list_for_op = m_list.map(id => parseInt(id))
2653
+ }
2654
+ const dialog = document.getElementById('email-ops-modal');
2655
+ if ( dialog ) {
2656
+ reset_op_starter_message('email',"<u>Please select an action to perform.</u>")
2657
+ show_op_buttons(`email-ops-${mtype}`)
2658
+ dialog.showModal();
2659
+ }
2660
+ }
2661
+ }
2662
+
2663
+ let g_var_restoreable_checkbox_ids = false
2664
+ let g_var_restoreable_mtype = false
2665
+ function restore_check_box_selections(which_dialog,action) {
2666
+ if ( (which_dialog !== select_all_op_dialog) || ((which_dialog === select_all_op_dialog) && (action === 'cancel')) ) {
2667
+ let mtype = window._current_mtype
2668
+ restore_checkbox_pattern(mtype)
2669
+ if ( g_var_restoreable_checkbox_ids ) {
2670
+ g_current_email_list_for_op = g_var_restoreable_checkbox_ids
2671
+ g_var_restoreable_checkbox_ids = false
2672
+ }
2673
+ reset_select_all_op_cb()
2674
+ }
2675
+ }
2676
+
2677
+ function single_mail_ops(event) {
2678
+ disable_ok_button()
2679
+ let save_emails_for_ops = g_current_email_list_for_op
2680
+ let mtype = window._current_mtype
2681
+ let email = g_current_edit_email
2682
+ if ( email && (typeof mtype === "string") && (mtype !== 'contact') ) {
2683
+ let id = email.id
2684
+ g_current_email_list_for_op = [id]
2685
+ g_var_restoreable_checkbox_ids = save_emails_for_ops
2686
+ g_var_restoreable_mtype = mtype
2687
+ do_op_modal(mtype,true)
2688
+ }
2689
+ }
2690
+
2691
+
2692
+ let g_current_contact_list_for_op = []
2693
+ async function do_contact_op_modal() {
2694
+ let m_list = await get_checked_messages_or_ask_for_all('contacts')
2695
+ if ( m_list ) {
2696
+ g_current_contact_list_for_op = m_list.map(id => parseInt(id))
2697
+ const dialog = contact_op_dialog;
2698
+ if ( dialog ) {
2699
+ reset_op_starter_message('contacts',"<u>Please select an action to perform.</u>")
2700
+ dialog.showModal();
2701
+ }
2702
+ }
2703
+ }
2704
+
2705
+
2706
+ function open_search_box() {
2707
+ const dialog = search_op_dialog
2708
+ if ( dialog ) {
2709
+ dialog.showModal();
2710
+ }
2711
+ }
2712
+
2713
+
2714
+
2715
+ async function is_ready_to_send_email(email) {
2716
+ // is_ready_to_send_email
2717
+ if ( email ) {
2718
+ // ---- ---- ---- ---- ---- ---- ---- ----
2719
+ let recipient = email.recipient
2720
+ let sender = email.sender
2721
+ let subject = email.subject
2722
+ let text = email.text
2723
+ let ready = true
2724
+ // ---- ---- ---- ---- ---- ---- ---- ----
2725
+ ready &&= (recipient.length !== 0)
2726
+ ready &&= (sender.length !== 0)
2727
+ ready &&= (subject.length !== 0)
2728
+ ready &&= (text.length !== 0)
2729
+
2730
+ if ( !ready ) {
2731
+ let user_should_see = {}
2732
+ if (sender.length === 0) {
2733
+ user_should_see.sender = true // not optional
2734
+ }
2735
+ if (recipient.length === 0) {
2736
+ user_should_see.recipient = true // not optional
2737
+ }
2738
+ if (subject.length === 0) {
2739
+ user_should_see.subject = true // not optional
2740
+ }
2741
+ if (text.length === 0) {
2742
+ user_should_see.text = false // optional
2743
+ }
2744
+ ready = await g_confirmation_modal.stylish_confirm(user_should_see)
2745
+ }
2746
+
2747
+ return ready
2748
+ }
2749
+ return false
2750
+ }
2751
+
2752
+
2753
+ async function send_email_list(from) {
2754
+ let id_list = g_current_email_list_for_op
2755
+ let object_list = get_list_of_objects(from,id_list)
2756
+ if ( object_list && object_list.length ) {
2757
+ if ( await send_emails(object_list) ) {
2758
+ add_objects_to_list('sent',object_list)
2759
+ delete_objects_from_list(from,id_list)
2760
+ }
2761
+ }
2762
+ }
2763
+
2764
+ async function do_send_mail(event) {
2765
+ let email = g_current_edit_email
2766
+ if ( email ) {
2767
+ if ( await is_ready_to_send_email(email) ) {
2768
+ let save_email_list_for_op = g_current_email_list_for_op
2769
+ g_current_email_list_for_op = [email.id]
2770
+ await send_email_list('drafts')
2771
+ g_current_email_list_for_op = save_email_list_for_op
2772
+ mail_switch_to('sent')
2773
+ return true
2774
+ }
2775
+ }
2776
+ return false
2777
+ }
2778
+
2779
+
2780
+ async function do_send_mail_closefader(event) {
2781
+ event.preventDefault()
2782
+ let status = await do_send_mail(event)
2783
+ if ( status ) {
2784
+ closefader(event,'email_edit')
2785
+ }
2786
+ }
2787
+
2788
+
2789
+ function email_list_move_to(from,to) {
2790
+ let id_list = g_current_email_list_for_op
2791
+ let object_list = get_list_of_objects(from,id_list)
2792
+ if ( object_list && object_list.length ) {
2793
+ add_objects_to_list(to,object_list)
2794
+ delete_objects_from_list(from,id_list)
2795
+ }
2796
+ }
2797
+
2798
+ function email_list_copy_to(from,to) {
2799
+ let id_list = g_current_email_list_for_op
2800
+ let object_list = get_list_of_objects(from,id_list)
2801
+ if ( object_list && object_list.length ) {
2802
+ add_objects_to_list(to,object_list)
2803
+ }
2804
+ }
2805
+
2806
+ function email_list_delete(from) {
2807
+ let id_list = g_current_email_list_for_op
2808
+ if ( id_list && id_list.length ) {
2809
+ delete_objects_from_list(from,id_list)
2810
+ }
2811
+ }
2812
+
2813
+
2814
+
2815
+ function increment_email_save_count() {
2816
+ if ( g_current_edit_email ) {
2817
+ g_current_edit_email._count_edits++
2818
+ g_current_edit_email.dirty = false
2819
+ }
2820
+ }
2821
+
2822
+ function mail_edit_mode_reset(event) {
2823
+ if ( g_current_edit_email && g_current_edit_email.dirty ) {
2824
+ let revert_email = g_current_edit_email
2825
+ let previous_values = revert_email._saved_updates.shift() // this is the last saved version, does not undo more{
2826
+ if ( previous_values ) {
2827
+ reload_email_by_undo(revert_email,previous_values)
2828
+ sort_one_or_more('drafts')
2829
+ }
2830
+ } else if ( g_current_edit_email && (g_current_edit_email._count_edits === 0) ) {
2831
+ let save_checked_emails = g_current_email_list_for_op
2832
+ g_current_email_list_for_op = [g_current_edit_email.id]
2833
+ email_list_delete('drafts')
2834
+ }
2835
+ }
2836
+
2837
+ function edit_mail_save(event) {
2838
+ increment_email_save_count()
2839
+ save_mail(g_current_edit_email)
2840
+ }
2841
+
2842
+ function void_current_edit_email() {
2843
+ g_current_edit_email = false
2844
+ }
2845
+
2846
+
2847
+ function disable_ok_button() {
2848
+ let ok_btn = document.getElementById("email-ops-modal-ok")
2849
+ if ( ok_btn ) {
2850
+ ok_btn.disabled = true
2851
+ }
2852
+ }
2853
+
2854
+
2855
+ function enable_ok_button() {
2856
+ let ok_btn = document.getElementById("email-ops-modal-ok")
2857
+ if ( ok_btn ) {
2858
+ ok_btn.disabled = false
2859
+ }
2860
+ }
2861
+
2862
+
2863
+
2864
+ function disable_selall_ok_button() {
2865
+ let ok_btn = document.getElementById("sel-all-ops-modal-ok")
2866
+ if ( ok_btn ) {
2867
+ ok_btn.disabled = true
2868
+ }
2869
+ }
2870
+
2871
+
2872
+ function enable_selall_ok_button() {
2873
+ let ok_btn = document.getElementById("sel-all-ops-modal-ok")
2874
+ if ( ok_btn ) {
2875
+ ok_btn.disabled = false
2876
+ }
2877
+ }
2878
+
2879
+ function enable_ok_button_if_any_selected(mtype) {
2880
+ let checkedBoxes = document.querySelectorAll(`.${mtype}_check_select:checked`);
2881
+ if ( checkedBoxes.length > 0 ) {
2882
+ enable_ok_button()
2883
+ } else {
2884
+ if ( g_current_edit_email !== false ) {
2885
+ if ( g_current_email_list_for_op.length === 0 ) {
2886
+ g_current_email_list_for_op.unshift(g_current_edit_email.id)
2887
+ }
2888
+ if ( g_current_email_list_for_op[0] == g_current_edit_email.id ) {
2889
+ enable_ok_button()
2890
+ }
2891
+ }
2892
+ }
2893
+ }
2894
+
2895
+
2896
+ function disable_ok_button_if_no_selection(mtype) {
2897
+ let checkedBoxes = document.querySelectorAll(`.${mtype}_check_select:checked`);
2898
+ if ( checkedBoxes.length === 0 ) {
2899
+ if ( g_current_edit_email !== false ) {
2900
+ if ( g_current_email_list_for_op.length === 0 ) {
2901
+ g_current_email_list_for_op.unshift(g_current_edit_email.id)
2902
+ }
2903
+ return
2904
+ }
2905
+ disable_ok_button()
2906
+ }
2907
+ }
2908
+
2909
+
2910
+ function prep_send_email_list(from) {
2911
+ if ( email_op_message_el ) {
2912
+ email_op_message_el.innerText = "Send selected emails?"
2913
+ email_op_dialog._acceptance_action = () => {
2914
+ if ( confirm("This decision if final. Proceed?") ) {
2915
+ send_email_list(from)
2916
+ }
2917
+ }
2918
+ enable_ok_button_if_any_selected(from)
2919
+ }
2920
+ }
2921
+ function prep_email_list_move_to(from,to) {
2922
+ if ( email_op_message_el ) {
2923
+ email_op_message_el.innerText = `Move these emails from ${from} to ${to}?`
2924
+ email_op_dialog._acceptance_action = () => {
2925
+ email_list_move_to(from,to)
2926
+ }
2927
+ enable_ok_button_if_any_selected(from)
2928
+ }
2929
+ }
2930
+ function prep_email_list_copy_to(from,to) {
2931
+ if ( email_op_message_el ) {
2932
+ email_op_message_el.innerText = `Clopy these emails from ${from} to ${to}?`
2933
+ email_op_dialog._acceptance_action = () => {
2934
+ email_list_copy_to(from,to)
2935
+ }
2936
+ enable_ok_button_if_any_selected(from)
2937
+ }
2938
+ }
2939
+ function prep_email_list_delete(from) {
2940
+ if ( email_op_message_el ) {
2941
+ email_op_message_el.innerText = `Permanently delete these emails?`
2942
+ email_op_dialog._acceptance_action = () => {
2943
+ if ( confirm("This action cannot be undone. Proceed?") ) {
2944
+ email_list_delete(from)
2945
+ }
2946
+ }
2947
+ enable_ok_button_if_any_selected(from)
2948
+ }
2949
+ }
2950
+
2951
+
2952
+
2953
+ function prep_email_list_reply_to(from) {
2954
+ if ( email_op_message_el ) {
2955
+ email_op_message_el.innerText = `Reply to these emails?`
2956
+ email_op_dialog._acceptance_action = () => {
2957
+ reply_to_emails(from)
2958
+ }
2959
+ enable_ok_button_if_any_selected(from)
2960
+ }
2961
+ }
2962
+
2963
+ function prep_email_list_reply_all(from) {
2964
+ if ( email_op_message_el ) {
2965
+ email_op_message_el.innerText = `Reply to all readers of these emails?`
2966
+ email_op_dialog._acceptance_action = () => {
2967
+ reply_all_to_emails(from)
2968
+ }
2969
+ enable_ok_button_if_any_selected(from)
2970
+ }
2971
+ }
2972
+
2973
+
2974
+ /**
2975
+ * These functions setup the mail draft (like create draft, that will allow for editing followed by a send)
2976
+ *
2977
+ * Server communication happens when these are send from drafts...
2978
+ * OR when the draft is saved (checkpoint save)
2979
+ *
2980
+ */
2981
+ function reply_to_emails(from) {
2982
+ enable_ok_button_if_any_selected(from)
2983
+ setup_email_reply_editing(from)
2984
+ }
2985
+
2986
+ function reply_all_to_emails(from) {
2987
+ enable_ok_button_if_any_selected(from)
2988
+ }
2989
+
2990
+
2991
+ /**
2992
+ */
2993
+ function setup_email_reply_editing(from) {
2994
+
2995
+ }
2996
+ function setup_email_reply_all_editing(from) {
2997
+
2998
+ }
2999
+
3000
+
3001
+ // contact edting ops
3002
+ const contact_edit_mode_select_el = document.getElementById("contact_edit_mode_select")
3003
+ const contact_edit_mode_cancel = document.getElementById("contact_edit_mode_cancel")
3004
+ const contact_launch_compose_el = document.getElementById("contact_launch_compose")
3005
+ const contact_remove_el = document.getElementById("contact_remove")
3006
+ const contact_properties_view = document.getElementById("contact-properties-view")
3007
+ const contact_properties_edit = document.getElementById("contact-properties-edit")
3008
+
3009
+
3010
+ function contact_edit_mode_toggle(set_val) {
3011
+ let start_edit = false
3012
+ let launch_save = false
3013
+ if ( typeof set_val !== "boolean" ) {
3014
+ let ev = set_val // should be an event
3015
+ let domel = ev.target
3016
+ let state = domel.innerText
3017
+ if ( state === "edit" ) {
3018
+ domel.innerText = "save" // next use will launch save
3019
+ if ( contact_edit_mode_cancel ) {
3020
+ contact_edit_mode_cancel.style.display = "inline-block"
3021
+ }
3022
+ start_edit = true
3023
+ } else {
3024
+ domel.innerText = "edit"
3025
+ if ( contact_edit_mode_cancel ) {
3026
+ contact_edit_mode_cancel.style.display = "none"
3027
+ }
3028
+ start_edit = false
3029
+ launch_save = true // shut down editing and update the contact record
3030
+ }
3031
+ } else {
3032
+ if ( contact_edit_mode_select_el && contact_edit_mode_cancel ) {
3033
+ if ( set_val ) {
3034
+ contact_edit_mode_select_el.innerText = "save"
3035
+ contact_edit_mode_cancel.style.display = "inline-block"
3036
+ start_edit = true
3037
+ } else {
3038
+ contact_edit_mode_select_el.innerText = "edit"
3039
+ contact_edit_mode_cancel.style.display = "none"
3040
+ start_edit = false
3041
+ }
3042
+ }
3043
+ }
3044
+ if ( contact_properties_view && contact_properties_edit ) {
3045
+ if ( start_edit ) {
3046
+ contact_properties_edit.style.display = "grid"
3047
+ contact_properties_view.style.display = "none"
3048
+ store_current_contact_undo_stack()
3049
+ } else {
3050
+ contact_properties_edit.style.display = "none"
3051
+ contact_properties_view.style.display = "grid"
3052
+ }
3053
+ }
3054
+ if ( launch_save ) {
3055
+ increment_contact_save_count()
3056
+ // finalize a save that has been placed in the data
3057
+ // clears the undo stack (this is a commit)
3058
+ }
3059
+ }
3060
+ //
3061
+
3062
+ function increment_contact_save_count() {
3063
+ if ( g_current_edit_contact ) {
3064
+ g_current_edit_contact._count_edits++
3065
+ g_current_edit_contact.dirty = false
3066
+ }
3067
+ }
3068
+
3069
+ function store_current_contact_undo_stack() {
3070
+ if ( g_current_edit_contact ) {
3071
+ const contact = g_current_edit_contact
3072
+ let save_contact = unload_contact_for_undo(g_current_edit_contact)
3073
+ contact._saved_updates.unshift(save_contact)
3074
+ }
3075
+ }
3076
+
3077
+ function restore_contact_values(revert_contact) {
3078
+ let previous_values = revert_contact._saved_updates.shift() // this is the last saved version, does not undo more{
3079
+ if ( previous_values ) {
3080
+ if ( revert_contact.dirty ) {
3081
+ reload_contact_by_undo(revert_contact,previous_values)
3082
+ }
3083
+ sort_one_or_more('contacts')
3084
+ }
3085
+ }
3086
+
3087
+
3088
+ // ---- ---- ---- ---- ---- ---- ---- ---- ----
3089
+
3090
+ function contact_edit_mode_reset(event) {
3091
+ contact_edit_mode_toggle(false)
3092
+ //
3093
+ if ( g_current_edit_contact ) {
3094
+ if ( g_current_edit_contact._count_edits === 0 ) { // , "_count_edits" : 0, "_saved_updates" : []
3095
+ let del_contact = g_current_edit_contact
3096
+ g_current_edit_contact = false
3097
+ g_current_email_list_for_op = g_current_contact_list_for_op = [del_contact.id]
3098
+ email_list_delete('contacts')
3099
+ } else if ( g_current_edit_contact.dirty ) {
3100
+ let revert_contact = g_current_edit_contact
3101
+ g_current_edit_contact = false
3102
+ restore_contact_values(revert_contact)
3103
+ }
3104
+ if ( event.target.className !== "closer_x" ) {
3105
+ closefader(false,'contact_view')
3106
+ }
3107
+ }
3108
+ //
3109
+ }
3110
+
3111
+
3112
+ function contact_launch_compose() {
3113
+ mail_create()
3114
+ if ( g_current_edit_contact && g_current_edit_email ) {
3115
+ g_current_edit_email.recipient = g_current_edit_contact.email
3116
+ update_mail_properties_edit("drafts",g_current_edit_email.id)
3117
+ }
3118
+ }
3119
+
3120
+ function remove_one_contact() {
3121
+ if ( g_current_edit_contact ) {
3122
+ if ( confirm("This action cannot be undone. Proceed?") ) {
3123
+ delete_emails_from_list('contacts',[g_current_edit_contact.id])
3124
+ remove_contact_from_server(g_current_edit_contact)
3125
+ }
3126
+ }
3127
+ }
3128
+
3129
+
3130
+ function prep_compose_for_contacts() {
3131
+ if ( contact_op_message_el ) {
3132
+ contact_op_message_el.innerText = `Compose a message for selected contacts?`
3133
+ contact_op_dialog._acceptance_action = () => {
3134
+ mail_create()
3135
+ if ( g_current_edit_contact && g_current_edit_email ) {
3136
+ g_current_edit_email.recipient = g_current_edit_contact.email
3137
+ update_mail_properties_edit("drafts",g_current_edit_email.id) // for opening the email editor for the contact
3138
+ }
3139
+ }
3140
+ }
3141
+ }
3142
+
3143
+ // This makes a work queue that will present to user one contact edit at a time.
3144
+ //
3145
+ function prep_edit_contacts() {
3146
+
3147
+ }
3148
+
3149
+ function prep_contact_delete() {
3150
+ if ( contact_op_message_el ) {
3151
+ contact_op_message_el.innerText = `Permanently delete these contacts?`
3152
+ contact_op_dialog._acceptance_action = () => {
3153
+ if ( confirm("This action cannot be undone. Proceed?") ) {
3154
+ g_current_email_list_for_op = g_current_contact_list_for_op
3155
+ email_list_delete('contacts')
3156
+ }
3157
+ }
3158
+ }
3159
+ }
3160
+
3161
+
3162
+ // attachments
3163
+ // -------------------------------------------------
3164
+
3165
+ async function onFileSelected(e) {
3166
+ if ( e.target.files.length ) {
3167
+ attachment_drop_file_handler(e.target.files)
3168
+ }
3169
+ }
3170
+
3171
+ async function onFilesSelected(e) {
3172
+ if ( e.target.files && e.target.files[0] ) {
3173
+ let file_proper = e.target.files[0] //
3174
+ //let upload_size = file_proper.size
3175
+ let [fname,blob] = await drop_one(e.target.files)
3176
+ file_proper.blob = blob
3177
+ // store as attachment
3178
+ let att = new Attachment(get_next_id(),fname,file_proper)
3179
+ add_atts_to_list('edit',[att])
3180
+ }
3181
+ }
3182
+
3183
+ function show_attachment(a_id) {
3184
+ alert(`showing ${a_id}`)
3185
+ }
3186
+
3187
+ function remove_attachment(a_id) {
3188
+ delete_atts_from_list('edit',[a_id])
3189
+ }
3190
+
3191
+
3192
+
3193
+ async function attachment_drop_file_handler(files) {
3194
+ if ( files && files.length ) {
3195
+ let files_blobs_tripples = await drop(files)
3196
+
3197
+ files_blobs_tripples.forEach(async file_tripple => {
3198
+ let [fname,file_proper,blob] = file_tripple
3199
+ file_proper.blob = blob
3200
+ // store as attachment
3201
+ let att = new Attachment(get_next_id(),fname,file_proper)
3202
+ add_atts_to_list('edit',[att])
3203
+ });
3204
+ }
3205
+ }
3206
+
3207
+
3208
+ window._x_app_handle_files = attachment_drop_file_handler
3209
+
3210
+ </script>
3211
+ <script>
3212
+
3213
+ class StylishConfirmModalOps {
3214
+
3215
+ constructor() {
3216
+ this.style_confirm_modal = document.getElementById("style-confirm-modal")
3217
+ this.stylish_confirm_ok_btn = document.getElementById("style-confirm-modal-ok")
3218
+ this.stylish_blocking_div = document.getElementById("blocking-confirmation")
3219
+ this.stylish_warn_div = document.getElementById("warn-confirmation")
3220
+ this.stylish_confirm_blockers = document.getElementById("list-blocking-confirmation")
3221
+ this.stylish_confirm_optional = document.getElementById("list-warn-confirmation")
3222
+ this.setup_modal_confirmation_response()
3223
+
3224
+ this.dialog_promise = false
3225
+ this.resolver = () => {}
3226
+ this.rejector = () => {}
3227
+ }
3228
+
3229
+ setup_modal_confirmation_response() {
3230
+ const dialog = this.style_confirm_modal
3231
+ if ( dialog ) {
3232
+ dialog.addEventListener('close', () => {
3233
+ const action = dialog.returnValue;
3234
+ switch (action) {
3235
+ case "confirm" : {
3236
+ if ( this.dialog_promise ) {
3237
+ this.resolver()
3238
+ }
3239
+ break;
3240
+ }
3241
+ case "cancel" : {
3242
+ if ( this.dialog_promise ) {
3243
+ this.rejector()
3244
+ }
3245
+ break
3246
+ }
3247
+ }
3248
+ });
3249
+ }
3250
+ }
3251
+
3252
+
3253
+ async show_stylish_confirmation() {
3254
+ if ( this.style_confirm_modal ) {
3255
+ this.dialog_promise = new Promise((resolve,reject) => {
3256
+ this.resolver = () => { resolve(true) }
3257
+ this.rejector = () => { reject(false) }
3258
+ })
3259
+ this.style_confirm_modal.showModal();
3260
+ try {
3261
+ await this.dialog_promise
3262
+ return true
3263
+ } catch(e) {
3264
+ return false
3265
+ }
3266
+ }
3267
+ return false
3268
+ }
3269
+
3270
+ async stylish_confirm(required_and_warn) {
3271
+ if ( typeof required_and_warn === "object" ) {
3272
+ this.stylish_confirm_ok_btn.disabled = true
3273
+ this.stylish_blocking_div.style.display = "none"
3274
+ this.stylish_warn_div.style.display = "none"
3275
+ //
3276
+ let blockers = []
3277
+ let optionals = []
3278
+ for ( let [field_name,is_blocking] of Object.entries(required_and_warn) ) {
3279
+ if ( is_blocking ) {
3280
+ blockers.push(field_name)
3281
+ } else {
3282
+ optionals.push(field_name)
3283
+ }
3284
+ }
3285
+ if ( blockers.length ) {
3286
+ this.stylish_blocking_div.style.display = "block"
3287
+ }
3288
+ if ( optionals.length ) {
3289
+ this.stylish_warn_div.style.display = "block"
3290
+ }
3291
+ if ( blockers.length === 0 ) {
3292
+ this.stylish_confirm_ok_btn.disabled = false
3293
+ }
3294
+ let blocker_list = ""
3295
+ let warning_list = ""
3296
+ for ( let blocker of blockers ) {
3297
+ blocker_list += `<div class="field-label">${blocker}</div><div class="field-value">empty</div>`
3298
+ }
3299
+ for ( let option of optionals ) {
3300
+ warning_list += `<div class="field-label">${option}</div><div class="field-value">empty</div>`
3301
+ }
3302
+ if ( blocker_list.length ) {
3303
+ this.stylish_confirm_blockers.innerHTML = blocker_list
3304
+ }
3305
+ if ( warning_list.length ) {
3306
+ this.stylish_confirm_optional.innerHTML = warning_list
3307
+ }
3308
+
3309
+ return await this.show_stylish_confirmation()
3310
+ }
3311
+ return false
3312
+ }
3313
+
3314
+
3315
+ }
3316
+
3317
+
3318
+ window.g_confirmation_modal = new StylishConfirmModalOps()
3319
+
3320
+
3321
+ </script>
3322
+ <script>
3323
+
3324
+ // https://github.com/omgovich/colord
3325
+
3326
+ //let all_windows = {}
3327
+
3328
+ const g_fader_interval = 50
3329
+
3330
+ // ---->>>
3331
+
3332
+ // === --------------------------------------- === --------------------------------------- === ---------------------------------------
3333
+ // ANIMATION
3334
+ // -- -- -- -- -- -- -- -- -- -- -- -- --
3335
+ //
3336
+
3337
+ var g_apparition = null;
3338
+ var g_current_pin = null;
3339
+ var g_fade_scheduled = null;
3340
+ var g_defade_scheduled = null;
3341
+
3342
+
3343
+ function hideFader(fdr) {
3344
+ fdr.style.visibility = "hidden"
3345
+ fdr.style.display = "none"
3346
+ // fdr.style.zIndex = -10
3347
+ stopDefade()
3348
+ stopFade()
3349
+ g_apparition = null;
3350
+ g_current_pin = null;
3351
+ }
3352
+
3353
+ function closefader(ev,whichFader) {
3354
+ if (ev) ev.stopPropagation()
3355
+ clear_pin_time()
3356
+ let fdr = document.querySelector('#' + whichFader);
3357
+ hideFader(fdr)
3358
+ }
3359
+
3360
+ function closesolid(whichSolid) {
3361
+ let sld = document.querySelector('#' + whichSolid);
3362
+ sld.style.visibility = "hidden"
3363
+ sld.style.display = "none";
3364
+ }
3365
+ // ---- ---- ---- ---- ---- ----
3366
+
3367
+ let g_pin_time = false
3368
+ function newest_pin(pinned) {
3369
+ g_pin_time = Date.now()
3370
+ setTimeout(() => { g_pin_time = false }, 5500 )
3371
+ }
3372
+
3373
+ function recent_pin(pinned) {
3374
+ if ( g_pin_time === false ) {
3375
+ return false
3376
+ }
3377
+ let check_time = Date.now()
3378
+ if ( (check_time - g_pin_time) > 5000 ) {
3379
+ g_pin_time = false
3380
+ return false
3381
+ }
3382
+ return true
3383
+ }
3384
+
3385
+ function clear_pin_time() {
3386
+ g_pin_time = false
3387
+ }
3388
+
3389
+
3390
+ function unpin_current(timeless) {
3391
+ if ( g_current_pin && !timeless && recent_pin(g_current_pin) ) {
3392
+ return false
3393
+ }
3394
+ if ( g_current_pin != null ) {
3395
+ g_current_pin.style.visibility = "hidden";
3396
+ g_current_pin.style.display = "none";
3397
+ // g_current_pin.style.zIndex = -10
3398
+ }
3399
+ return true
3400
+ }
3401
+ function fade_apparition(btn,evt) {
3402
+ if ( g_apparition !== null ) {
3403
+ var fader = g_apparition;
3404
+ //if ( evt ) console.log(fader.offsetWidth + "," + evt.clientX + "," + window.innerWidth)
3405
+ if ( ( evt !== undefined )&& (fader.offsetWidth >= evt.clientX) ) {
3406
+ return;
3407
+ }
3408
+ stopDefade()
3409
+ g_defade_scheduled = setInterval(() => { lowerAlpha(fader); },g_fader_interval);
3410
+ }
3411
+ }
3412
+ function stopDefade() {
3413
+ if ( g_defade_scheduled != null ) {
3414
+ clearInterval(g_defade_scheduled);
3415
+ }
3416
+ }
3417
+ function stopFade() {
3418
+ if ( g_fade_scheduled != null ) {
3419
+ clearInterval(g_fade_scheduled);
3420
+ }
3421
+ }
3422
+ function pin_ItsAlive(pinned) {
3423
+ newest_pin(pinned)
3424
+ if ( pinned && (typeof pinned.openAction === 'function')) {
3425
+ pinned.openAction()
3426
+ }
3427
+ g_apparition = null;
3428
+ }
3429
+ // ---- ---- ---- ---- ---- ----
3430
+ function raiseAlpha(aGhost) {
3431
+ if ( aGhost.style.opacity == 1.0 ) {
3432
+ stopDefade()
3433
+ pinBoxElem(aGhost)
3434
+ } else {
3435
+ aGhost.style.opacity = parseFloat(aGhost.style.opacity) + 0.025;
3436
+ }
3437
+ }
3438
+ function lowerAlpha(aGhost) {
3439
+ if ( aGhost.style.opacity <= 0.2 ) {
3440
+ hideFader(aGhost)
3441
+ } else {
3442
+ aGhost.style.opacity = parseFloat(aGhost.style.opacity) - 0.1;
3443
+ }
3444
+ }
3445
+ // ---- ---- ---- ---- ---- ----
3446
+ function replaceApparition(newGhost) {
3447
+ if ( !unpin_current() ) {
3448
+ return
3449
+ }
3450
+ if ( g_apparition !== null ) {
3451
+ stopDefade()
3452
+ stopFade()
3453
+ g_apparition.style.display = "none"
3454
+ g_apparition.style.visibility = "hidden";
3455
+ // newGhost.style.zIndex = -10
3456
+ }
3457
+ if ( newGhost !== null ) {
3458
+ newGhost.style.opacity = "0.0"
3459
+ newGhost.style.display = "block"
3460
+ newGhost.style.visibility = "visible"
3461
+ // newGhost.style.zIndex = 200
3462
+ g_apparition = newGhost
3463
+ g_defade_scheduled = setInterval(() => { raiseAlpha(newGhost); },50);
3464
+ }
3465
+ }
3466
+
3467
+ // ---- ---- ---- ---- ---- ----
3468
+ function pinBoxElem(thisPin) {
3469
+ clear_pin_time()
3470
+ // if ( g_current_pin !== thisPin ) unpin_current();
3471
+ g_current_pin = thisPin;
3472
+ stopDefade()
3473
+ thisPin.style.opacity = "0.0"
3474
+ thisPin.style.display = "block"
3475
+ thisPin.style.visibility = "visible"
3476
+ // thisPin.style.zIndex = 200
3477
+ //
3478
+ thisPin.style.opacity = "1.0"
3479
+ pin_ItsAlive(g_current_pin);
3480
+ }
3481
+
3482
+ function pinBox(selector) {
3483
+ // if ( selector in all_windows ) {
3484
+ // let winbox = all_windows[selector]
3485
+ // winbox.show()
3486
+ // winbox.focus()
3487
+ // return
3488
+ // }
3489
+ let thisPin = document.querySelector(selector);
3490
+ pinBoxElem(thisPin)
3491
+ }
3492
+
3493
+ // ---- ---- ---- ---- ---- ----
3494
+ function defadeBox(selector) {
3495
+ replaceApparition(document.querySelector(selector));
3496
+ }
3497
+
3498
+
3499
+
3500
+ let draggers = {}
3501
+ let current_dragger = false
3502
+
3503
+ let dragger_z_map = {}
3504
+ function rotate_z_index(drag_Node) {
3505
+ //
3506
+ let zs = Object.keys(dragger_z_map)
3507
+ let z = zs[zs.length-1]
3508
+ let waz = parseInt(drag_Node.style.zIndex)
3509
+ while ( waz < z ) {
3510
+ let demoted = dragger_z_map[waz+1]
3511
+ dragger_z_map[waz] = demoted
3512
+ demoted.style.zIndex = waz
3513
+ waz++
3514
+ }
3515
+ dragger_z_map[z] = drag_Node
3516
+ drag_Node.style.zIndex = z
3517
+ //
3518
+ }
3519
+
3520
+ function manage_z_index(drag_bars) {
3521
+
3522
+ let minz = 10000
3523
+
3524
+ for ( let db of drag_bars ) {
3525
+ let pnode = db.parentNode
3526
+ let z = parseInt(pnode.style.zIndex)
3527
+ if ( z < minz ) {
3528
+ minz = z
3529
+ }
3530
+ }
3531
+
3532
+ let z = minz
3533
+ for ( let db of drag_bars ) {
3534
+ let pnode = db.parentNode
3535
+ pnode.style.zIndex = z
3536
+ dragger_z_map[z] = pnode
3537
+ z++
3538
+ }
3539
+
3540
+ }
3541
+
3542
+
3543
+ function add_dragging() {
3544
+
3545
+ let drag_bars = document.getElementsByClassName("togglebar")
3546
+ manage_z_index(drag_bars)
3547
+ for ( let db of drag_bars ) {
3548
+
3549
+ let cname = db.parentNode.className
3550
+ if ( cname.indexOf(' ') > 0 ) {
3551
+ cname = cname.split(' ')[0]
3552
+ }
3553
+
3554
+ if ( cname === 'solid_able' ) {
3555
+ if ( db.parentNode.id === "intergalactic-explain" ) {
3556
+ cname = "fade_able"
3557
+ }
3558
+ }
3559
+
3560
+ if ( ["fade_able","right_fade_able"].indexOf(cname) >= 0 ) {
3561
+ let drag_Node = db.parentNode
3562
+ draggers[drag_Node.id] = {
3563
+ "offsetX" : 0,
3564
+ "offsetY" : 0,
3565
+ "isDragging" : false,
3566
+ "dragged" : drag_Node,
3567
+ "drag_control" : db
3568
+ }
3569
+
3570
+ db.onmousedown = (e) => {
3571
+ let drag_Node = e.target.parentNode;
3572
+ if ( !draggers[drag_Node.id] ) return
3573
+ rotate_z_index(drag_Node)
3574
+ e.preventDefault()
3575
+ draggers[drag_Node.id].isDragging = true;
3576
+ // Calculate the offset between the mouse position and the div's top-left corner
3577
+ draggers[drag_Node.id].offsetX = e.clientX - drag_Node.getBoundingClientRect().left;
3578
+ draggers[drag_Node.id].offsetY = e.clientY - drag_Node.getBoundingClientRect().top;
3579
+ db.style.cursor = 'grabbing';
3580
+ current_dragger = drag_Node.id
3581
+ }
3582
+
3583
+ db.onmouseup = (ev) => {
3584
+ if ( current_dragger ) {
3585
+ let dragger_stats = draggers[current_dragger]
3586
+ let drag_bar = dragger_stats.drag_control
3587
+ drag_bar.style.cursor = 'move';
3588
+ }
3589
+ }
3590
+ }
3591
+ }
3592
+
3593
+ document.addEventListener('mousemove', (e) => {
3594
+ if (!current_dragger) return;
3595
+
3596
+ if ( current_dragger ) {
3597
+ let dragger_stats = draggers[current_dragger]
3598
+ let drag_Node = dragger_stats.dragged
3599
+ // Calculate new position based on mouse movement and offsetif
3600
+ if ( drag_Node ) {
3601
+ let mouseX = e.clientX
3602
+ let mouseY = e.clientY
3603
+ //
3604
+ let newX = mouseX - dragger_stats.offsetX;
3605
+ let newY = mouseY - dragger_stats.offsetY;
3606
+ //
3607
+ if ( newX > 5 && newX < window.innerWidth ) {
3608
+ drag_Node.style.left = `${newX}px`;
3609
+ }
3610
+ //
3611
+ let stopper = document.getElementsByTagName("footer")[0]
3612
+ let stoRect = stopper ? stopper.getBoundingClientRect() : false
3613
+ let maxY = stoRect ? stoRect.top : 500
3614
+ //
3615
+ if ( (newY > 5) && (newY < window.innerHeight) && (newY < maxY )) {
3616
+ drag_Node.style.top = `${newY}px`;
3617
+ }
3618
+ }
3619
+ }
3620
+
3621
+ });
3622
+
3623
+ document.addEventListener('mouseup', () => {
3624
+ if ( current_dragger ) {
3625
+ let dragger_stats = draggers[current_dragger]
3626
+ let drag_bar = dragger_stats.drag_control
3627
+ drag_bar.style.cursor = 'move';
3628
+ }
3629
+ current_dragger = false
3630
+ });
3631
+
3632
+ }
3633
+ add_dragging()
3634
+
3635
+
3636
+
3637
+
3638
+
3639
+ let resizers = {}
3640
+ let current_resizer = false
3641
+
3642
+ function window_resize_event(e) {
3643
+ if (!current_resizer) return;
3644
+
3645
+ if ( current_resizer ) {
3646
+ let resizer_stats = resizers[current_resizer]
3647
+ let pnode = resizer_stats.dragged
3648
+ // Calculate new position based on mouse movement and offsetif
3649
+ if ( pnode ) {
3650
+ const newX = e.clientX;
3651
+ const newY = e.clientY;
3652
+ //
3653
+ let brect = pnode.getBoundingClientRect()
3654
+ let resizer = resizer_stats.drag_control
3655
+ let resize_rect = resizer.getBoundingClientRect()
3656
+ let r_h_delta = resize_rect.width
3657
+ let r_v_detla = resize_rect.height
3658
+ let newW = newX - brect.left + r_h_delta/2
3659
+ let newH = newY - brect.top + r_v_detla/2
3660
+ //
3661
+ if ( newW > 60 ) {
3662
+ pnode.style.width = `${newW}px`;
3663
+ }
3664
+ if ( newH > 60 ) {
3665
+ pnode.style.height = `${newH}px`;
3666
+ }
3667
+ }
3668
+ }
3669
+ }
3670
+
3671
+
3672
+ function add_resizing() {
3673
+ let sizer_bobs = document.getElementsByClassName("sizerbar")
3674
+ for ( let sb of sizer_bobs ) {
3675
+ let pnode = sb.parentNode
3676
+
3677
+ resizers[pnode.id] = {
3678
+ "isDragging" : false,
3679
+ "dragged" : pnode,
3680
+ "drag_control" : sb
3681
+ }
3682
+
3683
+ sb.onmousedown = (e) => {
3684
+ let pnode = e.target.parentNode;
3685
+ if ( !resizers[pnode.id] ) return
3686
+ e.preventDefault()
3687
+ resizers[pnode.id].isDragging = true;
3688
+ current_resizer = pnode.id
3689
+ }
3690
+
3691
+ sb.onmouseout = (e) => {
3692
+ window_resize_event(e)
3693
+ }
3694
+
3695
+ }
3696
+
3697
+
3698
+ document.addEventListener('mousemove', (e) => {
3699
+ window_resize_event(e)
3700
+ });
3701
+
3702
+
3703
+ document.addEventListener('mouseup', () => {
3704
+ current_resizer = false
3705
+ });
3706
+
3707
+ window.addEventListener('mouseup',() => {
3708
+ current_resizer = false
3709
+ })
3710
+
3711
+ }
3712
+
3713
+ add_resizing()
3714
+
3715
+
3716
+
3717
+
3718
+ // <div id="flow_display_button_ref">${dir_buttons}</div>
3719
+ // <div id="flow_display_below_button_ref" class="file-browsers">
3720
+
3721
+ document.addEventListener('mousemove',(e) => {
3722
+ if ( !current_resizer ) return
3723
+ let ref_obj = document.getElementById("flow_display_button_ref")
3724
+ let above_ref = document.getElementById("directory_section-breadcrumb")
3725
+ let need_ref_obj = document.getElementById("flow_display_below_button_ref")
3726
+ if ( above_ref && ref_obj && need_ref_obj ) {
3727
+ let refrect = ref_obj.getBoundingClientRect()
3728
+ let aboverect = above_ref.getBoundingClientRect()
3729
+ need_ref_obj.style.top = `${(refrect.height + aboverect.height + 22)}px`
3730
+ }
3731
+ })
3732
+
3733
+ </script>
3734
+ <script>
3735
+
3736
+ // general client stuff...
3737
+ //
3738
+ function drop_one(file) {
3739
+ if ( !file ) {
3740
+ throw new Error("drop-one: no file passed")
3741
+ }
3742
+ let p = new Promise((resolve,reject) => {
3743
+ var reader = new FileReader();
3744
+ let fname = file.name
3745
+ reader.onload = (e) => {
3746
+ let blob64 = e.target.result
3747
+ resolve([fname,file,blob64])
3748
+ };
3749
+ reader.readAsDataURL(file)
3750
+ })
3751
+ return p
3752
+ }
3753
+
3754
+ //
3755
+ function drop(files) {
3756
+ //
3757
+ let promises = [];
3758
+ //
3759
+ [...files].forEach(async file_proper => {
3760
+ promises.push(drop_one(file_proper))
3761
+ });
3762
+ //
3763
+ return Promise.all(promises)
3764
+ }
3765
+
3766
+
3767
+ </script>
3768
+ <script>
3769
+
3770
+ function preventDefaults(e) {
3771
+ e.preventDefault();
3772
+ e.stopPropagation();
3773
+ }
3774
+
3775
+ const dropZone = document.getElementById('edit-email-attachments');
3776
+
3777
+ // 1. Prevent default behaviors for all drag/drop events
3778
+ ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
3779
+ dropZone.addEventListener(eventName, preventDefaults, false);
3780
+ });
3781
+
3782
+ // 3. Handle the drop event itself
3783
+ dropZone.addEventListener('drop', handleDrop, false);
3784
+
3785
+ function handleDrop(e) {
3786
+ // Access the dropped files via DataTransfer
3787
+ const dt = e.dataTransfer;
3788
+ const files = dt.files;
3789
+
3790
+ if (files.length > 0) {
3791
+ window._x_app_handle_files(files);
3792
+ }
3793
+ }
3794
+
3795
+ </script>
3796
+ <script>
3797
+ // MODULE: POST FETCH (windowized)
3798
+
3799
+
3800
+ // $>> may include interface helpers for displaying success and error
3801
+
3802
+
3803
+
3804
+ //$>> fetchUrl
3805
+ // //
3806
+ // fetch with GET method
3807
+ /**
3808
+ *
3809
+ * Assume the endpoint is a complete URL (URI)
3810
+ * Each of the methods (helpers) pick a set of parameters useful for calls made the most often.
3811
+ *
3812
+ * The server should return an object, and this will parse it as JSON
3813
+ *
3814
+ * @param {string} endpoint
3815
+ * @returns {object|boolean} - returns false on error otherwise an object delivered from the server.
3816
+ */
3817
+ async function fetchUrl(endpoint) {
3818
+ let myRequest = new Request(endpoint);
3819
+ try {
3820
+ const body = await fetch(myRequest, {
3821
+ method: 'GET', // *GET, POST, PUT, DELETE, etc.
3822
+ mode: 'cors', // no-cors, *cors, same-origin
3823
+ cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
3824
+ credentials: 'omit', // include, *same-origin, omit
3825
+ redirect: 'follow', // manual, *follow, error
3826
+ referrerPolicy: 'no-referrer', // no-referrer, *client
3827
+ });
3828
+ //
3829
+ let infoObj = await body.json();
3830
+ return(infoObj)
3831
+ //
3832
+ } catch (e) {
3833
+ console.log(e.message)
3834
+ return(false)
3835
+ }
3836
+ }
3837
+
3838
+
3839
+
3840
+
3841
+ //$>> fetchEndPoint
3842
+ /**
3843
+ *
3844
+ * Requests an object from the including page's host.
3845
+ * This is a simple object file fetch.
3846
+ * It expects the server to return a string that can be parsed as JSON, or else there will be an error.
3847
+ * The end point string should be some part of the local host API.
3848
+ * If the port is passed, will be used to identify the server on the
3849
+ *
3850
+ * This method constructs the full URL(URI)
3851
+ *
3852
+ * fetch with GET method *
3853
+ * @param {string} endpoint
3854
+ * @param {string} port -- optionals
3855
+ * @returns {object|boolean}
3856
+ */
3857
+ async function fetchEndPoint(endpoint,port) {
3858
+ port = !(port) ? '' : ( port.length ? `:${port}` : '')
3859
+ let myRequest = new Request(`${location.protocol}//${location.hostname}${port}/${endpoint}`);
3860
+ try {
3861
+ const body = await fetch(myRequest, {
3862
+ method: 'GET', // *GET, POST, PUT, DELETE, etc.
3863
+ mode: 'cors', // no-cors, *cors, same-origin
3864
+ cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
3865
+ credentials: 'omit', // include, *same-origin, omit
3866
+ redirect: 'follow', // manual, *follow, error
3867
+ referrerPolicy: 'no-referrer', // no-referrer, *client
3868
+ });
3869
+ //
3870
+ let infoObj = await body.json();
3871
+ return(infoObj)
3872
+ //
3873
+ } catch (e) {
3874
+ console.log(e.message)
3875
+ return(false)
3876
+ }
3877
+ }
3878
+
3879
+
3880
+ //$>> fetchTextFile
3881
+ /**
3882
+ * Requests a string from the including page's host.
3883
+ * This is a simple text file fetch.
3884
+ * It expects the server to return a string, or else there will be an error.
3885
+ * The end point string should be some part of the local host API.
3886
+ * If the port is passed, will be used to identify the server on the
3887
+ *
3888
+ * This method constructs the full URL(URI)
3889
+ *
3890
+ * fetch with GET method
3891
+ *
3892
+ * @param {string} endpoint
3893
+ * @param {string} port -- optional
3894
+ * @returns {string}
3895
+ */
3896
+ async function fetchTextFile(endpoint,port) {
3897
+ port = !(port) ? '' : ( port.length ? `:${port}` : '')
3898
+ let myRequest = new Request(`${location.protocol}//${location.hostname}${port}/${endpoint}`);
3899
+ try {
3900
+ const body = await fetch(myRequest, {
3901
+ method: 'GET', // *GET, POST, PUT, DELETE, etc.
3902
+ mode: 'cors', // no-cors, *cors, same-origin
3903
+ cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
3904
+ credentials: 'omit', // include, *same-origin, omit
3905
+ redirect: 'follow', // manual, *follow, error
3906
+ referrerPolicy: 'no-referrer', // no-referrer, *client
3907
+ });
3908
+ //
3909
+ let html = await body.text();
3910
+ return(html)
3911
+ //
3912
+ } catch (e) {
3913
+ console.log(e.message)
3914
+ return(false)
3915
+ }
3916
+ }
3917
+
3918
+
3919
+ //$>> postData
3920
+ /**
3921
+ *
3922
+ * call fetch with method POST tyr to help with parameters.. If data is FromData set do_stringify to false
3923
+ * default content type 'application/json'
3924
+ * User 'cors', Default cres = omit, If ctype == 'multipart/form-data' be sure to use FormData -- lets fetch set content type.
3925
+ * RETURNS: parsed JSON object or an empty object. ... Check for fields
3926
+ * @param {string} url
3927
+ * @param {object} data
3928
+ * @param {string} creds - (optional)
3929
+ * @param {boolean} do_stringify
3930
+ * @param {string} ctype - content type
3931
+ * @returns {object}
3932
+ */
3933
+ async function postData(url = '', data = {}, creds = 'omit', do_stringify = true, ctype) {
3934
+ let content_type = 'application/json'
3935
+ if ( ctype !== undefined ) {
3936
+ content_type = ctype // ctype is content type
3937
+ }
3938
+ let options = {
3939
+ method: 'POST', // *GET, POST, PUT, DELETE, etc.
3940
+ mode: 'cors', // no-cors, *cors, same-origin
3941
+ cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
3942
+ credentials: creds, // include, *same-origin, omit
3943
+ headers: {
3944
+ 'Content-Type': content_type
3945
+ },
3946
+ redirect: 'follow', // manual, *follow, error
3947
+ referrerPolicy: 'no-referrer', // no-referrer, *client
3948
+ body: (do_stringify ? JSON.stringify(data) : data) // body data type must match "Content-Type" header
3949
+ }
3950
+
3951
+ if ( ctype === 'multipart/form-data') {
3952
+ delete options.headers['Content-Type'] // content type will be set automatically with a boundary
3953
+ }
3954
+
3955
+ // Default options are marked with *
3956
+ const response = await fetch(url, options);
3957
+ if ( response.ok == false ) {
3958
+ console.log(response.status + ': ' + response.statusText)
3959
+ return {}
3960
+ } else {
3961
+ return await response.json(); // parses JSON response into native JavaScript objects
3962
+ }
3963
+ }
3964
+
3965
+
3966
+
3967
+ //$>> postDataWithRefer
3968
+
3969
+ /**
3970
+ * call fetch with method POST try to help with parameters.. If data is FromData set do_stringify to false
3971
+ * default content type 'application/json'
3972
+ * User 'cors', Default cres = omit, If ctype == 'multipart/form-data' be sure to use FormData -- lets fetch set content type.
3973
+ *
3974
+ * @param {string} url
3975
+ * @param {object} data
3976
+ * @param {string} creds
3977
+ * @param {boolean} do_stringify
3978
+ * @param {string} ctype
3979
+ * @returns {object} - parsed JSON object or an empty object. ... Check for fields
3980
+ */
3981
+ async function postDataWithRefer(url = '', data = {}, creds = 'omit', do_stringify = true, ctype) {
3982
+ let content_type = 'application/json'
3983
+ if ( ctype !== undefined ) {
3984
+ content_type = ctype // ctype is content type
3985
+ }
3986
+ let options = {
3987
+ method: 'POST', // *GET, POST, PUT, DELETE, etc.
3988
+ mode: 'cors', // no-cors, *cors, same-origin
3989
+ cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
3990
+ credentials: creds, // include, *same-origin, omit
3991
+ headers: {
3992
+ 'Content-Type': content_type
3993
+ },
3994
+ redirect: 'error', // manual, *follow, error
3995
+ referrerPolicy: 'origin', // no-referrer, origin
3996
+ body: (do_stringify ? JSON.stringify(data) : data) // body data type must match "Content-Type" header
3997
+ }
3998
+
3999
+ if ( ctype === 'multipart/form-data') {
4000
+ delete options.headers['Content-Type'] // content type will be set automatically with a boundary
4001
+ }
4002
+
4003
+ // Default options are marked with *
4004
+ const response = await fetch(url, options);
4005
+ if ( response.ok == false ) {
4006
+ console.log(response.status + ': ' + response.statusText)
4007
+ return {}
4008
+ } else {
4009
+ return await response.json(); // parses JSON response into native JavaScript objects
4010
+ }
4011
+ }
4012
+
4013
+
4014
+ //$>> post_submit
4015
+
4016
+ /**
4017
+ * Takes in a list of names of form fields each having a "value" member.
4018
+ * The list is used to contsuct a JSON object which will be the body of the request.
4019
+ *
4020
+ * This method then calls postData with the url found in the field with id "post_url"
4021
+ *
4022
+ * If visusl indicators have been programmed with respect to this method.
4023
+ * If the `hide_interface_box` has been defined, then it will be called.
4024
+ * Similarly, `show_box` for ids 'success-box' and 'error-box'
4025
+ *
4026
+ * @param {Array} fields
4027
+ */
4028
+ async function post_submit(fields) {
4029
+ if ( !(Array.isArray(fields)) ) return
4030
+ let bdy = {}
4031
+ fields.forEach(element => {
4032
+ let fld = document.getElementById(element)
4033
+ if ( fld ) {
4034
+ bdy[element] = fld.value
4035
+ }
4036
+ });
4037
+ let url = bdy.post_url
4038
+ if ( url ) {
4039
+ delete bdy.post_url
4040
+ //
4041
+ let resp = await postData(url, bdy)
4042
+ //
4043
+ if ( resp && typeof hide_interface_box === "function" ) hide_interface_box()
4044
+ if ( resp && (resp.OK === 'true') ) {
4045
+ if( typeof show_box === "function" ) show_box('success-box')
4046
+ } else {
4047
+ if( typeof show_box === "function" ) show_box('error-box')
4048
+ }
4049
+ }
4050
+ }
4051
+
4052
+
4053
+
4054
+ //$>> make_host_request
4055
+
4056
+ /**
4057
+ *
4058
+ * This method wraps postData for the one use case that object (JSON) returned
4059
+ * by the host has a field "OK", which may have string values "true" or "false"
4060
+ *
4061
+ * @param {string} endpoint
4062
+ * @param {object} data
4063
+ * @returns {object|boolean}
4064
+ */
4065
+ async function make_host_request(endpoint,data) {
4066
+ try {
4067
+ let resp = await postData(endpoint, data ) //,'include')
4068
+ if ( resp.OK === "true" ) {
4069
+ return resp.data
4070
+ } else {
4071
+ return false
4072
+ }
4073
+ } catch (e) {
4074
+ return false
4075
+ }
4076
+ }
4077
+
4078
+
4079
+
4080
+
4081
+ //$$EXPORTABLE::
4082
+ /*
4083
+ fetchEndPoint
4084
+ fetchTextFile
4085
+ fetchUrl
4086
+ postData
4087
+ post_submit
4088
+ */
4089
+
4090
+ </script>
4091
+ <script>
4092
+
4093
+ async function hash_of(string) {
4094
+ let buf = new TextEncoder()
4095
+ string = buf.encode(string)
4096
+ let hash = await window.crypto.subtle.digest('SHA-256',string)
4097
+ return new Uint8Array(hash).toBase64()
4098
+ }
4099
+
4100
+ function gen_json_id(mail_ob) {
4101
+ if ( mail_obj ) {
4102
+ return 10
4103
+ } else {
4104
+ let current_user_name = window._current_user_account.name
4105
+ return hash_of(current_user_name + Date.now())
4106
+ }
4107
+ }
4108
+
4109
+ class MailJsonRpc {
4110
+ constructor(mtype,method,params) {
4111
+ this.id = 10 // get a good method for this id
4112
+ let user = window._current_user_account.name
4113
+ this.params = {
4114
+ "mail_type" : mtype,
4115
+ "user" : user,
4116
+ "params" : params,
4117
+ "date" : Date.now()
4118
+ }
4119
+ this.method = method
4120
+ this.jsonrpc = '2.0'
4121
+ }
4122
+ }
4123
+
4124
+ window._current_user_account = {
4125
+ "name" : "testing",
4126
+ "password" : "testing"
4127
+ }
4128
+
4129
+ let web_page_port = 9989
4130
+ let wss_app_port = 9990
4131
+
4132
+
4133
+ //
4134
+ // let mail_proto = { "id" : 1, "sender" : "richard@myhost.local", "subject" : "", "date" : date.toLocaleString(), "timestamp" : date.getTime(),
4135
+ // "recipient" : "",
4136
+ // "cc" : "", "bcc" : "",
4137
+ // "text" : "edit this message", "_count_edits" : 0, "_saved_updates" : [] }
4138
+
4139
+ // TALK TO THE SERVER
4140
+ async function load_a_bunch_of_emails(mtype) {
4141
+ let data = new MailJsonRpc(mtype,"get-mail")
4142
+
4143
+ let port = web_page_port
4144
+ let url = `http://localhost:${port}/json/email`
4145
+ let rpc_result = await postData(url, data)
4146
+ if ( rpc_result && (rpc_result.error === undefined) ) {
4147
+ console.log(rpc_result)
4148
+ if ( rpc_result.result === undefined ) return []
4149
+ return rpc_result.result
4150
+ }
4151
+ return []
4152
+ }
4153
+
4154
+ async function load_a_bunch_of_contacts() {
4155
+ let data = new MailJsonRpc('contacts',"get-contacts")
4156
+
4157
+ let port = web_page_port
4158
+ let url = `http://localhost:${port}/json/email`
4159
+ let rpc_result = await postData(url, data)
4160
+ if ( rpc_result && (rpc_result.error === undefined) ) {
4161
+ console.log(rpc_result)
4162
+ if ( rpc_result.result === undefined ) return []
4163
+ return rpc_result.result
4164
+ }
4165
+ return []
4166
+ }
4167
+
4168
+ // * add_objects_to_list
4169
+ // * delete_objects_from_list
4170
+ // * remove_one_contact
4171
+ // * send_emails
4172
+ // * save_mail -- to drafts
4173
+ // * save_contact
4174
+
4175
+ /*
4176
+ "get-mail"
4177
+ "store-mail"
4178
+ "remove-mail"
4179
+ "send-mail"
4180
+ "store-draft"
4181
+ "get-contacts"
4182
+ "store-contact"
4183
+ "remove-contact"
4184
+ */
4185
+
4186
+ /**
4187
+ */
4188
+ async function add_emails_to_server(to,object_list) {
4189
+ // server communication
4190
+ let data = new MailJsonRpc(to,"store-mail",object_list)
4191
+ //
4192
+ let port = web_page_port
4193
+ let url = `http://localhost:${port}/json/email`
4194
+ let rpc_result = await postData(url, data)
4195
+ if ( rpc_result && (rpc_result.error === undefined) ) {
4196
+ console.log(rpc_result)
4197
+ return true
4198
+ }
4199
+ return false
4200
+ }
4201
+
4202
+ /**
4203
+ */
4204
+ async function delete_emails_from_server(from,id_list) {
4205
+ // server communication
4206
+ let data = new MailJsonRpc(from,"remove-mail",id_list)
4207
+ //
4208
+ let port = web_page_port
4209
+ let url = `http://localhost:${port}/json/email`
4210
+ let rpc_result = await postData(url, data)
4211
+ if ( rpc_result && (rpc_result.error === undefined) ) {
4212
+ console.log(rpc_result)
4213
+ return true
4214
+ }
4215
+ return false
4216
+ }
4217
+
4218
+
4219
+ /**
4220
+ */
4221
+ async function send_emails(object_list) {
4222
+ // server communication
4223
+ let data = new MailJsonRpc("sent","send-mail",object_list)
4224
+
4225
+ let port = web_page_port
4226
+ let url = `http://localhost:${port}/json/email`
4227
+ let rpc_result = await postData(url, data)
4228
+ if ( rpc_result && (rpc_result.error === undefined) ) {
4229
+ return true
4230
+ }
4231
+ return false
4232
+ }
4233
+
4234
+ /**
4235
+ */
4236
+ async function save_mail(email_obj) {
4237
+ // server communicate
4238
+ let data = new MailJsonRpc("drafts","store-draft",email_obj)
4239
+
4240
+ let port = web_page_port
4241
+ let url = `http://localhost:${port}/json/email`
4242
+ let rpc_result = await postData(url, data)
4243
+ if ( rpc_result && (rpc_result.error === undefined) ) {
4244
+ return true
4245
+ }
4246
+ return false
4247
+ }
4248
+
4249
+
4250
+ /**
4251
+ */
4252
+ async function remove_contact_from_server(a_contact) {
4253
+ // server communication
4254
+ let data = new MailJsonRpc("contacts","remove-contact",a_contact)
4255
+
4256
+ let port = web_page_port
4257
+ let url = `http://localhost:${port}/json/email`
4258
+ let rpc_result = await postData(url, data)
4259
+ if ( rpc_result && (rpc_result.error === undefined) ) {
4260
+ return true
4261
+ }
4262
+ return false
4263
+ }
4264
+
4265
+ /**
4266
+ */
4267
+ async function save_contact(edited_contact) {
4268
+ // server communication
4269
+ let data = new MailJsonRpc("contacts","store-contact",edited_contact)
4270
+
4271
+ let port = web_page_port
4272
+ let url = `http://localhost:${port}/json/email`
4273
+ let rpc_result = await postData(url, data)
4274
+ if ( rpc_result && (rpc_result.error === undefined) ) {
4275
+ return true
4276
+ }
4277
+ return false
4278
+ }
4279
+
4280
+ </script>
4281
+ <script>
4282
+ //
4283
+ let ws_url = `http://localhost:${wss_app_port}`
4284
+ let g_ws_controller = null
4285
+
4286
+ class WsSocketController {
4287
+ constructor(url) {
4288
+ this.url = url
4289
+ this.socket = new WebSocket(url);
4290
+
4291
+ // Connection successfully opened
4292
+ let sock = this.socket
4293
+ this.socket.onopen = (event) => {
4294
+ if ( sock ) {
4295
+ let sid = true // an actual id from the server so that it can know itself
4296
+ let message = {
4297
+ "type" : "mail-ops",
4298
+ "message" : {
4299
+ "op" : "initial-messages",
4300
+ "server_id" : sid,
4301
+ "concern" : "copious",
4302
+ "data" : {
4303
+ "user_name" : window._current_user_account.name
4304
+ }
4305
+ }
4306
+ }
4307
+ let msg_as_str = JSON.stringify(message)
4308
+ sock.send(msg_as_str)
4309
+ }
4310
+ // statusSpan.textContent = 'Connected';
4311
+ // statusSpan.style.color = 'green';
4312
+ };
4313
+
4314
+ // Listen for incoming messages from server
4315
+ this.socket.onmessage = (event) => {
4316
+ let msg = JSON.parse(event.data)
4317
+ let data = msg.data
4318
+ //
4319
+ if ( data.op ) {
4320
+ switch ( data.op ) {
4321
+ case "initial-messages":
4322
+ case "all-updates" : {
4323
+ let message_map = data.data
4324
+ if ( window.add_emails_to_list === undefined ) {
4325
+ setTimeout(() => {
4326
+ if ( typeof message_map === "object" ) {
4327
+ for ( let [ky,mlist] of Object.entries(message_map) ) {
4328
+ window.add_emails_to_list(ky,mlist)
4329
+ }
4330
+ }
4331
+ },100)
4332
+ } else {
4333
+ if ( typeof message_map === "object" ) {
4334
+ for ( let [ky,mlist] of Object.entries(message_map) ) {
4335
+ window.add_emails_to_list(ky,mlist)
4336
+ }
4337
+ }
4338
+ }
4339
+ break
4340
+ }
4341
+ case "emails" : {
4342
+ break;
4343
+ }
4344
+ case "contacts" : {
4345
+ break;
4346
+ }
4347
+ case "nofify" : {
4348
+ break;
4349
+ }
4350
+ case "no-delivery" : {
4351
+ break;
4352
+ }
4353
+ case "proc-status": {
4354
+ console.log(data.data)
4355
+ break
4356
+ }
4357
+ }
4358
+ }
4359
+ };
4360
+
4361
+ // Connection closed
4362
+ this.socket.onclose = (event) => {
4363
+ // statusSpan.textContent = 'Disconnected';
4364
+ // statusSpan.style.color = 'red';
4365
+ this.socket = null;
4366
+ };
4367
+
4368
+ // Handle errors
4369
+ this.socket.onerror = (error) => {
4370
+ console.log(error)
4371
+ };
4372
+
4373
+
4374
+ window.addEventListener('close',() => {
4375
+ this.socket.close();
4376
+ })
4377
+ }
4378
+
4379
+ // Send Message to Server
4380
+ sendMessage(text) {
4381
+ if (text && socket && (socket.readyState === WebSocket.OPEN )) {
4382
+ this.socket.send(text);
4383
+ }
4384
+ }
4385
+
4386
+
4387
+ sendObject(obj) {
4388
+ let text = JSON.stringify(obj)
4389
+ this.sendMessage(text)
4390
+ }
4391
+
4392
+ }
4393
+
4394
+ g_ws_controller = new WsSocketController(ws_url)
4395
+
4396
+
4397
+ </script>
4398
+ <script>
4399
+ window.onload = () => {
4400
+ // initializers ----
4401
+ setup_email_ops_dialog()
4402
+ setup_contacts_ops_dialog()
4403
+ setup_search_ops_dialog()
4404
+ setup_edit_response()
4405
+ setup_select_all_ops_dialog()
4406
+ setup_checkbox_pattern_tracking()
4407
+ }
4408
+ </script>