mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2025-07-04 20:25:25 +02:00
Paypal (#41)
* Implement Titan Tokens clientside * Titan Tokens can be modified in the admin panel
This commit is contained in:
committed by
GitHub
parent
d363b66799
commit
8bc95f7b0e
56
webapp/titanembeds/static/js/admin_token_transactions.js
Normal file
56
webapp/titanembeds/static/js/admin_token_transactions.js
Normal file
@ -0,0 +1,56 @@
|
||||
/* global $, Materialize, location */
|
||||
|
||||
function postForm(user_id, amount) {
|
||||
var funct = $.ajax({
|
||||
dataType: "json",
|
||||
method: "POST",
|
||||
data: {"user_id": user_id, "amount": amount}
|
||||
});
|
||||
return funct.promise();
|
||||
}
|
||||
|
||||
function patchForm(user_id, amount) {
|
||||
var funct = $.ajax({
|
||||
dataType: "json",
|
||||
method: "PATCH",
|
||||
data: {"user_id": user_id, "amount": amount}
|
||||
});
|
||||
return funct.promise();
|
||||
}
|
||||
|
||||
$(function() {
|
||||
$("#new_submit").click(function () {
|
||||
var user_id = $("#new_user_id").val();
|
||||
var user_token = $("#new_user_token").val();
|
||||
if (user_id.length < 1 || user_token.length < 1) {
|
||||
Materialize.toast("The user ID or balance field can't be blank!", 2000);
|
||||
return;
|
||||
}
|
||||
var formPost = postForm(user_id, user_token);
|
||||
formPost.done(function (data) {
|
||||
location.reload();
|
||||
});
|
||||
formPost.fail(function (data) {
|
||||
if (data.status == 409) {
|
||||
Materialize.toast('This user id already exists!', 10000);
|
||||
} else {
|
||||
Materialize.toast('Oh no! Something has failed submitting a new entry!', 10000);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function submit_modify_user(user_id) {
|
||||
var amount = $("#input_"+user_id).val();
|
||||
var formPatch = patchForm(user_id, amount);
|
||||
formPatch.done(function (data) {
|
||||
location.reload();
|
||||
});
|
||||
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 css toggle!', 10000);
|
||||
}
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user