From b3c13e07598e7916da48debaa4670242bf76073b Mon Sep 17 00:00:00 2001 From: Jeremy Tan Date: Thu, 3 Oct 2013 21:15:22 +0800 Subject: [PATCH] Add logout functionality --- testing/MCTXWeb/public_html/index.html | 6 +++++- testing/MCTXWeb/public_html/static/mctx.gui.js | 12 +++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/testing/MCTXWeb/public_html/index.html b/testing/MCTXWeb/public_html/index.html index 3d9d616..5b0ddff 100644 --- a/testing/MCTXWeb/public_html/index.html +++ b/testing/MCTXWeb/public_html/index.html @@ -21,6 +21,10 @@ return false; }); + $("#logout").click(function () { + $("#logout").logout(); + }); + $("#main_controls").submit(function () { //Validate! return false; @@ -52,7 +56,7 @@
- +
diff --git a/testing/MCTXWeb/public_html/static/mctx.gui.js b/testing/MCTXWeb/public_html/static/mctx.gui.js index fc50ed5..c57babc 100644 --- a/testing/MCTXWeb/public_html/static/mctx.gui.js +++ b/testing/MCTXWeb/public_html/static/mctx.gui.js @@ -3,7 +3,7 @@ */ mctx = {}; -mctx.location = location.protocol + "//" + location.host; +mctx.location = location.protocol + "//" + location.host + "/"; mctx.api = mctx.location + "/api/"; mctx.expected_api_version = 0; mctx.has_control = false; @@ -178,6 +178,16 @@ $.fn.login = function () { }); }; +$.fn.logout = function () { + $.ajax({ + url : mctx.api + "unbind" + }).always(function () { + //Note: this only clears the nameless cookie + document.cookie = ""; + window.location = mctx.location + "login.html"; + }); +} + $.fn.setErrorLog = function () { var url = mctx.api + "errorlog"; var outdiv = this; -- 2.20.1