Skip to content

Commit

Permalink
Merge pull request #1 from W0x3R/dev-page
Browse files Browse the repository at this point in the history
Dev page
  • Loading branch information
W0x3R authored Jan 14, 2024
2 parents dd47057 + 40bb4a2 commit bcbf17f
Show file tree
Hide file tree
Showing 22 changed files with 776 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
prepros.config
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Naughts-and-crosses
# Naughts-and-crosses

# w0x3r.github.io/Naughts-and-crosses/
1 change: 1 addition & 0 deletions css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added images/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/fav-icons/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/fav-icons/android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/fav-icons/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions images/fav-icons/browserconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="./images/favicon/mstile-150x150.png"/>
<TileColor>#ffffff</TileColor>
</tile>
</msapplication>
</browserconfig>
Binary file added images/fav-icons/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/fav-icons/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/fav-icons/favicon.ico
Binary file not shown.
Binary file added images/fav-icons/mstile-150x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions images/fav-icons/safari-pinned-tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions images/fav-icons/site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "Naughts and crosses",
"short_name": "Naughts and crosses",
"icons": [
{
"src": "android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
47 changes: 47 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Naughts and crosses</title>
<link rel="apple-touch-icon" sizes="180x180" href="./images/fav-icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="./images/fav-icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="./images/fav-icons/favicon-16x16.png">
<link rel="manifest" href="./images/fav-icons/site.webmanifest">
<link rel="mask-icon" href="./images/fav-icons/safari-pinned-tab.svg" color="#000000">
<link rel="shortcut icon" href="./images/fav-icons/favicon.ico">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-config" content="./images/favicon/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
<link rel="stylesheet" href="./css/style.css">
</head>

<body>
<div class="container">
<main class="main">
<div class="main__res"></div>
<div class="main__square">
<div class="main__square-item"></div>
<div class="main__square-item"></div>
<div class="main__square-item"></div>
<div class="main__square-item"></div>
<div class="main__square-item"></div>
<div class="main__square-item"></div>
<div class="main__square-item"></div>
<div class="main__square-item"></div>
<div class="main__square-item"></div>
</div>
<button class="main__button">NEW GAME</button>
</main>
<div class="footer">
<h1 class="footer__title"><a href="https://github.com/W0x3R" target="_blank">Naughts
and
crosses</a></h1>
</div>
</div>
<script src="./js/index.js"></script>
</body>

</html>
1 change: 1 addition & 0 deletions js/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added src/images/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions src/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
const square = document.querySelector('.main__square');
const squareElements = document.querySelectorAll('.main__square-item')
const res = document.querySelector('.main__res')
const newGameButton = document.querySelector('.main__button')

let count = 0;

function cross(target) {
if (count % 2 === 0 && target.textContent === '') {
target.textContent = '◯'
target.classList.add('o')
count++
}
}

function zero(target) {
if (count % 2 !== 0 && target.textContent === '') {
target.textContent = '✕'
target.classList.add('x')
count++
}
}

function init(e) {
cross(e.target)
zero(e.target)
showWin()
}

square.addEventListener('click', init)

function showWin() {
let comboOfWin = [
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[0, 3, 6],
[1, 4, 7],
[2, 5, 8],
[0, 4, 8],
[2, 4, 6],
]

for (let i = 0; i < comboOfWin.length; i++) {
if (squareElements[comboOfWin[i][0]].classList.contains('x') && squareElements[comboOfWin[i][1]].classList.contains('x') && squareElements[comboOfWin[i][2]].classList.contains('x')) {
square.removeEventListener('click', init)
setTimeout(() => {
squareElements[comboOfWin[i][0]].classList.add('main__square-item_win')
squareElements[comboOfWin[i][1]].classList.add('main__square-item_win')
squareElements[comboOfWin[i][2]].classList.add('main__square-item_win')
res.textContent = 'X WIN'
}, 250)
}
else if (squareElements[comboOfWin[i][0]].classList.contains('o') && squareElements[comboOfWin[i][1]].classList.contains('o') && squareElements[comboOfWin[i][2]].classList.contains('o')) {
square.removeEventListener('click', init)
setTimeout(() => {
squareElements[comboOfWin[i][0]].classList.add('main__square-item_win')
squareElements[comboOfWin[i][1]].classList.add('main__square-item_win')
squareElements[comboOfWin[i][2]].classList.add('main__square-item_win')
res.textContent = '0 WIN'
}, 250)

}
else if (count === 9) {
res.textContent = 'GAME DRAW'
square.removeEventListener('click', init)
}
}
}

function newGame() {
count = 0;
squareElements.forEach(e => {
e.textContent = ''
e.classList.remove('x', 'o', 'main__square-item_win')
})
res.textContent = ''
square.addEventListener('click', init)
}

newGameButton.addEventListener('click', newGame)

13 changes: 13 additions & 0 deletions src/sass/_adaptive.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.main {
&__square {
@media screen and (max-width: 680px) {
@include width-height(300px, 300px);

&-item {
@media screen and (max-width: 680px) {
@include width-height(100px, 100px);
}
}
}
}
}
12 changes: 12 additions & 0 deletions src/sass/_mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@mixin flexBox($flex-direction: row, $align-items: normal, $justify-content: normal, $flex-wrap: nowrap) {
display: flex;
flex-direction: $flex-direction;
align-items: $align-items;
justify-content: $justify-content;
flex-wrap: $flex-wrap;
}

@mixin width-height($width, $height) {
width: $width;
height: $height;
}
Loading

0 comments on commit bcbf17f

Please sign in to comment.