ulrich
2020-05-18 a0da3240882184b461d70c519cc8ec0469be9367
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
 
 
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!" );
    }
  });      
}