Projekt

Obecné

Profil

Stáhnout (2.23 KB) Statistiky
| Větev: | Revize:
1
<div id="login-modal" class="modal fade" role="dialog">
2
    <div class="modal-dialog modal-dialog-centered" role="document">
3
        <div class="modal-content">
4
            <div class="modal-header">
5
                <h4 class="modal-title">Přihlásit se</h4>
6
                <button type="button" class="close" data-dismiss="modal">&times;</button>
7
            </div>
8
            <div class="modal-body">
9
                <div class="container">
10
                    <div class="row">
11
                        <div class="col-xs-12 col-sm-5">
12
                            <label for="nick">Přihlašovací jméno</label>
13
                        </div>
14
                        <div class="col-xs-12 col-sm-7">
15
                            <input type="text" id="nick">
16
                        </div>
17
                    </div>
18
                    <div class="row">
19
                        <div class="col-xs-12 col-sm-5">
20
                            <label for="password">Heslo</label>
21
                        </div>
22
                        <div class="col-xs-12 col-sm-7">
23
                            <input type="password" id="password">
24
                        </div>
25
                    </div>
26
                </div>
27
            </div>
28
            <div class="modal-footer">
29
                <button type="button" class="btn btn-default" data-dismiss="modal" onclick="login()">Přihlásit se</button>
30
                <button type="button" class="btn btn-default" data-dismiss="modal">Zavřít</button>
31
            </div>
32
        </div>
33
    </div>
34
</div>
35

    
36
<script>
37
    function login(){
38
        var data = new FormData();
39
        data.append("username", document.getElementById('nick').value);
40
        data.append("password", document.getElementById('password').value);
41
        var xhr = new XMLHttpRequest();
42
        xhr.open("POST", "controller/LoginController.php");
43
        xhr.onload = function(){
44
            if(this.response == 'Incorrect username and/or password!'){ //login was not successful, show modal
45
                $("#invalid-login-modal").modal("show");
46
            }else{ //login was successful, refresh page to apply changes in visible items
47
                location.reload();
48
            }
49
        };
50
        xhr.send(data);
51

    
52
        return false;
53
    }
54

    
55
</script>
(6-6/10)