Skip to content

Commit

Permalink
Remove jQuery and replace with XHR (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
burgwyn committed Apr 4, 2019
1 parent 1b24edc commit 9f834f9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ coverage/*
# login-related files
public/script.js
public/login.html
public/jquery-2.2.4.min.js
3 changes: 3 additions & 0 deletions config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,7 @@ module.exports = {
net: 'empty',
tls: 'empty',
},
performance: {
hints: "warning",
},
};
4 changes: 0 additions & 4 deletions public/jquery-2.2.4.min.js

This file was deleted.

25 changes: 11 additions & 14 deletions public/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,20 @@ <h2>Custom</h2>
<button type="submit">Submit</button>
</form>
</div>
<script src="./jquery-2.2.4.min.js"></script>
<script>
function login(username, password) {
$.ajax({
type:"POST",
url:"%API_URL%/accounts/token/",
data: "username=" + username + "&password=" + password,
success: function(data) {
window.location.href = '%PUBLIC_URL%/tokenValidation?tmApiToken=' + data.token
},
error: function(){
alert('Request failed');
},
dataType: 'json',
});
// create XMLHttpRequest
var xhr = new XMLHttpRequest();
xhr.open("POST", "%API_URL%/accounts/token/");
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
window.location.href = '%PUBLIC_URL%/tokenValidation?tmApiToken=' + JSON.parse(xhr.response).token
}
};

};
xhr.send("username=" + username + "&password=" + password);
}

function submitLogin() {
login(document.getElementById('username').value, document.getElementById('password').value);
Expand Down

0 comments on commit 9f834f9

Please sign in to comment.