Upload files to "/"

This commit is contained in:
s490129 2024-06-13 22:38:24 +02:00
parent afc6814985
commit c47ee03b12
5 changed files with 217 additions and 0 deletions

83
SQLiteToProlog.java Normal file
View File

@ -0,0 +1,83 @@
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class SQLiteToProlog {
public static void main(String[] args) {
SQLiteToPrologConverter converter = new SQLiteToPrologConverter("tasks.db", "prolog.pl");
try {
converter.convert();
System.out.println("Data has been written to prolog.pl");
} catch (Exception e) {
e.printStackTrace();
}
}
}
class SQLiteToPrologConverter {
private String dbPath;
private String prologFilePath;
public SQLiteToPrologConverter(String dbPath, String prologFilePath) {
this.dbPath = dbPath;
this.prologFilePath = prologFilePath;
}
public void convert() throws ClassNotFoundException, SQLException, IOException {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
// Ładowanie klasy sterownika JDBC SQLite
Class.forName("org.sqlite.JDBC");
// Nawiązywanie połączenia z bazą danych SQLite
conn = DriverManager.getConnection("jdbc:sqlite:" + dbPath);
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT * FROM tasks");
// Tworzenie pliku Prolog i zapis danych
BufferedWriter writer = new BufferedWriter(new FileWriter(prologFilePath));
writer.write("has_duplicates(List) :- ");
writer.newLine();
writer.write("\tmember(X, List),");
writer.newLine();
writer.write("\tselect(X, List, Rest), ");
writer.newLine();
writer.write("\tmember(X, Rest), !.");
writer.newLine();
writer.write("collect_todos(Ys) :-");
writer.newLine();
writer.write("\tfindall(Y, todo(_, Y), Ys).");
writer.newLine();
writer.write("todos_have_duplicates :-");
writer.newLine();
writer.write("\tcollect_todos(Ys),");
writer.newLine();
writer.write("\thas_duplicates(Ys).");
writer.newLine();
while (rs.next()) {
int id = rs.getInt("id");
String task = rs.getString("task");
// Formatowanie wiersza jako relacji Prolog
String prologFact = String.format("todo(%d, '%s').", id, task.replace("'", "\\'"));
writer.write(prologFact);
writer.newLine();
}
writer.close();
} finally {
if (rs != null) rs.close();
if (stmt != null) stmt.close();
if (conn != null) conn.close();
}
}
}

Binary file not shown.

116
style.css Normal file
View File

@ -0,0 +1,116 @@
@keyframes blink {
0%, 50%, 100% {
opacity: 1;
}
25%, 75% {
opacity: 0;
}
}
.logo {
animation: blink 3s ease 0s 1 normal forwards;
outline: 1px solid #ff0000;
background: linear-gradient(0deg, #ff0000 0%, #c0f500 100%);
text-align: center;
line-height: 2;
font-size: 50px;
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
}
body {
font-family: 'Helvetica Neue', sans-serif;
background-color: #2c3e50;
color: #ecf0f1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
padding: 20px;
}
form {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
max-width: 400px;
background-color: #34495e;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
.input {
width: 100%;
padding: 12px;
margin-bottom: 15px;
border: 1px solid #1abc9c;
border-radius: 4px;
font-size: 16px;
background-color: #2c3e50;
color: #ecf0f1;
transition: border-color 0.3s, background-color 0.3s;
}
.input:focus {
border-color: #16a085;
outline: none;
background-color: #34495e;
}
.button {
width: 100%;
background-color: #1abc9c;
color: white;
padding: 12px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s;
}
.button:hover {
background-color: #16a085;
}
#todoList {
list-style: none;
padding: 0;
margin-top: 20px;
width: 100%;
max-width: 400px;
}
#todoList li {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px;
margin-top: 10px;
background-color: #34495e;
border-radius: 4px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
transition: background-color 0.3s;
}
#todoList li:hover {
background-color: #3b566e;
}
#todoList button {
background-color: #e74c3c;
border: none;
border-radius: 4px;
color: #ecf0f1;
cursor: pointer;
padding: 6px 10px;
font-size: 14px;
transition: background-color 0.3s;
}
#todoList button:hover {
background-color: #c0392b;
}

BIN
tasks.db Normal file

Binary file not shown.

18
todo.html Normal file
View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>To-Do List</title>
<link rel="stylesheet" href="style.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="script.js"></script>
</head>
<body>
<div class="logo">.TODO!</div>
<input class='input' type="text" id="todoInput" placeholder="Enter task">
<button class='button' id="addBtn">Add task</button>
<ul id="todoList"></ul>
</body>
</html>