edit.js 3.2 KB

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