25 lines
800 B
JavaScript
25 lines
800 B
JavaScript
|
const url = "http://localhost/p20/get.php"
|
||
|
|
||
|
fetch(url)
|
||
|
.then(response => response.json())
|
||
|
.then(data => {
|
||
|
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'));
|
||
|
}
|