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

Displayed visitors count and downloads counts for each daatset #47

Open
wants to merge 3 commits 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
2 changes: 1 addition & 1 deletion assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ nav ul li{
display: flex;

display: none;
flex-direction: row;
flex-direction: column;
flex-wrap: wrap;
justify-content: space-evenly;
align-items: center;
Expand Down
37 changes: 30 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ <h1>DataSets</h1>
<div class="tile-logo">
<ion-icon name="folder-outline"></ion-icon>
</div>
&nbsp&nbsp&nbsp&nbsp&nbsp
<h1 style="border-left: 3px black solid;" >&nbsp Views: <span id="count">0</span> </h1>
</section>

<section class="datasets">
Expand All @@ -65,13 +67,16 @@ <h1>DataSets</h1>
</p>
<div class="util">
<div class="d-logo">
<button class="logo-button"><a id="d-iris" href="./datasets/Iris.csv" download="iris.csv">
<button class="logo-button" onclick="downloadButtonIris()"><a id="d-iris" href="./datasets/Iris.csv" download="iris.csv">
<ion-icon name="download-outline"></ion-icon></a></button>
</div>
<div class="copy-link">
<button class="copy-button" onclick="copy('d-iris')">Copy Link</button> <!--Created copy() function takes id of anchor tag to copy its href to clipboared-->
</div>
</div>
<p>
Downloads: <span id="iris-downloads" >0</span>
</p>
</div>

<div class="card beginner-db">
Expand All @@ -80,13 +85,16 @@ <h1>DataSets</h1>
</p>
<div class="util">
<div class="d-logo">
<button class="logo-button"><a id="d-titanic" href="./datasets/titanic.csv" download="Titanic.csv">
<button class="logo-button" onclick="downloadButtonTitanic()"><a id="d-titanic" href="./datasets/titanic.csv" download="Titanic.csv">
<ion-icon name="download-outline"></ion-icon></a></button>
</div>
<div class="copy-link">
<button class="copy-button" onclick="copy('d-titanic')">Copy Link</button>
</div>
</div>
<p>
Downloads: <span id="titanic-downloads">0</span>
</p>
</div>


Expand All @@ -96,13 +104,16 @@ <h1>DataSets</h1>
</p>
<div class="util">
<div class="d-logo">
<button class="logo-button"><a id="d-weather-history" href="./datasets/weatherHistory.xlsx" download="weatherHistory.xlsx">
<button class="logo-button" onclick="downloadButtonWeatherHistory()"><a id="d-weather-history" href="./datasets/weatherHistory.xlsx" download="weatherHistory.xlsx">
<ion-icon name="download-outline"></ion-icon></a></button>
</div>
<div class="copy-link">
<button class="copy-button" onclick="copy('d-weather-history')">Copy Link</button>
</div>
</div>
<p>
Downloads: <span id="weather-history-downloads" >0</span>
</p>
</div>

<div class="card intermediate-db">
Expand All @@ -127,13 +138,16 @@ <h1>DataSets</h1>
</p>
<div class="util">
<div class="d-logo">
<button class="logo-button"><a id="d-Ads-Click-through-Rate" href="./datasets/Ads_CTR_Optimisation.csv" download="Ads_CTR_Optimisation.csv">
<button class="logo-button" onclick="downloadButtonAdsClick()" ><a id="d-Ads-Click-through-Rate" href="./datasets/Ads_CTR_Optimisation.csv" download="Ads_CTR_Optimisation.csv">
<ion-icon name="download-outline"></ion-icon></a></button>
</div>
<div class="copy-link">
<button class="copy-button" onclick="copy('d-Ads-Click-through-Rate')">Copy Link</button>
</div>
</div>
<p>
Downloads: <span id="ads-click-downloads" >0</span>
</p>
</div>

<div class="card beginner-d">
Expand All @@ -142,13 +156,16 @@ <h1>DataSets</h1>
</p>
<div class="util">
<div class="d-logo">
<button class="logo-button"><a id="d-Reddit-Vaccine-Myths" href="./datasets/reddit_vm.csv" download="reddit_vm.csv">
<button class="logo-button" onclick="downloadButtonRedditVaccineMyths()"><a id="d-Reddit-Vaccine-Myths" href="./datasets/reddit_vm.csv" download="reddit_vm.csv">
<ion-icon name="download-outline"></ion-icon></a></button>
</div>
<div class="copy-link">
<button class="copy-button" onclick="copy('d-Ads-Click-through-Rate')">Copy Link</button>
</div>
</div>
<p>
Downloads: <span id="reddit-vaccine-downloads" >0</span>
</p>
</div>


Expand All @@ -158,13 +175,16 @@ <h1>DataSets</h1>
</p>
<div class="util">
<div class="d-logo">
<button class="logo-button"><a id="d-Twitch Data" href="./datasets/twitchdata-update.csv" download="twitchdata-update.csv">
<button class="logo-button" onclick="downloadButtonTwitchData()"><a id="d-Twitch Data" href="./datasets/twitchdata-update.csv" download="twitchdata-update.csv">
<ion-icon name="download-outline"></ion-icon></a></button>
</div>
<div class="copy-link">
<button class="copy-button" onclick="copy('d-twitchdata-update')">Copy Link</button>
</div>
</div>
<p>
Downloads: <span id="twitch-data-downloads" >0</span>
</p>
</div>

<div class="card beginner-db">
Expand All @@ -173,13 +193,16 @@ <h1>DataSets</h1>
</p>
<div class="util">
<div class="d-logo">
<button class="logo-button"><a id="d-movies" href="./datasets/MoviesDataset.csv" download="MoviesDataset.csv">
<button class="logo-button" onclick="downloadButtonMovies()"><a id="d-movies" href="./datasets/MoviesDataset.csv" download="MoviesDataset.csv">
<ion-icon name="download-outline"></ion-icon></a></button>
</div>
<div class="copy-link">
<button class="copy-button" onclick="copy('d-movies')">Copy Link</button>
</div>
</div>
<p>
Downloads: <span id="movies-downloads" >0</span>
</p>

</div>

Expand Down
77 changes: 76 additions & 1 deletion script/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,79 @@ function w3RemoveClass(element, name) {
function copy(id) {
Url = document.getElementById(id).href
navigator.clipboard.writeText(Url)
}
}





// functions to display number of downloads for each dataset
function downloadButtonIris(){
var counter = document.getElementById('iris-downloads');
console.log(counter.innerHTML);
localStorage.setItem('iris', parseInt(counter.innerHTML) + 1);
counter.innerHTML = localStorage.getItem('iris');
}
function downloadButtonTitanic(){
var counter = document.getElementById('titanic-downloads');
console.log(counter.innerHTML);
localStorage.setItem('titanic', parseInt(counter.innerHTML) + 1);
counter.innerHTML = localStorage.getItem('titanic');
}
function downloadButtonWeatherHistory(){
console.log("cndjcb");
var counter = document.getElementById('weather-history-downloads');
localStorage.setItem('weather-history', parseInt(counter.innerHTML) + 1);
counter.innerHTML = localStorage.getItem('weather-history');
}
function downloadButtonAdsClick(){
var counter = document.getElementById('ads-click-downloads');
console.log(counter.innerHTML);
localStorage.setItem('ads-click', parseInt(counter.innerHTML) + 1);
counter.innerHTML = localStorage.getItem('ads-click');
}
function downloadButtonRedditVaccineMyths(){
var counter = document.getElementById('reddit-vaccine-downloads');
console.log(counter.innerHTML);
localStorage.setItem('reddit-vaccine', parseInt(counter.innerHTML) + 1);
counter.innerHTML = localStorage.getItem('reddit-vaccine');
}
function downloadButtonTwitchData(){
var counter = document.getElementById('twitch-data-downloads');
console.log(counter.innerHTML);
localStorage.setItem('twitch-data', parseInt(counter.innerHTML) + 1);
counter.innerHTML = localStorage.getItem('twitch-data');
}
function downloadButtonMovies(){
var counter = document.getElementById('movies-downloads');
console.log(counter.innerHTML);
localStorage.setItem('movies', parseInt(counter.innerHTML) + 1);
counter.innerHTML = localStorage.getItem('movies');
}

// retain number of downloads on page refresh
window.onload = function(){
document.getElementById('ads-click-downloads').innerHTML = localStorage.getItem('ads-click') || '0';
document.getElementById('weather-history-downloads').innerHTML = localStorage.getItem('weather-history') || '0';
document.getElementById('iris-downloads').innerHTML = localStorage.getItem('iris') || '0';
document.getElementById('titanic-downloads').innerHTML = localStorage.getItem('titanic') || '0';
document.getElementById('reddit-vaccine-downloads').innerHTML = localStorage.getItem('reddit-vaccine') || '0';
document.getElementById('twitch-data-downloads').innerHTML = localStorage.getItem('twitch-data') || '0';
document.getElementById('movies-downloads').innerHTML = localStorage.getItem('movies') || '0';

}


// function to track visitors count
const countEl = document.getElementById('count');

updateVisitCount();

function updateVisitCount() {
fetch('https://api.countapi.xyz/update/data4all-karishmav/karishmavanwari/?amount=1')
.then(res => res.json())
.then(res => {
document.getElementById('count').innerHTML = res.value;
})
}