aboutsummaryrefslogtreecommitdiff
path: root/src/client/js/main.js
blob: 12593e62bd60d3a6e4c942aa2ab4d3818c3b1892 (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
var app = Elm.fullscreen(Elm.Main, {
  initialTime: new Date().getTime(),
  translations: document.getElementById('messages').innerHTML,
  config: document.getElementById('config').innerHTML,
  sign: null
});

navigator.id.watch({
  loggedInUser: null,
  onlogin: function(assertion) {
    app.ports.sign.send({
      operation: 'SignIn',
      assertion: assertion
    });
  },
  onlogout: function() {}
});

app.ports.persona.subscribe(function(communication) {
  if(communication === 'SignIn') {
    navigator.id.request();
  } else if(communication === 'SignOut') {
    navigator.id.logout();
    app.ports.sign.send({
      operation: 'SignOut'
    });
  }
});