You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.1 KiB
Smarty
36 lines
1.1 KiB
Smarty
12 years ago
|
<h1>Login</h1>
|
||
|
<div class="well">
|
||
|
<div class="alert alert-error" id="error" style="display:none">
|
||
|
<button type="button" class="close" data-dismiss="alert">×</button>
|
||
|
<strong>Failed Login Attempt</strong> <p></p>
|
||
|
</div>
|
||
|
<label>Username</label><input type="text" placeholder="Enter Username" id="username" /><br />
|
||
|
<label>Password</label><input type="password" placeholder="Enter Password" id="password" /><br />
|
||
|
<button class="btn btn-primary" id="login" type="submit">Login</button>
|
||
|
</div>
|
||
|
<script type="text/javascript">
|
||
|
(function() {
|
||
|
var username = document.getElementById('username'),
|
||
|
password = document.getElementById('password'),
|
||
|
login = document.getElementById('login'),
|
||
|
error = document.getElementById('error');
|
||
|
|
||
|
login.onclick = function() {
|
||
|
socket.emit('user.login', {
|
||
|
username: username.value,
|
||
|
password: password.value
|
||
|
});
|
||
|
};
|
||
|
|
||
|
socket.on('user.login', function(data) {
|
||
|
console.log(data);
|
||
|
if (data.status === 0) {
|
||
|
jQuery('#error').show(50);
|
||
|
jQuery('#error p').html(data.message);
|
||
|
} else {
|
||
|
alert('success');
|
||
|
jQuery('#error').hide(50);
|
||
|
}
|
||
|
});
|
||
|
}());
|
||
|
</script>
|