2022-09-19 07:39:13 -05:00
//<TO-DO>
2023-09-30 16:05:47 -05:00
//change local variables with new ones
2022-09-19 07:39:13 -05:00
//-FIX IMAGE RATIOS
//-FIX CALENDAR
2022-09-25 05:12:37 -05:00
//-ADD SUPPORT PAGE
//archive doesn't work constanlt refreshing
2023-09-30 16:05:47 -05:00
// var fake_date = new Date("October 4, 2023 08:00:00");
2022-09-19 07:39:13 -05:00
// Date = function(){return fake_date;};
// Date.now = () => fake_date.getTime();
2022-09-25 05:12:37 -05:00
//json sitrgifiy local objects
//pre-load images
//image placeholder
// gameover movie name
2024-09-22 20:10:30 -05:00
var gameBeginning = new Date ( 'October 1, 2024 00:00:00' ) ;
var countDownTime = new Date ( ) ;
var present _date = new Date ( ) ;
dayCounter ( ) ;
window . addEventListener ( "load" , function ( ) {
loader . style . display = 'none' ;
} ) ;
if ( dayCount < 0 ) {
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>Horrordle will be back starting October 1st!" ;
document . getElementById ( "feedback" ) . innerHTML = " <br><br> <a href='https://twitter.com/horrordle'>follow me on twitter for updates</a><br><br> " ;
2024-09-29 12:24:18 -05:00
} else if ( dayCount > 30 ) {
2024-09-22 20:10:30 -05:00
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='https://twitter.com/horrordle'>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." ;
} else {
2022-10-27 07:37:49 -05:00
getReady ( )
2022-10-31 08:35:47 -05:00
2022-10-27 07:37:49 -05:00
function getReady ( ) {
2022-09-26 08:14:06 -05:00
2024-09-22 20:10:30 -05:00
2022-09-26 08:40:31 -05:00
guess = 'Skipped' ;
2022-09-26 08:14:06 -05:00
2024-09-29 12:24:18 -05:00
if ( ! localStorage . getItem ( 'playedBefore__' ) ) {
2022-09-25 13:45:13 -05:00
// window.location = window.location.href + "#info";
2022-09-28 10:44:13 -05:00
window . location = "https://gocivici.github.io/horrordle/#info"
2022-09-28 10:35:39 -05:00
// window.location = "file:///C:/Users/gogob/Documents/dEATHDLE/Test/index.html#info"
2024-09-29 12:24:18 -05:00
localStorage . setItem ( 'playedBefore__' , "true" ) ;
2022-09-25 13:45:13 -05:00
}
2022-09-25 05:12:37 -05:00
2024-09-29 12:24:18 -05:00
if ( localStorage . getItem ( 'archiveButtonPressed__' ) ) {
2022-10-31 08:35:47 -05:00
document . getElementsByClassName ( "gif" ) [ 0 ] . style . display = "none" ;
}
2022-09-25 13:45:13 -05:00
var buttonNo = 0 ;
2022-09-28 10:35:39 -05:00
2022-09-25 13:45:13 -05:00
bonusRoundState = false ;
2022-08-07 03:40:24 -05:00
var playedBefore = false ;
2022-09-07 09:05:49 -05:00
var sameDay = false ;
2022-10-27 07:37:49 -05:00
}
2022-08-07 03:40:24 -05:00
for ( var i = 0 ; i < localStorage . length ; i ++ ) {
console . log ( localStorage . key ( i ) ) ;
}
2022-09-25 08:26:54 -05:00
function revealButtons ( g = guessNo ) {
picButtons = document . getElementsByClassName ( 'imageButton' ) ;
picButtons [ g ] . classList . add ( 'active' ) ;
2022-10-27 07:37:49 -05:00
picButtons [ 0 ] . style . display = "none" ;
picButtons [ 1 ] . style . display = "none" ;
picButtons [ 2 ] . style . display = "none" ;
2023-09-30 16:05:47 -05:00
picButtons [ 3 ] . style . display = "none" ;
2022-09-25 08:26:54 -05:00
for ( var i = 0 ; i <= g ; i ++ ) {
console . log ( "revealButton guess no " + guessNo ) ;
picButtons [ i ] . style . display = "inline" ;
picButtons [ i ] . classList . remove ( 'active' ) ;
}
2022-09-25 13:45:13 -05:00
showPic ( ) ;
// picButtons[g].classList.add('active');
2022-09-25 08:26:54 -05:00
}
// document.getElementById("button2").style.display = "none"
// document.getElementById("button3").style.display = "none"
2022-10-09 10:14:30 -05:00
// document.getElementById("footer").style.display = "block"
2022-08-07 03:40:24 -05:00
2022-09-11 03:32:29 -05:00
2022-08-07 03:40:24 -05:00
var pix = [ ] ;
2022-09-20 08:30:32 -05:00
// autocomplete(document.getElementById("guess"), movies);
2024-09-22 20:10:30 -05:00
// var gameBeginning = new Date('October 1, 2024 00:00:00');
// var countDownTime = new Date();
// var present_date = new Date();
2022-10-28 04:26:17 -05:00
// var present_date = new Date('November 1, 2022 00:00:00');
2022-09-30 14:51:26 -05:00
// var present_date = new Date('September 26, 2022 00:00:00');
2022-09-11 07:41:49 -05:00
2022-08-07 03:40:24 -05:00
// gameBeginning = new Date(gameBeginning.getTime() + 0 * 60 * 1000);
2022-10-27 07:37:49 -05:00
// console.log(gameBeginning.getTimezoneOffset());
2022-10-31 08:35:47 -05:00
if ( dayCount > 30 ) {
document . getElementsByClassName ( "gif" ) [ 0 ] . style . display = "block" ;
}
2022-10-27 07:37:49 -05:00
// console.log("gameBeginning: ",gameBeginning);
// console.log("now: ",present_date);
// console.log("Current dayCount: ", dayCount)
2022-09-19 07:39:13 -05:00
2022-09-26 03:23:35 -05:00
// console.log(textResult);
2022-10-31 08:35:47 -05:00
2022-09-19 07:39:13 -05:00
2022-08-07 03:40:24 -05:00
markCalendar ( ) ;
2024-09-22 20:10:30 -05:00
2022-08-07 03:40:24 -05:00
function markCalendar ( ) {
2022-10-31 08:35:47 -05:00
calendarResult = " "
2022-09-28 10:35:39 -05:00
winCount = 0 ;
loseCount = 0 ;
2022-08-07 03:40:24 -05:00
dates = document . getElementsByClassName ( 'calendar__number' ) ;
2022-10-27 07:37:49 -05:00
console . log ( "dateslength: " + dates . length ) ;
2024-09-22 20:10:30 -05:00
console . log ( "datesObejcts: " + dates ) ;
2022-08-07 03:40:24 -05:00
var tag = [ ] ;
for ( var i = 0 ; i < dates . length ; i ++ ) {
if ( dates [ i ] . innerHTML == dayCount ) {
2022-10-27 07:37:49 -05:00
dates [ i + 1 ] . classList . add ( 'current' ) ;
}
2022-09-26 08:14:06 -05:00
2024-09-29 12:24:18 -05:00
if ( localStorage . getItem ( 'day__' + ( i ) ) ) {
if ( localStorage . getItem ( 'day__' + ( i ) ) == 'true' ) {
2022-10-27 07:37:49 -05:00
dates [ i ] . classList . add ( 'won' ) ;
2022-10-31 08:35:47 -05:00
calendarResult += "🟩"
if ( ( i + 6 ) % 7 == 0 ) { calendarResult += "\n" }
2022-09-28 10:35:39 -05:00
winCount = winCount + 1 ;
2024-09-29 12:24:18 -05:00
} else if ( localStorage . getItem ( 'day__' + ( i ) ) == 'false' ) {
2022-10-27 07:37:49 -05:00
dates [ i ] . classList . add ( 'lost' ) ;
2022-10-31 08:35:47 -05:00
calendarResult += "🟥"
if ( ( i + 6 ) % 7 == 0 ) { calendarResult += "\n" }
2022-09-28 10:35:39 -05:00
loseCount = loseCount + 1 ;
2022-08-07 03:40:24 -05:00
}
2023-09-30 16:05:47 -05:00
} else if ( dates [ i ] . innerHTML <= dayCount ) {
2022-08-07 03:40:24 -05:00
2022-10-27 07:37:49 -05:00
dates [ i ] . classList . add ( 'past' ) ;
dates [ i ] = document . createElement ( 'a' ) ;
2022-10-31 08:35:47 -05:00
calendarResult += "🟧"
if ( ( i + 6 ) % 7 == 0 ) { calendarResult += "\n" }
2022-08-07 03:40:24 -05:00
//dates[j].setAttribute('href','#');
2024-09-29 12:24:18 -05:00
if ( localStorage . getItem ( "playedToday__" ) ) {
2023-09-30 16:05:47 -05:00
// dates[i].setAttribute('onclick','getArchive(' + (i+1) +')');
2022-09-25 05:12:37 -05:00
// dates[j] = "<a href='#'>" + dates[j] + "</a>";
}
2023-09-30 16:05:47 -05:00
}
2022-08-07 03:40:24 -05:00
// dates[j] = "<a href='" + dayCount + "'>" + dates[j] + "</a>";
//tag[j].appendChild(dates[j]);
//console.log(tag[j]);
2022-10-27 07:37:49 -05:00
// console.log(dates[j]);
2022-08-07 03:40:24 -05:00
2022-10-27 07:37:49 -05:00
// console.log(dates[i]);
2022-08-07 03:40:24 -05:00
}
2022-10-31 08:35:47 -05:00
// calendarResult = calendarResult.replace(/(.{8})/g, "$1|");
console . log ( "calo reso" + calendarResult ) ;
2022-09-28 10:35:39 -05:00
console . log ( "win:" + winCount )
console . log ( "lose:" + loseCount )
winPerc . textContent = Math . ceil ( winCount / ( winCount + loseCount ) * 100 ) + "%" ;
totalPlays . textContent = winCount + loseCount
2022-08-07 03:40:24 -05:00
}
var points = "⬛⬛⬛"
//check if the user played this before
2022-09-25 08:26:54 -05:00
firstCheck ( ) ;
revealButtons ( ) ;
2022-09-11 03:32:29 -05:00
function firstCheck ( ) {
guessNo = 0 ;
2022-08-07 03:40:24 -05:00
feedback . textContent = "🩸 " + ( 3 - guessNo ) + " guesses remaining" ;
2024-09-29 12:24:18 -05:00
if ( ! localStorage . getItem ( 'streak__' ) ) { localStorage . setItem ( 'streak__' , 0 ) }
if ( ! localStorage . getItem ( 'firstGuessStat__' ) ) { localStorage . setItem ( 'firstGuessStat__' , 0 ) }
if ( ! localStorage . getItem ( 'secondGuessStat__' ) ) { localStorage . setItem ( 'secondGuessStat__' , 0 ) }
if ( ! localStorage . getItem ( 'thirdGuessStat__' ) ) { localStorage . setItem ( 'thirdGuessStat__' , 0 ) }
2022-09-11 03:32:29 -05:00
}
2022-09-07 09:05:49 -05:00
2022-08-07 03:40:24 -05:00
2022-09-26 03:23:35 -05:00
2022-08-07 03:40:24 -05:00
function clearGuess ( ) {
2024-09-29 12:24:18 -05:00
localStorage . removeItem ( 'firstGuess__' ) ;
localStorage . removeItem ( 'secondGuess__' ) ;
localStorage . removeItem ( 'guessNo__' ) ;
localStorage . removeItem ( 'winningGuess__' ) ;
localStorage . removeItem ( 'lost__' ) ;
localStorage . removeItem ( 'movieName__' ) ;
localStorage . removeItem ( "playedToday__" ) ;
localStorage . removeItem ( 'result__' ) ;
2022-09-11 03:32:29 -05:00
document . getElementById ( "firstGuess" ) . style . display = "none" ;
document . getElementById ( "secondGuess" ) . style . display = "none" ;
2022-09-11 04:00:27 -05:00
document . getElementById ( "shareResult" ) . style . display = "none" ;
document . getElementById ( "guessForm" ) . style . display = "block" ;
2022-10-09 10:14:30 -05:00
document . getElementById ( "countDown" ) . style . display = "none" ;
2022-10-31 08:35:47 -05:00
// document.getElementById("footer").style.display = "none";
2022-10-27 07:37:49 -05:00
// 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";
2022-09-11 10:54:00 -05:00
2022-08-07 03:40:24 -05:00
}
2022-09-25 05:12:37 -05:00
2022-08-07 03:40:24 -05:00
function checkingGuess ( ) {
2022-09-07 09:05:49 -05:00
2022-08-07 03:40:24 -05:00
2024-09-29 12:24:18 -05:00
streakNumber . textContent = localStorage . getItem ( 'streak__' ) ;
2022-09-28 10:35:39 -05:00
2024-09-29 12:24:18 -05:00
if ( localStorage . getItem ( 'day__' ) == dayCount ) {
2022-08-07 03:40:24 -05:00
playedBefore = true ;
2024-09-29 12:24:18 -05:00
textResult = localStorage . getItem ( 'result__' )
document . getElementById ( "movieName" ) . innerHTML = localStorage . getItem ( 'movieName__' )
2022-09-25 13:45:13 -05:00
2022-10-27 07:37:49 -05:00
// console.log("played before: ",playedBefore);
// console.log(localStorage.getItem('firstGuess'));
// console.log(localStorage.getItem('secondGuess'));
2024-09-29 12:24:18 -05:00
if ( localStorage . getItem ( 'guessNo__' ) ) { guessNo = localStorage . getItem ( 'guessNo__' ) } ;
2022-08-07 03:40:24 -05:00
feedback . textContent = "🩸 " + ( 3 - guessNo ) + " guesses remaining" ;
2024-09-29 12:24:18 -05:00
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" ; }
2024-09-29 12:56:31 -05:00
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" ; } ;
2024-09-29 12:24:18 -05:00
if ( localStorage . getItem ( 'lost__' ) ) { document . getElementById ( "congratz" ) . innerHTML = "You lost☠️ " ; document . getElementsByClassName ( "resultContainer" ) [ 0 ] . style . borderColor = "#C62828" ; }
secondGuess . textContent = "❌ " + localStorage . getItem ( 'secondGuess__' ) ;
2022-09-25 08:26:54 -05:00
revealButtons ( ) ;
2022-08-07 03:40:24 -05:00
} else {
clearGuess ( ) ;
2024-09-29 12:24:18 -05:00
localStorage . setItem ( 'day__' , dayCount ) ;
2022-08-07 03:40:24 -05:00
}
2022-09-25 05:12:37 -05:00
markCalendar ( ) ;
2022-09-28 10:35:39 -05:00
2022-08-07 03:40:24 -05:00
}
2023-09-30 16:05:47 -05:00
2022-10-27 07:37:49 -05:00
2022-09-25 05:12:37 -05:00
window . onload = deathOftheDay ( ) ;
2023-09-30 16:05:47 -05:00
checkingGuess ( ) ;
2022-10-27 07:37:49 -05:00
2022-09-25 05:12:37 -05:00
// console.log(dayCount);
2022-08-07 03:40:24 -05:00
2023-10-19 03:12:43 -05:00
async function attemptImageLoad ( url ) {
return new Promise ( ( resolve , reject ) => {
const image = new Image ( ) ;
2022-08-07 03:40:24 -05:00
2023-10-19 03:12:43 -05:00
image . addEventListener ( 'error' , ( ) => {
reject ( image ) ;
} ) ;
2022-08-07 03:40:24 -05:00
2023-10-19 03:12:43 -05:00
image . addEventListener ( 'load' , ( ) => {
resolve ( image ) ;
} ) ;
image . src = url ;
} )
}
async function deathOftheDay ( x = dayCount ) {
2022-08-07 03:40:24 -05:00
pix = [ ] ;
2024-09-22 20:10:30 -05:00
movieOfTheDay = movies [ x ] ;
2022-10-28 04:26:17 -05:00
document . getElementById ( "movieFrame" ) . style . display = "block" ;
2023-10-19 03:12:43 -05:00
let imageLocation = 'images'
try {
2024-09-29 12:24:18 -05:00
await attemptImageLoad ( ` ${ imageLocation } / ${ movieOfTheDay [ 0 ] } /1.jpg ` )
2023-10-19 03:12:43 -05:00
} catch ( e ) {
imageLocation = 'images/2022'
}
2023-09-30 16:05:47 -05:00
for ( let i = 1 ; i < 5 ; i ++ ) {
2024-09-29 12:24:18 -05:00
pix . push ( imageLocation + "/" + movieOfTheDay [ 0 ] + "/" + i + ".jpg" ) ;
preloadImage ( imageLocation + "/" + movieOfTheDay [ 0 ] + "/" + i + ".jpg" ) ;
2022-08-07 03:40:24 -05:00
}
2022-09-28 10:35:39 -05:00
// preloadImage("images/"+movieOfTheDay[0]+"/poster.png");
2023-10-19 03:12:43 -05:00
document . getElementById ( "posterFrame" ) . src = imageLocation + "/" + movieOfTheDay [ 0 ] + "/poster.jpg" ;
2022-09-25 13:45:13 -05:00
console . log ( 'Movie: ' , movieOfTheDay [ 0 ] ) ;
2022-08-07 03:40:24 -05:00
console . log ( 'Array: ' , pix ) ;
2022-09-25 08:26:54 -05:00
showPic ( ) ;
2024-09-22 20:10:30 -05:00
2022-09-25 08:26:54 -05:00
// picButton = document.getElementsByClassName('picButton');
// picButton.setAttribute('onclick','getImage()');
}
function showPic ( p = guessNo ) {
2022-09-26 08:14:06 -05:00
// document.getElementById("movieFrame").src = "http://www.deelay.me/3000/https://via.placeholder.com/1920x1080";
2022-09-25 08:26:54 -05:00
document . getElementById ( "movieFrame" ) . src = pix [ p ] ;
2022-09-25 13:45:13 -05:00
buttonNo = p ;
2022-09-25 08:26:54 -05:00
picButtons = document . getElementsByClassName ( 'imageButton' ) ;
2023-09-30 16:05:47 -05:00
for ( let i = 0 ; i < 4 ; i ++ ) {
2022-09-25 08:26:54 -05:00
picButtons [ i ] . classList . remove ( 'active' ) ;
}
picButtons [ p ] . classList . add ( 'active' ) ;
// for (let i = 0; i < 2; i++) {
// const element = array[i];
// }
2022-08-07 03:40:24 -05:00
}
2023-10-19 03:12:43 -05:00
function transitionToCompletedState ( ) {
document . getElementById ( "movieFrame" ) . style . display = "none" ;
document . getElementsByClassName ( "resultContainer" ) [ 0 ] . style . display = "flex" ;
2024-09-29 12:24:18 -05:00
localStorage . setItem ( 'result__' , textResult ) ;
2023-10-19 03:12:43 -05:00
document . getElementById ( "feedback" ) . style . display = "block" ;
document . getElementById ( "feedback" ) . innerHTML = "Next movie at <b>midnight!</b> 🕛 <br>" ;
document . getElementById ( "resultText" ) . innerHTML = textResult ;
document . getElementById ( "resultText" ) . style . display = "block" ;
document . getElementById ( "countDown" ) . style . display = "block" ;
document . getElementById ( "footer" ) . style . display = "block" ;
document . getElementById ( "shareResult" ) . style . display = "block" ;
document . getElementById ( "submitBonusGuess" ) . style . display = "none" ;
document . getElementById ( "skipBonusGuess" ) . style . display = "none" ;
document . getElementsByClassName ( "picButtons" ) [ 0 ] . style . display = "none" ;
showPic ( movieOfTheDay [ 1 ] )
addData ( ) ;
}
2022-09-25 13:45:13 -05:00
function submitBonus ( b = 0 ) {
if ( buttonNo == movieOfTheDay [ 1 ] && b == 0 ) {
2024-09-22 20:10:30 -05:00
// bonusRoundState= true;
document . getElementById ( "bonusQuestion" ) . style . display = "none" ;
// document.getElementById("bonusQuestion").innerHTML ="Bonus Question ⭐"+ "<br />" + "Survivor: "+ movieOfTheDay[2];
2022-09-25 13:45:13 -05:00
2024-09-22 20:10:30 -05:00
// textResult = textResult + "(⭐)"
2022-09-25 13:45:13 -05:00
console . log ( "you win!" )
2022-09-28 10:35:39 -05:00
} else if ( b == 1 ) {
// document.getElementById("bonusQuestion").innerHTML = "Survivor: "+ movieOfTheDay[2];
document . getElementById ( "congratz" ) . innerHTML = "You lost☠️ " ;
document . getElementsByClassName ( "resultContainer" ) [ 0 ] . style . borderColor = "#C62828" ;
2022-09-25 13:45:13 -05:00
}
else {
console . log ( 'you lose' )
2024-09-22 20:10:30 -05:00
// document.getElementById("bonusQuestion").innerHTML = "Bonus Question ❌"+ "<br />" + "Survivor: "+ movieOfTheDay[2];
2022-09-25 13:45:13 -05:00
}
2023-10-19 03:12:43 -05:00
transitionToCompletedState ( )
2022-09-25 13:45:13 -05:00
}
2022-10-27 07:37:49 -05:00
setResult ( ) ;
function setResult ( ) {
2024-09-29 12:24:18 -05:00
if ( ! localStorage . getItem ( 'result__' ) ) {
2022-09-28 10:35:39 -05:00
textResult = "🔪" ;
2022-09-27 10:24:46 -05:00
} else {
2024-09-29 12:24:18 -05:00
textResult = localStorage . getItem ( 'result__' ) ;
2022-10-27 07:37:49 -05:00
}
2022-09-27 10:24:46 -05:00
}
2022-08-07 03:40:24 -05:00
function checkGuess ( ) {
2024-09-29 12:24:18 -05:00
localStorage . setItem ( 'playedBefore__' , 'true' ) ;
2022-09-11 03:32:29 -05:00
2022-10-27 07:37:49 -05:00
// console.log("day count:" + dayCount);
2022-09-20 08:30:32 -05:00
let myGuess = guess
2022-09-26 03:23:35 -05:00
2022-09-25 13:45:13 -05:00
if ( myGuess === movieOfTheDay [ 0 ] ) {
2022-09-26 03:23:35 -05:00
2024-09-29 12:24:18 -05:00
if ( guessNo == 0 ) { localStorage . setItem ( 'firstGuessStat__' , parseInt ( localStorage . getItem ( 'firstGuessStat__' ) ) + 1 ) ; }
if ( guessNo == 1 ) { localStorage . setItem ( 'secondGuessStat__' , parseInt ( localStorage . getItem ( 'secondGuessStat__' ) ) + 1 ) ; }
if ( guessNo == 2 ) { localStorage . setItem ( 'thirdGuessStat__' , parseInt ( localStorage . getItem ( 'thirdGuessStat__' ) ) + 1 ) ; }
localStorage . setItem ( 'streak__' , parseInt ( localStorage . getItem ( 'streak__' ) ) + 1 ) ;
localStorage . setItem ( 'day__' + dayCount , 'true' ) ;
2022-10-27 07:37:49 -05:00
2022-09-19 07:39:13 -05:00
// document.getElementById("movieFrame").src = "images/"+movieOfTheDay+"/poster.jpg";
2024-09-29 12:24:18 -05:00
console . log ( localStorage . getItem ( 'day__' + dayCount ) ) ;
streakNumber . textContent = localStorage . getItem ( 'streak__' ) ;
2022-08-07 03:40:24 -05:00
document . getElementById ( "guessForm" ) . style . display = "none" ;
2022-09-25 13:45:13 -05:00
document . getElementById ( "feedback" ) . style . display = "none" ;
document . getElementById ( "movieName" ) . innerHTML = movieOfTheDay [ 0 ] + " ✅" ;
2022-09-11 03:32:29 -05:00
2024-09-29 12:24:18 -05:00
localStorage . setItem ( 'movieName__' , movieOfTheDay [ 0 ] + " ✅" )
2022-09-29 12:57:17 -05:00
// document.getElementById("bonusQuestion").innerHTML = "⭐BONUS ROUND⭐<br> Can you guess which <b>image</b> contains the survivor?";
2023-10-19 03:12:43 -05:00
2024-09-22 20:10:30 -05:00
// if(movieOfTheDay.length > 1) {
// document.getElementById("bonusQuestion").innerHTML = "⭐BONUS ROUND⭐<br> Use the buttons below to choose the image with the survivor";
// document.getElementById("submitBonusGuess").style.display = "inline";
// document.getElementById("skipBonusGuess").style.display = "inline";
// } else {
// transitionToCompletedState()
// }
2023-10-19 03:12:43 -05:00
2022-08-07 03:40:24 -05:00
textResult = textResult + "🟩" ;
for ( var i = 1 ; i < ( 3 - guessNo ) ; i ++ ) {
textResult = textResult + "⬛" ;
}
2024-09-29 12:24:18 -05:00
localStorage . setItem ( 'result__' , textResult ) ;
2022-09-25 13:45:13 -05:00
// document.getElementById("countDown").style.display = "block";
// document.getElementById("shareResult").style.display = "block";
// document.getElementsByClassName("picButtons")[0].classList.add('bonusScreen')
tempButton = document . getElementsByClassName ( "imageButton" ) ;
for ( let i = 0 ; i < 3 ; i ++ ) {
tempButton [ i ] . classList . add ( "bonusScreen" ) ;
}
2022-10-27 07:37:49 -05:00
// document.getElementsByClassName("imageButton")[0].style.fontSize = "32px";
2024-09-29 12:24:18 -05:00
localStorage . setItem ( "winningGuess__" , guess ) ;
localStorage . setItem ( "playedToday__" , "yes" ) ;
2022-09-25 13:45:13 -05:00
document . getElementById ( "firstGuess" ) . style . display = "none" ;
document . getElementById ( "secondGuess" ) . style . display = "none" ;
2022-10-27 07:37:49 -05:00
dates [ dayCount ] . classList . add ( 'won' ) ;
2024-09-22 20:10:30 -05:00
submitBonus ( 2 )
2022-09-11 09:11:13 -05:00
2022-08-07 03:40:24 -05:00
} else if ( guessNo == 1 ) {
guessNo = guessNo + 1 ;
2024-09-29 12:24:18 -05:00
localStorage . setItem ( 'guessNo__' , guessNo ) ;
2022-09-11 03:32:29 -05:00
feedback . textContent = "🩸 " + ( 3 - guessNo ) + " guesses remaining" ;
2022-08-07 03:40:24 -05:00
document . getElementById ( "movieFrame" ) . src = pix [ guessNo ] ;
2022-09-26 08:14:06 -05:00
firstGuess . textContent = "❌ " + guess ;
2024-09-29 12:24:18 -05:00
localStorage . setItem ( 'firstGuess__' , guess ) ;
2022-08-07 03:40:24 -05:00
document . getElementById ( "firstGuess" ) . style . display = "block" ;
textResult = textResult + "🟥" ;
2024-09-29 12:24:18 -05:00
localStorage . setItem ( 'result__' , textResult ) ;
2022-09-25 08:26:54 -05:00
revealButtons ( ) ;
2022-08-07 03:40:24 -05:00
} else if ( guessNo < 2 ) {
guessNo = guessNo + 1 ;
2024-09-29 12:24:18 -05:00
localStorage . setItem ( 'guessNo__' , guessNo ) ;
2022-09-11 03:32:29 -05:00
feedback . textContent = "🩸 " + ( 3 - guessNo ) + " guesses remaining" ;
2022-08-07 03:40:24 -05:00
document . getElementById ( "movieFrame" ) . src = pix [ guessNo ] ;
2022-09-26 08:14:06 -05:00
secondGuess . textContent = "❌ " + guess ;
2024-09-29 12:24:18 -05:00
localStorage . setItem ( 'secondGuess__' , guess ) ;
2022-08-07 03:40:24 -05:00
document . getElementById ( "secondGuess" ) . style . display = "block" ;
textResult = textResult + "🟥" ;
2024-09-29 12:24:18 -05:00
localStorage . setItem ( 'result__' , textResult ) ;
2022-09-25 08:26:54 -05:00
revealButtons ( ) ;
2022-08-07 03:40:24 -05:00
}
else {
2022-09-28 10:35:39 -05:00
// guessNo = guessNo + 1;
2022-08-07 03:40:24 -05:00
feedback . textContent = "GAME OVER" ;
2022-09-28 10:35:39 -05:00
// document.getElementById("movieName").innerHTML = movieOfTheDay[0];
2022-08-07 03:40:24 -05:00
textResult = textResult + "🟥" ;
2022-09-28 10:35:39 -05:00
document . getElementById ( "guessForm" ) . style . display = "none" ;
document . getElementById ( "feedback" ) . style . display = "none" ;
document . getElementById ( "firstGuess" ) . style . display = "none" ;
document . getElementById ( "secondGuess" ) . style . display = "none" ;
2024-09-29 12:24:18 -05:00
localStorage . setItem ( 'guessNo__' , guessNo ) ;
localStorage . setItem ( 'streak__' , 0 ) ;
localStorage . setItem ( 'day__' + dayCount , 'false' ) ;
localStorage . setItem ( "lost__" , "yes" ) ;
localStorage . setItem ( "playedToday__" , "yes" ) ;
2023-10-06 09:06:49 -05:00
dates [ dayCount ] . classList . add ( 'lost' ) ;
2022-09-28 10:35:39 -05:00
submitBonus ( 1 ) ;
2022-08-07 03:40:24 -05:00
}
2022-10-11 08:55:04 -05:00
2022-08-07 03:40:24 -05:00
console . log ( textResult ) ;
2022-09-11 03:32:29 -05:00
document . getElementById ( "guessForm" ) . reset ( ) ;
2022-09-25 05:12:37 -05:00
markCalendar ( ) ;
2022-09-26 08:40:31 -05:00
guess = "Skipped"
2022-09-26 08:14:06 -05:00
2022-08-07 03:40:24 -05:00
}
2024-09-22 20:10:30 -05:00
countdowAndRefresh ( ) ;
2022-09-20 08:30:32 -05:00
const autoCompleteJS = new autoComplete ( {
2022-10-02 05:09:54 -05:00
placeHolder : "Search for Movies..." ,
2022-09-25 13:45:13 -05:00
// wrapper: false,
2022-09-20 08:30:32 -05:00
data : {
2022-09-25 13:45:13 -05:00
src : movies . map ( movies => movies [ 0 ] )
2022-09-20 08:30:32 -05:00
} ,
resultItem : {
highlight : true ,
} ,
events : {
input : {
selection : ( event ) => {
const selection = event . detail . selection . value ;
autoCompleteJS . input . value = selection ;
} ,
open ( ) {
const position =
autoCompleteJS . input . getBoundingClientRect ( ) . bottom + autoCompleteJS . list . getBoundingClientRect ( ) . height >
( window . innerHeight || document . documentElement . clientHeight ) ;
if ( position ) {
autoCompleteJS . list . style . bottom = autoCompleteJS . input . offsetHeight + 8 + "px" ;
} else {
// autoCompleteJS.list.style.bottom = -autoCompleteJS.list.offsetHeight - 8 + "px";
}
} ,
2022-08-07 03:40:24 -05:00
}
}
2022-09-20 08:30:32 -05:00
} ) ;
2022-09-26 08:40:31 -05:00
2022-09-20 08:30:32 -05:00
autoCompleteJS . input . addEventListener ( "selection" , function ( event ) {
2022-09-26 08:40:31 -05:00
// guess = "skipped"
// event.detail.selection.value = "skipped";
2022-09-20 08:30:32 -05:00
const feedback = event . detail ;
// Prepare User's Selected Value
guess = event . detail . selection . value
autoCompleteJS . input . value = guess ;
// Console log autoComplete data feedback
2022-10-27 07:37:49 -05:00
// console.log(event.detail.selection.value);
2022-09-27 10:24:46 -05:00
checkGuess ( ) ;
2022-09-20 08:30:32 -05:00
} ) ;
2022-08-07 03:40:24 -05:00
function copyToClipboard ( ) {
2023-09-30 16:05:47 -05:00
navigator . clipboard . writeText ( "Horrordle #" + ( dayCount + 1 ) + "\n" + textResult ) . then ( ( ) => {
2022-08-07 03:40:24 -05:00
shareResult . value = "copied!" ;
2022-10-11 08:55:04 -05:00
2022-08-07 03:40:24 -05:00
// Alert the user that the action took place.
// Nobody likes hidden stuff being done under the hood!
} ) ;
}
2022-10-31 08:35:47 -05:00
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!
} ) ;
}
2022-08-07 03:40:24 -05:00
2022-09-25 05:12:37 -05:00
function getArchive ( j , d = dayCount ) {
2022-10-27 07:37:49 -05:00
for ( var i = 0 ; i < dates . length ; i ++ ) {
dates [ i ] . classList . remove ( 'current' ) ;
}
2023-09-30 16:05:47 -05:00
// present_date.setYear(2023);
2022-10-28 04:26:17 -05:00
present _date . setMonth ( 9 , j ) ;
// present_date.setDate(j);
console . log ( present _date ) ;
2022-10-27 07:37:49 -05:00
getReady ( ) ;
var pix = [ ] ;
dayCounter ( ) ;
2022-10-28 04:26:17 -05:00
markCalendar ( ) ;
2022-10-27 07:37:49 -05:00
var points = "⬛⬛⬛"
firstCheck ( ) ;
clearGuess ( ) ;
revealButtons ( ) ;
checkingGuess ( ) ;
deathOftheDay ( ) ;
setResult ( ) ;
// dayCounter();
// firstCheck();
// revealButtons();
// clearGuess();
// dates[d-1].classList.remove('current');
// d = j;
// dates[j-1].classList.add('current');
// deathOftheDay(j);
// document.getElementById('guess').value = "";
2022-08-07 03:40:24 -05:00
location . href = '#' ;
//window.open("#");
}
2022-09-27 10:24:46 -05:00
submitGuess . addEventListener ( 'click' , checkGuess )
2022-09-11 03:32:29 -05:00
const labels = [
'First Guess' ,
'Second Guess' ,
'Third Guess' ,
] ;
2022-09-25 05:12:37 -05:00
2022-09-11 03:32:29 -05:00
const data = {
labels : labels ,
datasets : [ {
label : 'Number of guesses' ,
2022-09-26 08:14:06 -05:00
backgroundColor : [ '#BB86FC' ] ,
2022-09-11 03:32:29 -05:00
fontColor : 'white' ,
color : 'white' ,
2024-09-29 12:24:18 -05:00
data : [ localStorage . getItem ( 'firstGuessStat__' ) , localStorage . getItem ( 'secondGuessStat__' ) , localStorage . getItem ( 'thirdGuessStat__' ) ] ,
2022-09-11 03:32:29 -05:00
} ]
} ;
Chart . defaults . color = 'white'
Chart . defaults . borderColor = 'grey'
const config = {
type : 'bar' ,
data : data ,
options : {
2022-09-25 08:26:54 -05:00
// maintainAspectRatio: false,
2022-09-11 03:32:29 -05:00
scales : {
yAxes : {
ticks : {
stepSize : 1
}
}
}
}
} ;
2024-09-22 20:10:30 -05:00
function addData ( ) {
2024-09-29 12:24:18 -05:00
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__' ) ;
2024-09-22 20:10:30 -05:00
myChart . update ( ) ;
}
const myChart = new Chart (
document . getElementById ( 'myChart' ) ,
config
) ;
function preloadImage ( url )
{
var img = new Image ( ) ;
img . src = url ;
} ;
function resetFunction ( ) {
if ( confirm ( "this will delete all you progress, are you sure?" ) == true ) {
window . localStorage . clear ( ) ;
} else {
}
}
function remember ( ) {
2024-09-29 12:24:18 -05:00
localStorage . setItem ( 'archiveButtonPressed__' , 'true' ) ;
2024-09-22 20:10:30 -05:00
document . getElementsByClassName ( "gif" ) [ 0 ] . style . display = "none" ;
}
}
function dayCounter ( ) {
dayCount = Math . floor ( ( present _date - gameBeginning ) / ( 1000 * 60 * 60 * 24 ) ) ;
console . log ( "dayCount: " + dayCount ) ;
return dayCount ;
}
function countdowAndRefresh ( ) {
2023-09-30 16:05:47 -05:00
var x = setInterval ( function ( ) {
// countDownTime.setDate(Math.floor((present_date - gameBeginning) / (1000 * 60 * 60 * 24))+2);
dayCounter ( ) ;
2022-09-19 07:39:13 -05:00
2023-09-30 16:05:47 -05:00
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 ) ) ;
2024-09-29 12:24:18 -05:00
if ( localStorage . getItem ( 'day__' ) != dayCount ) {
2023-09-30 16:05:47 -05:00
window . location . reload ( ) ;
}
} , 1000 ) ;
2024-09-22 20:10:30 -05:00
//window.localStorage.clear();
}