-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #171 from Yashgabani845/cricket
cricket live score api implementation added
- Loading branch information
Showing
4 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
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,26 @@ | ||
# Cricket Score Dashboard | ||
|
||
This is a simple web application that displays current cricket matches, live scores, and a list of players using data fetched from cricket APIs. | ||
|
||
## Features | ||
|
||
- Displays current cricket matches with details like venue and date. | ||
- Shows live scores of ongoing cricket matches. | ||
- Provides a list of cricket players. | ||
|
||
## Technologies Used | ||
|
||
- HTML | ||
- CSS (Bootstrap) | ||
- JavaScript | ||
|
||
## How to Use | ||
|
||
1. Clone this repository to your local machine. | ||
|
||
```bash | ||
git clone <repository-url> | ||
|
||
2. go to folder Cricket_Score_API | ||
|
||
3. Run index.html 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,60 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Cricket Score Dashboard</title> | ||
<!-- Bootstrap CSS --> | ||
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark"> | ||
<a class="navbar-brand" href="#">Cricket Score Dashboard</a> | ||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
<div class="collapse navbar-collapse" id="navbarNav"> | ||
<ul class="navbar-nav"> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="#currentMatches">Current Matches</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="#liveScores">Live Scores</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="#playerList">Player List</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</nav> | ||
|
||
<div class="container mt-5"> | ||
<div id="currentMatches" class="mt-5"> | ||
<h2>Current Matches</h2> | ||
<div id="currentMatchesList" class="row"> | ||
<!-- Data will be fetched and displayed here --> | ||
</div> | ||
</div> | ||
<div id="liveScores" class="mt-5"> | ||
<h2>Live Scores</h2> | ||
<div id="liveScoresList" class="row"> | ||
<!-- Data will be fetched and displayed here --> | ||
</div> | ||
</div> | ||
<div id="playerList" class="mt-5"> | ||
<h2>Player List</h2> | ||
<ul id="playerListItems"> | ||
|
||
</ul> | ||
</div> | ||
</div> | ||
|
||
|
||
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js"></script> | ||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> | ||
<script src="script.js"> | ||
|
||
</script> | ||
</body> | ||
</html> |
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,71 @@ | ||
// Function to fetch current matches | ||
function fetchCurrentMatches() { | ||
fetch('https://api.cricapi.com/v1/currentMatches?apikey=9df522d1-26ac-494c-9085-484911641a9f&offset=0') | ||
.then(response => response.json()) | ||
.then(data => { | ||
const currentMatchesList = document.getElementById('currentMatchesList'); | ||
currentMatchesList.innerHTML = ''; // Clear previous content | ||
data.data.forEach(match => { | ||
const matchCard = ` | ||
<div class="col-md-6 mb-3"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<h5 class="card-title">${match.name}</h5> | ||
<p class="card-text">Status: ${match.status}</p> | ||
<p class="card-text">Venue: ${match.venue}</p> | ||
<p class="card-text">Date: ${match.date}</p> | ||
</div> | ||
</div> | ||
</div> | ||
`; | ||
currentMatchesList.innerHTML += matchCard; | ||
}); | ||
}); | ||
} | ||
|
||
// Function to fetch live scores | ||
function fetchLiveScores() { | ||
fetch('https://api.cricapi.com/v1/cricScore?apikey=9df522d1-26ac-494c-9085-484911641a9f') | ||
.then(response => response.json()) | ||
.then(data => { | ||
const liveScoresList = document.getElementById('liveScoresList'); | ||
liveScoresList.innerHTML = ''; // Clear previous content | ||
data.data.forEach(score => { | ||
const scoreCard = ` | ||
<div class="col-md-6 mb-3"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<h5 class="card-title">${score.t1} vs ${score.t2}</h5> | ||
<p class="card-text">Status: ${score.status}</p> | ||
<p class="card-text">Series: ${score.series}</p> | ||
</div> | ||
</div> | ||
</div> | ||
`; | ||
liveScoresList.innerHTML += scoreCard; | ||
}); | ||
}); | ||
} | ||
|
||
// Function to fetch player list | ||
function fetchPlayerList() { | ||
fetch('https://api.cricapi.com/v1/players?apikey=9df522d1-26ac-494c-9085-484911641a9f&offset=0') | ||
.then(response => response.json()) | ||
.then(data => { | ||
const playerListItems = document.getElementById('playerListItems'); | ||
playerListItems.innerHTML = ''; // Clear previous content | ||
data.data.forEach(player => { | ||
const playerItem = ` | ||
<li>${player.name} - ${player.country}</li> | ||
`; | ||
playerListItems.innerHTML += playerItem; | ||
}); | ||
}); | ||
} | ||
|
||
// Fetch data when the page loads | ||
document.addEventListener('DOMContentLoaded', () => { | ||
fetchCurrentMatches(); | ||
fetchLiveScores(); | ||
fetchPlayerList(); | ||
}); |
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