This commit is contained in:
jakub
2025-10-25 19:07:17 +02:00
parent ec69901011
commit 83195ab72f
4 changed files with 765 additions and 0 deletions

View File

@@ -0,0 +1,116 @@
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$pattern = $_POST['pattern'];
$rowNum = $_POST['rowNum'];
$customPattern = $_POST['customPattern'];
$pattern = htmlspecialchars($pattern);
}
?>
<!doctype html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Z114 - Pusty Diament</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Zadanie Z114</h1>
<h2>Autor: Jakub Grzegorczyk</h2>
</header>
<div class="box">
<h3>Cel</h3>
<p>Stwórz stronę internetową, która generuje wzór w kształcie diamentu (romboidalny układ) z "cegiełek", gdzie środek diamentu pozostaje pusty, a "cegły" tworzą tylko obrzeże.</p>
<h3>Wymagania</h3>
<ol>
<li>
Strona zawiera formularz HTML z następującymi elementami:
<ul>
<li>Lista rozwijana (<code>&ltselect&gt</code>) z predefiniowanymi wzorami "cegły" (np. <code>[==]</code>, <code>{**}</code>, <code><##></code>, <code>@@@</code>) oraz opcją "Inny wzór".
</li>
<li>Pole tekstowe do wprowadzenia własnego wzoru "cegły", jeśli wybrano "Inny wzór".</li>
<li>Pole numeryczne do określenia liczby wierszy diamentu (od 1 do 50).</li>
<li>Przycisk "Rysuj pusty diament" do przesłania formularza metodą POST.</li>
</ul>
</li>
<li>
Po przesłaniu formularza, PHP generuje diament:
<ul>
<li>Górna część: od 1 "cegły" w pierwszym wierszu do pełnej szerokości w środkowym wierszu.</li>
<li>Dolna część: symetryczne zwężanie od środkowego wiersza do 1 "cegły".</li>
<li>W wierszach dłuższych niż 1 "cegły" pojawiają się tylko na początku i końcu, a środek pozostaje pusty.</li>
</ul>
</li>
<li>
Stylizacja CSS:
<ul>
<li>"Cegły" (<code>span class="cegla"</code>) mają tło, cień i efekt skalowania przy najechaniu myszą.</li>
<li>Puste miejsca w środku diamentu muszą mieć dynamiczną szerokość równą szerokości wybranej "cegły" (użyj np. niewidocznych &ltspan&gt z taką samą stylizacją).</li>
<li>Strona ma estetyczne tło (np. gradient) i wyśrodkowany układ.</li>
</ul>
</li>
</ol>
<h3>Przykład wyniku</h3>
<p>Dla wzoru [==] i 5 wierszy:</p>
<pre>
[==]
[==] [==]
[==] [==]
[==] [==]
[==]
</pre>
<h3>Wskazówki</h3>
<ul>
<li>Użyj pętli w PHP do generowania wierszy diamentu.</li>
<li>Zadbaj o to, by odstępy w środku były proporcjonalne do rozmiaru "cegły" (np. poprzez ukryte elementy).</li>
<li>Przetestuj różne wzory "cegły" (krótkie i długie), aby upewnić się, że układ działa poprawnie.</li>
</ul>
<h3>Dodatkowe wyzwanie (opcjonalne)</h3>
<p>Dodaj walidację, aby upewnić się, że własny wzór "cegły" nie jest pusty i ma maksymalnie 10 znaków.</p>
</div>
<div class="box">
<form action="index.php" method="post">
<fieldset>
<legend>Wybierz wzór:</legend>
<label for="pattern">Wzór:</label>
<select name="pattern" id="pattern">
<option value="[==]">[==]</option>
<option value="{**}">{**}</option>
<option value="<##>"><##></option>
<option value="@@@">@@@</option>
<option value="custom">Inny wzór</option>
</select>
<label for="customPattern">Inny wzór:</label>
<input type="text" name="customPattern" id="customPattern">
<label for="rowNum">Ilość Wierszy:</label>
<input type="number" name="rowNum" id="rowNum" min="1" max="50">
</fieldset>
<button type="submit">Rysuj pusty diament</button>
</form>
</div>
</body>
<script>
const patternSelect = document.getElementById('pattern');
const customPatternInput = document.getElementById('customPattern');
const customPatternLabel = document.querySelector('label[for="customPattern"]');
function toggleCustomPattern() {
if (patternSelect.value === 'custom') {
customPatternInput.style.display = 'inline-block';
customPatternLabel.style.display = 'inline-block';
} else {
customPatternInput.style.display = 'none';
customPatternLabel.style.display = 'none';
}
}
// Ukryj pole przy załadowaniu strony
toggleCustomPattern();
// Nasłuchuj zmian w select
patternSelect.addEventListener('change', toggleCustomPattern);
</script>
</html>

View File

@@ -0,0 +1,291 @@
/* === UNIVERSAL SCHOOL TEMPLATE CSS (BLACK & WHITE EDITION) === */
/* clean, modern, and copy-paste friendly for all projects */
/* === RESET === */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
/* === VARIABLES === */
:root {
--accent: #000;
--border: #000;
--bg: #fff;
--bg-alt: #f7f7f7;
--text: #111;
--shadow: rgba(0, 0, 0, 0.15) 3px 3px 6px;
--radius: 1em;
--max-width: 1300px;
}
/* === PAGE === */
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Verdana, sans-serif;
background: linear-gradient(180deg, #ffffff 0%, #f5f5f5 100%);
color: var(--text);
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
line-height: 1.6;
}
/* === HEADER === */
header {
border: 2px solid var(--border);
border-radius: var(--radius);
padding: 20px 30px;
box-shadow: var(--shadow);
background: var(--bg);
width: 95%;
max-width: var(--max-width);
text-align: center;
margin-top: 25px;
transition: box-shadow 0.3s ease, transform 0.2s ease;
}
header:hover {
box-shadow: rgba(0, 0, 0, 0.25) 4px 4px 10px;
transform: translateY(-2px);
}
header h1 {
font-size: 2.2rem;
}
header h2 {
margin-top: 0.5rem;
font-weight: 400;
font-size: 1.1rem;
color: #444;
}
/* === BOX === */
.box {
border: 2px solid var(--border);
border-radius: var(--radius);
padding: 25px 35px;
margin-top: 25px;
background: var(--bg);
box-shadow: var(--shadow);
width: 95%;
max-width: var(--max-width);
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.box:hover {
transform: translateY(-2px);
box-shadow: rgba(0, 0, 0, 0.25) 4px 4px 10px;
}
/* === TEXT ELEMENTS === */
p {
margin-bottom: 1rem;
}
h1, h2, h3, h4 {
margin-bottom: 0.5rem;
font-weight: 600;
}
a {
color: #000;
text-decoration: underline;
font-weight: 500;
}
a:hover {
opacity: 0.7;
}
/* === LISTS === */
ul, ol {
margin: 1rem 0 1rem 1.5rem;
}
li {
margin-bottom: 0.4rem;
}
/* === TABLES === */
table {
width: 100%;
border-collapse: collapse;
margin: 1rem 0;
background: var(--bg);
border: 2px solid var(--border);
border-radius: 0.6em;
overflow: hidden;
box-shadow: var(--shadow);
}
th, td {
padding: 10px 12px;
border-bottom: 1px solid #ccc;
}
th {
background: var(--bg-alt);
font-weight: bold;
text-align: left;
}
tr:hover {
background: #f2f2f2;
}
/* === FORMS === */
form {
display: flex;
flex-direction: column;
gap: 1.2rem;
margin-top: 1rem;
}
fieldset {
border: 2px solid var(--border);
border-radius: 0.8em;
padding: 1.2rem 1.5rem;
background: var(--bg-alt);
}
legend {
font-weight: bold;
color: #000;
padding: 0 0.4rem;
font-size: 1.05rem;
}
label {
font-weight: 500;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
textarea,
select {
width: 100%;
font-size: 1rem;
margin-top: 6px;
margin-bottom: 8px;
border: 2px solid var(--border);
border-radius: 0.5em;
padding: 0.4rem 0.5rem;
transition: all 0.2s ease;
background: var(--bg);
}
textarea {
resize: vertical;
min-height: 100px;
}
input:focus,
textarea:focus,
select:focus {
outline: none;
border-color: #000;
box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
background: #f9f9f9;
}
input[type="radio"],
input[type="checkbox"] {
accent-color: #000;
transform: scale(1.2);
margin-right: 0.3rem;
}
/* === BUTTONS === */
button,
input[type="submit"],
input[type="button"],
input[type="reset"] {
padding: 10px 20px;
border: 2px solid var(--border);
border-radius: 0.5em;
font-weight: bold;
font-size: 1rem;
background: linear-gradient(180deg, #fff 0%, #f2f2f2 100%);
cursor: pointer;
transition: all 0.2s ease;
align-self: flex-start;
}
button {
width: 100%;
}
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover {
background: #eaeaea;
box-shadow: rgba(0, 0, 0, 0.25) 3px 3px 6px;
transform: translateY(-2px);
}
button:active,
input[type="submit"]:active,
input[type="button"]:active,
input[type="reset"]:active {
transform: translateY(0);
box-shadow: rgba(0, 0, 0, 0.15) 1px 1px 3px;
background: #f7f7f7;
}
/* === HR, CODE, ETC. === */
hr {
border: 0;
border-top: 2px solid var(--border);
margin: 1.5rem 0;
}
img {
max-width: 100%;
border-radius: 0.5em;
}
code, pre {
background: #f4f4f4;
border: 1px solid #ccc;
border-radius: 0.4em;
padding: 0.3em 0.5em;
font-family: "Courier New", monospace;
}
pre {
padding: 1em;
overflow-x: auto;
}
/* === RESPONSIVE === */
@media (max-width: 900px) {
header, .box {
width: 95%;
padding: 20px;
}
button {
width: 100%;
}
textarea {
width: 100%;
}
}
@media (max-width: 600px) {
header h1 {
font-size: 1.7rem;
}
header h2 {
font-size: 0.95rem;
}
}

View File

@@ -0,0 +1,67 @@
<?php
?>
<!doctype html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Z58 - Znaki i kody ASCII</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Zadanie Z58</h1>
<h2>Autor: Jakub Grzegorczyk</h2>
</header>
<div class="box">
<p>
Napisz program, który daje użytkownikowi wybór, czy chce wyświetlić numer kodu ASCII dla podanego znaku (za pomocą funkcji ord()), czy znak dla podanego kodu ASCII (za pomocą funkcji chr()), a następnie wykonuje wybrane działanie. Program powinien przyjmować dane z formularza, weryfikować ich poprawność i wyświetlać wynik w czytelny sposób.
<br>
<b>Wskazówki dla ucznia</b>
</p>
<ul>
<li>Użyj listy rozwijanej (select), aby użytkownik wskazał, co chce zrobić.</li>
<li>Dla kodu ASCII → znak: sprawdź, czy podana wartość jest liczbą (is_numeric()) i mieści się w zakresie 0-255 (standardowy ASCII).</li>
<li>Dla znaku → kod ASCII: akceptuj pojedynczy znak i użyj ord() na pierwszym znaku ciągu.</li>
<li>Zabezpiecz dane wejściowe za pomocą htmlspecialchars(), ale tylko przy wyświetlaniu, aby nie zmieniać danych do obliczeń.</li>
<li>Wyświetl zarówno dane wejściowe, jak i wynik działania.</li>
</ul>
</div>
<div class="box">
<form action="index.php" method="post">
<fieldset>
<legend>Wybierz działanie:</legend>
<label for="action">Działanie</label>
<select name="action" id="action">
<option value="to_ascii" selected="">Znak → Kod ASCII</option>
<option value="to_char">Kod ASCII → Znak</option>
</select>
<label for="x">Wprowadź wartość:</label>
<input type="text" name="x" id="x" required>
</fieldset>
<button type="submit">Wyślij</button>
</form>
</div>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$action = $_POST['action'];
$x = $_POST['x'];
echo '<div class="box">';
if ($action == 'to_ascii') {
if (strlen($x) == 1) {
echo "Znak: " . htmlspecialchars($x) . "<br>";
echo "Kod ASCII: " . ord($x) . "<br>";
}
} elseif ($action == 'to_char') {
if (is_numeric($x) && $x >= 0 && $x <= 255) {
echo "Kod ASCII: " . htmlspecialchars($x) . "<br>";
echo "Znak: " . chr($x) . "<br>";
}
}
echo '</div>';
}
?>
</body>
</html>

View File

@@ -0,0 +1,291 @@
/* === UNIVERSAL SCHOOL TEMPLATE CSS (BLACK & WHITE EDITION) === */
/* clean, modern, and copy-paste friendly for all projects */
/* === RESET === */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
/* === VARIABLES === */
:root {
--accent: #000;
--border: #000;
--bg: #fff;
--bg-alt: #f7f7f7;
--text: #111;
--shadow: rgba(0, 0, 0, 0.15) 3px 3px 6px;
--radius: 1em;
--max-width: 1300px;
}
/* === PAGE === */
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Verdana, sans-serif;
background: linear-gradient(180deg, #ffffff 0%, #f5f5f5 100%);
color: var(--text);
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
line-height: 1.6;
}
/* === HEADER === */
header {
border: 2px solid var(--border);
border-radius: var(--radius);
padding: 20px 30px;
box-shadow: var(--shadow);
background: var(--bg);
width: 95%;
max-width: var(--max-width);
text-align: center;
margin-top: 25px;
transition: box-shadow 0.3s ease, transform 0.2s ease;
}
header:hover {
box-shadow: rgba(0, 0, 0, 0.25) 4px 4px 10px;
transform: translateY(-2px);
}
header h1 {
font-size: 2.2rem;
}
header h2 {
margin-top: 0.5rem;
font-weight: 400;
font-size: 1.1rem;
color: #444;
}
/* === BOX === */
.box {
border: 2px solid var(--border);
border-radius: var(--radius);
padding: 25px 35px;
margin-top: 25px;
background: var(--bg);
box-shadow: var(--shadow);
width: 95%;
max-width: var(--max-width);
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.box:hover {
transform: translateY(-2px);
box-shadow: rgba(0, 0, 0, 0.25) 4px 4px 10px;
}
/* === TEXT ELEMENTS === */
p {
margin-bottom: 1rem;
}
h1, h2, h3, h4 {
margin-bottom: 0.5rem;
font-weight: 600;
}
a {
color: #000;
text-decoration: underline;
font-weight: 500;
}
a:hover {
opacity: 0.7;
}
/* === LISTS === */
ul, ol {
margin: 1rem 0 1rem 1.5rem;
}
li {
margin-bottom: 0.4rem;
}
/* === TABLES === */
table {
width: 100%;
border-collapse: collapse;
margin: 1rem 0;
background: var(--bg);
border: 2px solid var(--border);
border-radius: 0.6em;
overflow: hidden;
box-shadow: var(--shadow);
}
th, td {
padding: 10px 12px;
border-bottom: 1px solid #ccc;
}
th {
background: var(--bg-alt);
font-weight: bold;
text-align: left;
}
tr:hover {
background: #f2f2f2;
}
/* === FORMS === */
form {
display: flex;
flex-direction: column;
gap: 1.2rem;
margin-top: 1rem;
}
fieldset {
border: 2px solid var(--border);
border-radius: 0.8em;
padding: 1.2rem 1.5rem;
background: var(--bg-alt);
}
legend {
font-weight: bold;
color: #000;
padding: 0 0.4rem;
font-size: 1.05rem;
}
label {
font-weight: 500;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
textarea,
select {
width: 100%;
font-size: 1rem;
margin-top: 6px;
margin-bottom: 8px;
border: 2px solid var(--border);
border-radius: 0.5em;
padding: 0.4rem 0.5rem;
transition: all 0.2s ease;
background: var(--bg);
}
textarea {
resize: vertical;
min-height: 100px;
}
input:focus,
textarea:focus,
select:focus {
outline: none;
border-color: #000;
box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
background: #f9f9f9;
}
input[type="radio"],
input[type="checkbox"] {
accent-color: #000;
transform: scale(1.2);
margin-right: 0.3rem;
}
/* === BUTTONS === */
button,
input[type="submit"],
input[type="button"],
input[type="reset"] {
padding: 10px 20px;
border: 2px solid var(--border);
border-radius: 0.5em;
font-weight: bold;
font-size: 1rem;
background: linear-gradient(180deg, #fff 0%, #f2f2f2 100%);
cursor: pointer;
transition: all 0.2s ease;
align-self: flex-start;
}
button {
width: 100%;
}
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover {
background: #eaeaea;
box-shadow: rgba(0, 0, 0, 0.25) 3px 3px 6px;
transform: translateY(-2px);
}
button:active,
input[type="submit"]:active,
input[type="button"]:active,
input[type="reset"]:active {
transform: translateY(0);
box-shadow: rgba(0, 0, 0, 0.15) 1px 1px 3px;
background: #f7f7f7;
}
/* === HR, CODE, ETC. === */
hr {
border: 0;
border-top: 2px solid var(--border);
margin: 1.5rem 0;
}
img {
max-width: 100%;
border-radius: 0.5em;
}
code, pre {
background: #f4f4f4;
border: 1px solid #ccc;
border-radius: 0.4em;
padding: 0.3em 0.5em;
font-family: "Courier New", monospace;
}
pre {
padding: 1em;
overflow-x: auto;
}
/* === RESPONSIVE === */
@media (max-width: 900px) {
header, .box {
width: 95%;
padding: 20px;
}
button {
width: 100%;
}
textarea {
width: 100%;
}
}
@media (max-width: 600px) {
header h1 {
font-size: 1.7rem;
}
header h2 {
font-size: 0.95rem;
}
}