Skip to content

Commit

Permalink
Merge pull request #2484 from AsmitaMishra24/master
Browse files Browse the repository at this point in the history
Added Github Repository Analyzer
  • Loading branch information
Sulagna-Dutta-Roy committed Jul 22, 2024
2 parents c76d531 + 390c5d2 commit 4c658ce
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 0 deletions.
Binary file added Github Repository Analyzer/icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Github Repository Analyzer/icon16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Github Repository Analyzer/icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions Github Repository Analyzer/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Github Repository Analyzer</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Github Repository Analyzer</h1>
<form id="repo-form">
<label for="owner">Repository Owner:</label>
<input type="text" id="owner" name="owner" required>

<label for="repo">Repository Name:</label>
<input type="text" id="repo" name="repo" required>

<button type="submit">Analyzer</button>
</form>

<div id="results"></div>
</div>
<script src="script.js"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions Github Repository Analyzer/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"manifest_version": 3,
"name": "GitHub Repository Analyzer",
"version": "1.0",
"description": "Analyze GitHub repositories from your browser.",
"permissions": [
"activeTab"
],
"host_permissions": [
"https://api.github.com/*"
],
"action": {
"default_popup": "index.html",
"default_icon": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
}
},
"icons": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
}
}

45 changes: 45 additions & 0 deletions Github Repository Analyzer/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
document.addEventListener('DOMContentLoaded', () => {
const form = document.getElementById('repo-form');
const resultsDiv = document.getElementById('results');

if (!form || !resultsDiv) {
console.error('Form or results container not found.');
return;
}

form.addEventListener('submit', async (event) => {
event.preventDefault();

const ownerInput = document.getElementById('owner');
const repoInput = document.getElementById('repo');

if (!ownerInput || !repoInput) {
console.error('Owner or repo input fields not found.');
return;
}

const owner = ownerInput.value.trim(); //ownerInput if null then error
const repo = repoInput.value.trim(); //repoInput if null then error

resultsDiv.innerHTML = 'Loading...';

try {
const response = await fetch(`https://api.github.com/repos/${owner}/${repo}`);
if (!response.ok) throw new Error('Repository not found');

const repoData = await response.json();

resultsDiv.innerHTML = `
<h2>Repository Details</h2>
<p><strong>Name:</strong> ${repoData.name}</p>
<p><strong>Description:</strong> ${repoData.description || 'No description available'}</p>
<p><strong>Stars:</strong> ${repoData.stargazers_count}</p>
<p><strong>Forks:</strong> ${repoData.forks_count}</p>
<p><strong>Open Issues:</strong> ${repoData.open_issues_count}</p>
<p><strong>Language:</strong> ${repoData.language || 'Not specified'}</p>
`;
} catch (error) {
resultsDiv.innerHTML = `<p>Error: ${error.message}</p>`;
}
});
});
48 changes: 48 additions & 0 deletions Github Repository Analyzer/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
body {
font-family: Arial, sans-serif;
width: 300px;
margin: 0;
padding: 0;
}

.container {
padding: 20px;
}

h1 {
font-size: 16px;
margin-bottom: 10px;
}

form {
display: flex;
flex-direction: column;
}

label {
margin: 5px 0;
}

input {
padding: 5px;
margin-bottom: 10px;
border: 1px solid #ddd;
border-radius: 4px;
}

button {
padding: 5px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}

button:hover {
background-color: #0056b3;
}

#results {
margin-top: 10px;
}

0 comments on commit 4c658ce

Please sign in to comment.