Created
March 9, 2015 02:19
-
-
Save samjacobson/4a3bfd66c7d8920ddc54 to your computer and use it in GitHub Desktop.
Armadagps.co.nz xlogin code (with raven error collector)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.2/jquery.xdomainrequest.min.js"></script> | |
<script src="//cdn.ravenjs.com/1.1.16/raven.min.js"></script> | |
<script> | |
Raven.config('http://[email protected]/5', { | |
whitelistUrls: [/www\.armadagps\.co\.nz/] | |
}).install(); | |
$('#login').on('submit', function( event ) { | |
$('#login_error').text("Logging in..."); | |
$.ajax('http://gps.armadagps.co.nz/myaccount/xlogin', { | |
data: $(this).serialize(), | |
type: 'POST', | |
success: function(data, textStatus, jqXHR) { | |
console.log('success', data, textStatus); | |
data = $.parseJSON(data); | |
if(data.success) | |
window.location = data.url; | |
else { | |
$('#login_error').text("Login failed. Please check your username and password."); | |
Raven.captureMessage('Incorrect login: ', {extra: {textStatus: textStatus, data: data}}); | |
} | |
}, | |
error: function(jqXHR, textStatus, errorThrown) { | |
Raven.captureMessage('Login error', {extra: {textStatus: textStatus, errorThrown: errorThrown}}); | |
console.log('error', textStatus, errorThrown); | |
$('#login_error').text("Unable to process request. Please try again."); | |
} | |
}); | |
event.preventDefault(); | |
}); | |
$('#forgotpassword').on('submit', function( event ) { | |
$('#forgot_error').text("Working..."); | |
$.ajax('http://gps.armadagps.co.nz/myaccount/xforgotpassword', { | |
data: $(this).serialize(), | |
type: 'POST', | |
success: function(data, textStatus, jqXHR) { | |
console.log('success', data, textStatus); | |
data = $.parseJSON(data); | |
if(data.success) | |
$('#forgot_error').text("Done"); | |
else | |
$('#forgot_error').text("Failed. Please check your username."); | |
}, | |
error: function(jqXHR, textStatus, errorThrown) { | |
console.log('error', textStatus, errorThrown); | |
$('#forgot_error').text("Unable to process request. Please try again."); | |
} | |
}); | |
event.preventDefault(); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment