Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github user finder #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//fetch data from form!
var form = document.getElementById("myForm");


form.addEventListener('submit', function (e) {

//prevent the auto submission of form
e.preventDefault();

var search = document.getElementById("search").value;

//to remove space in b/w firstName & lastName
var originalName = search.split(' ').join('');

document.getElementById("result").innerHTML = '';

fetch("https://api.github.com/users/" + originalName)
.then((result) => result.json())
.then((data) => {
console.log(data)

document.getElementById("result").classList.add("discription");

document.getElementById("result").innerHTML = `
<a target="_blank" href="https://www.github.com/${originalName}"> <img src="${data.avatar_url}"/></a>
`
})
})
39 changes: 39 additions & 0 deletions searchbar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap demo</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous">
<link rel="stylesheet" href="styles.css">
</head>

<body>
<div class="container">
<br><br>
<h1>GIT USER FINDER</h1>

<br><br><br>
<form action="" id="myForm" autocomplete="off">
<div class="form-group">
<input type="text" class="form-control" id="search" placeholder="Search Username">
<br>
</div>
<div class="form-group">
<button class="btn btn-dark btn-block" id="btn1" onclick="functionName()"
style="align-items: center; justify-content: center; display: flex; background-color: #F7D060; ">
Search User
</button>
</div>
</form>

</div>

<div id="result">

</div>
<script src="index.js"></script>
</body>
</html>
15 changes: 15 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*{
justify-content: center;
align-items: center;
text-align: center;
}

body{

background-image: linear-gradient(to right, #eea2a2 0%, #bbc1bf 19%, #57c6e1 42%, #b49fda 79%, #7ac5d8 100%);

}

h1{
font-size: 80px;
}