<html>
<head>
<link href="" rel="stylesheet" type="text/css" title="Layout">
</head>
<body>
<form id="password-reset-form" method="get">
<table class="logindisp" style="max-width:80%;" cellspacing="15" align="center">
<tr>
</tr>
<tr>
<td class="detail4" style="white-space:nowrap;">
<span>Dealer Number</span>
<input placeholder="dealer number" id="CompanyNumber" type="text" class="iteminput" value="" size="0" style="font-size:18px;border-color:;" autofocus />
</td>
</tr>
<br />
<br />
<tr>
<td class="detail4" style="white-space:nowrap;">
<span>New Password</span>
<input placeholder="password" id="Password" type="text" class="iteminput" value="" size="0" style="font-size:18px;border-color:;" autofocus />
</td>
</tr>
<br />
<br />
<tr>
<td class="detail4" style="white-space:nowrap;">
<span>New Password</span>
<input placeholder="retype password" id="PasswordConfirmation" type="text" class="iteminput" value="" size="0" style="font-size:18px;border-color:;" autofocus />
</td>
</tr>
<br />
<br />
<tr>
<td colspan="3" class="buttoncell" style="padding-top:15px;">
<input id="submit-button" type="button" name="submit" value="Reset Password" class="newbutton" style="font-size:18px; margin-left:100px;" />
</td>
</tr>
</table>
</form>
<script>
document.getElementById("submit-button").addEventListener("click", async function resetpassword() {
const myCompanyNumber = document.querySelector('#CompanyNumber');
const myPassword = document.querySelector('#Password');
const myPasswordConfirmation = document.querySelector('#PasswordConfirmation');
var myAuthKey = "{0}";
var url = "";
const currentURL = window.location.href;
// this is to handle what enviornment the request is coming from
if (currentURL.includes("localhost")) {
url = "https://localhost:44392/v3/submitreset"
}
else if (currentURL.includes("c:")) {
url = "https://localhost:44392/v3/submitreset"
}
else if (currentURL.includes("127.0.0.1")) {
url = "https://localhost:44392/v3/submitreset"
}
else if (currentURL.includes("api.reinke.com")) {
url = "https://api.reinke.com/v3/submitreset"
}
else {
url = "https://api-beta.reinke.com/v3/submitreset"
};
console.log(url);
// define object to be JSONified
const formdata = {
AuthKey: myAuthKey.valueOf(),
DealerNumber: myCompanyNumber.value,
Password: myPassword.value,
PasswordConfirmation: myPasswordConfirmation.value
};
// Creating a XHR object
const http = new XMLHttpRequest();
// open a connection asynchronously
http.open("POST", url, true);
// Set the request header i.e. which type of content you are sending
http.setRequestHeader("Content-type", "application/json");
// Convert Object data to JSON and throw it in a string
const data = JSON.stringify(formdata);
// Get the response from the API endpoint
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
alert(http.responseText);
}
};
http.send(data);
});
</script>
</body>
</html>
Comments
0 B
|👍
/👎