added end screen

This commit is contained in:
gocivici 2022-10-31 15:35:47 +02:00
parent a658bafb71
commit 8ee74b2e0a
6 changed files with 77 additions and 21 deletions

View File

@ -38,7 +38,7 @@
<a class="mobileInfo" href="#info"><i class="fa fa-question"></i></a> <a class="mobileInfo" href="#info"><i class="fa fa-question"></i></a>
<a class="mobileInfo" href="#support"><i class="fa fa-heart"></i></a> <a class="mobileInfo" href="#support"><i class="fa fa-heart"></i></a>
<a class="wideInfo" href="#support"><i class="fa fa-heart"></i></a> <a class="wideInfo" href="#support"><i class="fa fa-heart"></i></a>
<a href="#stats"><i class="fas fa-chart-bar"></i></a> <a onclick="remember()" href="#stats"><image class="gif" src="new.gif"></image><i class="fas fa-history"></i></a>
</div> </div>
</div> </div>
</div> </div>
@ -88,7 +88,7 @@
<div id="stats" class="overlay"> <div id="stats" class="overlay">
<div class="popup"> <div class="popup">
<h2>Stats</h2> <h2>Archive</h2>
<h3>October 2022</h3> <h3>October 2022</h3>
<div class="archive"> <div class="archive">
@ -146,16 +146,16 @@
</div> </div>
</div> </div>
<div class="chartNumber"> <!-- <div class="chartNumber">
<canvas id="myChart"></canvas> <canvas id="myChart"></canvas>
</div> </div> -->
<a class="close" href="#">&times;</a> <a class="close" href="#">&times;</a>
<!-- <h3>Streak</h3> --> <!-- <h3>Streak</h3> -->
<!-- <div id="streakNumber" class="content"> <!-- <div id="streakNumber" class="content">
your stats your stats
</div> --> </div> -->
<input onclick="copyToClipboardCalendar()" type="button" id="shareResultCalender" value="Share Total Result">
<button onclick="resetFunction();"class="resetButton">Reset Stats</button> <!-- <button onclick="resetFunction();"class="resetButton">Reset Stats</button> -->
</div> </div>
</div> </div>

68
main.js
View File

@ -11,6 +11,9 @@
//image placeholder //image placeholder
// gameover movie name // gameover movie name
getReady() getReady()
function getReady() { function getReady() {
window.addEventListener ("load", function() { window.addEventListener ("load", function() {
@ -25,6 +28,13 @@ guess='Skipped';
localStorage.setItem('playedBefore',"true"); localStorage.setItem('playedBefore',"true");
} }
if(localStorage.getItem('archiveButtonPressed')){
document.getElementsByClassName("gif")[0].style.display="none";
}
var buttonNo = 0; var buttonNo = 0;
@ -85,8 +95,8 @@ var movies = [
["The Invisible Man",2,"Cecilia Kass"], ["The Invisible Man",2,"Cecilia Kass"],
["Triangle",0,"Jess"], ["Triangle",0,"Jess"],
["10 Cloverfield Lane",1,"Michelle"], ["10 Cloverfield Lane",1,"Michelle"],
["The Ruins",2,"Amy"],
["28 Days Later",1,"Jim"], ["28 Days Later",1,"Jim"],
["The Ruins",2,"Amy"],
["Halloween",2,"Laurie Strode"], ["Halloween",2,"Laurie Strode"],
["Escape Room"], ["Escape Room"],
["The Shining"], ["The Shining"],
@ -1071,6 +1081,9 @@ var movies = [
// gameBeginning = new Date(gameBeginning.getTime() + 0 * 60 * 1000); // gameBeginning = new Date(gameBeginning.getTime() + 0 * 60 * 1000);
// console.log(gameBeginning.getTimezoneOffset()); // console.log(gameBeginning.getTimezoneOffset());
dayCounter(); dayCounter();
if(dayCount>30){
document.getElementsByClassName("gif")[0].style.display="block";
}
// console.log("gameBeginning: ",gameBeginning); // console.log("gameBeginning: ",gameBeginning);
// console.log("now: ",present_date); // console.log("now: ",present_date);
// console.log("Current dayCount: ", dayCount) // console.log("Current dayCount: ", dayCount)
@ -1080,12 +1093,14 @@ var movies = [
function dayCounter(){ function dayCounter(){
dayCount = Math.floor((present_date - gameBeginning) / (1000 * 60 * 60 * 24)); dayCount = Math.floor((present_date - gameBeginning) / (1000 * 60 * 60 * 24));
console.log("dayCount: " + dayCount); console.log("dayCount: " + dayCount);
return dayCount; return dayCount;
} }
markCalendar(); markCalendar();
function markCalendar() { function markCalendar() {
calendarResult=" "
winCount = 0; winCount = 0;
loseCount = 0; loseCount = 0;
dates = document.getElementsByClassName('calendar__number'); dates = document.getElementsByClassName('calendar__number');
@ -1101,9 +1116,13 @@ loseCount = 0;
if (localStorage.getItem('day'+(i))) { if (localStorage.getItem('day'+(i))) {
if (localStorage.getItem('day'+(i))=='true') { if (localStorage.getItem('day'+(i))=='true') {
dates[i].classList.add('won'); dates[i].classList.add('won');
calendarResult+="🟩"
if((i+6)%7==0){calendarResult+="\n"}
winCount=winCount + 1; winCount=winCount + 1;
} else if (localStorage.getItem('day'+(i))=='false') { } else if (localStorage.getItem('day'+(i))=='false') {
dates[i].classList.add('lost'); dates[i].classList.add('lost');
calendarResult+="🟥"
if((i+6)%7==0){calendarResult+="\n"}
loseCount=loseCount + 1; loseCount=loseCount + 1;
} }
@ -1112,6 +1131,8 @@ loseCount = 0;
dates[i].classList.add('past'); dates[i].classList.add('past');
dates[i] = document.createElement('a'); dates[i] = document.createElement('a');
calendarResult+="🟧"
if((i+6)%7==0){calendarResult+="\n"}
//dates[j].setAttribute('href','#'); //dates[j].setAttribute('href','#');
// if(localStorage.getItem("playedToday")){ // if(localStorage.getItem("playedToday")){
dates[i].setAttribute('onclick','getArchive(' + (i+1) +')'); dates[i].setAttribute('onclick','getArchive(' + (i+1) +')');
@ -1127,6 +1148,8 @@ loseCount = 0;
// console.log(dates[i]); // console.log(dates[i]);
} }
// calendarResult = calendarResult.replace(/(.{8})/g, "$1|");
console.log("calo reso"+ calendarResult);
console.log("win:"+ winCount) console.log("win:"+ winCount)
console.log("lose:"+ loseCount) console.log("lose:"+ loseCount)
winPerc.textContent = Math.ceil(winCount/(winCount+loseCount)*100)+"%"; winPerc.textContent = Math.ceil(winCount/(winCount+loseCount)*100)+"%";
@ -1166,7 +1189,7 @@ function clearGuess() {
document.getElementById("shareResult").style.display = "none"; document.getElementById("shareResult").style.display = "none";
document.getElementById("guessForm").style.display = "block"; document.getElementById("guessForm").style.display = "block";
document.getElementById("countDown").style.display = "none"; document.getElementById("countDown").style.display = "none";
document.getElementById("footer").style.display = "none"; // document.getElementById("footer").style.display = "none";
// document.getElementById("resultText").innerHTML =textResult; // document.getElementById("resultText").innerHTML =textResult;
document.getElementById("movieFrame").style.display = "block"; document.getElementById("movieFrame").style.display = "block";
document.getElementsByClassName("resultContainer")[0].style.display="none"; document.getElementsByClassName("resultContainer")[0].style.display="none";
@ -1246,8 +1269,8 @@ window.onload = deathOftheDay();
document.getElementById("movieFrame").style.display = "none"; document.getElementById("movieFrame").style.display = "none";
document.getElementById("guessForm").style.display = "none"; document.getElementById("guessForm").style.display = "none";
document.getElementsByClassName("picButtons")[0].style.display="none"; document.getElementsByClassName("picButtons")[0].style.display="none";
document.getElementById("movieName").innerHTML = "Thanks for playing Horrordle!"; document.getElementById("movieName").innerHTML = "<br><br>Thanks for playing!";
document.getElementById("feedback").innerHTML = "Thanks for playing Horrordle!"; document.getElementById("feedback").innerHTML = "Horrordle will be back next October! <br><br> <a href='test'>follow me on twitter for updates</a><br><br> In the meantime you can go back and play <br> the days you've missed by visiting the <br> <a href='#stats'>archive page</a> on the top right and <br>clicking on the orange dates.";
} }
// picButton = document.getElementsByClassName('picButton'); // picButton = document.getElementsByClassName('picButton');
@ -1305,7 +1328,7 @@ window.onload = deathOftheDay();
document.getElementsByClassName("picButtons")[0].style.display="none"; document.getElementsByClassName("picButtons")[0].style.display="none";
showPic(movieOfTheDay[1]) showPic(movieOfTheDay[1])
// console.log(buttonNo); // console.log(buttonNo);
addData(); // addData();
} }
setResult(); setResult();
function setResult(){ function setResult(){
@ -1465,6 +1488,16 @@ function copyToClipboard() {
}); });
} }
function copyToClipboardCalendar() {
navigator.clipboard.writeText("Horrordle 2022: \n" + calendarResult + "").then(() => {
shareResultCalender.value = "copied!";
// Alert the user that the action took place.
// Nobody likes hidden stuff being done under the hood!
});
}
function getArchive(j,d = dayCount){ function getArchive(j,d = dayCount){
for (var i = 0; i < dates.length; i++) { for (var i = 0; i < dates.length; i++) {
@ -1568,16 +1601,16 @@ const config = {
// // window.location.reload(); // // window.location.reload();
// } // }
// }, 1000); // }, 1000);
function addData(){ // function addData(){
myChart.data.datasets[0].data[0] = localStorage.getItem('firstGuessStat'); // myChart.data.datasets[0].data[0] = localStorage.getItem('firstGuessStat');
myChart.data.datasets[0].data[1] = localStorage.getItem('secondGuessStat'); // myChart.data.datasets[0].data[1] = localStorage.getItem('secondGuessStat');
myChart.data.datasets[0].data[2] = localStorage.getItem('thirdGuessStat'); // myChart.data.datasets[0].data[2] = localStorage.getItem('thirdGuessStat');
myChart.update(); // myChart.update();
} // }
const myChart = new Chart( // const myChart = new Chart(
document.getElementById('myChart'), // document.getElementById('myChart'),
config // config
); // );
function preloadImage(url) function preloadImage(url)
{ {
var img=new Image(); var img=new Image();
@ -1591,4 +1624,9 @@ function resetFunction() {
} }
} }
function remember(){
localStorage.setItem('archiveButtonPressed','true');
document.getElementsByClassName("gif")[0].style.display="none";
}
//window.localStorage.clear(); //window.localStorage.clear();

BIN
new.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
new.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
new2.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -26,6 +26,16 @@
font-size: 1.5em; font-size: 1.5em;
} }
.gif{
transform:rotate(60deg);
width: 35px;
margin-left: 5px;
top:2px;
padding-right: 5px;
position:absolute;
display:none;
}
.resultImage{ .resultImage{
/* padding-right: 8px; */ /* padding-right: 8px; */
display: flex; display: flex;
@ -413,6 +423,14 @@ i{
margin-right: auto; margin-right: auto;
} }
#shareResultCalender{
background-color: green;
margin-top: 20px;
bottom: 5px;
display:block;
margin-left: auto;
margin-right: auto;
}
#countDown{ #countDown{
display: none; display: none;
} }