Compare commits

..

No commits in common. "5f5c9affe672ab28f8ed8ab06f89902ea6da2442" and "35942874226ddfb9d01fa1f3b5d02208aa44f07f" have entirely different histories.

5 changed files with 28 additions and 46 deletions

View File

@ -1,14 +1,21 @@
//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) fetch(url)
.then(response => response.json()) .then(response => response.json())
.then(data => { .then( data => {
sortujSufiksy(data) console.log(data)
}); })
function sortujSufiksy(data) { function sortujSufiksy() {
const slowo = document.getElementById('slowo').value;
data.forEach((element) => document.querySelector('#nieposortowane').innerHTML += `<li> ${JSON.stringify(element.osoby)} </li>`); 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');
} }

View File

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

View File

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

View File

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