blob: 0cb77f509b9269e8b25fa14c444ff9652711aad8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
///<reference path="../../typings/index.d.ts" />
import * as $ from "jquery";
import {APIController} from "./controllers/connection/api";
import {removeUserInfo} from "./user-authentication";
window["jQuery"] = $;
$(document).ready(() => {
const api = new APIController(() => {
});
$("#delete-account").on("click", () => {
const modalDialog = <any>$("#confirm-delete-account");
// Function called on delete confirmation
const callback = () => {
api.deleteUser(parseInt(localStorage.getItem("userId"))).then(() => {
removeUserInfo();
gapi.auth2.getAuthInstance().signOut().then(() => {
window.location.href = "/";
});
}, (reason: any) => {
modalDialog.find("button.confirm").off();
modalDialog.modal("hide");
const alert = $(".account-delete-alert");
alert.find("code").text(reason.code + ": " + reason.description);
alert.slideDown(200);
setTimeout(() => {
alert.slideUp(200);
}, 5000);
});
};
modalDialog.find("button.confirm").on("click", callback);
modalDialog.modal("show");
});
});
|