mirror of
https://gitlab.com/commento/commento.git
synced 2025-06-29 22:56:37 -04:00
api,frontend: add unsubscribe
This commit is contained in:
@ -74,6 +74,12 @@ const jsCompileMap = {
|
||||
"js/logout.js"
|
||||
],
|
||||
"js/commento.js": ["js/commento.js"],
|
||||
"js/unsubscribe.js": [
|
||||
"js/constants.js",
|
||||
"js/utils.js",
|
||||
"js/http.js",
|
||||
"js/unsubscribe.js",
|
||||
],
|
||||
};
|
||||
|
||||
gulp.task("scss-devel", function () {
|
||||
|
54
frontend/js/unsubscribe.js
Normal file
54
frontend/js/unsubscribe.js
Normal file
@ -0,0 +1,54 @@
|
||||
(function (global, document) {
|
||||
"use strict";
|
||||
|
||||
(document);
|
||||
|
||||
var e;
|
||||
|
||||
// Update the email records.
|
||||
global.emailUpdate = function() {
|
||||
$(".err").text("");
|
||||
$(".msg").text("");
|
||||
e.sendModeratorNotifications = $("#moderator").is(":checked");
|
||||
e.sendReplyNotifications = $("#reply").is(":checked");
|
||||
|
||||
var json = {
|
||||
"email": e,
|
||||
};
|
||||
|
||||
global.buttonDisable("#save-button");
|
||||
global.post(global.origin + "/api/email/update", json, function(resp) {
|
||||
global.buttonEnable("#save-button");
|
||||
if (!resp.success) {
|
||||
$(".err").text(resp.message);
|
||||
return;
|
||||
}
|
||||
|
||||
$(".msg").text("Successfully updated!");
|
||||
});
|
||||
}
|
||||
|
||||
// Checks the unsubscribeSecretHex token to retrieve current settings.
|
||||
global.emailGet = function() {
|
||||
$(".err").text("");
|
||||
$(".msg").text("");
|
||||
var json = {
|
||||
"unsubscribeSecretHex": global.paramGet("unsubscribeSecretHex"),
|
||||
};
|
||||
|
||||
global.post(global.origin + "/api/email/get", json, function(resp) {
|
||||
$(".loading").hide();
|
||||
if (!resp.success) {
|
||||
$(".err").text(resp.message);
|
||||
return;
|
||||
}
|
||||
|
||||
e = resp.email;
|
||||
$("#email").text(e.email);
|
||||
$("#moderator").prop("checked", e.sendModeratorNotifications);
|
||||
$("#reply").prop("checked", e.sendReplyNotifications);
|
||||
$(".checkboxes").attr("style", "");
|
||||
});
|
||||
};
|
||||
|
||||
} (window.commento, document));
|
49
frontend/sass/unsubscribe-main.scss
Normal file
49
frontend/sass/unsubscribe-main.scss
Normal file
@ -0,0 +1,49 @@
|
||||
@import "checkbox.scss";
|
||||
@import "button.scss";
|
||||
|
||||
.unsubscribe-container {
|
||||
margin-top: 72px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
.unsubscribe {
|
||||
max-width: 600px;
|
||||
width: 100%;
|
||||
|
||||
.loading {
|
||||
font-size: 32px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.err {
|
||||
color: $red-6;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.msg {
|
||||
color: $green-6;
|
||||
font-weight: bold;
|
||||
margin-bottom: 12px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.checkboxes {
|
||||
.email {
|
||||
margin-bottom: 32px;
|
||||
font-size: 21px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.email::before {
|
||||
content: "Changing email notifications for ";
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.row {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
4
frontend/sass/unsubscribe.scss
Normal file
4
frontend/sass/unsubscribe.scss
Normal file
@ -0,0 +1,4 @@
|
||||
@import "common-main.scss";
|
||||
@import "navbar-main.scss";
|
||||
@import "unsubscribe-main.scss";
|
||||
@import "tomorrow.scss";
|
49
frontend/unsubscribe.html
Normal file
49
frontend/unsubscribe.html
Normal file
@ -0,0 +1,49 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="user-scalable=no, initial-scale=1.0">
|
||||
<script src="[[[.CdnPrefix]]]/js/jquery.js"></script>
|
||||
<script src="[[[.CdnPrefix]]]/js/unsubscribe.js"></script>
|
||||
<link rel="icon" href="[[[.CdnPrefix]]]/images/120x120.png">
|
||||
<link rel="stylesheet" href="[[[.CdnPrefix]]]/css/unsubscribe.css">
|
||||
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700|Source+Sans+Pro:200,300,400,700" rel="stylesheet">
|
||||
<title>Commento: Unsubscribe</title>
|
||||
</head>
|
||||
|
||||
<div class="navbar">
|
||||
<a href="[[[.Origin]]]/" class="navbar-item navbar-logo-text"><img src="[[[.CdnPrefix]]]/images/logo.svg" class="navbar-logo">Commento</a>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
window.onload = function() {
|
||||
window.commento.emailGet();
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="unsubscribe-container">
|
||||
<div class="unsubscribe">
|
||||
<div class="err"></div>
|
||||
<div class="loading">Loading...</div>
|
||||
<div class="checkboxes" style="display: none">
|
||||
<div class="email" id="email"></div>
|
||||
<div class="row no-border commento-round-check indent" id="mod-checkbox">
|
||||
<input type="checkbox" id="moderator" value="moderator">
|
||||
<label for="moderator">Email me moderator-related notifications</label>
|
||||
<div class="pitch">
|
||||
If you're a moderator of any domain, depending on each domain's moderator email policy, you may receive emails when a new comment is posted or when a comment is pending moderation. Unchecking this override those settings for you.
|
||||
</div>
|
||||
</div>
|
||||
<div class="row no-border commento-round-check indent" id="reply-checkbox">
|
||||
<input type="checkbox" id="reply" value="reply">
|
||||
<label for="reply">Email me when someone replies to my comment</label>
|
||||
<div class="pitch">
|
||||
When someone replies to your comment, you can choose to receive a notification. These emails will be batched and delayed (by 10 minutes) so that your inbox won't get overwhelmed.
|
||||
</div>
|
||||
</div>
|
||||
<div class="msg"></div>
|
||||
<button id="save-button" class="button" onclick="window.commento.emailUpdate()">Update</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
[[[.Footer]]]
|
||||
</html>
|
Reference in New Issue
Block a user