diff --git a/week-12/index.html b/week-12/index.html new file mode 100644 index 0000000..b4eca61 --- /dev/null +++ b/week-12/index.html @@ -0,0 +1,20 @@ + + + + + + Assignment-12 + + + +
+

Uconn Github User Search

+ + +

+
+
+ + + + diff --git a/week-12/script.js b/week-12/script.js new file mode 100644 index 0000000..b308e79 --- /dev/null +++ b/week-12/script.js @@ -0,0 +1,38 @@ +function searchUsers() { + const searchInput = document.getElementById('searchInput').value; + if (searchInput.length < 1) { + alert('Please enter a username'); + return; + } + + const apiUrl = `https://github.uconn.edu/api/v3/search/users?q=${searchInput}`; + + fetch(apiUrl) + .then(response => response.json()) + .then(data => { + const results = document.getElementById('results'); + const resultsCount = document.getElementById('resultsCount'); + + results.innerHTML = ''; + resultsCount.innerText = `Found ${data.total_count} result(s).`; + + data.items.forEach(user => { + const userElement = document.createElement('div'); + userElement.innerHTML = ` +
+ Avatar +
+
${user.login}
+ View Profile +
+
+ `; + results.appendChild(userElement); + }); + }) + .catch(error => { + console.error('Error:', error); + alert('An error occurred. Please try again.'); + }); + } + diff --git a/week-12/style.css b/week-12/style.css new file mode 100644 index 0000000..bedc536 --- /dev/null +++ b/week-12/style.css @@ -0,0 +1,52 @@ +body { + font-family: Arial, sans-serif; + margin: 10%; + } + +input{ + padding: 10px; + border-radius: 10px; + width: 200px; +} + +button{ + padding: 10px; + border-radius: 10px; +} + +#results{ + display: flex; + flex-wrap: wrap; + float: left; +} + +.card{ + border: 2px solid; + border-radius: 20px; + margin: 10px; + padding: 20px; + align-items:center; +} + +img{ + width: 280px; + height: 280px; + color:rgb(0, 0, 0); + border-radius: 20px; +} + + +h5{ + text-align: left; + font-size: 20px; +} + +#profilebtn{ + text-align: left; + padding: 5px; + border: 2px solid; + border-radius: 10px; + margin-bottom: 30px; + text-decoration: none; +} +