This commit is contained in:
FlyInTheBox 2023-03-29 13:46:24 +02:00
parent 51dc25d05b
commit 804fe2242f
8 changed files with 142 additions and 236 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

View file

@ -1,22 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="container">
<div class="card-container">
<div class="card" style="background-image: url(https://picsum.photos/300/400?random=1)"></div>
<div class="buttons">
<div class="button button-dislike">&#10005;</div>
<div class="button button-like">&#10003;</div>
</div>
</div>
</div>
</body>
<script src="script.js"></script>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

View file

@ -1,120 +0,0 @@
let card = document.querySelector('.card-container');
let cardLeft = document.querySelector('.card-left');
let cardRight = document.querySelector('.card-right');
let cardLiked = document.querySelector('.card-liked');
let cardDisliked = document.querySelector('.card-disliked');
let startX;
let startY;
let currentX;
let currentY;
let dragging = false;
card.addEventListener('mousedown', function(e) {
startX = e.clientX;
startY = e.clientY;
dragging = true;
card.classList.add('dragging');
});
document.addEventListener('mousemove', function(e) {
if (dragging) {
currentX = e.clientX;
currentY = e.clientY;
let diffX = currentX - startX;
let diffY = currentY - startY;
card.style.transform = 'translate(' + diffX + 'px, ' + diffY + 'px)';
let leftButton = document.querySelector('.button-dislike');
let rightButton = document.querySelector('.button-like');
if (diffX > 0) {
leftButton.style.opacity = 0;
rightButton.style.opacity = diffX / (window.innerWidth / 2);
} else if (diffX < 0) {
rightButton.style.opacity = 0;
leftButton.style.opacity = Math.abs(diffX) / (window.innerWidth / 2);
}
}
});
document.addEventListener('mouseup', function(e) {
if (dragging) {
dragging = false;
card.classList.remove('dragging');
card.style.transform = '';
let diffX = currentX - startX;
if (diffX > window.innerWidth / 3) {
card.classList.add('card-right');
cardLiked.style.opacity = 1;
} else if (diffX < -window.innerWidth / 3) {
card.classList.add('card-left');
cardDisliked.style.opacity = 1;
} else {
card.classList.add('card');
}
setTimeout(function() {
card.remove();
let newCard = document.createElement('div');
newCard.classList.add('card-container');
let randomNumber = Math.floor(Math.random() * 100);
newCard.innerHTML = `
<div class="card" style="background-image: url(https://picsum.photos/300/400?random=${randomNumber})"></div>
<div class="buttons">
<div class="button button-dislike">&#10005;</div>
<div class="button button-like">&#10003;</div>
</div>
`;
document.querySelector('#container').appendChild(newCard);
card = document.querySelector('.card-container');
cardLeft = document.querySelector('.card-left');
cardRight = document.querySelector('.card-right');
cardLiked = document.querySelector('.card-liked');
cardDisliked = document.querySelector('.card-disliked');
}, 300);
}
});
document.querySelector('.button-like').addEventListener('click', function() {
card.classList.add('card-liked');
setTimeout(function() {
card.remove();
let newCard = document.createElement('div');
newCard.classList.add('card-container');
let randomNumber = Math.floor(Math.random() * 100);
newCard.innerHTML = `
<div class="card" style="background-image: url(https://picsum.photos/300/400?random=${randomNumber})"></div>
<div class="buttons">
<div class="button button-dislike">&#10005;</div>
<div class="button button-like">&#10003;</div>
</div>
`;
document.querySelector('#container').appendChild(newCard);
card = document.querySelector('.card-container');
cardLeft = document.querySelector('.card-left');
cardRight = document.querySelector('.card-right');
cardLiked = document.querySelector('.card-liked');
cardDisliked = document.querySelector('.card-disliked');
}, 300);
});
document.querySelector('.button-dislike').addEventListener('click', function() {
card.classList.add('card-disliked');
setTimeout(function() {
card.remove();
let newCard = document.createElement('div');
newCard.classList.add('card-container');
let randomNumber = Math.floor(Math.random() * 100);
newCard.innerHTML = `
<div class="card" style="background-image: url(https://picsum.photos/300/400?random=${randomNumber})"></div>
<div class="buttons">
<div class="button button-dislike">&#10005;</div>
<div class="button button-like">&#10003;</div>
</div>
`;
document.querySelector('#container').appendChild(newCard);
card = document.querySelector('.card-container');
cardLeft = document.querySelector('.card-left');
cardRight = document.querySelector('.card-right');
cardLiked = document.querySelector('.card-liked');
cardDisliked = document.querySelector('.card-disliked');
}, 300);
});

View file

@ -1,94 +0,0 @@
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
#container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
}
.card-container {
position: relative;
width: 300px;
height: 400px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
overflow: hidden;
cursor: grab;
}
.card-container:hover {
box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.4);
}
.card-container:active {
cursor: grabbing;
}
.card {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
transition: transform 0.3s ease-in-out;
}
.card-left {
transform: translateX(-200%) rotate(-30deg);
opacity: 0;
}
.card-right {
transform: translateX(200%) rotate(30deg);
opacity: 0;
}
.card-liked {
transform: translateX(200%) rotate(30deg);
opacity: 0;
}
.card-disliked {
transform: translateX(-200%) rotate(-30deg);
opacity: 0;
}
.buttons {
display: flex;
justify-content: space-between;
align-items: center;
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 10px;
background-color: rgba(0, 0, 0, 0.4);
color: #fff;
font-size: 24px;
font-weight: bold;
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
transition: opacity 0.3s ease-in-out;
opacity: 0;
}
.card-container:hover .buttons {
opacity: 1;
}
.button-like {
color: #00ff00;
}
.button-dislike {
color: #ff0000;
}

View file

@ -0,0 +1,59 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<form action="Ankieta.php" method="post">
<fieldset style="border: 4px solid yellowgreen;">
<legend>Ankieta</legend>
<?php
$imie = $nazwisko = $kto = '';
$imie_blad = $nazwisko_blad = $kto_blad = '';
if($_SERVER['REQUEST_METHOD']=='POST') {
if (empty($_POST['imie'])) {
$imie_blad = "Wpisz tu imię";
}
else {
$imie = $_POST['imie'];
}
}
if($_SERVER['REQUEST_METHOD']=='POST') {
if (empty($_POST['nazwisko'])) {
$nazwisko_blad = "Wpisz tu nazwisko";
}
else {
$nazwisko = $_POST['nazwisko'];
}
}
if ($_SERVER['REQUEST_METHOD']=='POST') {
if (empty($_POST['profesja'])) {
$kto_blad = "Wybierz jedną opcję";
}
else {
$kto = $_POST['profesja'];
}
}
?>
<label for="imie">Imię</label>
<span style="color:red;">* <?=$imie_blad?></span><br>
<input type="text" id="imie" name="imie" value="<?=$imie?>"><br>
<label for="nazwisko">Nazwisko</label>
<span style="color: red">* <?=$nazwisko_blad?></span><br>
<input type="text" id="nazwisko" name="nazwisko" value="<?=$nazwisko?>"><br>
<label for="asdf" >Wybierz jedną opcję </label>
<span style="color: red">* <?=$kto_blad?></span>
<br>
<input type="radio" id="uczeń" name="profesja[]" value="stanowisko" <?php if ($kto && strstr(implode('', $kto), 'uczen')) echo 'checked';?>>
<label for="uczeń">uczeń</label><br>
<input type="radio" id="absolwent" name="profesja[]" value="absolwent" <?php if ($kto && strstr(implode('', $kto), 'absolwent')) echo 'checked';?>>
<label for="absolwent">absolwent</label><br>
<input type="radio" id="nauczyciel" name="profesja[]" value="nauczyciel" <?php if ($kto && strstr(implode('', $kto), 'nauczyciel')) echo 'checked';?>>
<label for="nauczyciel">nauczyciel</label><br>
<input type="radio" id="pracownik_administracji" name="profesja[]" value="pracownik administracji" <?php if ($kto && strstr(implode('', $kto), 'pracownik_administracji')) echo 'checked';?>>
<label for="pracownik_administracji">pracownik administracji</label><br>
<button type="submit">Submit</button>
</fieldset>
</form>
</body>
</html>

View file

@ -0,0 +1,83 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Formularz z walidacją</title>
</head>
<body>
<form action="index.php" method="post">
<fieldset style="border: 1px solid darkgreen; background-color: lightgreen">
<legend style="border:1px solid darkgreen;background-color: lightgreen">Formularz z walidacją</legend>
<?php
$login = $email = $kto = $page = $miasto = '';
$login_blad = $email_blad = $kto_blad = $page_blad = $miasto_blad = '';
if($_SERVER['REQUEST_METHOD']=='POST') {
if (empty($_POST['login'])) {
$login_blad = "Wpisz tu imię";
}
else {
$login = $_POST['login'];
}
if (empty($_POST['email'])) {
$email_blad = "Wpisz tu email";
}
else {
$email = $_POST['email'];
}
if (empty($_POST['gender'])) {
$kto_blad = "Wybierz jedną opcję";
}
else {
$kto = $_POST['gender'];
}
if (empty($_POST['miasto'])) {
$miasto_blad = "Wybierz miasto";
}
else {
$miasto = $_POST['miasto'];
}
if (empty($_POST['page'])) {
$page_blad = "Wpisz tu adres strony";
}
else {
$page = $_POST['page'];
}
}
?>
<label for="login">Login:</label>
<span style="color:red;">* <?=$login_blad?></span><br>
<input type="text" id="login" name="login" placeholder="podaj login" value="<?=$login?>"><br><br>
<label for="email">Email:</label>
<span style="color: red">* <?=$email_blad?></span><br>
<input type="text" id="email" name="email" placeholder="podaj email" value="<?=$email?>"><br><br>
<label for="page">Strona internetowa:</label>
<span style="color:red;">* <?=$page_blad?></span><br>
<input type="text" id="page" name="page" placeholder="podaj stronę internetową" value="<?=$page?>"><br><br>
<br>
<label for="#" >Wybierz miasto/miasta: </label>
<span style="color: red">* <?=$miasto_blad?></span><br>
<input type="checkbox" id="warszawa" name="miasto[]" value="warszawa" <?php if ($miasto && strstr(implode('', $miasto), 'warszawa')) echo 'checked';?>>
<label for="warszawa">Warszawa</label><br>
<input type="checkbox" id="poznan" name="miasto[]" value="poznan" <?php if ($miasto && strstr(implode('', $miasto), 'poznan')) echo 'checked';?>>
<label for="poznan">Poznań</label><br>
<input type="checkbox" id="gdansk" name="miasto[]" value="gdansk" <?php if ($miasto && strstr(implode('', $miasto), 'gdansk')) echo 'checked';?>>
<label for="gdansk">Gdańsk</label><br>
<input type="checkbox" id="szczecin" name="miasto[]" value="szczecin" <?php if ($miasto && strstr(implode('', $miasto), 'szczecin')) echo 'checked';?>>
<label for="szczecin">Szczecin</label><br><br>
<label for="#" >Wybierz jedną opcję </label>
<span style="color: red">* <?=$kto_blad?></span><br>
<input type="radio" id="kobieta" name="gender[]" value="kobieta" <?php if ($kto && strstr(implode('', $kto), 'kobieta')) echo 'checked';?>>
<label for="kobieta">kobieta</label><br>
<input type="radio" id="mezczyzna" name="gender[]" value="mezczyzna" <?php if ($kto && strstr(implode('', $kto), 'mezczyzna')) echo 'checked';?>>
<label for="mezczyzna">mężczyzna</label><br>
<input type="radio" id="unknown" name="gender[]" value="unknown" <?php if ($kto && strstr(implode('', $kto), 'unknown')) echo 'checked';?>>
<label for="unknown">nie chcę podawać</label><br><br>
<button type="submit">Wyślij</button>
</fieldset>
</form>
</body>
</html>