edit.js 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. $(document).ready(function() {
  2. if ($("#goto_null").is(":checked")) {
  3. $('#textarea_alias_goto').prop('disabled', true);
  4. }
  5. $("#goto_null").click(function( event ) {
  6. if ($("#goto_null").is(":checked")) {
  7. $('#textarea_alias_goto').prop('disabled', true);
  8. }
  9. else {
  10. $("#textarea_alias_goto").removeAttr('disabled');
  11. }
  12. });
  13. });
  14. jQuery(function($){
  15. // http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
  16. function validateEmail(email) {
  17. var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  18. return re.test(email);
  19. }
  20. function draw_wl_policy_domain_table() {
  21. ft_wl_policy_mailbox_table = FooTable.init('#wl_policy_domain_table', {
  22. "columns": [
  23. {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"},
  24. {"name":"prefid","style":{"maxWidth":"40px","width":"40px"},"title":"ID","filterable": false,"sortable": false},
  25. {"sorted": true,"name":"value","title":lang.spamfilter_table_rule},
  26. {"name":"object","title":"Scope"}
  27. ],
  28. "empty": lang.empty,
  29. "rows": $.ajax({
  30. dataType: 'json',
  31. url: '/api/v1/get/policy_wl_domain/' + table_for_domain,
  32. jsonp: false,
  33. error: function () {
  34. console.log('Cannot draw mailbox policy wl table');
  35. },
  36. success: function (data) {
  37. $.each(data, function (i, item) {
  38. if (!validateEmail(item.object)) {
  39. item.chkbox = '<input type="checkbox" data-id="policy_wl_domain" name="multi_select" value="' + item.prefid + '" />';
  40. }
  41. else {
  42. item.chkbox = '<input type="checkbox" disabled title="' + lang.spamfilter_table_domain_policy + '" />';
  43. }
  44. });
  45. }
  46. }),
  47. "paging": {
  48. "enabled": true,
  49. "limit": 5,
  50. "size": pagination_size
  51. },
  52. "sorting": {
  53. "enabled": true
  54. }
  55. });
  56. }
  57. function draw_bl_policy_domain_table() {
  58. ft_bl_policy_mailbox_table = FooTable.init('#bl_policy_domain_table', {
  59. "columns": [
  60. {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"},
  61. {"name":"prefid","style":{"maxWidth":"40px","width":"40px"},"title":"ID","filterable": false,"sortable": false},
  62. {"sorted": true,"name":"value","title":lang.spamfilter_table_rule},
  63. {"name":"object","title":"Scope"}
  64. ],
  65. "empty": lang.empty,
  66. "rows": $.ajax({
  67. dataType: 'json',
  68. url: '/api/v1/get/policy_bl_domain/' + table_for_domain,
  69. jsonp: false,
  70. error: function () {
  71. console.log('Cannot draw mailbox policy bl table');
  72. },
  73. success: function (data) {
  74. $.each(data, function (i, item) {
  75. if (!validateEmail(item.object)) {
  76. item.chkbox = '<input type="checkbox" data-id="policy_bl_domain" name="multi_select" value="' + item.prefid + '" />';
  77. }
  78. else {
  79. item.chkbox = '<input type="checkbox" disabled tooltip="' + lang.spamfilter_table_domain_policy + '" />';
  80. }
  81. });
  82. }
  83. }),
  84. "paging": {
  85. "enabled": true,
  86. "limit": 5,
  87. "size": pagination_size
  88. },
  89. "sorting": {
  90. "enabled": true
  91. }
  92. });
  93. }
  94. draw_wl_policy_domain_table();
  95. draw_bl_policy_domain_table();
  96. });