Last active
August 29, 2015 14:16
-
-
Save samjacobson/80720b76c09df96fbcd1 to your computer and use it in GitHub Desktop.
GpsEngine VAR xlogin code
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
<html> | |
<head> | |
<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> | |
$('#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) { | |
data = $.parseJSON(data); | |
if(data.success) { | |
// Support server mobile detection: | |
if(data.ismobile) | |
window.location = data.mobileurl; | |
else | |
window.location = data.url; | |
} | |
else { | |
$('#login_error').text("Login failed. Please check your username and password."); | |
} | |
}, | |
error: function(jqXHR, 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) { | |
data = $.parseJSON(data); | |
if(data.success) | |
$('#forgot_error').text("Done"); | |
else | |
$('#forgot_error').text("Failed. Please check your username."); | |
}, | |
error: function(jqXHR, textStatus, errorThrown) { | |
$('#forgot_error').text("Unable to process request. Please try again."); | |
} | |
}); | |
event.preventDefault(); | |
}); | |
</script> | |
</head> | |
<body> | |
<form name="login" id="login"> | |
Username: <input name="username" type="text"> | |
<br/> | |
Password:<input name="password" type="password"> | |
<br/> | |
<input type="submit" value="Login"> | |
<br/> | |
<span id="login_error" style="color: red"></span> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use this code you need to change all instances of "gps.armadagps.co.nz" to your own domain name that you will use for hosting the application. This domain name should have a CNAME record provided to you by GpsEngine.
Host the above code on your own website.