From e62473b629b362808fe6dd3958389454ac854519 Mon Sep 17 00:00:00 2001
From: ulrich@undisclosed <ulrich@ulrich-vaio>
Date: Tue, 19 May 2020 13:12:08 +0000
Subject: [PATCH] In Arbeit: Piktogramme, Abmelden, Stile verfeinert

---
 web/profil2/app.js |   42 ++++++++++++++++++++++++++++++++----------
 1 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/web/profil2/app.js b/web/profil2/app.js
index be2c42b..b1b7b41 100644
--- a/web/profil2/app.js
+++ b/web/profil2/app.js
@@ -10,10 +10,9 @@
     self.get_user_data();
     
     var suedDiv = document.querySelector('.sued');
-    //if (suedDiv.classList.contains('sued-open')) {
-      suedDiv.classList.remove('sued-open');
-      suedDiv.style.height = '0';
-    //}
+    suedDiv.classList.remove('sued-open');
+    suedDiv.style.height = '0';
+    document.querySelector('.zurueck-btn').style.color = '#eee';
   };
   
   /*
@@ -25,14 +24,36 @@
       document.querySelector('.user-save-btn').addEventListener('click', self.kennwort_speichern);
     });
   };
-  
+
   this.kennwort_speichern = function() {
+    var userId = document.querySelector('#anmeldename').textContent;
+    var aktKw = document.querySelector('#kennwort').value;
+    var neuKw = document.querySelector('#kennwortNeu').value;
+    var wKw = document.querySelector('#kennwortw').value;
+    if(neuKw === wKw) {
+      var m = '?c=de.uhilger.um.api.Profil&m=setUserPw&p=' + userId + '&p=' + aktKw + '&p=' + neuKw;
+      var u = '../prf' + m;
+      self.http_get(u, function(antwort) {
+        self.meldung(antwort, 1500);
+      });
+    } else {
+      // Kennworte unterschiedlich
+      self.meldung('Kennworte stimmen nicht &uuml;berein', 1500);
+    }
+  };
+  
+  this.meldung = function(text, dauer) {
     var suedDiv = document.querySelector('.sued');
-    suedDiv.textContent = 'Kennwort speichern';
-    //if (!suedDiv.classList.contains('sued-open')) {
-      suedDiv.classList.add('sued-open');
-      suedDiv.style.height = '1.5em';
-    //}
+    suedDiv.textContent = text;
+    suedDiv.classList.add('sued-open');
+    suedDiv.style.height = '1.5em';
+    setTimeout(function () {
+      var suedDiv = document.querySelector('.sued');
+      if (suedDiv.classList.contains('sued-open')) {
+        suedDiv.classList.remove('sued-open');
+        suedDiv.style.height = '0';
+      }
+    }, 1500);    
   };
   
   this.get_user_data = function() {
@@ -65,6 +86,7 @@
     if(method === 'GET')  {
       xhr.send();
     } else if(method === 'POST' || method === 'PUT') {
+      xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
       xhr.send(data);
     }
   };

--
Gitblit v1.9.3