APIs

Show:
  1. /**
  2. StudioLite MediaSignage Inc (c) open source digital signage project
  3. Visit Github for licenses and docs: http://git.digitalsignage.com
  4. @class StudioLite
  5. @constructor
  6. @return {Object} instantiated StudioLite
  7. **/
  8. define(['underscore', 'jquery', 'backbone', 'bootstrap', 'backbone.controller', 'ComBroker', 'Lib', 'Pepper', 'PepperHelper', 'Elements', 'bootbox', 'platform'], function (_, $, Backbone, Bootstrap, backbonecontroller, ComBroker, Lib, Pepper, PepperHelper, Elements, bootbox, platform) {
  9.  
  10. var StudioLite = Backbone.Controller.extend({
  11.  
  12. // app init
  13. initialize: function () {
  14. var self = this;
  15. window.BB = Backbone;
  16. window.bootbox = bootbox;
  17. window.TSLiteModules = {};
  18. BB.globs = {};
  19. BB.globs['CREDENTIALS'] = '';
  20. BB.SERVICES = {};
  21. BB.EVENTS = {};
  22. BB.CONSTS = {};
  23. BB.CONSTS.APP_STUDIO_LITE = '0';
  24. BB.CONSTS.APP_CUSTOMER_TERMINAL = '1';
  25. BB.CONSTS.APP_REMOTE_STATUS = '2';
  26. BB.globs['UNIQUE_COUNTER'] = 0;
  27. BB.globs['RC4KEY'] = '226a3a42f34ddd778ed2c3ba56644315';
  28. BB.lib = new Lib();
  29. BB.lib.addBackboneViewOptions();
  30. BB.lib.addBackboneCollectionSave();
  31. BB.lib.selectionSwitcher();
  32. BB.comBroker = new ComBroker();
  33. BB.comBroker.name = 'AppBroker';
  34. BB.Pepper = new Pepper();
  35. _.extend(BB.Pepper, BB.comBroker);
  36. BB.Pepper.clearServices();
  37. BB.Pepper.name = 'JalapenoBroker';
  38. BB.PepperHelper = new PepperHelper();
  39. window.pepper = BB.Pepper;
  40. window.log = BB.lib.log;
  41. BB.platform = platform;
  42. BB.lib.forceBrowserCompatibility();
  43. BB.lib.promptOnExit();
  44. BB.CONSTS.ROOT_URL = 'https://secure.digitalsignage.com' + (BB.lib.inDevMode() ? ':442' : ''); // change to 442 for debuggin
  45. BB.CONSTS.BASE_URL = BB.CONSTS.ROOT_URL + (BB.lib.inDevMode() ? '/_studiolite-dev/studiolite.html' : '/_studiolite-dist/studiolite.html');
  46.  
  47. //console.log(platform.name + ' ' + platform.version);
  48.  
  49. $.ajaxSetup({
  50. cache: false,
  51. timeout: 8000,
  52. crossDomain: true
  53. });
  54.  
  55. _.templateSettings = {
  56. interpolate: /\{\{(.+?)\}\}/g
  57. };
  58.  
  59. // localization
  60. require(['LanguageSelectorView', 'Elements'], function (LanguageSelectorView, Elements) {
  61. new LanguageSelectorView({appendTo: Elements.LANGUAGE_SELECTION_LOGIN});
  62. });
  63.  
  64. // theme
  65. require(['simplestorage'], function (simplestorage) {
  66. var theme = simplestorage.get('theme');
  67. if (theme && theme != 'light')
  68. BB.lib.loadCss('style_' + theme + '.css');
  69. BB.CONSTS['THEME'] = _.isUndefined(theme) ? 'light' : theme;
  70. });
  71.  
  72. // dev mode module loader
  73. if (BB.lib.inDevMode()) {
  74. $.getJSON('https://secure.digitalsignage.com/getIp', function (e) {
  75. var ip = e.ip.replace(/\./ig, '');
  76. if (ip.match('76255130')) {
  77. require(['SampleView'], function (i_SampleView) {
  78. new i_SampleView();
  79. });
  80. }
  81. })
  82. }
  83.  
  84. var mode = window.location.href.match(RegExp("(mode=)(.*)(&param=)(.*)"));
  85. var app;
  86.  
  87. // FQ Customer Terminal
  88. if (!_.isNull(mode) && (mode[2] == 'customerTerminal' || mode[2] == 'remoteStatus')) {
  89. switch (mode[2]) {
  90. case 'customerTerminal':
  91. {
  92. app = BB.CONSTS.APP_CUSTOMER_TERMINAL;
  93. break;
  94. }
  95. case 'remoteStatus':
  96. {
  97. app = BB.CONSTS.APP_REMOTE_STATUS;
  98. break;
  99. }
  100. }
  101. require(['FQTerminalController', 'Events'], function (FQTerminalController) {
  102. new FQTerminalController({
  103. param: mode[4],
  104. app: app
  105. });
  106. });
  107. return;
  108. }
  109.  
  110. // hand out to app controller
  111. require(['LayoutRouter', 'Events'], function (LayoutRouter, Events) {
  112. var LayoutRouter = new LayoutRouter({app: BB.CONSTS.APP_STUDIO_LITE});
  113. BB.history.start();
  114. LayoutRouter.navigate('authenticate/_/_', {trigger: true});
  115. });
  116. }
  117. });
  118.  
  119. return StudioLite;
  120. });