| | |
| | | } |
| | | target.classList.add("nutzer-gewaehlt"); |
| | | }; |
| | | |
| | | this.nutzer_speichern = function() { |
| | | var user = self.nutzer_dialog_lesen(); |
| | | var kww = document.getElementById('nutzer-wkw').value; |
| | | if(user.pw !== kww) { |
| | | self.meldung_mit_timeout("Kennworte stimmen nicht ueberein.", 1500); |
| | | } else { |
| | | self.neuen_nutzer_speichern('p=' + self.serialisieren(user)); |
| | | } |
| | | }; |
| | | |
| | | this.nutzer_dialog_lesen = function() { |
| | | var id = document.getElementById('nutzer-id').value; |
| | | var vname = document.getElementById('nutzer-vorname').value; |
| | | var nname = document.getElementById('nutzer-name').value; |
| | | var email = document.getElementById('nutzer-email').value; |
| | | var kw = document.getElementById('nutzer-kw').value; |
| | | var user = new User(id, kw, vname, nname, email); |
| | | return user; |
| | | }; |
| | | |
| | | /* Funktionen aus App-Vorlage */ |
| | | |
| | |
| | | var dlg = document.querySelector(".dialog"); |
| | | dlg.style.flexBasis = '0em'; |
| | | self.seitenleiste_umschalten(); |
| | | self.um_get_login(); |
| | | self.um_get_user_list(); |
| | | self.get_login(); |
| | | self.get_user_list(); |
| | | self.loc = window.location.protocol + '//' + window.location.host; |
| | | }; |
| | | |
| | |
| | | this.meldung_mit_timeout = function (meldung, timeout) { |
| | | var s = document.querySelector('.sued'); |
| | | s.textContent = meldung; |
| | | if (!s.classList.contains('sued-open')) { |
| | | s.classList.add('sued-open'); |
| | | s.style.height = '1.5em'; |
| | | } |
| | | setTimeout(function () { |
| | | s.textContent = 'Bereit.'; |
| | | setTimeout(function () { |
| | |
| | | setTimeout(function () { |
| | | dlg.innerHTML = html; |
| | | document.querySelector('.close-btn').addEventListener('click', self.dialog_schliessen); |
| | | var btn = document.getElementById('nutzer-speichern-btn'); |
| | | if(btn !== null) { |
| | | btn.addEventListener('click', self.nutzer_speichern); |
| | | } |
| | | }, 300); |
| | | }); |
| | | }; |
| | |
| | | |
| | | /* API functions */ |
| | | |
| | | this.um_get_user_list = function() { |
| | | this.get_user_list = function() { |
| | | //var m = 'getUserNameList'; |
| | | var m = 'getUserNameList'; |
| | | var u = '../svc/' + m; |
| | | self.um_get(u, "json", function (antwort) { |
| | | self.http_get(u, function (antwort) { |
| | | self.vorlagen.html_erzeugen( |
| | | 'data/tpl/inhalt.tpl', |
| | | JSON.parse(antwort), |
| | |
| | | }); |
| | | }); |
| | | }; |
| | | |
| | | this.neuen_nutzer_speichern = function(u) { |
| | | var url = '../svc/createUser'; |
| | | self.http_post(url, u, function (antwort) { |
| | | self.get_user_list(); |
| | | self.dialog_schliessen(); |
| | | }); |
| | | }; |
| | | |
| | | /* -------- An- und Abmelden ------------- */ |
| | | |
| | | this.um_get_login = function() { |
| | | this.get_login = function() { |
| | | var m = '?c=de.uhilger.um.pub.SessionManager&m=getSessionUser'; |
| | | var u = '../pub' + m; |
| | | self.um_get(u, "text", function (resp) { |
| | | self.http_get(u, function (resp) { |
| | | self.userid = resp; |
| | | self.login_zeigen(); |
| | | //document.querySelector("#userMenu").textContent = resp; |
| | |
| | | this.um_logout = function() { |
| | | var m = '?c=de.uhilger.um.pub.SessionManager&m=expireSession'; |
| | | var u = '../pub' + m; |
| | | self.um_get(u, "text", function (resp) { |
| | | self.http_get(u, function (resp) { |
| | | //$('#userMenu').text('nicht angemeldet'); |
| | | window.location.href = '../logout.html'; |
| | | }); |
| | |
| | | |
| | | /* -------- ajax helper functions ----------- */ |
| | | |
| | | this.um_get = function (u, dtype, scallback) { |
| | | this.http_get = function (u, scallback) { |
| | | var xmlhttp = new XMLHttpRequest(); |
| | | var url = u; |
| | | xmlhttp.onreadystatechange = function() { |
| | | if (this.readyState == 4 && this.status == 200) { |
| | | if (this.readyState === 4 && this.status === 200) { |
| | | scallback(this.responseText); |
| | | } |
| | | }; |
| | |
| | | xmlhttp.send(); |
| | | }; |
| | | |
| | | this.http_post = function (url, data, callback) { |
| | | var xhr = new XMLHttpRequest(); |
| | | xhr.onreadystatechange = function() { |
| | | if (this.readyState === 4 && this.status === 200) { |
| | | callback(this.responseText); |
| | | } |
| | | }; |
| | | xhr.open("POST", url, true); |
| | | xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); |
| | | xhr.send(data); |
| | | }; |
| | | |
| | | /* ----- Hilfsfunktionen ----- */ |
| | | |
| | | this.serialisieren = function(obj) { |