2022-09-19 07:39:13 -05:00
//<TO-DO>
//-FIX IMAGE RATIOS
//-FIX CALENDAR
2022-09-25 05:12:37 -05:00
//-ADD SUPPORT PAGE
//archive doesn't work constanlt refreshing
2022-09-19 07:39:13 -05:00
// var fake_date = new Date("September 19, 2022 23:58: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
2022-09-26 08:14:06 -05:00
window . addEventListener ( "load" , function ( ) {
loader . style . display = 'none' ;
} ) ;
2022-09-26 08:40:31 -05:00
guess = 'Skipped' ;
2022-09-26 08:14:06 -05:00
2022-09-25 13:45:13 -05:00
if ( ! localStorage . getItem ( 'playedBefore' ) ) {
// window.location = window.location.href + "#info";
2022-09-26 08:40:31 -05:00
// window.location = "https://gorkem.cc/horo#info"
window . location = "file:///C:/Users/gogob/Documents/dEATHDLE/Test/index.html#info"
2022-09-26 03:23:35 -05:00
localStorage . setItem ( 'playedBefore' , "true" ) ;
2022-09-25 13:45:13 -05:00
}
2022-09-25 05:12:37 -05:00
2022-09-25 13:45:13 -05:00
var buttonNo = 0 ;
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-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' ) ;
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-08-07 03:40:24 -05:00
2022-09-11 03:32:29 -05:00
2022-09-25 13:45:13 -05:00
var movies = [ [ "The Texas Chainsaw Massacre" , 1 , "Sally Hardesty" ] , [ "It Follows" , 2 , "Jaime Height" ] , [ "Friday the 13th" , 0 , "Alice Hardy" ] , [ "Event Horizon" , 2 , "Lieutenant Starck" ] , [ "Hellraiser" , 2 , "Kirsty Cotton" ] , [ "A Nightmare on Elm Street" , 1 , "Nancy Thompson" ] , [ "The Cabin in the Woods" , 2 ] , [ "American Psycho" , 0 ] ] ;
2022-08-07 03:40:24 -05:00
var pix = [ ] ;
2022-09-20 08:30:32 -05:00
// autocomplete(document.getElementById("guess"), movies);
2022-09-27 10:24:46 -05:00
var gameBeginning = new Date ( 'September 23, 2022 00:00:00' ) ;
2022-09-11 07:41:49 -05:00
var countDownTime = new Date ( ) ;
var present _date = new Date ( ) ;
2022-08-07 03:40:24 -05:00
// gameBeginning = new Date(gameBeginning.getTime() + 0 * 60 * 1000);
console . log ( gameBeginning . getTimezoneOffset ( ) ) ;
2022-09-19 07:39:13 -05:00
dayCounter ( ) ;
2022-08-07 03:40:24 -05:00
console . log ( "gameBeginning: " , gameBeginning ) ;
console . log ( "now: " , present _date ) ;
2022-09-19 07:39:13 -05:00
2022-09-26 03:23:35 -05:00
// console.log(textResult);
2022-09-19 07:39:13 -05:00
function dayCounter ( ) {
dayCount = Math . floor ( ( present _date - gameBeginning ) / ( 1000 * 60 * 60 * 24 ) ) ;
return dayCount ;
}
2022-08-07 03:40:24 -05:00
markCalendar ( ) ;
function markCalendar ( ) {
dates = document . getElementsByClassName ( 'calendar__number' ) ;
console . log ( dates [ 10 ] . innerHTML ) ;
var tag = [ ] ;
for ( var i = 0 ; i < dates . length ; i ++ ) {
if ( dates [ i ] . innerHTML == dayCount ) {
dates [ i ] . classList . add ( 'current' ) ;
2022-09-26 08:14:06 -05:00
for ( var j = 0 ; j <= i ; j ++ ) {
2022-08-07 03:40:24 -05:00
if ( localStorage . getItem ( 'day' + ( j + 1 ) ) ) {
if ( localStorage . getItem ( 'day' + ( j + 1 ) ) == 'true' ) {
dates [ j ] . classList . add ( 'won' ) ;
} else if ( localStorage . getItem ( 'day' + ( j + 1 ) ) == 'false' ) {
dates [ j ] . classList . add ( 'lost' ) ;
}
} else {
dates [ j ] . classList . add ( 'past' ) ;
dates [ j ] = document . createElement ( 'a' ) ;
//dates[j].setAttribute('href','#');
2022-09-25 05:12:37 -05:00
if ( localStorage . getItem ( "playedToday" ) ) {
// dates[j].setAttribute('onclick','getArchive(' + (j+1) +')');
// dates[j] = "<a href='#'>" + dates[j] + "</a>";
}
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]);
console . log ( dates [ j ] ) ;
}
console . log ( dates [ i ] ) ;
}
}
}
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" ;
if ( ! localStorage . getItem ( 'streak' ) ) { localStorage . setItem ( 'streak' , 0 ) }
2022-09-11 03:32:29 -05:00
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-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 ( ) {
localStorage . removeItem ( 'firstGuess' ) ;
localStorage . removeItem ( 'secondGuess' ) ;
localStorage . removeItem ( 'guessNo' ) ;
localStorage . removeItem ( 'winningGuess' ) ;
2022-09-25 13:45:13 -05:00
localStorage . removeItem ( 'movieName' ) ;
2022-09-25 05:12:37 -05:00
localStorage . removeItem ( "playedToday" ) ;
2022-09-11 10:54:00 -05:00
// 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-09-11 07:41:49 -05:00
document . getElementById ( "countDown" ) . 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
streakNumber . textContent = localStorage . getItem ( 'streak' ) ;
if ( localStorage . getItem ( 'day' ) == dayCount ) {
playedBefore = true ;
textResult = localStorage . getItem ( 'result' )
2022-09-25 13:45:13 -05:00
document . getElementById ( "movieName" ) . innerHTML = localStorage . getItem ( 'movieName' )
2022-08-07 03:40:24 -05:00
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" ;
2022-09-11 09:11:13 -05:00
if ( localStorage . getItem ( 'result' ) ) { localStorage . setItem ( 'result' , textResult ) ; document . getElementById ( "resultText" ) . innerHTML = textResult }
2022-09-26 08:14:06 -05:00
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" ; }
2022-09-25 13:45:13 -05:00
if ( localStorage . getItem ( 'winningGuess' ) ) { document . getElementsByClassName ( "picButtons" ) [ 0 ] . style . display = "none" ; revealButtons ( 2 ) ; document . getElementById ( "feedback" ) . innerHTML = "Next movie will reveal at <b>midnight!</b> 🕛" ; document . getElementById ( "shareResult" ) . style . display = "block" ; document . getElementById ( "countDown" ) . 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" ; } ;
2022-09-26 08:14:06 -05:00
secondGuess . textContent = "❌ " + localStorage . getItem ( 'secondGuess' ) ;
2022-09-25 08:26:54 -05:00
revealButtons ( ) ;
2022-08-07 03:40:24 -05:00
} else {
clearGuess ( ) ;
2022-09-07 09:05:49 -05:00
localStorage . setItem ( 'day' , dayCount ) ;
2022-08-07 03:40:24 -05:00
}
2022-09-25 05:12:37 -05:00
markCalendar ( ) ;
2022-08-07 03:40:24 -05:00
}
2022-09-07 09:05:49 -05:00
checkingGuess ( ) ;
2022-09-25 05:12:37 -05:00
window . onload = deathOftheDay ( ) ;
// console.log(dayCount);
2022-08-07 03:40:24 -05:00
2022-09-25 05:12:37 -05:00
function deathOftheDay ( x = dayCount ) {
2022-08-07 03:40:24 -05:00
pix = [ ] ;
2022-09-25 05:12:37 -05:00
movieOfTheDay = movies [ x - 1 ] ;
2022-08-07 03:40:24 -05:00
for ( let i = 1 ; i < 4 ; i ++ ) {
2022-09-25 13:45:13 -05:00
pix . push ( "images/" + movieOfTheDay [ 0 ] + "/" + i + ".png" ) ;
preloadImage ( "images/" + movieOfTheDay [ 0 ] + "/" + i + ".png" ) ;
2022-08-07 03:40:24 -05:00
}
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 ( ) ;
// 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' ) ;
for ( let i = 0 ; i < 3 ; i ++ ) {
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
}
2022-09-25 13:45:13 -05:00
function submitBonus ( b = 0 ) {
if ( buttonNo == movieOfTheDay [ 1 ] && b == 0 ) {
bonusRoundState = true ;
// document.getElementById("bonusQuestion").style.display="none";
document . getElementById ( "bonusQuestion" ) . innerHTML = "Survivor: " + movieOfTheDay [ 2 ] + " ⭐" ;
textResult = textResult + "[⭐]"
console . log ( "you win!" )
}
else {
console . log ( 'you lose' )
document . getElementById ( "bonusQuestion" ) . innerHTML = "Survivor: " + movieOfTheDay [ 2 ] ;
}
localStorage . setItem ( 'result' , textResult ) ;
document . getElementById ( "feedback" ) . style . display = "block" ;
document . getElementById ( "feedback" ) . innerHTML = "Next movie revealed at midnight! 🕛 <br>" ;
document . getElementById ( "resultText" ) . innerHTML = textResult ;
2022-09-26 03:23:35 -05:00
document . getElementById ( "resultText" ) . style . display = "block" ;
2022-09-25 13:45:13 -05:00
document . getElementById ( "countDown" ) . 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 ] )
console . log ( buttonNo ) ;
2022-09-26 08:14:06 -05:00
addData ( ) ;
2022-09-25 13:45:13 -05:00
}
2022-09-27 10:24:46 -05:00
if ( ! localStorage . getItem ( 'result' ) ) {
2022-09-26 03:23:35 -05:00
textResult = "Horrordle #" + dayCount + "\n🔪" ;
2022-09-27 10:24:46 -05:00
} else {
textResult = localStorage . getItem ( 'result' ) ;
}
2022-08-07 03:40:24 -05:00
function checkGuess ( ) {
2022-09-25 13:45:13 -05:00
localStorage . setItem ( 'playedBefore' , 'true' ) ;
2022-09-11 03:32:29 -05:00
2022-08-07 03:40:24 -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
2022-09-11 03:32:29 -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 ) ; }
2022-08-07 03:40:24 -05:00
localStorage . setItem ( 'streak' , parseInt ( localStorage . getItem ( 'streak' ) ) + 1 ) ;
localStorage . setItem ( 'day' + dayCount , 'true' ) ;
2022-09-19 07:39:13 -05:00
// document.getElementById("movieFrame").src = "images/"+movieOfTheDay+"/poster.jpg";
2022-08-07 03:40:24 -05:00
console . log ( localStorage . getItem ( 'day' + dayCount ) ) ;
streakNumber . textContent = " " + localStorage . getItem ( 'streak' ) ;
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
2022-09-25 13:45:13 -05:00
localStorage . setItem ( 'movieName' , movieOfTheDay [ 0 ] + " ✅" )
document . getElementById ( "bonusQuestion" ) . innerHTML = "⭐BONUS ROUND⭐<br> Can you guess the survivor?" ;
document . getElementById ( "submitBonusGuess" ) . style . display = "inline" ;
document . getElementById ( "skipBonusGuess" ) . style . display = "inline" ;
2022-08-07 03:40:24 -05:00
textResult = textResult + "🟩" ;
for ( var i = 1 ; i < ( 3 - guessNo ) ; i ++ ) {
textResult = textResult + "⬛" ;
}
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" ) ;
}
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" ;
2022-08-07 03:40:24 -05:00
dates [ dayCount - 1 ] . classList . add ( 'won' ) ;
2022-09-25 08:26:54 -05:00
revealButtons ( 2 ) ;
2022-09-11 09:11:13 -05:00
2022-08-07 03:40:24 -05:00
} else if ( guessNo == 1 ) {
guessNo = guessNo + 1 ;
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 ;
2022-09-20 08:30:32 -05:00
localStorage . setItem ( 'firstGuess' , guess ) ;
2022-08-07 03:40:24 -05:00
document . getElementById ( "firstGuess" ) . style . display = "block" ;
textResult = textResult + "🟥" ;
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 ;
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 ;
2022-09-20 08:30:32 -05:00
localStorage . setItem ( 'secondGuess' , guess ) ;
2022-08-07 03:40:24 -05:00
document . getElementById ( "secondGuess" ) . style . display = "block" ;
textResult = textResult + "🟥" ;
localStorage . setItem ( 'result' , textResult ) ;
2022-09-25 08:26:54 -05:00
revealButtons ( ) ;
2022-08-07 03:40:24 -05:00
}
else {
feedback . textContent = "GAME OVER" ;
textResult = textResult + "🟥" ;
localStorage . setItem ( 'guessNo' , guessNo ) ;
localStorage . setItem ( 'streak' , 0 ) ;
localStorage . setItem ( 'day' + dayCount , 'false' ) ;
2022-09-25 05:12:37 -05:00
localStorage . setItem ( "playedToday" , "yes" ) ;
2022-08-07 03:40:24 -05:00
dates [ dayCount - 1 ] . classList . add ( 'lost' ) ;
}
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
}
2022-09-20 08:30:32 -05:00
const autoCompleteJS = new autoComplete ( {
2022-09-27 10:24:46 -05:00
placeHolder : "Search for Horror 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
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 ( ) {
navigator . clipboard . writeText ( textResult ) . then ( ( ) => {
shareResult . value = "copied!" ;
// Alert the user that the action took place.
// Nobody likes hidden stuff being done under the hood!
} ) ;
}
2022-09-25 05:12:37 -05:00
function getArchive ( j , d = dayCount ) {
2022-08-07 03:40:24 -05:00
2022-09-25 05:12:37 -05:00
dates [ d - 1 ] . classList . remove ( 'current' ) ;
d = j ;
2022-08-07 03:40:24 -05:00
dates [ j - 1 ] . classList . add ( 'current' ) ;
2022-09-25 05:12:37 -05:00
deathOftheDay ( j ) ;
2022-08-07 03:40:24 -05:00
document . getElementById ( 'guess' ) . value = "" ;
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' ,
data : [ localStorage . getItem ( 'firstGuessStat' ) , localStorage . getItem ( 'secondGuessStat' ) , localStorage . getItem ( 'thirdGuessStat' ) ] ,
} ]
} ;
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
}
}
}
}
} ;
2022-09-11 07:41:49 -05:00
var x = setInterval ( function ( ) {
2022-09-11 09:11:13 -05:00
// countDownTime.setDate(Math.floor((present_date - gameBeginning) / (1000 * 60 * 60 * 24))+2);
2022-09-19 07:39:13 -05:00
dayCounter ( ) ;
dateVariable = present _date . getDate ( )
countDownTime . setDate ( dateVariable + 1 ) ;
countDownTime . setHours ( 0 ) ;
2022-09-11 09:11:13 -05:00
countDownTime . setMinutes ( 0 ) ;
2022-09-11 07:41:49 -05:00
countDownTime . setSeconds ( 0 ) ;
var now = new Date ( ) ;
2022-09-20 08:30:32 -05:00
// console.log("now: ",now);
2022-09-11 07:41:49 -05:00
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 " ;
2022-09-19 07:39:13 -05:00
//console.log(remainingTime);
2022-09-20 08:30:32 -05:00
// console.log(localStorage.getItem('day'));
// console.log("day count: " + dayCount);
2022-09-19 07:39:13 -05:00
dayCount = Math . floor ( ( now - gameBeginning ) / ( 1000 * 60 * 60 * 24 ) ) ;
if ( localStorage . getItem ( 'day' ) != dayCount ) {
window . location . reload ( ) ;
2022-09-11 07:41:49 -05:00
}
} , 1000 ) ;
2022-09-26 08:14:06 -05:00
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 ( ) ;
}
2022-09-11 03:32:29 -05:00
const myChart = new Chart (
document . getElementById ( 'myChart' ) ,
config
2022-09-19 07:39:13 -05:00
) ;
2022-09-25 05:12:37 -05:00
function preloadImage ( url )
{
var img = new Image ( ) ;
img . src = url ;
} ;
2022-09-19 07:39:13 -05:00
//window.localStorage.clear();