Customizable msg posting timeout and msg length

This commit is contained in:
Jeremy Zhang
2018-03-25 04:43:39 +00:00
parent 18f25d0852
commit e8424a63c8
11 changed files with 116 additions and 5 deletions

View File

@ -54,6 +54,28 @@ $("#mentions_limit").keyup(function(event){
}
});
$("#post_timeout").keyup(function(event){
if(event.keyCode == 13){
var pathname = window.location.pathname;
var value = $("#post_timeout").val()
var payload = {"post_timeout": value}
$.post(pathname, payload, function(data) {
Materialize.toast('Updated post timeout setting!', 2000)
});
}
});
$("#max_message_length").keyup(function(event){
if(event.keyCode == 13){
var pathname = window.location.pathname;
var value = $("#max_message_length").val()
var payload = {"max_message_length": value}
$.post(pathname, payload, function(data) {
Materialize.toast('Updated max message length setting!', 2000)
});
}
});
$("#invite_link").keyup(function(event){
if(event.keyCode == 13){
var pathname = window.location.pathname;

View File

@ -19,6 +19,7 @@
/* global disabled */
/* global wdtEmojiBundle */
/* global EmojiConvertor */
/* global post_timeout */
(function () {
const theme_options = ["DiscordDark", "MetroEdge", "BetterTitan"]; // All the avaliable theming names
@ -1589,7 +1590,7 @@
if (event.keyCode == 16) {
shift_pressed = true;
}
if(event.keyCode == 13 && !shift_pressed && $(this).val().length >= 1 && $(this).val().length <= 350) {
if(event.keyCode == 13 && !shift_pressed && $(this).val().length >= 1) {
$(this).val($.trim($(this).val()));
$(this).blur();
$("#messagebox").attr('readonly', true);
@ -1613,15 +1614,13 @@
});
funct.catch(function(data) {
if (data.status == 429) {
Materialize.toast('You are sending messages too fast! 1 message per 5 seconds', 10000);
Materialize.toast('You are sending messages too fast! 1 message per ' + post_timeout + ' seconds', 10000);
}
});
funct.always(function() {
$("#messagebox").attr('readonly', false);
$("#messagebox").focus();
});
} else if (event.keyCode == 13 && !shift_pressed && $(this).val().length > 350) {
Materialize.toast('You are sending messages too long! 350 characters limit.', 10000);
}
});