From 33cf84d16c0846a82d71eb801ae9ad00b8e2a51f Mon Sep 17 00:00:00 2001 From: yshuu822006 Date: Sun, 7 Jun 2026 10:28:02 +0530 Subject: [PATCH] first commit --- check_db.js | 14 + css/index.css | 35 ++ database.js | 67 ++-- index.html | 345 +++++++++++++++--- js/app.js | 884 +++++++++++++++++----------------------------- js/store.js | 96 ++++- package-lock.json | 2 +- server.js | 310 +++++++++++----- server_debug.log | 10 + server_output.log | 10 + server_test.log | 10 + server_test2.log | 10 + 12 files changed, 1040 insertions(+), 753 deletions(-) create mode 100644 check_db.js create mode 100644 server_debug.log create mode 100644 server_output.log create mode 100644 server_test.log create mode 100644 server_test2.log diff --git a/check_db.js b/check_db.js new file mode 100644 index 0000000..d40ee37 --- /dev/null +++ b/check_db.js @@ -0,0 +1,14 @@ +const sqlite3 = require('sqlite3'); +const path = require('path'); + +const db = new sqlite3.Database(path.join(__dirname, 'studyplan.db')); + +db.all("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name", (err, rows) => { + if (err) { + console.error('Error:', err); + } else { + console.log('Tables in database:'); + rows.forEach(row => console.log(` - ${row.name}`)); + } + db.close(); +}); diff --git a/css/index.css b/css/index.css index 59ae8c8..04822c4 100644 --- a/css/index.css +++ b/css/index.css @@ -5183,3 +5183,38 @@ body { .subject-sidebar-item:hover .delete-subject-btn { opacity: 1; } + +/* Notes Styling */ +.note-card { + transition: all 0.2s ease; + background: var(--color-background-primary); +} + +.note-card:hover { + border-color: var(--color-border-primary); + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); +} + +.note-card:hover .note-edit-btn { + background: var(--color-background-secondary); + border-color: var(--color-border-primary); +} + +#notes-section { + background: var(--color-background-primary); + min-height: 100vh; +} + +#notes-search { + background: var(--color-background-secondary) !important; + transition: all 0.2s; +} + +#notes-search:focus { + border-color: var(--color-border-primary) !important; + outline: none; +} + +#notes-list { + animation: fadeIn 0.3s ease-in-out; +} diff --git a/database.js b/database.js index d2a34f8..7fb3d11 100644 --- a/database.js +++ b/database.js @@ -5,6 +5,15 @@ const db = new sqlite3.Database(path.join(__dirname, 'studyplan.db')); function initDb() { db.serialize(() => { + // Users Table + db.run(`CREATE TABLE IF NOT EXISTS users ( + id TEXT PRIMARY KEY, + email TEXT NOT NULL UNIQUE, + password TEXT NOT NULL, + reset_token TEXT, + reset_token_expiry DATETIME, + created_at DATETIME DEFAULT CURRENT_TIMESTAMP + )`); // Subjects Table db.run(`CREATE TABLE IF NOT EXISTS subjects ( @@ -15,18 +24,9 @@ function initDb() { created_at DATETIME DEFAULT CURRENT_TIMESTAMP )`); - // ================= USERS TABLE ================= - db.run(`CREATE TABLE IF NOT EXISTS users ( - id TEXT PRIMARY KEY, - email TEXT UNIQUE NOT NULL, - password TEXT NOT NULL, - created_at DATETIME DEFAULT CURRENT_TIMESTAMP - )`); - - // ================= TASKS TABLE ================= + // Tasks Table db.run(`CREATE TABLE IF NOT EXISTS tasks ( id TEXT PRIMARY KEY, - user_email TEXT, subject_id TEXT, title TEXT NOT NULL, description TEXT, @@ -36,8 +36,6 @@ function initDb() { confidence_score REAL, notes TEXT, archived INTEGER DEFAULT 0, - estimated_duration INTEGER, - is_estimated_duration_min BOOLEAN, labels TEXT DEFAULT '[]', created_at DATETIME DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (subject_id) REFERENCES subjects(id) @@ -46,59 +44,34 @@ function initDb() { // Add labels column to existing tasks table if it doesn't exist db.all("PRAGMA table_info(tasks)", (err, rows) => { if (err) return; - const hasLabels = rows.some(r => r.name === 'labels'); if (!hasLabels) { db.run("ALTER TABLE tasks ADD COLUMN labels TEXT DEFAULT '[]'"); } - - // ================= ADD USER EMAIL COLUMN ================= - const hasUserEmail = rows.some(r => r.name === 'user_email'); - if (!hasUserEmail) { - db.run("ALTER TABLE tasks ADD COLUMN user_email TEXT"); - } }); -db.all("PRAGMA table_info(tasks)", (err, rows) => { - if (err) return; - - const columnNames = rows.map((row) => row.name); - - // Estimated duration columns - if (!columnNames.includes("estimated_duration")) { - db.run("ALTER TABLE tasks ADD COLUMN estimated_duration INTEGER"); - } - if (!columnNames.includes("is_estimated_duration_min")) { - db.run( - "ALTER TABLE tasks ADD COLUMN is_estimated_duration_min BOOLEAN" - ); - } - - // Labels column - if (!columnNames.includes("labels")) { - db.run("ALTER TABLE tasks ADD COLUMN labels TEXT DEFAULT '[]'"); - } -}); + // Notes Table + db.run(`CREATE TABLE IF NOT EXISTS notes ( + id TEXT PRIMARY KEY, + title TEXT NOT NULL, + content TEXT, + created_at DATETIME DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME DEFAULT CURRENT_TIMESTAMP + )`); // Pre-populate some subjects if empty db.get('SELECT COUNT(*) as count FROM subjects', (err, row) => { if (row && row.count === 0) { console.log("Seeding subjects..."); - - const stmt = db.prepare( - "INSERT INTO subjects (id, name, short_code, color) VALUES (?, ?, ?, ?)" - ); - + const stmt = db.prepare("INSERT INTO subjects (id, name, short_code, color) VALUES (?, ?, ?, ?)"); stmt.run('sub_1', 'Computer Science', 'CS', 'var(--color-text-info)'); stmt.run('sub_2', 'Mathematics', 'Maths', 'var(--color-text-success)'); stmt.run('sub_3', 'English Lit', 'English', 'var(--color-text-purple)'); stmt.run('sub_4', 'Physics', 'Physics', 'var(--color-text-warning)'); - stmt.finalize(); } }); - }); } -module.exports = { db, initDb }; \ No newline at end of file +module.exports = { db, initDb }; diff --git a/index.html b/index.html index aa1d464..ce11140 100644 --- a/index.html +++ b/index.html @@ -44,10 +44,63 @@

Wel Sign Up

+ + + + + + + +