check_configure_kerio_buisness_mail.tpl 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <style>
  2. .has-error { background-color: #f003 !important; }
  3. .has-success { background-color: #0f03 !important; }
  4. </style>
  5. <script>
  6. function is_domain(str) {
  7. console.log(str);
  8. const regexp = /^[a-z0-9-]+\.[a-z][a-z]+$/;
  9. return regexp.test(str);
  10. }
  11. function checkInput (domain, pid) {
  12. var xhttp = new XMLHttpRequest();
  13. var success = false;
  14. xhttp.onreadystatechange = function() {
  15. if (this.readyState == 4 && this.status == 200) {
  16. if( this.responseText.trim() == 'yes') {
  17. console.log(this.responseText);
  18. $(customFields[0]).addClass('has-success');
  19. $(customFields[0]).removeClass('has-error');
  20. $("#hint").text('');
  21. if ($(checkBox[0]).hasClass('checked')) {
  22. $("#btnCompleteProductConfig").prop("disabled",false);
  23. } else {
  24. $("#btnCompleteProductConfig").prop("disabled",true);
  25. $("#hint").text('Bitte akzeptieren Sie die erweiterten Nutzungsbedingungen!');
  26. }
  27. } else if ( this.responseText.trim() == 'invalid') {
  28. console.log(this.responseText);
  29. $(customFields[0]).addClass('has-error');
  30. $(customFields[0]).removeClass('has-success');
  31. $("#btnCompleteProductConfig").prop("disabled",true);
  32. $("#hint").text('Ungültiger Domainname!');
  33. } else {
  34. console.log(this.responseText);
  35. $(customFields[0]).addClass('has-error');
  36. $(customFields[0]).removeClass('has-success');
  37. $("#hint").text('Domain ' + $(customFields[0]).val() + ' nicht verfügbar!');
  38. $("#btnCompleteProductConfig").prop("disabled",true);
  39. }
  40. }
  41. };
  42. xhttp.open("GET", "modules/servers/kerioEmail/kerioDomainAvailable.php?domain=" + domain + '&pid=' + pid, true);
  43. xhttp.send();
  44. };
  45. jQuery(document).ready(function(){
  46. customFields = $("*[id^='customfield']");
  47. checkBoxHelper = $("*[class^='iCheck-helper']");
  48. checkBox = $("*[id^='iCheck-customfield']")
  49. $("#btnCompleteProductConfig").prop("disabled",true);
  50. $("#hint").text('Bitte wählen Sie Ihre Maildomain und akzeptieren Sie die erweiterten Nutzungsbedingungen!');
  51. if(typeof domain !== 'undefined'){
  52. // console.log({$domain});
  53. // $(customFields[0]).val() = {$domain}; // domain
  54. }else{
  55. $(customFields[0]).val('') = "blubb.de"; // domain
  56. }
  57. $(checkBox[0]).removeClass('checked'); // checkbox
  58. $(customFields[0]).blur(function () {
  59. if (is_domain($(customFields[0]).val().trim())) {
  60. setTimeout(function () {
  61. checkInput( $(customFields[0]).val().trim(), {$productinfo['pid']});
  62. }, 1);
  63. } else {
  64. $(customFields[0]).addClass('has-error');
  65. $(customFields[0]).removeClass('has-success');
  66. $("#btnCompleteProductConfig").prop("disabled",true);
  67. $("#hint").text('Ungültiger Domainname!');
  68. }
  69. });
  70. $(customFields[0]).on('input', function () {
  71. if (is_domain($(customFields[0]).val().trim())) {
  72. setTimeout(function () {
  73. checkInput( $(customFields[0]).val().trim(), {$productinfo['pid']});
  74. }, 1);
  75. } else {
  76. $(customFields[0]).addClass('has-error');
  77. $(customFields[0]).removeClass('has-success');
  78. $("#btnCompleteProductConfig").prop("disabled",true);
  79. $("#hint").text('Ungültiger Domainname!');
  80. }
  81. });
  82. $(checkBoxHelper[0]).click(function () {
  83. if (is_domain($(customFields[0]).val().trim())) {
  84. setTimeout(function () {
  85. checkInput( $(customFields[0]).val().trim(), {$productinfo['pid']});
  86. }, 1);
  87. } else {
  88. $(customFields[0]).addClass('has-error');
  89. $(customFields[0]).removeClass('has-success');
  90. $("#btnCompleteProductConfig").prop("disabled",true);
  91. $("#hint").text('Ungültiger Domainname!');
  92. }
  93. });
  94. });
  95. </script>