From b7475d69c0d52f1639a13fae0afc617767852173 Mon Sep 17 00:00:00 2001
From: ulrich <not disclosed>
Date: Sun, 19 Feb 2017 10:19:09 +0000
Subject: [PATCH] Abmelden eingeabaut

---
 web/ui/ui.js |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/web/ui/ui.js b/web/ui/ui.js
index fbd30d5..6d50cfd 100644
--- a/web/ui/ui.js
+++ b/web/ui/ui.js
@@ -8,7 +8,8 @@
   $('#closeFile').on('click', fm_menu_datei_schliessen);
   $('#myModal').on('hidden.bs.modal', function (e) {
     $('#modal_ok').attr('onclick','').unbind('click');
-  })
+  });
+  $('#logout').click(fm_logout);  
   fm_get_login();
 }
 
@@ -26,10 +27,12 @@
   $('#dateiansicht').show();  
 }
 
+/* ----- API Calls ------------- */
+
 function fm_get_login() {
   var m = '?c=de.uhilger.um.pub.SessionManager&m=getSessionUser';
   var u = '../../um/pub' + m;
-  fm_get(u, function(resp) {
+  fm_get(u, "json", function(resp) {
     $('#userMenu').text(resp.UserData.firstName);
   });  
 }
@@ -65,6 +68,17 @@
   */
 }
 
+function fm_logout() {
+  var m = '?c=de.uhilger.filecms.pub.SessionManager&m=expireSession';
+  var u = '../pub' + m;
+  
+  fm_get(u, "text", function(resp) {
+    $('#userMenu').text('nicht angemeldet');
+    window.location.href = '../logout.html';
+  });
+}
+
+
 /* ---- codemirror editor handling -------- */
 
 function fm_code_edit(content) {
@@ -92,11 +106,11 @@
 
 /* -------- helper functions ----------- */
 
-function fm_get(u, scallback) {
+function fm_get(u, dtype, scallback) {
   $.ajax({
     url: u,
     type: "GET",
-    dataType: "json",
+    dataType: dtype,
     success: scallback,
     error: function (xhr, status, errorThrown) {
       alert("Error: " + errorThrown + " Status: " + status + " URL: " + u);

--
Gitblit v1.9.3