Compare commits

...

2 Commits

Author SHA1 Message Date
piotrb 2ac625d825 qstack + localhost 2024-05-20 10:04:52 +02:00
piotrb 433fcc4754 init 2024-05-20 07:14:55 +02:00
5 changed files with 26 additions and 12 deletions

View File

@ -1,7 +1,22 @@
const url = "http://localhost/15.05/get.php"
const url = "http://localhost/p20/get.php"
fetch( url + 'get.php')
fetch(url)
.then(response => response.json())
.then( data => {
.then(data => {
console.log(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');
}

View File

@ -1,4 +1,4 @@
<?
<?php
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";

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,15 +8,16 @@
<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>
<button onclick="sortujSufiksy()">Sortuj Sufiksy</button>
<h2>Nieposortowane Sufiksy</h2>
<pre id="nieposortowane"></pre>
<h2>Posortowane Sufiksy</h2>
<pre id="posortowane"></pre>
<script src="js.js"></script>
<script src="fetch.js"></script>
</body>

3
js.js
View File

@ -8,6 +8,7 @@ function sortujSufiksy() {
sufiksy.sort();
document.getElementById('posortowane').textContent = formatSufiksy(sufiksy);
}
function formatSufiksy(sufiksy) {
return sufiksy.map((sufiks, index) => `${index + 1} ${sufiks}`).join('\n');
}
}

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;