mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2025-07-05 04:35:23 +02:00
Implement server webhook icons as cosmetics & fixes
This commit is contained in:
@ -1,10 +1,13 @@
|
||||
/* global $, Materialize, location */
|
||||
|
||||
function postForm(user_id, css) {
|
||||
function postForm(user_id, css, css_limit, webhook_icon) {
|
||||
if (css_limit == "") {
|
||||
css_limit = 0;
|
||||
}
|
||||
var funct = $.ajax({
|
||||
dataType: "json",
|
||||
method: "POST",
|
||||
data: {"user_id": user_id, "css": css}
|
||||
data: {"user_id": user_id, "css": css, "css_limit": css_limit, "webhook_icon": webhook_icon}
|
||||
});
|
||||
return funct.promise();
|
||||
}
|
||||
@ -36,7 +39,9 @@ $(function() {
|
||||
return;
|
||||
}
|
||||
var css_checked = $("#new_css_switch").is(':checked');
|
||||
var formPost = postForm(user_id, css_checked);
|
||||
var css_limit = $("#new_css_limit").val();
|
||||
var webhook_icon_checked = $("#new_webhook_icon_switch").is(':checked');
|
||||
var formPost = postForm(user_id, css_checked, css_limit, webhook_icon_checked);
|
||||
formPost.done(function (data) {
|
||||
location.reload();
|
||||
});
|
||||
@ -94,4 +99,19 @@ function update_css_limit(user_id, value) {
|
||||
Materialize.toast('Oh no! Something has failed changing the css limit field!', 10000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function update_webhook_icon_switch(user_id, element) {
|
||||
var webhook_checked = $(element).is(':checked');
|
||||
var formPatch = patchForm(user_id, {"webhook_icon": webhook_checked});
|
||||
formPatch.done(function (data) {
|
||||
Materialize.toast('Webhook Icon updated!', 10000);
|
||||
});
|
||||
formPatch.fail(function (data) {
|
||||
if (data.status == 409) {
|
||||
Materialize.toast('This user id does not exists!', 10000);
|
||||
} else {
|
||||
Materialize.toast('Oh no! Something has failed changing the webhook icon toggle!', 10000);
|
||||
}
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user