diff --git a/src/app/components/home/home.component.ts b/src/app/components/home/home.component.ts index 2ffdcd3..6fdbc27 100644 --- a/src/app/components/home/home.component.ts +++ b/src/app/components/home/home.component.ts @@ -1270,20 +1270,20 @@ export class HomeComponent implements OnInit, OnDestroy { alert("You must select a nation or random nationalities before generating a team"); return false } - // let lastTime: any = localStorage.getItem('Last request time'); - // if (lastTime !== null) { - // lastTime = parseInt(lastTime); - // let currentTime = new Date().getTime(); - // if (lastTime + 300000 > currentTime) { - // let timeLeft = (lastTime + 300000) - currentTime; - // let min = Math.floor(timeLeft / 60000); - // let seconds = Math.round((timeLeft % 60000) / 1000) - // let str = seconds == 60 ? (min+1) + ":00" : min + ":" + (seconds < 10 ? "0" : "") + seconds; + let lastTime: any = localStorage.getItem('Last request time'); + if (lastTime !== null) { + lastTime = parseInt(lastTime); + let currentTime = new Date().getTime(); + if (lastTime + 300000 > currentTime) { // if 5 minutes haven't passed since last request + let timeLeft = (lastTime + 300000) - currentTime; + let min = Math.floor(timeLeft / 60000); + let seconds = Math.round((timeLeft % 60000) / 1000) + let str = seconds == 60 ? (min+1) + ":00" : min + ":" + (seconds < 10 ? "0" : "") + seconds; - // console.log(`Please wait for ${str} to generate a new team.`); - // return false; - // } - // } + alert(`Please wait ${str} to generate a new team.`); + return false; + } + } if (this.players.length > 0) { if (window.confirm("Are you sure? Any unsaved data will be deleted.")) { this.resetStarters(true); @@ -1425,7 +1425,6 @@ export class HomeComponent implements OnInit, OnDestroy { } }); // getMiddleName function - console.log(player, this.playerCount); this.players.push(player); this.sortedData.push(player); this.playerCount++;