Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hiteshpr committed Oct 2, 2017
0 parents commit e644eca
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
Empty file added README
Empty file.
57 changes: 57 additions & 0 deletions script.js
@@ -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.

Copy link
@slaporte

slaporte Oct 6, 2017

To get around the "Access-Control-Allow-Origin" problem, you'll need to set dataType: "jsonp". Check out this note.

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.

Copy link
@slaporte

slaporte Oct 6, 2017

Note, this should be format=json, and jquery will take care of the jsonp parameters for you!



success: function(result){
alert("Data: "+ "\nStatus: " + status);
}
});
}
46 changes: 46 additions & 0 deletions usercontri.html
@@ -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>

0 comments on commit e644eca

Please sign in to comment.