From c96e6ffafb62bde1e08987b1fdf3c0786487f6ec Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 24 Jan 2017 12:06:09 +0100 Subject: Initial commit --- src/scripts/profile.entry.ts | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/scripts/profile.entry.ts (limited to 'src/scripts/profile.entry.ts') 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 @@ +/// +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 = $("#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"); + }); +}); -- cgit v1.2.3