public/js/music_playlist.js
/**
 * Handle user authorization signup form submit button.
 */
Handle user authorization signup form submit button.
Handle user authorization signup form submit button .
function sendAuthUserSignupForm() {
    var name = document.getElementById('formAuthUserSignupName');
    var nameValue = name.value;
    var email = document.getElementById('formAuthUserSignupEmail');
    var emailValue = email.value;
    var password = document.getElementById('formAuthUserSignupPassword');
    var passwordValue = password.value;
    var passwordConfirmation = document.getElementById('formAuthUserSignupPasswordConfirm');
    var passwordConfirmationValue = passwordConfirmation.value;
    var status = document.getElementById('formAuthUserSignupStatus');
    if (nameValue == '' || emailValue == '' || passwordValue == '' || passwordConfirmationValue == '') {
        status.innerText = 'Fill in all fields!'
        return;
    }
    else if (passwordValue != passwordConfirmationValue) {
        status.innerText = 'Passwords are not equal!'
        return;
    }
    var url = base_url + "/api/auth/signup";
    var data = {'name': nameValue, 'email': emailValue, 'password': passwordValue, 'password_confirmation': passwordConfirmationValue};
    fetch(url, {
        credentials: "same-origin",
        method: 'POST',
        body: JSON.stringify(data),
        headers:{
            'Content-Type': 'application/json',
            'X-Requested-With': 'XMLHttpRequest',
            'X-CSRF-TOKEN': getCSRFToken()
        }
    })
    .then(function(response) {
        return response.json();
    })
    .then(function(json) {
        status.innerText = JSON.stringify(json);
    }); 
}
function sendAuthUserSignupForm ( ) { var name = document . getElementById ( 'formAuthUserSignupName' ) ; var nameValue = name . value ; var email = document . getElementById ( 'formAuthUserSignupEmail' ) ; var emailValue = email . value ; var password = document . getElementById ( 'formAuthUserSignupPassword' ) ; var passwordValue = password . value ; var passwordConfirmation = document . getElementById ( 'formAuthUserSignupPasswordConfirm' ) ; var passwordConfirmationValue = passwordConfirmation . value ; var status = document . getElementById ( 'formAuthUserSignupStatus' ) ; if ( nameValue == '' || emailValue == '' || passwordValue == '' || passwordConfirmationValue == '' ) { status . innerText = 'Fill in all fields!' return ; } else if ( passwordValue != passwordConfirmationValue ) { status . innerText = 'Passwords are not equal!' return ; } var url = base_url + "/api/auth/signup" ; var data = { 'name' : nameValue , 'email' : emailValue , 'password' : passwordValue , 'password_confirmation' : passwordConfirmationValue } ; fetch ( url , { credentials : "same-origin" , method : 'POST' , body : JSON . stringify ( data ) , headers : { 'Content-Type' : 'application/json' , 'X-Requested-With' : 'XMLHttpRequest' , 'X-CSRF-TOKEN' : getCSRFToken ( ) } } ) . then ( function ( response ) { return response . json ( ) ; } ) . then ( function ( json ) { status . innerText = JSON . stringify ( json ) ; } ) ; }
Handle user authorization signup form submit button.
Handle user authorization signup form submit button .