Merge pull request #2 from gocivici/thankyou-screen-and-archive

Thankyou screen and archive
This commit is contained in:
Görkem 2022-10-31 15:37:00 +02:00 committed by GitHub
commit a643b1f11b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 204 additions and 84 deletions

View File

@ -38,7 +38,7 @@
<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="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>
@ -88,7 +88,7 @@
<div id="stats" class="overlay">
<div class="popup">
<h2>Stats</h2>
<h2>Archive</h2>
<h3>October 2022</h3>
<div class="archive">
@ -141,20 +141,21 @@
<div class="calendar__number">29</div>
<div class="calendar__number">30</div>
<div class="calendar__number">31</div>
<div class="calendar__number">1</div>
</div>
</div>
</div>
<div class="chartNumber">
<!-- <div class="chartNumber">
<canvas id="myChart"></canvas>
</div>
</div> -->
<a class="close" href="#">&times;</a>
<!-- <h3>Streak</h3> -->
<!-- <div id="streakNumber" class="content">
your stats
</div> -->
<button onclick="resetFunction();"class="resetButton">Reset Stats</button>
<input onclick="copyToClipboardCalendar()" type="button" id="shareResultCalender" value="Share Total Result">
<!-- <button onclick="resetFunction();"class="resetButton">Reset Stats</button> -->
</div>
</div>

257
main.js
View File

@ -10,6 +10,11 @@
//pre-load images
//image placeholder
// gameover movie name
getReady()
function getReady() {
window.addEventListener ("load", function() {
loader.style.display = 'none';
@ -23,12 +28,20 @@ guess='Skipped';
localStorage.setItem('playedBefore',"true");
}
if(localStorage.getItem('archiveButtonPressed')){
document.getElementsByClassName("gif")[0].style.display="none";
}
var buttonNo = 0;
bonusRoundState = false;
var playedBefore = false;
var sameDay = false;
}
for (var i = 0; i < localStorage.length; i++){
console.log(localStorage.key(i));
}
@ -36,6 +49,9 @@ for (var i = 0; i < localStorage.length; i++){
function revealButtons(g = guessNo){
picButtons = document.getElementsByClassName('imageButton');
picButtons[g].classList.add('active');
picButtons[0].style.display = "none";
picButtons[1].style.display = "none";
picButtons[2].style.display = "none";
for (var i = 0; i <= g; i++){
console.log("revealButton guess no " + guessNo);
picButtons[i].style.display = "inline";
@ -1056,68 +1072,84 @@ var movies = [
];
var pix = [];
// autocomplete(document.getElementById("guess"), movies);
var gameBeginning = new Date('September 30, 2022 00:00:00');
var gameBeginning = new Date('October 1, 2022 00:00:00');
var countDownTime = new Date();
var present_date = new Date();
// var present_date = new Date('November 1, 2022 00:00:00');
// var present_date = new Date('September 26, 2022 00:00:00');
// gameBeginning = new Date(gameBeginning.getTime() + 0 * 60 * 1000);
console.log(gameBeginning.getTimezoneOffset());
// console.log(gameBeginning.getTimezoneOffset());
dayCounter();
console.log("gameBeginning: ",gameBeginning);
console.log("now: ",present_date);
if(dayCount>30){
document.getElementsByClassName("gif")[0].style.display="block";
}
// console.log("gameBeginning: ",gameBeginning);
// console.log("now: ",present_date);
// console.log("Current dayCount: ", dayCount)
// console.log(textResult);
function dayCounter(){
dayCount = Math.floor((present_date - gameBeginning) / (1000 * 60 * 60 * 24));
console.log("dayCount: " + dayCount);
return dayCount;
}
markCalendar();
function markCalendar() {
calendarResult=" "
winCount = 0;
loseCount = 0;
dates = document.getElementsByClassName('calendar__number');
console.log(dates[10].innerHTML);
console.log("dateslength: " + dates.length);
var tag = [];
for (var i = 0; i < dates.length; i++) {
if (dates[i].innerHTML==dayCount) {
dates[i].classList.add('current');
dates[i+1].classList.add('current');
}
for (var j = 0; j <= i; j++) {
if (localStorage.getItem('day'+(j+1))) {
if (localStorage.getItem('day'+(j+1))=='true') {
dates[j].classList.add('won');
if (localStorage.getItem('day'+(i))) {
if (localStorage.getItem('day'+(i))=='true') {
dates[i].classList.add('won');
calendarResult+="🟩"
if((i+6)%7==0){calendarResult+="\n"}
winCount=winCount + 1;
} else if (localStorage.getItem('day'+(j+1))=='false') {
dates[j].classList.add('lost');
} else if (localStorage.getItem('day'+(i))=='false') {
dates[i].classList.add('lost');
calendarResult+="🟥"
if((i+6)%7==0){calendarResult+="\n"}
loseCount=loseCount + 1;
}
}else {
dates[j].classList.add('past');
dates[j] = document.createElement('a');
dates[i].classList.add('past');
dates[i] = document.createElement('a');
calendarResult+="🟧"
if((i+6)%7==0){calendarResult+="\n"}
//dates[j].setAttribute('href','#');
if(localStorage.getItem("playedToday")){
// dates[j].setAttribute('onclick','getArchive(' + (j+1) +')');
// if(localStorage.getItem("playedToday")){
dates[i].setAttribute('onclick','getArchive(' + (i+1) +')');
// dates[j] = "<a href='#'>" + dates[j] + "</a>";
}
}
// }
// dates[j] = "<a href='" + dayCount + "'>" + dates[j] + "</a>";
//tag[j].appendChild(dates[j]);
//console.log(tag[j]);
console.log(dates[j]);
}
// console.log(dates[j]);
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("lose:"+ loseCount)
winPerc.textContent = Math.ceil(winCount/(winCount+loseCount)*100)+"%";
@ -1157,7 +1189,24 @@ function clearGuess() {
document.getElementById("shareResult").style.display = "none";
document.getElementById("guessForm").style.display = "block";
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("movieFrame").style.display = "block";
document.getElementsByClassName("resultContainer")[0].style.display="none";
document.getElementsByClassName("picButtons")[0].style.display="block";
document.getElementById("movieName").innerHTML="";
document.getElementById("bonusQuestion").innerHTML="";
tempButton = document.getElementsByClassName("imageButton");
for (let i = 0; i < 3; i++) {
tempButton[i].classList.remove("bonusScreen");
}
// revealButtons(2);
// document.getElementById("movieFrame").style.display = "block";
// document.getElementById("resultContainer").style.display = "none";
}
@ -1174,15 +1223,15 @@ streakNumber.textContent =localStorage.getItem('streak');
textResult=localStorage.getItem('result')
document.getElementById("movieName").innerHTML = localStorage.getItem('movieName')
console.log("played before: ",playedBefore);
console.log(localStorage.getItem('firstGuess'));
console.log(localStorage.getItem('secondGuess'));
// console.log("played before: ",playedBefore);
// console.log(localStorage.getItem('firstGuess'));
// console.log(localStorage.getItem('secondGuess'));
if(localStorage.getItem('guessNo')){guessNo=localStorage.getItem('guessNo')};
feedback.textContent = "🩸 " + (3-guessNo) + " guesses remaining";
if(localStorage.getItem('result')) {localStorage.setItem('result', textResult);}
if(localStorage.getItem('firstGuess')){firstGuess.textContent = "❌ " + localStorage.getItem('firstGuess');document.getElementById("firstGuess").style.display = "block";}
if(localStorage.getItem('secondGuess')){secondGuess.textContent = "❌ " + localStorage.getItem('secondGuess');document.getElementById("secondGuess").style.display = "block";}
if(localStorage.getItem('winningGuess')||localStorage.getItem('lost')){document.getElementById("resultText").innerHTML =textResult;document.getElementById("movieFrame").style.display = "none";document.getElementsByClassName("resultContainer")[0].style.display="flex";document.getElementsByClassName("picButtons")[0].style.display="none";revealButtons(2);document.getElementById("feedback").innerHTML = "Next movie at <b>midnight!</b> 🕛";document.getElementById("shareResult").style.display = "block";document.getElementById("countDown").style.display = "block";document.getElementById("footer").style.display = "block";document.getElementById("guessForm").style.display = "none";document.getElementById("firstGuess").style.display = "none";document.getElementById("secondGuess").style.display = "none";document.getElementById("resultText").style.display="block";}else {document.getElementById("shareResult").style.display = "none";document.getElementById("guessForm").style.display = "block";document.getElementById("resultText").style.display="none";};
if(localStorage.getItem('winningGuess')||localStorage.getItem('lost')){document.getElementById("resultText").innerHTML =textResult;document.getElementById("movieFrame").style.display = "none";document.getElementsByClassName("resultContainer")[0].style.display="flex";document.getElementsByClassName("picButtons")[0].style.display="none";document.getElementById("feedback").innerHTML = "Next movie at <b>midnight!</b> 🕛";document.getElementById("shareResult").style.display = "block";document.getElementById("countDown").style.display = "block";document.getElementById("footer").style.display = "block";document.getElementById("guessForm").style.display = "none";document.getElementById("firstGuess").style.display = "none";document.getElementById("secondGuess").style.display = "none";document.getElementById("resultText").style.display="block";}else {document.getElementById("resultText").innerHTML =textResult;document.getElementById("movieFrame").style.display = "block";document.getElementsByClassName("resultContainer")[0].style.display="none";document.getElementsByClassName("picButtons")[0].style.display="block";document.getElementById("shareResult").style.display = "none";document.getElementById("countDown").style.display = "none";document.getElementById("footer").style.display = "block";document.getElementById("guessForm").style.display = "block";};
if(localStorage.getItem('lost')){ document.getElementById("congratz").innerHTML = "You lost☠"; document.getElementsByClassName("resultContainer")[0].style.borderColor = "#C62828";}
secondGuess.textContent = "❌ " + localStorage.getItem('secondGuess');
revealButtons();
@ -1194,7 +1243,9 @@ markCalendar();
}
checkingGuess();
window.onload = deathOftheDay();
// console.log(dayCount);
@ -1202,8 +1253,9 @@ window.onload = deathOftheDay();
function deathOftheDay(x=dayCount){
pix = [];
movieOfTheDay = movies[x-1];
movieOfTheDay = movies[x];
if (x<31){
document.getElementById("movieFrame").style.display = "block";
for (let i = 1; i < 4; i++) {
pix.push("images/"+movieOfTheDay[0]+"/"+i+".png");
preloadImage("images/"+movieOfTheDay[0]+"/"+i+".png");
@ -1213,6 +1265,13 @@ window.onload = deathOftheDay();
console.log('Movie: ', movieOfTheDay[0]);
console.log('Array: ', pix);
showPic();
} else{
document.getElementById("movieFrame").style.display = "none";
document.getElementById("guessForm").style.display = "none";
document.getElementsByClassName("picButtons")[0].style.display="none";
document.getElementById("movieName").innerHTML = "<br><br>Thanks for playing!";
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.setAttribute('onclick','getImage()');
@ -1268,18 +1327,21 @@ window.onload = deathOftheDay();
document.getElementById("skipBonusGuess").style.display="none";
document.getElementsByClassName("picButtons")[0].style.display="none";
showPic(movieOfTheDay[1])
console.log(buttonNo);
addData();
// console.log(buttonNo);
// addData();
}
setResult();
function setResult(){
if(!localStorage.getItem('result')){
textResult = "🔪";
}else{
textResult = localStorage.getItem('result');
}
}
function checkGuess() {
localStorage.setItem('playedBefore','true');
console.log("day count:" + dayCount);
// console.log("day count:" + dayCount);
let myGuess = guess
if (myGuess === movieOfTheDay[0]) {
@ -1289,8 +1351,9 @@ console.log("day count:" + dayCount);
if(guessNo==2){localStorage.setItem('thirdGuessStat',parseInt(localStorage.getItem('thirdGuessStat')) + 1);}
localStorage.setItem('streak',parseInt(localStorage.getItem('streak')) + 1);
localStorage.setItem('day'+dayCount,'true');
// document.getElementById("movieFrame").src = "images/"+movieOfTheDay+"/poster.jpg";
// console.log(localStorage.getItem('day'+dayCount));
console.log(localStorage.getItem('day'+dayCount));
streakNumber.textContent = localStorage.getItem('streak');
document.getElementById("guessForm").style.display = "none";
document.getElementById("feedback").style.display = "none";
@ -1313,14 +1376,14 @@ console.log("day count:" + dayCount);
for (let i = 0; i < 3; i++) {
tempButton[i].classList.add("bonusScreen");
}
document.getElementsByClassName("imageButton")[0].style.fontSize = "32px";
// document.getElementsByClassName("imageButton")[0].style.fontSize = "32px";
localStorage.setItem("winningGuess", guess);
localStorage.setItem("playedToday", "yes");
document.getElementById("firstGuess").style.display = "none";
document.getElementById("secondGuess").style.display = "none";
dates[dayCount-1].classList.add('won');
dates[dayCount].classList.add('won');
revealButtons(2);
} else if(guessNo==1){
@ -1411,7 +1474,7 @@ autoCompleteJS.input.addEventListener("selection", function (event) {
guess = event.detail.selection.value
autoCompleteJS.input.value = guess;
// Console log autoComplete data feedback
console.log(event.detail.selection.value);
// console.log(event.detail.selection.value);
checkGuess();
});
@ -1425,14 +1488,46 @@ 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){
for (var i = 0; i < dates.length; i++) {
dates[i].classList.remove('current');
}
present_date.setMonth(9,j);
// present_date.setDate(j);
console.log(present_date);
getReady();
var pix = [];
dayCounter();
markCalendar();
var points = "⬛⬛⬛"
firstCheck();
clearGuess();
revealButtons();
checkingGuess();
deathOftheDay();
setResult();
dates[d-1].classList.remove('current');
d = j;
dates[j-1].classList.add('current');
deathOftheDay(j);
document.getElementById('guess').value = "";
// dayCounter();
// firstCheck();
// revealButtons();
// clearGuess();
// dates[d-1].classList.remove('current');
// d = j;
// dates[j-1].classList.add('current');
// deathOftheDay(j);
// document.getElementById('guess').value = "";
location.href='#';
//window.open("#");
}
@ -1477,45 +1572,45 @@ const config = {
}
};
var x = setInterval(function() {
// countDownTime.setDate(Math.floor((present_date - gameBeginning) / (1000 * 60 * 60 * 24))+2);
dayCounter();
// var x = setInterval(function() {
// // countDownTime.setDate(Math.floor((present_date - gameBeginning) / (1000 * 60 * 60 * 24))+2);
// dayCounter();
dateVariable = present_date.getDate()
countDownTime.setDate(dateVariable+1);
countDownTime.setHours(0);
countDownTime.setMinutes(0);
countDownTime.setSeconds(0);
var now = new Date();
// console.log("now: ",now);
var remainingTime = countDownTime - now;
const second = 1000;
const minute = second * 60;
const hour = minute * 60;
const day = hour * 24;
hoursLeft = Math.trunc((remainingTime % day) / hour);
minutesLeft = Math.trunc((remainingTime % hour) / minute);
secondsLeft = Math.trunc((remainingTime % minute) / second);
document.getElementById("countDown").innerHTML = hoursLeft + "h "
+ minutesLeft + "m " + secondsLeft + "s ";
//console.log(remainingTime);
// console.log(localStorage.getItem('day'));
// console.log("day count: " + dayCount);
dayCount = Math.floor((now - gameBeginning) / (1000 * 60 * 60 * 24));
if (localStorage.getItem('day')!=dayCount) {
window.location.reload();
}
}, 1000);
function addData(){
myChart.data.datasets[0].data[0] = localStorage.getItem('firstGuessStat');
myChart.data.datasets[0].data[1] = localStorage.getItem('secondGuessStat');
myChart.data.datasets[0].data[2] = localStorage.getItem('thirdGuessStat');
myChart.update();
}
const myChart = new Chart(
document.getElementById('myChart'),
config
);
// dateVariable = present_date.getDate()
// countDownTime.setDate(dateVariable+1);
// countDownTime.setHours(0);
// countDownTime.setMinutes(0);
// countDownTime.setSeconds(0);
// var now = new Date();
// // console.log("now: ",now);
// var remainingTime = countDownTime - now;
// const second = 1000;
// const minute = second * 60;
// const hour = minute * 60;
// const day = hour * 24;
// hoursLeft = Math.trunc((remainingTime % day) / hour);
// minutesLeft = Math.trunc((remainingTime % hour) / minute);
// secondsLeft = Math.trunc((remainingTime % minute) / second);
// document.getElementById("countDown").innerHTML = hoursLeft + "h "
// + minutesLeft + "m " + secondsLeft + "s ";
// //console.log(remainingTime);
// // console.log(localStorage.getItem('day'));
// // console.log("day count: " + dayCount);
// dayCount = Math.floor((now - gameBeginning) / (1000 * 60 * 60 * 24));
// if (localStorage.getItem('day')!=dayCount) {
// // window.location.reload();
// }
// }, 1000);
// function addData(){
// myChart.data.datasets[0].data[0] = localStorage.getItem('firstGuessStat');
// myChart.data.datasets[0].data[1] = localStorage.getItem('secondGuessStat');
// myChart.data.datasets[0].data[2] = localStorage.getItem('thirdGuessStat');
// myChart.update();
// }
// const myChart = new Chart(
// document.getElementById('myChart'),
// config
// );
function preloadImage(url)
{
var img=new Image();
@ -1528,4 +1623,10 @@ function resetFunction() {
}
}
function remember(){
localStorage.setItem('archiveButtonPressed','true');
document.getElementsByClassName("gif")[0].style.display="none";
}
//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;
}
.gif{
transform:rotate(60deg);
width: 35px;
margin-left: 5px;
top:2px;
padding-right: 5px;
position:absolute;
display:none;
}
.resultImage{
/* padding-right: 8px; */
display: flex;
@ -413,6 +423,14 @@ i{
margin-right: auto;
}
#shareResultCalender{
background-color: green;
margin-top: 20px;
bottom: 5px;
display:block;
margin-left: auto;
margin-right: auto;
}
#countDown{
display: none;
}