You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

96 line
1.7 KiB

  1. define([
  2. 'js/system/client',
  3. 'ui/factory',
  4. 'js/rendering/renderer',
  5. 'js/objects/objects',
  6. 'js/rendering/effects',
  7. 'js/rendering/numbers',
  8. 'js/input',
  9. 'js/system/events',
  10. 'js/resources',
  11. 'ui/templates/online/online',
  12. 'ui/templates/tooltips/tooltips'
  13. ], function (
  14. client,
  15. uiFactory,
  16. renderer,
  17. objects,
  18. effects,
  19. numbers,
  20. input,
  21. events,
  22. resources
  23. ) {
  24. return {
  25. hasFocus: true,
  26. init: function () {
  27. if (isMobile)
  28. $('.ui-container').addClass('mobile');
  29. client.init(this.onClientReady.bind(this));
  30. },
  31. onClientReady: function () {
  32. client.request({
  33. module: 'clientConfig',
  34. method: 'getResourcesList',
  35. callback: this.onGetResourceList.bind(this)
  36. });
  37. },
  38. onGetResourceList: function (list) {
  39. resources.init(list);
  40. events.on('onResourcesLoaded', this.start.bind(this));
  41. },
  42. start: function () {
  43. window.onfocus = this.onFocus.bind(this, true);
  44. window.onblur = this.onFocus.bind(this, false);
  45. $(window).on('contextmenu', this.onContextMenu.bind(this));
  46. objects.init();
  47. renderer.init();
  48. input.init();
  49. numbers.init();
  50. uiFactory.init();
  51. uiFactory.build('login', 'body');
  52. this.update();
  53. $('.loader-container').remove();
  54. },
  55. onFocus: function (hasFocus) {
  56. //Hack: Later we might want to make it not render when out of focus
  57. this.hasFocus = true;
  58. if (!hasFocus)
  59. input.resetKeys();
  60. },
  61. onContextMenu: function (e) {
  62. const allowed = ['txtUsername', 'txtPassword'].some(s => $(e.target).hasClass(s));
  63. if (!allowed) {
  64. e.preventDefault();
  65. return false;
  66. }
  67. },
  68. update: function () {
  69. objects.update();
  70. renderer.update();
  71. uiFactory.update();
  72. numbers.render();
  73. renderer.render();
  74. requestAnimationFrame(this.update.bind(this));
  75. }
  76. };
  77. });