7acb2ca533
Renamed "includes" to "templates" Added .htaccess to redirect requests to index.php Added function to split request URL into array Corrected locations in scripts and pages
29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
function login() {
|
|
var username = document.getElementById ( "form-username" ).value;
|
|
var password = document.getElementById ( "form-password" ).value;
|
|
password = SHA512 ( password );
|
|
var xhr = new XMLHttpRequest ( );
|
|
xhr.open ( "POST", 'login', true );
|
|
xhr.onreadystatechange = function ( ) {
|
|
if ( xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200 ) {
|
|
if (xhr.status == 200) {
|
|
var response = xhr.responseText;
|
|
response = JSON.parse ( response );
|
|
if ( response [ 'status' ] == 200 ) {
|
|
window.location.href = script_name;
|
|
}
|
|
else {
|
|
document.getElementById ( "responsetext" ).innerHTML = response [ 'error_message' ];
|
|
}
|
|
}
|
|
else {
|
|
console.log ( 'Server communication error: ' + xhr.statusText );
|
|
}
|
|
}
|
|
}
|
|
data = new FormData ( );
|
|
data.append('username', username);
|
|
data.append('password', password);
|
|
xhr.send( data );
|
|
}
|