Compare commits

..

15 Commits

Author SHA1 Message Date
james 5f5c9affe6 Merge branch 'jakubk' into dev 2024-05-21 09:51:18 +02:00
u1 3cc3e92d8b clean code 2024-05-21 08:24:27 +01:00
u1 d7505f59d3 u 2024-05-21 07:57:17 +01:00
Twoje Imię Nazwisko edff1c9ebd merge fix 2024-05-20 14:02:52 +02:00
piotrb 65c5b61829 merge 2024-05-20 12:08:44 +02:00
piotrb bdda7e717f i 2024-05-20 11:38:56 +02:00
piotrb e527916149 dane przekazane do funkcji 2024-05-20 10:32:10 +02:00
piotrb 24dc33d4cf Merge branch 'PiotrB' into dev 2024-05-20 10:09:18 +02:00
piotrb 2ac625d825 qstack + localhost 2024-05-20 10:04:52 +02:00
james c225a7d197 Merge branch 'jakubk' into dev 2024-05-20 07:50:30 +02:00
james d08593c413 Merge branch 'jakubk' into dev 2024-05-20 07:34:46 +02:00
pawel 817002a439 db update 2024-05-20 07:24:59 +02:00
pawel d8a7ad5383 fetch 2024-05-20 07:24:17 +02:00
pawel 0cf2d32d88 rob 2024-05-20 07:21:55 +02:00
piotrb 433fcc4754 init 2024-05-20 07:14:55 +02:00
5 changed files with 46 additions and 28 deletions

View File

@ -1,21 +1,14 @@
const url = "http://localhost/p20/get.php"
//const url = "http://localhost/p20/get.php"
const url = "http://qstack.pl:8080/z1/get.php"
let lista
fetch(url)
.then(response => response.json())
.then(data => {
console.log(data)
})
sortujSufiksy(data)
});
function sortujSufiksy() {
const slowo = document.getElementById('slowo').value;
const sufiksy = [];
for (let i = 0; i < slowo.length; i++) {
sufiksy.push(slowo.slice(i));
}
document.getElementById('nieposortowane').textContent = formatSufiksy(sufiksy);
sufiksy.sort();
document.getElementById('posortowane').textContent = formatSufiksy(sufiksy);
}
function formatSufiksy(sufiksy) {
return sufiksy.map((sufiks, index) => `${index + 1} ${sufiks}`).join('\n');
function sortujSufiksy(data) {
data.forEach((element) => document.querySelector('#nieposortowane').innerHTML += `<li> ${JSON.stringify(element.osoby)} </li>`);
}

View File

@ -2,7 +2,7 @@
$dbhost = "qstack.pl";
$dbuser = "boost";
$dbpass = "pass";
$dbname = "osoby";
$dbname = "db";
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
$ans = mysqli_query($conn, "SELECT * FROM osoby");

View File

@ -1,5 +1,6 @@
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@ -7,16 +8,21 @@
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Sortowanie Sufiksów</h1>
<input type="text" id="slowo" placeholder="Podaj słowo">
<button onclick="sortujSufiksy()">Sortuj Sufiksy</button>
<h2>Nieposortowane Sufiksy</h2>
<pre id="nieposortowane"></pre>
<div class="pre" id="nieposortowane"></div>
<h2>Posortowane Sufiksy</h2>
<pre id="posortowane"></pre>
<div class="pre" id="posortowane"></div>
<script src="fetch.js"></script>
<li id="lista">
<ol></ol>
</li>
</body>
</html>

17
qstack.php Normal file
View File

@ -0,0 +1,17 @@
<?php
$dbhost = "qstack.pl";
$dbuser = "root";
$dbpass = "";
$dbname = "osoby";
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
$ans = mysqli_query($conn, "SELECT * FROM osoby");
$json = array();
while ($row = mysqli_fetch_assoc($ans)) {
$json[] = $row;
}
echo json_encode($json);
?>

View File

@ -1,4 +1,3 @@
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
@ -14,7 +13,6 @@ h1 {
margin-bottom: 20px;
}
input[type="text"] {
width: calc(100% - 22px);
padding: 10px;
@ -24,7 +22,6 @@ input[type="text"] {
box-sizing: border-box;
}
button {
display: block;
width: 100%;
@ -41,7 +38,6 @@ button:hover {
background-color: #004494;
}
h2 {
color: #0056b3;
border-bottom: 2px solid #0056b3;
@ -49,10 +45,16 @@ h2 {
margin-top: 20px;
}
pre {
#nieposortowane {
display: flex;
flex-direction: column;
}
/* .pre {
background-color: #fff;
border: 1px solid #ccc;
padding: 10px;
border-radius: 4px;
overflow-x: auto;
}
} */