pages.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. App.Pages.init = function(){
  2. App.Ajax.request('MAIN.getInitial', {}, function(reply){
  3. App.Env.initialParams = reply.data;
  4. //App.Helpers.updateInitial();
  5. });
  6. App.Pages.prepareHTML();
  7. $('.section.active').removeClass('active');
  8. $('#'+App.Env.world).addClass('active');
  9. }
  10. App.Pages.prepareHTML = function()
  11. {
  12. if ('undefined' != typeof App.Pages[App.Env.world].prepareHTML) {
  13. App.Pages.prepareHTML();
  14. }
  15. else {
  16. App.Model[App.Env.world].loadList();
  17. }
  18. }
  19. App.Pages.DNS.showSubform = function(ref)
  20. {
  21. App.Helpers.showLoading();
  22. var data = ref.find('.source:first').val();
  23. App.Ajax.request('DNS.getListRecords', {
  24. spell: data
  25. }, function(reply) {
  26. var tpl = App.Templates.get('SUBFORM', 'dns');
  27. var tpl_records = App.HTML.Build.dns_records(reply.data);
  28. tpl.set(':SUBRECORDS', tpl_records);
  29. $(ref).find('.show-records').addClass('hidden');
  30. $(ref).after(tpl.finalize());
  31. App.Helpers.updateScreen();
  32. });
  33. }
  34. App.Pages.DNS.edit = function(elm) {
  35. var options = elm.find('.source').val();
  36. fb.warn(elm);
  37. fb.warn(options);
  38. var tpl = App.HTML.Build.dns_form(options);
  39. elm.replaceWith(tpl);
  40. }
  41. /*
  42. //
  43. // DNS
  44. App.Pages.DNS.saveForm = function(evt, params){
  45. var elm = $(evt.target);
  46. elm = elm.parents('.b-new-entry');
  47. if (elm.attr('id') == App.Constants.DNS_FORM_ID) {
  48. var values = App.Helpers.getFormValues(elm);
  49. if(App.Validate.dnsForm(values)) {
  50. App.Model.DNS.update(values, source);
  51. var tpl = App.HTML.Build.dns_entry(values);
  52. $('#' + App.Constants.DNS_FORM_ID).replaceWith(tpl);
  53. }
  54. }
  55. else {
  56. var source = $(elm).find('.source').val();
  57. var values = App.Helpers.getFormValues(elm);
  58. if(App.Validate.dnsForm(values)) {
  59. App.Model.DNS.update(values, source);
  60. var tpl = App.HTML.Build.dns_entry(values);
  61. elm.replaceWith(tpl);
  62. }
  63. }
  64. App.Helpers.updateScreen();
  65. }
  66. //
  67. // IP
  68. App.Pages.IP.prepareHTML = function(){
  69. App.Model.IP.loadList();
  70. }
  71. App.Pages.IP.saveForm = function(evt, params){
  72. var elm = $(evt.target);
  73. elm = elm.parents('.b-new-entry');
  74. if (elm.attr('id') == App.Constants.IP_FORM_ID) {
  75. var values = App.Helpers.getFormValues(elm);
  76. if(App.Validate.ipForm(values)) {
  77. App.Model.IP.update(values, source);
  78. var tpl = App.HTML.Build.ip_entry(values);
  79. $('#' + App.Constants.IP_FORM_ID).replaceWith(tpl);
  80. }
  81. }
  82. else {
  83. var source = $(elm).find('.source').val();
  84. var values = App.Helpers.getFormValues(elm);
  85. if(App.Validate.ipForm(values)) {
  86. App.Model.IP.update(values, source);
  87. var tpl = App.HTML.Build.ip_entry(values);
  88. elm.replaceWith(tpl);
  89. }
  90. }
  91. App.Helpers.updateScreen();
  92. }
  93. */
  94. /*
  95. App.Pages.IP.edit = function(elm) {
  96. var options = elm.find('.source').val();
  97. fb.warn(elm);
  98. fb.warn(options);
  99. var tpl = App.HTML.Build.ip_form(options);
  100. elm.replaceWith(tpl);
  101. }
  102. App.Pages.IP.ipNotSaved = function(reply) {
  103. return App.Helpers.alert(reply.message);
  104. }
  105. App.Pages.IP.remove = function(evt) {
  106. var confirmed = confirm('Are you sure?');
  107. if (!confirmed) {
  108. return;
  109. }
  110. var elm = $(evt.target);
  111. elm.parents('.ip-details-row');
  112. var values = elm.find('.source').val();
  113. App.Model.IP.remove(values, elm);
  114. }
  115. */