Compare commits
2 Commits
e527916149
...
65c5b61829
Author | SHA1 | Date |
---|---|---|
piotrb | 65c5b61829 | |
piotrb | bdda7e717f |
25
fetch.js
25
fetch.js
|
@ -1,9 +1,13 @@
|
||||||
const url = "http://localhost/p20/get.php"
|
const url = "http://localhost/p20/get.php"
|
||||||
|
<<<<<<< HEAD
|
||||||
let lista
|
let lista
|
||||||
|
=======
|
||||||
|
>>>>>>> dev2
|
||||||
|
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
<<<<<<< HEAD
|
||||||
// console.log(data)
|
// console.log(data)
|
||||||
sortujSufiksy(data)
|
sortujSufiksy(data)
|
||||||
})
|
})
|
||||||
|
@ -25,4 +29,25 @@ function sortujSufiksy(data) {
|
||||||
|
|
||||||
function formatSufiksy(sufiksy) {
|
function formatSufiksy(sufiksy) {
|
||||||
return sufiksy.map((sufiks, index) => `${index + 1} ${sufiks}`).join('\n');
|
return sufiksy.map((sufiks, index) => `${index + 1} ${sufiks}`).join('\n');
|
||||||
|
=======
|
||||||
|
sortujSufiksy(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'));
|
||||||
|
>>>>>>> dev2
|
||||||
}
|
}
|
|
@ -14,9 +14,15 @@
|
||||||
<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>
|
||||||
|
<<<<<<< HEAD
|
||||||
<pre id="nieposortowane"></pre>
|
<pre id="nieposortowane"></pre>
|
||||||
<h2>Posortowane Sufiksy</h2>
|
<h2>Posortowane Sufiksy</h2>
|
||||||
<pre id="posortowane"></pre>
|
<pre id="posortowane"></pre>
|
||||||
|
=======
|
||||||
|
<div class="pre" id="nieposortowane"></div>
|
||||||
|
<h2>Posortowane Sufiksy</h2>
|
||||||
|
<div class="pre" id="posortowane"></div>
|
||||||
|
>>>>>>> dev2
|
||||||
<script src="fetch.js"></script>
|
<script src="fetch.js"></script>
|
||||||
|
|
||||||
<li id="lista">
|
<li id="lista">
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
?>
|
16
styles.css
16
styles.css
|
@ -45,10 +45,24 @@ h2 {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
pre {
|
pre {
|
||||||
|
=======
|
||||||
|
#nieposortowane {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* .pre {
|
||||||
|
>>>>>>> dev2
|
||||||
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;
|
||||||
}
|
<<<<<<< HEAD
|
||||||
|
}
|
||||||
|
=======
|
||||||
|
} */
|
||||||
|
>>>>>>> dev2
|
||||||
|
|
Loading…
Reference in New Issue