-
-
-
-
-
{{ .strings.markdownSupported }}
-
+
+
+
+
+
+
+
{{ .strings.markdownSupported }}
+
+
+
+
{{ .strings.preview }}
+
+
diff --git a/package-lock.json b/package-lock.json
index a9a802e..0c5c9d1 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,6 +9,7 @@
"license": "ISC",
"dependencies": {
"@ts-stack/markdown": "^1.3.0",
+ "@types/node": "^15.0.1",
"a17t": "^0.4.0",
"esbuild": "^0.8.57",
"lodash": "^4.17.19",
@@ -35,9 +36,9 @@
}
},
"node_modules/@types/node": {
- "version": "14.14.16",
- "resolved": "https://registry.npm.taobao.org/@types/node/download/@types/node-14.14.16.tgz?cache=0&sync_timestamp=1608756036972&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fnode%2Fdownload%2F%40types%2Fnode-14.14.16.tgz",
- "integrity": "sha1-PMNR+NSBAd6t/tTJ5PEWBI1De0s="
+ "version": "15.0.1",
+ "resolved": "https://registry.nlark.com/@types/node/download/@types/node-15.0.1.tgz?cache=0&sync_timestamp=1619534647758&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40types%2Fnode%2Fdownload%2F%40types%2Fnode-15.0.1.tgz",
+ "integrity": "sha1-7zTeoIgQKNETmL5b9OhWdD49w1o="
},
"node_modules/a17t": {
"version": "0.4.0",
@@ -1835,9 +1836,9 @@
}
},
"@types/node": {
- "version": "14.14.16",
- "resolved": "https://registry.npm.taobao.org/@types/node/download/@types/node-14.14.16.tgz?cache=0&sync_timestamp=1608756036972&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40types%2Fnode%2Fdownload%2F%40types%2Fnode-14.14.16.tgz",
- "integrity": "sha1-PMNR+NSBAd6t/tTJ5PEWBI1De0s="
+ "version": "15.0.1",
+ "resolved": "https://registry.nlark.com/@types/node/download/@types/node-15.0.1.tgz?cache=0&sync_timestamp=1619534647758&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40types%2Fnode%2Fdownload%2F%40types%2Fnode-15.0.1.tgz",
+ "integrity": "sha1-7zTeoIgQKNETmL5b9OhWdD49w1o="
},
"a17t": {
"version": "0.4.0",
diff --git a/package.json b/package.json
index 2d8ca85..7a10fac 100644
--- a/package.json
+++ b/package.json
@@ -18,6 +18,7 @@
"homepage": "https://github.com/hrfee/jfa-go#readme",
"dependencies": {
"@ts-stack/markdown": "^1.3.0",
+ "@types/node": "^15.0.1",
"a17t": "^0.4.0",
"esbuild": "^0.8.57",
"lodash": "^4.17.19",
diff --git a/ts/modules/accounts.ts b/ts/modules/accounts.ts
index 579335d..a06d77d 100644
--- a/ts/modules/accounts.ts
+++ b/ts/modules/accounts.ts
@@ -1,4 +1,7 @@
import { _get, _post, _delete, toggleLoader, toDateString } from "../modules/common.js";
+import { templateEmail } from "../modules/settings.js";
+import { Marked } from "@ts-stack/markdown";
+import { stripMarkdown } from "../modules/stripmd.js";
interface User {
id: string;
@@ -193,6 +196,9 @@ export class accountsList {
private _addUserButton = document.getElementById("accounts-add-user") as HTMLSpanElement;
private _announceButton = document.getElementById("accounts-announce") as HTMLSpanElement;
+ private _announcePreview: HTMLElement;
+ private _previewLoaded = false;
+ private _announceTextarea = document.getElementById("textarea-announce") as HTMLTextAreaElement;
private _deleteUser = document.getElementById("accounts-delete-user") as HTMLSpanElement;
private _disableEnable = document.getElementById("accounts-disable-enable") as HTMLSpanElement;
private _deleteNotify = document.getElementById("delete-user-notify") as HTMLInputElement;
@@ -432,7 +438,16 @@ export class accountsList {
}
}, true);
}
-
+ loadPreview = () => {
+ let content = this._announceTextarea.value;
+ if (!this._previewLoaded) {
+ content = stripMarkdown(content);
+ this._announcePreview.textContent = content;
+ } else {
+ content = Marked.parse(content);
+ this._announcePreview.innerHTML = content;
+ }
+ }
announce = () => {
const modalHeader = document.getElementById("header-announce");
modalHeader.textContent = window.lang.quantity("announceTo", this._collectUsers().length);
@@ -440,16 +455,16 @@ export class accountsList {
let list = this._collectUsers();
const button = form.querySelector("span.submit") as HTMLSpanElement;
const subject = document.getElementById("announce-subject") as HTMLInputElement;
- const message = document.getElementById("textarea-announce") as HTMLTextAreaElement;
+
subject.value = "";
- message.value = "";
+ this._announceTextarea.value = "";
form.onsubmit = (event: Event) => {
event.preventDefault();
toggleLoader(button);
let send = {
"users": list,
"subject": subject.value,
- "message": message.value
+ "message": this._announceTextarea.value
}
_post("/users/announce", send, (req: XMLHttpRequest) => {
if (req.readyState == 4) {
@@ -463,7 +478,29 @@ export class accountsList {
}
});
};
- window.modals.announce.show();
+ _get("/config/emails/Announcement", null, (req: XMLHttpRequest) => {
+ if (req.readyState == 4) {
+ const preview = document.getElementById("announce-preview") as HTMLDivElement;
+ if (req.status != 200) {
+ preview.innerHTML = `