-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from alik-r/avatar
Avatar
- Loading branch information
Showing
10 changed files
with
176 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
FROM nginx:1.21.3-alpine | ||
|
||
COPY nginx.conf /etc/nginx/nginx.conf | ||
|
||
COPY ./index.html /usr/share/nginx/html/index.html | ||
COPY ./register.html /usr/share/nginx/html/register.html | ||
COPY ./roulette.html /usr/share/nginx/html/roulette.html | ||
|
||
COPY ./style.css /usr/share/nginx/html/style.css | ||
COPY ./styles/ /usr/share/nginx/html/styles/ | ||
COPY ./fonts/ /usr/share/nginx/html/fonts/ | ||
COPY ./images/ /usr/share/nginx/html/images/ | ||
COPY ./scripts/ /usr/share/nginx/html/scripts/ | ||
|
||
EXPOSE 80 |
This file was deleted.
Oops, something went wrong.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,10 @@ | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Gabarito&display=swap"> | ||
<link rel="stylesheet" href="styles/main_style.css"> | ||
|
||
<script src="https://unpkg.com/[email protected]"></script> | ||
<script src="https://unpkg.com/[email protected]/dist/ext/json-enc.js"></script> | ||
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js"></script> | ||
<script defer src="scripts/avatar.js"></script> | ||
<title>Register</title> | ||
</head> | ||
|
||
|
@@ -15,42 +18,88 @@ | |
Don’t bet on <br> | ||
your soul | ||
</div> | ||
<section class="container"> | ||
|
||
<section class="container" x-data="{ isRegister: true }"> | ||
<div class="header"> | ||
<button class="tab" id="login-tab">Login</button> | ||
<button class="tab-active" id="register-tab">Register</button> | ||
<button class="tab" :class="{ 'tab-active': !isRegister }" @click="isRegister = false">Login</button> | ||
<button class="tab" :class="{ 'tab-active': isRegister }" @click="isRegister = true">Register</button> | ||
</div> | ||
<form id="register-form"> | ||
|
||
<form class="container-register" id="register-form" x-show="isRegister" hx-post="/api/login" hx-trigger="submit" hx-target="#response" | ||
hx-ext='json-enc' hx-headers='{"Content-Type": "application/json"}'> | ||
|
||
<div class="input-box"> | ||
<label>Username</label> | ||
<input type="text" name="username" required> | ||
</div> | ||
<div class="input-box"> | ||
<label>Email</label> | ||
<input type="email" name="email-register"> | ||
<input type="email" name="email" required> | ||
</div> | ||
<div class="input-box"> | ||
<label>Password</label> | ||
<input type="password" name = 'password-register'> | ||
<input type="password" name="password" required> | ||
</div> | ||
<div class="input-box"> | ||
<label>Avatar</label> | ||
<div id="avatarContainer" class="avatar-grid"> | ||
|
||
</div> | ||
<div class="avatar-grid" id="avatarContainer"></div> | ||
<input type="hidden" name="avatar" id="selectedAvatar"> | ||
|
||
</div> | ||
<button class="submit-btn" type="submit">Register</button> | ||
</form> | ||
<form id="login-form" style="display: none;"> | ||
|
||
<form class="container-login" id="login-form" x-show="!isRegister" hx-post="/api/login" hx-trigger="submit" hx-include="#login-form" | ||
hx-target="#response" hx-headers='{"Content-Type": "application/json"}' hx-ext='json-enc'> | ||
<div class="input-box"> | ||
<label>Email</label> | ||
<input type="email" name="login-email"> | ||
<input type="email" name="email" required> | ||
</div> | ||
<div class="input-box"> | ||
<label>Password</label> | ||
<input type="password" name="login-password"> | ||
<input type="password" name="password" required> | ||
</div> | ||
<button class="submit-btn" type="submit">Login</button> | ||
</form> | ||
|
||
<div id="response"></div> | ||
</section> | ||
<script src="scripts/avatar.js"></script> | ||
<script src="scripts/script.js"></script> | ||
|
||
</body> | ||
|
||
</html> | ||
<script> | ||
document.addEventListener('DOMContentLoaded', function () { | ||
const avatarContainer = document.getElementById('avatarContainer'); | ||
const selectedAvatarInput = document.getElementById('selectedAvatar'); | ||
|
||
avatarContainer.addEventListener('click', function (event) { | ||
if (event.target && event.target.tagName === 'IMG') { | ||
const avatarDiv = event.target.closest('.avatar-item'); | ||
const avatarPath = event.target.src; | ||
|
||
document.querySelectorAll('.avatar-item').forEach(item => item.classList.remove('selected')); | ||
avatarDiv.classList.add('selected'); | ||
|
||
selectedAvatarInput.value = avatarPath; | ||
} | ||
}); | ||
}); | ||
</script> | ||
<script> | ||
document.addEventListener("htmx:afterRequest", (event) => { | ||
if (event.detail.successful) { | ||
const response = JSON.parse(event.detail.xhr.responseText); | ||
if (response.token) { | ||
localStorage.setItem("authToken", response.token); | ||
|
||
if (response.is_register === "true") { | ||
document.getElementById("response").innerText = "Registered successfully!"; | ||
} else { | ||
document.getElementById("response").innerText = "Logged in successfully!"; | ||
} | ||
|
||
location.href = "/roulette.html"; | ||
} else { | ||
document.getElementById("response").innerText = "Failed to login or register."; | ||
} | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,20 @@ | ||
const avatarContainer = document.getElementById('avatarContainer'); | ||
|
||
const avatars = ['images/avatars/avatar1.png', | ||
'images/avatars/avatar2.png', | ||
'images/avatars/avatar3.png', | ||
'images/avatars/avatar4.png', | ||
'images/avatars/avatar5.png', | ||
'images/avatars/avatar6.png', | ||
'images/avatars/avatar7.png', | ||
'images/avatars/avatar8.png', | ||
'images/avatars/avatar9.png', | ||
'images/avatars/avatar10.png', | ||
'images/avatars/avatar11.png', | ||
'images/avatars/avatar12.png', | ||
'images/avatars/avatar13.png', | ||
'images/avatars/avatar14.png', | ||
'images/avatars/avatar15.png', | ||
const avatars = [ | ||
'images/avatars/avatar1.png', 'images/avatars/avatar2.png', 'images/avatars/avatar3.png', | ||
'images/avatars/avatar4.png', 'images/avatars/avatar5.png', 'images/avatars/avatar6.png', | ||
'images/avatars/avatar7.png', 'images/avatars/avatar8.png', 'images/avatars/avatar9.png', | ||
'images/avatars/avatar10.png', 'images/avatars/avatar11.png', 'images/avatars/avatar12.png', | ||
'images/avatars/avatar13.png', 'images/avatars/avatar14.png', 'images/avatars/avatar15.png' | ||
]; | ||
|
||
function generateAvatars(){ | ||
avatars.forEach((avatars,index)=>{ | ||
function generateAvatars() { | ||
avatars.forEach((avatarPath, index) => { | ||
const avatarDiv = document.createElement('div'); | ||
avatarDiv.classList.add('avatar-item'); | ||
avatarDiv.innerHTML = `<img src ="${avatars}" alt = Avatar ${index+1} />`; | ||
|
||
avatarDiv.addEventListener('click',()=>{ | ||
document.querySelectorAll('.avatar-item').forEach(item => item.classList.remove('selected')); | ||
avatarDiv.classList.add('selected'); | ||
|
||
}); | ||
avatarDiv.innerHTML = `<img src="${avatarPath}" alt="Avatar ${index + 1}" />`; | ||
avatarContainer.appendChild(avatarDiv); | ||
|
||
}); | ||
|
||
} | ||
|
||
generateAvatars(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.