index.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="apple-mobile-web-app-capable" content="yes" />
  5. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
  6. <meta charset="UTF-8">
  7. <meta name="theme-color" content="#4b75ff">
  8. <link rel="stylesheet" href="../script/semantic/semantic.min.css">
  9. <script src="../script/jquery.min.js"></script>
  10. <script src="../script/ao_module.js"></script>
  11. <script src="../script/semantic/semantic.min.js"></script>
  12. <title>ArSamba Settings</title>
  13. <style>
  14. body{
  15. background-color:white;
  16. }
  17. .success{
  18. color: #20c942;
  19. }
  20. .failed{
  21. color: #eb4034;
  22. }
  23. </style>
  24. </head>
  25. <body>
  26. <br>
  27. <div class="ui text container">
  28. <div class="ui header">
  29. <i class="windows icon"></i>
  30. <div class="content">
  31. Samba Settings
  32. <div class="sub header">for arozos systems</div>
  33. </div>
  34. </div>
  35. <p>Account Status: <span id="acstatus" class="failed">Disabled</span></p>
  36. <div id="enableAccount">
  37. <h3>Enable My Samba Account</h3>
  38. <form class="ui form" onsubmit="createAccount(event);">
  39. <div class="fluid field">
  40. <label>Username (Read Only)</label>
  41. <input type="text" id="username" readonly="true">
  42. </div>
  43. <div class="field">
  44. <label>Password</label>
  45. <input type="password" id="pw">
  46. </div>
  47. <div class="field">
  48. <label>Confirm Password</label>
  49. <input type="password" id="rpw">
  50. </div>
  51. <button class="ui green button" type="submit">Create</button>
  52. </form>
  53. </div>
  54. <div id="disableAccount" style="display:none;">
  55. <h3>Disable My Samba Account</h3>
  56. <p>This operation will remove your samba user account from the system</p>
  57. <button class="ui red button" onclick="removeUser(event)">Disable</button>
  58. </div>
  59. <br><br>
  60. <script>
  61. //Do not allow window resize
  62. ao_module_setFixedWindowSize();
  63. //Get username from system
  64. $.get("../system/users/userinfo", function(data){
  65. var username = data.Username;
  66. $("#username").val(username);
  67. //Get the account status
  68. $.get("./getStatus?username=" + username, function(data){
  69. if (data == true){
  70. $("#acstatus").text("Enabled");
  71. $("#acstatus").attr("class","success");
  72. $("#enableAccount").hide();
  73. $("#disableAccount").show();
  74. } else{
  75. $("#acstatus").text("Disabled");
  76. $("#acstatus").attr("class","failed");
  77. $("#enableAccount").show();
  78. $("#disableAccount").hide();
  79. }
  80. });
  81. });
  82. function removeUser(e){
  83. //Process the user creation process
  84. $.get("../system/users/userinfo", function(data){
  85. //Get the username
  86. var username = data.Username;
  87. $.ajax({
  88. url: "./remove",
  89. method: "POST",
  90. data: {username: username},
  91. success: function(data){
  92. //Creation succeed. Reload this page
  93. window.location.reload();
  94. }
  95. });
  96. });
  97. }
  98. function createAccount(e){
  99. e.preventDefault();
  100. //Get the userinfo again in case the user has changed name during the setting period
  101. $.get("../system/users/userinfo", function(data){
  102. //Get the username
  103. var username = data.Username;
  104. //Check if the password match
  105. var pw = $("#pw").val();
  106. var rpw = $("#rpw").val();
  107. if (pw != rpw){
  108. //Password not match
  109. $("#rpw").parent().addClass("error");
  110. return
  111. }else{
  112. $("#rpw").parent().removeClass("error");
  113. }
  114. //Process the user creation process
  115. $.ajax({
  116. url: "./create",
  117. method: "POST",
  118. data: {username: username, password: pw},
  119. success: function(data){
  120. //Creation succeed. Reload this page
  121. window.location.reload();
  122. }
  123. });
  124. });
  125. }
  126. </script>
  127. </body>
  128. </html>