summaryrefslogtreecommitdiff
path: root/public/assets/js/index.js
blob: ef2b8f4a63b2e8d33a50dffe830447dab63c8c78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var app = (function () {
  var app = {};

  app.init = function () {
    app.debug = !!window.location.search.match("debug");
    app.router = new SiteRouter();
    app.router.initialize();
    app.view = null;

    $(window).on("focus", app.focus);
    $(window).on("blur", app.blur);

    set_background_color_from_time();

    auth.init(app.ready);
    sdk.init();
  };

  app.ready = function () {
    audio.init();
    app.player = new AudioPlayer();
    app.router.route();
  };

  app.focused = true;
  app.typing = false;

  app.focus = function () {
    app.focused = true;
    set_background_color_from_time();
  };

  app.blur = function () {
    app.focused = false;
  };

  document.addEventListener("DOMContentLoaded", app.init);

  return app;
})();