Skip to content

Instantly share code, notes, and snippets.

@samjacobson
Last active August 29, 2015 14:16
Show Gist options
  • Save samjacobson/80720b76c09df96fbcd1 to your computer and use it in GitHub Desktop.
Save samjacobson/80720b76c09df96fbcd1 to your computer and use it in GitHub Desktop.
GpsEngine VAR xlogin code
<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>
@samjacobson
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment