function um_prf_init() { $('#meldung-box').hide(); $('#anmeldename').hide(); $('.user-save-btn').click(um_prf_user_save); $('#logout').click(um_prf_apicall_logout); um_prf_apicall_get_login(); } function um_prf_user_form_fuellen(resp) { $('#anmeldename').text(resp.UserData.id); $('#vorname').val(resp.UserData.firstName); $('#nachname').val(resp.UserData.lastName); } function um_prf_user_save() { var uid = $('#anmeldename').text(); var aktKennwort = $('#kennwort').val(); var neuKennwort = $('#kennwortNeu').val(); var wKennwort = $('#kennwortw').val(); if(neuKennwort === '' || wKennwort === '') { um_prf_meldung_anzeigen('Das neue Kennwort darf nicht leer sein.'); } else if(neuKennwort !== wKennwort) { um_prf_meldung_anzeigen('Kennworte stimmen nicht überein'); } else if(aktKennwort === neuKennwort) { um_prf_meldung_anzeigen('Altes und neues Kennwort müssen sich unterscheiden'); } else { um_prf_apicall_kennwort_aendern(uid, aktKennwort, neuKennwort); } } function um_prf_meldung_anzeigen(msg) { $('#meldung-box').show(); $("#mldg-x").on('click', function() { $("#mldg-x").attr('onclick','').unbind('click'); $('.meldung').slideUp('fast', function() { $('#meldung-box').hide(); }); }); $('.meldung').empty(); $('.meldung').text(msg); $('.meldung').slideDown('fast', function(){ // }); } function um_prf_apicall_get_login() { var m = '?c=de.uhilger.um.pub.SessionManager&m=getSessionUser'; var u = '../pub' + m; $.ajax({ url: u, type: "GET", dataType : "json", success: function( resp ) { $('#userMenu').text(resp.UserData.firstName); um_prf_user_form_fuellen(resp); }, error: function( xhr, status, errorThrown ) { $('#fehler').html("Error: " + errorThrown + " Status: " + status); }, complete: function( xhr, status ) { //alert( "The request is complete!" ); } }); } function um_prf_apicall_get_user() { var m = '?c=de.uhilger.um.api.Profil&m=getUser'; var u = '../prf' + m; $.ajax({ url: u, type: "GET", dataType : "json", success: function( resp ) { um_prf_user_form_fuellen(resp); }, error: function( xhr, status, errorThrown ) { $('#fehler').html("Error: " + errorThrown + " Status: " + status); }, complete: function( xhr, status ) { //alert( "The request is complete!" ); } }); } function um_prf_apicall_kennwort_aendern(userId, aktKw, neuKw) { var m = '?c=de.uhilger.um.api.Profil&m=setUserPw&p=' + userId + '&p=' + aktKw + '&p=' + neuKw; var u = '../prf' + m; $.ajax({ url: u, type: "GET", dataType : "text", success: function( resp ) { um_prf_meldung_anzeigen(resp); }, error: function( xhr, status, errorThrown ) { $('#fehler').html("Error: " + errorThrown + " Status: " + status); }, complete: function( xhr, status ) { //alert( "The request is complete!" ); } }); } function um_prf_apicall_logout() { var m = '?c=de.uhilger.um.pub.SessionManager&m=expireSession'; var u = '../pub' + m; $.ajax({ url: u, type: "GET", dataType : "text", success: function( resp ) { $('#userMenu').text('nicht angemeldet'); window.location.href = '../logout.html'; }, error: function( xhr, status, errorThrown ) { $('#fehler').html("Error: " + errorThrown + " Status: " + status); }, complete: function( xhr, status ) { //alert( "The request is complete!" ); } }); }