edit.js 3.7 KB

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