check_configure_nextcloud.tpl 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <script>
  2. function checkUserName ( username, pid) {
  3. var nameRegex = /^[a-zA-Z0-9\-]+$/;
  4. var validUsername = username.match(nameRegex);
  5. if(validUsername == null) {
  6. console.log("Invalid Username: "+username);
  7. $(customFields[4]).prop("disabled",true);
  8. $(customFields[5]).prop("disabled",true);
  9. $(customFields[2]).addClass('has-error');
  10. $(customFields[2]).css('background-color', '#f003');;
  11. $("#hintHead").text('Der Benutzername darf nur Klein- bzw. Grossbuchstaben (ohne Umlaute), Zahlen und den Bindestrich enthalten.');
  12. $("#hintLength").text('');
  13. $("#hintNumeric").text('');
  14. $("#hintSymbols").text('');
  15. $("#hintUpperLower").text('');
  16. return;
  17. }
  18. var xhttp = new XMLHttpRequest();
  19. var success = false;
  20. console.log("UserName: " + username);
  21. xhttp.onreadystatechange = function() {
  22. if (this.readyState == 4 && this.status == 200) {
  23. if( this.responseText.trim() == 'yes') {
  24. console.log("Response: " + this.responseText);
  25. $(customFields[4]).prop("disabled",false);
  26. $(customFields[2]).addClass('has-success');
  27. $(customFields[2]).css('background-color', '#0f03');;
  28. $("#hintHead").text('');
  29. $("#hintLength").text('');
  30. $("#hintNumeric").text('');
  31. $("#hintSymbols").text('');
  32. $("#hintUpperLower").text('');
  33. } else if (this.responseText.trim() == 'no') {
  34. console.log("Response: " + this.responseText);
  35. $(customFields[4]).prop("disabled",true);
  36. $(customFields[5]).prop("disabled",true);
  37. $(customFields[2]).addClass('has-error');
  38. $(customFields[2]).css('background-color', '#f003');;
  39. $("#hintHead").text('Der Benutzername ' + $(customFields[2]).val() + ' ist nicht verfügbar!');
  40. $("#hintLength").text('');
  41. $("#hintNumeric").text('');
  42. $("#hintSymbols").text('');
  43. $("#hintUpperLower").text('');
  44. } else if (this.responseText.trim() == 'invalid') {
  45. console.log("Response: " + this.responseText);
  46. $(customFields[4]).prop("disabled",true);
  47. $(customFields[5]).prop("disabled",true);
  48. $(customFields[2]).addClass('has-error');
  49. $(customFields[2]).css('background-color', '#f003');;
  50. $("#hintHead").text('Der Benutzername darf nur Klein- bzw. Grossbuchstaben (ohne Umlaute), Zahlen und den Bindestrich enthalten.');
  51. $("#hintLength").text('');
  52. $("#hintNumeric").text('');
  53. $("#hintSymbols").text('');
  54. $("#hintUpperLower").text('');
  55. } else {
  56. console.log("Response: " + this.responseText);
  57. $(customFields[4]).prop("disabled",true);
  58. $(customFields[5]).prop("disabled",true);
  59. $(customFields[2]).addClass('has-error');
  60. $(customFields[2]).css('background-color', '#f003');;
  61. $("#hintHead").text('Bei der Abfrage ist ein Fehler aufgetreten, es kann nicht fortgefahren werden. Bitte kontaktieren Sie den Support');
  62. $("#hintLength").text('');
  63. $("#hintNumeric").text('');
  64. $("#hintSymbols").text('');
  65. $("#hintUpperLower").text('');
  66. }
  67. }
  68. };
  69. xhttp.open("GET", "modules/servers/nextcloud/nextCloudUserAvailable.php?name=" + username + '&pid=' + pid, true);
  70. xhttp.send();
  71. };
  72. {literal}
  73. function checkEMail ( email, pid) {
  74. var mailRegex = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
  75. var validEMail = email.match(mailRegex);
  76. if(validEMail == null) {
  77. console.log("Invalid EMail: "+email);
  78. $(customFields[4]).prop("disabled",true);
  79. $(customFields[5]).prop("disabled",true);
  80. $(customFields[3]).addClass('has-error');
  81. $(customFields[3]).css('background-color', '#f003');;
  82. $("#hintHead").text('Bitte eine gültige E-Mail-Adresse angeben.');
  83. $("#hintLength").text('');
  84. $("#hintNumeric").text('');
  85. $("#hintSymbols").text('');
  86. $("#hintUpperLower").text('');
  87. return;
  88. }
  89. var xhttp = new XMLHttpRequest();
  90. var success = false;
  91. console.log("E-Mail: " + email);
  92. xhttp.open("GET", "modules/servers/nextcloud/nextCloudEMailAvailable.php?email=" + email + '&pid=' + pid, false);
  93. xhttp.send();
  94. console.log("Ready State: " + xhttp.readyState);
  95. console.log("Status: " + xhttp.status);
  96. if (xhttp.readyState == 4 && xhttp.status == 200) {
  97. if( xhttp.responseText.trim() == 'yes') {
  98. $(customFields[4]).prop("disabled",false);
  99. $(customFields[5]).prop("disabled",true);
  100. $(customFields[3]).addClass('has-success');
  101. $(customFields[3]).css('background-color', '#0f03');;
  102. $("#hintHead").text('');
  103. $("#hintLength").text('');
  104. $("#hintNumeric").text('');
  105. $("#hintSymbols").text('');
  106. $("#hintUpperLower").text('');
  107. } else if (xhttp.responseText.trim() == 'no') {
  108. console.log("Response: " + xhttp.responseText);
  109. $(customFields[4]).prop("disabled",true);
  110. $(customFields[5]).prop("disabled",true);
  111. $(customFields[3]).addClass('has-error');
  112. $(customFields[3]).css('background-color', '#f003');;
  113. $("#hintHead").text('E-Mail ' + $(customFields[3]).val() + ' nicht verfügbar!');
  114. $("#hintLength").text('');
  115. $("#hintNumeric").text('');
  116. $("#hintSymbols").text('');
  117. $("#hintUpperLower").text('');
  118. } else if (xhttp.responseText.trim() == 'invalid') {
  119. console.log("Response: " + xhttp.responseText);
  120. $(customFields[4]).prop("disabled",true);
  121. $(customFields[5]).prop("disabled",true);
  122. $(customFields[3]).addClass('has-error');
  123. $(customFields[3]).css('background-color', '#f003');;
  124. $("#hintHead").text('Die E-Mail Adresse ist ungültig.');
  125. $("#hintLength").text('');
  126. $("#hintNumeric").text('');
  127. $("#hintSymbols").text('');
  128. $("#hintUpperLower").text('');
  129. } else {
  130. console.log("Response: " + xhttp.responseText);
  131. $(customFields[4]).prop("disabled",true);
  132. $(customFields[5]).prop("disabled",true);
  133. $(customFields[3]).addClass('has-error');
  134. $(customFields[3]).css('background-color', '#f003');;
  135. $("#hintHead").text('Bei der Abfrage ist ein Fehler aufgetreten, es kann nicht fortgefahren werden. Bitte kontaktieren Sie den Support');
  136. $("#hintLength").text('');
  137. $("#hintNumeric").text('');
  138. $("#hintSymbols").text('');
  139. $("#hintUpperLower").text('');
  140. }
  141. }
  142. };
  143. {/literal}
  144. jQuery(document).ready(function(){
  145. customFields = $("*[id^='customfield']");
  146. $("#btnCompleteProductConfig").prop("disabled",true);
  147. $(customFields[4]).val('');
  148. $(customFields[5]).val('');
  149. if ($(customFields[2]).val().length > 0) {
  150. checkUserName( $(customFields[2]).val(), {$productinfo['pid']});
  151. }
  152. $(customFields[4]).prop("disabled",true);
  153. $(customFields[5]).prop("disabled",true);
  154. $(customFields[2]).blur(function () {
  155. checkUserName( $(customFields[2]).val(), {$productinfo['pid']});
  156. });
  157. $(customFields[3]).blur(function () {
  158. checkEMail( $(customFields[3]).val(), {$productinfo['pid']});
  159. });
  160. $(customFields[4]).focus (function () {
  161. $("#hintHead").text('Tipps für ein gutes Passwort');
  162. $("#hintLength").text('Benutzen Sie mindestens 10 Zeichen');
  163. $("#hintNumeric").text('Benutzen Sie mindestens eine Zahl');
  164. $("#hintSymbols").text('Benutzen Sie auch mindestens eines der folgenden Symbole (# $ ! % + - etc...)');
  165. $("#hintUpperLower").text('Benutzen Sie Groß- und Kleinschreibung');
  166. });
  167. $(customFields[4]).keyup(function () {
  168. var pwlengthOK = false;
  169. var numericOK = false;
  170. var symbolsOK = false;
  171. var upperOK = false;
  172. var pw = $(customFields[4]).val();
  173. var pwlength = (pw.length);
  174. if (pwlength > 9) {
  175. pwlengthOK = true;
  176. $("#hintLength").text('');
  177. } else {
  178. pwlengthOK = false;
  179. $("#hintLength").text('Benutzen Sie mindestens 10 Zeichen');
  180. }
  181. var numeric = pw.replace(/[0-9]/g, "");
  182. var numnumeric = (pw.length - numeric.length);
  183. if (numnumeric > 0) {
  184. numericOK = true;
  185. $("#hintNumeric").text('');
  186. } else {
  187. numericOK = false;
  188. $("#hintNumeric").text('Benutzen Sie mindestens eine Zahl');
  189. }
  190. var symbols = pw.replace(/\W/g, "");
  191. var numsymbols = (pw.length - symbols.length);
  192. if (numsymbols > 0) {
  193. symbolsOK = true;
  194. $("#hintSymbols").text('');
  195. } else {
  196. symbolsOK = false;
  197. $("#hintSymbols").text('Benutzen Sie auch mindestens ein Symbol oder Sonderzeichen (# $ ! % & + - etc...)');
  198. }
  199. var upper = pw.replace(/[A-Z]/g, "");
  200. var numupper = (pw.length - upper.length);
  201. var lower = pw.replace(/[a-z]/g, "");
  202. var numlower = (pw.length - lower.length);
  203. if ((numupper > 0) && (numlower > 0)) {
  204. upperlowerOK = true;
  205. $("#hintUpperLower").text('');
  206. } else {
  207. upperlowerOK = false;
  208. $("#hintUpperLower").text('Benutzen Sie Groß- und Kleinschreibung');
  209. }
  210. $(customFields[4]).removeClass('has-error has-warning has-success');
  211. if (pwlengthOK && numericOK && symbolsOK && upperlowerOK) {
  212. $(customFields[5]).prop("disabled",false);
  213. $(customFields[4]).addClass('has-success');
  214. $(customFields[4]).css('background-color', '#0f03');;
  215. $("#hintHead").text('');
  216. } else {
  217. $(customFields[5]).prop("disabled",true);
  218. $(customFields[4]).addClass('has-error');
  219. $(customFields[4]).css('background-color', '#f003');;
  220. $("#hintHead").text('Tipps für ein gutes Passwort');
  221. }
  222. });
  223. $(customFields[5]).keyup(function () {
  224. if ($(customFields[5]).val() == $(customFields[4]).val()) {
  225. $("#btnCompleteProductConfig").prop("disabled",false);
  226. $(customFields[5]).addClass('has-success');
  227. $(customFields[5]).css('background-color', '#0f03');;
  228. $("#hintHead").text('');
  229. } else {
  230. $("#btnCompleteProductConfig").prop("disabled",true);
  231. $(customFields[5]).addClass('has-error');
  232. $(customFields[5]).css('background-color', '#f003');;
  233. $("#hintHead").text('Passworte stimmen nicht überein!');
  234. }
  235. });
  236. });
  237. </script>