summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/core/web/index.html
blob: 6ac9b29ec909458f5b470861f235d8e6a33a4281 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html>
   <head>
      <title>Bitmask WebSockets Endpoint</title>
      <script src="bitmask.js"></script>
      <script type="text/javascript">
         var ellog = null;

         window.onload = function() {
            ellog = document.getElementById('log');

            bitmask.events.register("KEYMANAGER_KEY_FOUND", event_handler);
         };

         function login() {
            var email = document.getElementById('email').value;
            var password = document.getElementById('password').value;
            bitmask.user.auth(email, password).then(function(response) {
                log("We are logged in: ");
                for (k in response) {
                    log("    " + k + ": " + response[k]);
                }
            }, function(error) {
                log("Some error ocurred: " + error);
            });
         };

         function logout() {
            bitmask.user.logout().then(function(response) {
                log("We are logged out: ");
                for (k in response) {
                    log("    " + k + ": " + response[k]);
                }
            }, function(error) {
                log("Some error ocurred: " + error);
            });
	 };

         function event_handler(evnt, content) {
            log("Event: " + evnt);
            for (i in content) {
               log("    " + content[i]);
            }
         };

         function log(m) {
            ellog.innerHTML += m + '\n';
            ellog.scrollTop = ellog.scrollHeight;
         };
      </script>
   </head>
   <body>
      <h1>Bitmask Control Panel</h1>
      <noscript>You must enable JavaScript</noscript>
      <form>
         <p>Email address: <input id="email" type="text" size="50" maxlength="50" value="user@mail.bitmask.net"></p>
         <p>Password: <input id="password" type="password" size="50" maxlength="50" ></p>
      </form>
      <button onclick='login();'>Log In</button>
      <button onclick='logout();'>Log Out</button>
      <pre id="log" style="height: 20em; overflow-y: scroll; background-color: #faa;"></pre>
   </body>
</html>