personal.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /**
  2. * Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
  3. * This file is licensed under the Affero General Public License version 3 or later.
  4. * See the COPYING-README file.
  5. */
  6. $(document).ready(function(){
  7. $("#passwordbutton").click( function(){
  8. if ($('#pass1').val() != '' && $('#pass2').val() != '') {
  9. // Serialize the data
  10. var post = $( "#passwordform" ).serialize();
  11. $('#passwordchanged').hide();
  12. $('#passworderror').hide();
  13. // Ajax foo
  14. $.post( 'ajax/changepassword.php', post, function(data){
  15. if( data.status == "success" ){
  16. $('#pass1').val('');
  17. $('#pass2').val('');
  18. $('#passwordchanged').show();
  19. }
  20. else{
  21. $('#passworderror').html( data.data.message );
  22. $('#passworderror').show();
  23. }
  24. });
  25. return false;
  26. } else {
  27. $('#passwordchanged').hide();
  28. $('#passworderror').show();
  29. return false;
  30. }
  31. });
  32. $("#displaynamebutton").click( function(){
  33. if ($('#displayName').val() != '' ) {
  34. // Serialize the data
  35. var post = $( "#displaynameform" ).serialize();
  36. $('#displaynamechanged').hide();
  37. $('#displaynemerror').hide();
  38. // Ajax foo
  39. $.post( 'ajax/changedisplayname.php', post, function(data){
  40. if( data.status == "success" ){
  41. $('#displaynamechanged').show();
  42. }
  43. else{
  44. $('#newdisplayname').val(data.data.displayName)
  45. $('#displaynameerror').html( data.data.message );
  46. $('#displaynameerror').show();
  47. }
  48. });
  49. return false;
  50. } else {
  51. $('#displayName').val($('#oldDisplayName').val());
  52. $('#displaynamechanged').hide();
  53. $('#displaynameerror').show();
  54. return false;
  55. }
  56. });
  57. $('#lostpassword #email').blur(function(event){
  58. if ($(this).val() == this.defaultValue){
  59. return;
  60. }
  61. event.preventDefault();
  62. this.defaultValue = $(this).val();
  63. OC.msg.startSaving('#lostpassword .msg');
  64. var post = $( "#lostpassword" ).serialize();
  65. $.post( 'ajax/lostpassword.php', post, function(data){
  66. OC.msg.finishedSaving('#lostpassword .msg', data);
  67. });
  68. });
  69. $("#languageinput").chosen();
  70. $("#languageinput").change( function(){
  71. // Serialize the data
  72. var post = $( "#languageinput" ).serialize();
  73. // Ajax foo
  74. $.post( 'ajax/setlanguage.php', post, function(data){
  75. if( data.status == "success" ){
  76. location.reload();
  77. }
  78. else{
  79. $('#passworderror').html( data.data.message );
  80. }
  81. });
  82. return false;
  83. });
  84. } );
  85. OC.msg={
  86. startSaving:function(selector){
  87. $(selector)
  88. .html( t('settings', 'Saving...') )
  89. .removeClass('success')
  90. .removeClass('error')
  91. .stop(true, true)
  92. .show();
  93. },
  94. finishedSaving:function(selector, data){
  95. if( data.status == "success" ){
  96. $(selector).html( data.data.message )
  97. .addClass('success')
  98. .stop(true, true)
  99. .delay(3000)
  100. .fadeOut(600);
  101. }else{
  102. $(selector).html( data.data.message ).addClass('error');
  103. }
  104. }
  105. };