-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e644eca
Showing
3 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
$(document).ready(function(){ | ||
|
||
$("input[name='username']").keyup(function(){ | ||
|
||
if($(this).val().length > 0){ | ||
$("#success-icon").css("display","block"); | ||
$(this).parent().parent().addClass("has-success"); | ||
$("#error-icon").css("display","none"); | ||
$(this).parent().parent().removeClass("has-error"); | ||
} | ||
else{ | ||
$("#success-icon").css("display","none"); | ||
$(this).parent().parent().removeClass("has-success"); | ||
} | ||
}); | ||
|
||
}); | ||
|
||
function formSubmit(){ | ||
|
||
var userName = $("input[name='username']"); | ||
|
||
if(validateForm(userName)){ | ||
dispalyResult(userName); | ||
} | ||
} | ||
|
||
function validateForm(userName){ | ||
|
||
|
||
if(userName.val().length > 0 ) { | ||
$("#error-icon").css("display","none"); | ||
$(userName).parent().parent().removeClass("has-error"); | ||
return true; | ||
}else{ | ||
|
||
$("#error-icon").css("display","block"); | ||
$(userName).parent().parent().addClass("has-error"); | ||
return false; | ||
} | ||
} | ||
|
||
function dispalyResult(userName){ | ||
/* | ||
console.log(userName.val());*/ | ||
|
||
$.ajax({ | ||
type:"GET", | ||
dataType:"html", | ||
This comment has been minimized.
Sorry, something went wrong. |
||
url:"https://en.wikipedia.org/w/api.php?action=query&action=centralauthtoken&format=jsonp&list=usercontribs&ucuser="+userName.val()+"&ucdir=older", | ||
This comment has been minimized.
Sorry, something went wrong.
slaporte
|
||
|
||
|
||
success: function(result){ | ||
alert("Data: "+ "\nStatus: " + status); | ||
} | ||
}); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<!-- bootstrap --> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | ||
|
||
<!-- jQuery library --> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | ||
|
||
<!-- Latest compiled JavaScript --> | ||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> | ||
|
||
<script type="text/javascript" src="script.js"></script> | ||
<title>Outreachy Microtask</title> | ||
</head> | ||
|
||
<body> | ||
|
||
|
||
<div class="container"> <!-- container class of bootstrap --> | ||
|
||
<div class="jumbotron"> | ||
<h2> Enter the user name to see latest wikipedia edits! </h2> | ||
</div> | ||
|
||
<!-- Form to enter the user-name --> | ||
|
||
<div > | ||
<label for="user-name"> User Name: </label> | ||
|
||
<div class="input-group"> | ||
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span> | ||
<input id="username" name="username" type="text" class="form-control" placeholder="Enter user-name"> | ||
<span class="glyphicon glyphicon-ok form-control-feedback" id="success-icon" style="display: none;"></span> | ||
<span class="glyphicon glyphicon-remove form-control-feedback" id="error-icon" style="display: none;"></span> | ||
</div> | ||
<br/> | ||
<button type="submit" class="btn btn-default" onclick="formSubmit()">Submit</button> | ||
</div> | ||
|
||
</div> | ||
|
||
</body> | ||
</html> |
To get around the "Access-Control-Allow-Origin" problem, you'll need to set
dataType: "jsonp"
. Check out this note.