summaryrefslogtreecommitdiff
path: root/src/scripts/profile.entry.ts
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-01-24 12:06:09 +0100
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-01-24 12:06:09 +0100
commitc96e6ffafb62bde1e08987b1fdf3c0786487f6ec (patch)
tree37eaf4cf199ca77dc131b4212c526b707adf2e30 /src/scripts/profile.entry.ts
Initial commit
Diffstat (limited to 'src/scripts/profile.entry.ts')
-rw-r--r--src/scripts/profile.entry.ts40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/scripts/profile.entry.ts b/src/scripts/profile.entry.ts
new file mode 100644
index 00000000..57c6b56c
--- /dev/null
+++ b/src/scripts/profile.entry.ts
@@ -0,0 +1,40 @@
+///<reference path="../../typings/index.d.ts" />
+import * as $ from "jquery";
+import {APIController} from "./controllers/connection/api";
+import {removeUserInfo} from "./user";
+window["jQuery"] = $;
+
+
+$(document).ready(() => {
+ let api = new APIController(() => {
+ });
+
+ $("#delete-account").on("click", () => {
+ let modalDialog = <any>$("#confirm-delete-account");
+
+ // Function called on delete confirmation
+ let 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");
+
+ let 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");
+ });
+});