settings.php 2.03 KB
Newer Older
nextime's avatar
nextime committed
1 2 3 4 5 6 7 8 9 10 11
<?
@include_once("../includes/common.php");
if($GUISUBSECTION=="") {
?>
<script>

var updateUser = function(r) {
  $("#username").text(r.data.username);
  $("#email").val(r.data.email);
  $("#desktophome").val(r.data.desktop_homepath);
  $("#mobilehome").val(r.data.mobile_homepath);
12 13 14
  $("#lang").val(r.data.language);
  $("#webspeech").val(r.data.webspeech);
  $("#speechlang").val(r.data.speechlang);
nextime's avatar
nextime committed
15
  $("#gui_theme").val(r.data.gui_theme);
16 17
  $("#leftb").val(r.data.left_bar);
  $("#rightb").val(r.data.right_bar);
nextime's avatar
nextime committed
18 19 20 21
  if(r.data.tts==1)
    $('#tts-switch').bootstrapSwitch('setState', true); //$("#tts").attr('checked', true);
  else
    $('#tts-switch').bootstrapSwitch('setState', false); //$("#tts").attr('checked', false); 
22
  if(r.data.slide==1)
23
    $('#slide-switch').bootstrapSwitch('setState', true);
24
  else
25
    $('#slide-switch').bootstrapSwitch('setState', false);
26
  $("#userform").show();
nextime's avatar
nextime committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
};


$.get("/rest/v1.2/users/me/json", updateUser);

$("#userform").on("submit", function(event) {
   event.preventDefault();
   if($("#userform input[name=passwd]").val()!=$("#userform input[name=pwd2]").val())
   {
      popupFader('danger', 'ERROR:','Le password inserite non coincidono');
      playTTS('Errore, Le password inserite non coincidono');
   } else {
      $.ajax({url: "/rest/v1.2/users/me/json", type:"PUT", data: $(this).serialize(),
               success: function(res) {
                  popupFader('success', 'SUCCESS:','Utente aggiornato correttamente...');
nextime's avatar
nextime committed
42 43 44 45
                  var a = playTTS('Utente aggiornato correttamente');
                  a.addEventListener("ended", function(){
                     $.get("/rest/v1.2/users/refreshme/json", function(){location.reload();});
                  });
nextime's avatar
nextime committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59
               },
               error: function(res) {
                  msg=$.parseJSON(res.responseText).data;
                  popupFader('danger', 'ERROR:',msg);
                  playTTS('Errore, utente non aggiornato');
                  $.get("/rest/v1.2/users/me/json", updateUser);
               }
            });
   }
});
<?
}
?>
</script>