view.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. App.View.popup = function(content)
  2. {
  3. var tpl = App.Templates.get('popup', 'general');
  4. if ('undefined' != typeof App.Templates.html.popup[content]) {
  5. var content = App.Templates.get(content, 'popup').finalize();
  6. }
  7. tpl.set(':content', content);
  8. $('#popup-bg, #popup').remove();
  9. $(document.body).append(tpl.finalize());
  10. }
  11. App.View.closePopup = function()
  12. {
  13. $('.black_overlay').remove();
  14. $('.popup_content').remove();
  15. }
  16. App.View.updateInitialInfo = function(key, object)
  17. {
  18. var expr = '.'+key;
  19. var object = parseInt(object, 10);
  20. var html = object + ' ' + App.Messages.get(key, (object > 1));
  21. $(expr).html(html);
  22. }
  23. App.View.listItems = function(reply){
  24. var acc = [];
  25. var build_method = App.Env.getWorldName() + '_entry';
  26. var data = reply.data;
  27. // TODO: fix it data.data
  28. $.each(data, function(key)
  29. {
  30. var o = data[key];
  31. fb.warn(key);
  32. acc[acc.length++] = App.HTML.Build[build_method](o, key);
  33. });
  34. var html = acc.done().wrapperize('ENTRIES_WRAPPER', App.Env.getWorldName());
  35. App.Ref.CONTENT.html(html);
  36. App.Helpers.updateScreen();
  37. }
  38. /*App.View.start = function(){
  39. };
  40. App.View.showDatabases = function(databases){
  41. var tpl = App.HTML.makeDatabases(databases);
  42. $('#navigation').html(tpl.wrapperize('database_wrap', 'database'));
  43. }
  44. App.View.openDatabase = function(data, ref, db_name){
  45. var tpl = App.HTML.makeDbTableList(data);
  46. $('.databases .tables').remove();
  47. $('.databases .active').removeClass('active');
  48. $(ref).after(tpl.wrapperize('database_table_wrap', 'database'));
  49. $(ref).attr('className', 'active do.closeDatabase('+db_name+')"');
  50. }
  51. App.View.openTable = function(data, ref, table_name){
  52. var tpl = App.HTML.makeDbFieldsList(data);
  53. $(ref).next('.fields').remove();
  54. $(ref).after(tpl.wrapperize('database_field_wrap', 'database'));
  55. $(ref).attr('className', 'active do.closeTable('+table_name+')"');
  56. App.Helpers.updateScreen();
  57. }
  58. App.View.resultReturned = function(reply){
  59. if(reply.result){
  60. $('#results').text(reply.data);
  61. }else{
  62. $('#results').text(reply.message);
  63. }
  64. }
  65. App.View.Pages.IP.list = function(reply){
  66. var acc = [];
  67. $(reply.data).each(function(i, o){
  68. acc[acc.length++] = App.HTML.Build.ip_entry(o);
  69. });
  70. var html = acc.done().wrapperize('ENTRIES_WRAPPER', 'ip');
  71. App.Ref.CONTENT.html(html);
  72. App.Helpers.updateScreen();
  73. }
  74. App.View.Pages.DNS.list = function(reply){
  75. var acc = [];
  76. $(reply.data).each(function(i, o){
  77. acc[acc.length++] = App.HTML.Build.dns_entry(o);
  78. });
  79. var html = acc.done().wrapperize('ENTRIES_WRAPPER', 'dns');
  80. App.Ref.CONTENT.html(html);
  81. App.Helpers.updateScreen();
  82. }
  83. */