Skip to content

Commit

Permalink
standard push
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Schwartz committed Jan 26, 2024
1 parent 87bbf76 commit b4a02ff
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 64 deletions.
84 changes: 48 additions & 36 deletions games.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,40 +291,52 @@ function applyLanguageSettings(language) {
});


document.addEventListener('DOMContentLoaded', function() {
// Start the hangman game
startGame();

// Set up the cookie consent modal
var modal = document.getElementById('cookie-consent-modal');
var acceptBtn = document.getElementById('accept-cookies');
var declineBtn = document.getElementById('decline-cookies');
var bodyContent = document.querySelector('.main-content');

// Check cookie consent status
if (!getCookie('cookieConsent')) {
modal.style.display = 'block';
bodyContent.classList.add('blur-background');
}

// Event listeners for accept and decline buttons
acceptBtn.addEventListener('click', function() {
setCookie('cookieConsent', 'accepted', 30);
modal.style.display = 'none';
bodyContent.classList.remove('blur-background');
});

declineBtn.addEventListener('click', function() {
setCookie('cookieConsent', 'declined', 30);
modal.style.display = 'none';
bodyContent.classList.remove('blur-background');
});

// Set up the random sentence generator form submission
document.getElementById('random').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent the form from submitting in the traditional way
generateRandomSentence(); // Call the function to generate and display the sentence
document.addEventListener('DOMContentLoaded', function() {
// Start the hangman game
startGame();

// Set up the cookie consent modal
var modal = document.getElementById('cookie-consent-modal');
var acceptBtn = document.getElementById('accept-cookies');
var declineBtn = document.getElementById('decline-cookies');
var bodyContent = document.querySelector('.main-content');
var letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];

// Check cookie consent status
if (!getCookie('cookieConsent')) {
modal.style.display = 'block';
bodyContent.classList.add('blur-background');
}

// Event listeners for accept and decline buttons
acceptBtn.addEventListener('click', function() {
setCookie('cookieConsent', 'accepted', 30);
modal.style.display = 'none';
bodyContent.classList.remove('blur-background');
});

declineBtn.addEventListener('click', function() {
setCookie('cookieConsent', 'declined', 30);
modal.style.display = 'none';
bodyContent.classList.remove('blur-background');
});

// Setup event listeners for letter buttons
letters.forEach(function(letter) {
var button = document.getElementById('button-' + letter);
if (button) {
button.addEventListener('click', function() {
makeGuess(letter);
});
}
});

// Set up the random sentence generator form submission
document.getElementById('random').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent the form from submitting in the traditional way
generateRandomSentence(); // Call the function to generate and display the sentence
});

// Additional code if needed
});
});



57 changes: 29 additions & 28 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,34 +50,35 @@ <h2>Languapps</h2>
<img id="hangman-image" src="/images/hang/h0.png" alt="hangman">
</div>
<button onclick="startGame()">Start New Game</button>
<div id="letter-buttons">
<button id="button-a" onclick="makeGuess('a')">a</button>
<button id="button-b" onclick="makeGuess('b')">b</button>
<button id="button-c" onclick="makeGuess('c')">c</button>
<button id="button-d" onclick="makeGuess('d')">d</button>
<button id="button-e" onclick="makeGuess('e')">e</button>
<button id="button-f" onclick="makeGuess('f')">f</button>
<button id="button-g" onclick="makeGuess('g')">g</button>
<button id="button-h" onclick="makeGuess('h')">h</button>
<button id="button-i" onclick="makeGuess('i')">i</button>
<button id="button-j" onclick="makeGuess('j')">j</button>
<button id="button-k" onclick="makeGuess('k')">k</button>
<button id="button-l" onclick="makeGuess('l')">l</button>
<button id="button-m" onclick="makeGuess('m')">m</button>
<button id="button-n" onclick="makeGuess('n')">n</button>
<button id="button-o" onclick="makeGuess('o')">o</button>
<button id="button-p" onclick="makeGuess('p')">p</button>
<button id="button-q" onclick="makeGuess('q')">q</button>
<button id="button-r" onclick="makeGuess('r')">r</button>
<button id="button-s" onclick="makeGuess('s')">s</button>
<button id="button-t" onclick="makeGuess('t')">t</button>
<button id="button-u" onclick="makeGuess('u')">u</button>
<button id="button-v" onclick="makeGuess('v')">v</button>
<button id="button-w" onclick="makeGuess('w')">w</button>
<button id="button-x" onclick="makeGuess('x')">x</button>
<button id="button-y" onclick="makeGuess('y')">y</button>
<button id="button-z" onclick="makeGuess('z')">z</button>
</div>
<div id="letter-buttons">
<button id="button-a">a</button>
<button id="button-b">b</button>
<button id="button-c">c</button>
<button id="button-d">d</button>
<button id="button-e">e</button>
<button id="button-f">f</button>
<button id="button-g">g</button>
<button id="button-h">h</button>
<button id="button-i">i</button>
<button id="button-j">j</button>
<button id="button-k">k</button>
<button id="button-l">l</button>
<button id="button-m">m</button>
<button id="button-n">n</button>
<button id="button-o">o</button>
<button id="button-p">p</button>
<button id="button-q">q</button>
<button id="button-r">r</button>
<button id="button-s">s</button>
<button id="button-t">t</button>
<button id="button-u">u</button>
<button id="button-v">v</button>
<button id="button-w">w</button>
<button id="button-x">x</button>
<button id="button-y">y</button>
<button id="button-z">z</button>
</div>




Expand Down

0 comments on commit b4a02ff

Please sign in to comment.