diff --git a/SQLiteToProlog.java b/SQLiteToProlog.java new file mode 100644 index 0000000..5c10e49 --- /dev/null +++ b/SQLiteToProlog.java @@ -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(); + } + } +} diff --git a/SQLiteToPrologConverter.class b/SQLiteToPrologConverter.class new file mode 100644 index 0000000..cc1675a Binary files /dev/null and b/SQLiteToPrologConverter.class differ diff --git a/style.css b/style.css new file mode 100644 index 0000000..ca48359 --- /dev/null +++ b/style.css @@ -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; +} diff --git a/tasks.db b/tasks.db new file mode 100644 index 0000000..8fa241f Binary files /dev/null and b/tasks.db differ diff --git a/todo.html b/todo.html new file mode 100644 index 0000000..4f8df4b --- /dev/null +++ b/todo.html @@ -0,0 +1,18 @@ + + + + + + To-Do List + + + + + + + + + + + +