1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
---|
2 | <html>
|
---|
3 | <head>
|
---|
4 | <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
|
---|
5 | <meta content="utf-8" http-equiv="encoding">
|
---|
6 | <title>User Log in</title>
|
---|
7 |
|
---|
8 | </head>
|
---|
9 | <body>
|
---|
10 | <center>
|
---|
11 | <fieldset style="width: 300px">
|
---|
12 | <legend> Register as new user </legend>
|
---|
13 | <table>
|
---|
14 | <tr>
|
---|
15 | <td>User name (required)</td>
|
---|
16 | <td><input type="text" id="name" name="username"
|
---|
17 | required="required" /></td>
|
---|
18 | </tr>
|
---|
19 | <tr>
|
---|
20 | <td>Password</td>
|
---|
21 | <td><input type="password" id="password" name="userpass" /></td>
|
---|
22 | </tr>
|
---|
23 | <tr>
|
---|
24 | <td>E-mail</td>
|
---|
25 | <td><input type="text" id="email" name="mail" " /></td>
|
---|
26 | </tr>
|
---|
27 | <tr>
|
---|
28 | <td><button onClick="register()">Register</button></td>
|
---|
29 | </tr>
|
---|
30 | </table>
|
---|
31 | <br> <b>Notice</b>: email is optional, but if you loose your
|
---|
32 | password your account will become unreachable.
|
---|
33 | </fieldset>
|
---|
34 |
|
---|
35 | </center>
|
---|
36 | <br/>
|
---|
37 | <div id="errorreport" style="display:none;">
|
---|
38 | The server refused the request with the following reply:
|
---|
39 | <div id="errortext">
|
---|
40 | </div>
|
---|
41 | </div>
|
---|
42 |
|
---|
43 |
|
---|
44 | <script>
|
---|
45 | "use strict";
|
---|
46 |
|
---|
47 | function register() {
|
---|
48 | var xmlHttp = new XMLHttpRequest();
|
---|
49 | xmlHttp.open("PUT", "Accounts", true); // false for synchronous request
|
---|
50 | xmlHttp.setRequestHeader('Content-Type', "text/json");
|
---|
51 | xmlHttp.onreadystatechange = function() {
|
---|
52 | if (xmlHttp.readyState == 4) {
|
---|
53 | if (xmlHttp.status == 200) {
|
---|
54 | alert("logged in!");
|
---|
55 | } else { // ugly stacktrace in html format
|
---|
56 | //alert("register was rejected:...");
|
---|
57 | document.getElementById('errorreport').style.display="block";
|
---|
58 | document.getElementById('errortext').innerHTML=xmlHttp.responseText;
|
---|
59 |
|
---|
60 | }
|
---|
61 | }
|
---|
62 | }
|
---|
63 | xmlHttp.send(JSON.stringify({
|
---|
64 | 'name' : document.getElementById('name').value,
|
---|
65 | 'password' : document.getElementById('password').value,
|
---|
66 | 'email' : document.getElementById('email').value
|
---|
67 | }));
|
---|
68 |
|
---|
69 | }
|
---|
70 | </script>
|
---|
71 |
|
---|
72 | <noscript>Sorry, your browser does not support JavaScript!</noscript>
|
---|
73 | </body>
|
---|
74 | </html>
|
---|