Compare commits
No commits in common. "dev2" and "piotrb" have entirely different histories.
28
fetch.js
28
fetch.js
|
@ -1,25 +1,7 @@
|
||||||
const url = "http://localhost/p20/get.php"
|
const url = "http://localhost/15.05/get.php"
|
||||||
|
|
||||||
fetch(url)
|
fetch( url + 'get.php')
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then( data => {
|
||||||
sortujSufiksy(data)
|
console.log(data)
|
||||||
});
|
})
|
||||||
|
|
||||||
function sortujSufiksy(data) {
|
|
||||||
const slowo = document.getElementById('slowo').value;
|
|
||||||
// console.log("tetst" + slowo)
|
|
||||||
const sufiksy = [];
|
|
||||||
for (let i = 0; i < slowo.length; i++) {
|
|
||||||
sufiksy.push(slowo.slice(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
data.forEach((element) => document.querySelector('#nieposortowane').innerHTML += `<li> ${JSON.stringify(element.osoby)} </li>`);
|
|
||||||
// console.log(formatSufiksy(sufiksy));
|
|
||||||
// sufiksy.sort();
|
|
||||||
// document.querySelector('#posortowane').innerHTML += formatSufiksy(sufiksy);
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatSufiksy(sufiksy) {
|
|
||||||
// console.log(sufiksy.map((sufiks, index) => `${index + 1} ${sufiks}`).join('\n'));
|
|
||||||
}
|
|
9
get.php
9
get.php
|
@ -1,14 +1,13 @@
|
||||||
<?php
|
<?
|
||||||
$dbhost = "qstack.pl";
|
$dbhost = "localhost";
|
||||||
$dbuser = "boost";
|
$dbuser = "root";
|
||||||
$dbpass = "pass";
|
$dbpass = "";
|
||||||
$dbname = "osoby";
|
$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");
|
||||||
$json = array();
|
$json = array();
|
||||||
|
|
||||||
|
|
||||||
while ($row = mysqli_fetch_assoc($ans)) {
|
while ($row = mysqli_fetch_assoc($ans)) {
|
||||||
$json[] = $row;
|
$json[] = $row;
|
||||||
}
|
}
|
||||||
|
|
23
index.html
23
index.html
|
@ -1,28 +1,13 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="pl">
|
<html lang="en">
|
||||||
|
|
||||||
<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">
|
||||||
<title>Sortowanie Sufiksów</title>
|
<title>Document</title>
|
||||||
<link rel="stylesheet" href="styles.css">
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<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>
|
|
||||||
<div class="pre" id="nieposortowane"></div>
|
|
||||||
<h2>Posortowane Sufiksy</h2>
|
|
||||||
<div class="pre" id="posortowane"></div>
|
|
||||||
<script src="fetch.js"></script>
|
<script src="fetch.js"></script>
|
||||||
|
|
||||||
<li id="lista">
|
|
||||||
<ol></ol>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
17
qstack.php
17
qstack.php
|
@ -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);
|
|
||||||
|
|
||||||
?>
|
|
60
styles.css
60
styles.css
|
@ -1,60 +0,0 @@
|
||||||
body {
|
|
||||||
font-family: Arial, sans-serif;
|
|
||||||
background-color: #f5f5f5;
|
|
||||||
color: #333;
|
|
||||||
margin: 0;
|
|
||||||
padding: 20px;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
text-align: center;
|
|
||||||
color: #0056b3;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="text"] {
|
|
||||||
width: calc(100% - 22px);
|
|
||||||
padding: 10px;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
border-radius: 4px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
button {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
padding: 10px;
|
|
||||||
background-color: #0056b3;
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
border-radius: 4px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
button:hover {
|
|
||||||
background-color: #004494;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
color: #0056b3;
|
|
||||||
border-bottom: 2px solid #0056b3;
|
|
||||||
padding-bottom: 5px;
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#nieposortowane {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* .pre {
|
|
||||||
background-color: #fff;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
padding: 10px;
|
|
||||||
border-radius: 4px;
|
|
||||||
overflow-x: auto;
|
|
||||||
} */
|
|
Loading…
Reference in New Issue