[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-117413":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":8,"htmlUrl":8,"language":9,"languages":8,"totalLinesOfCode":8,"stars":10,"forks":11,"watchers":12,"openIssues":13,"contributorsCount":13,"subscribersCount":13,"size":13,"stars1d":14,"stars7d":15,"stars30d":15,"stars90d":13,"forks30d":13,"starsTrendScore":16,"compositeScore":17,"rankGlobal":8,"rankLanguage":8,"license":8,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":20,"hasPages":18,"topics":21,"createdAt":8,"pushedAt":22,"updatedAt":23,"readmeContent":24,"aiSummary":8,"trendingCount":13,"starSnapshotCount":13,"syncStatus":14,"lastSyncTime":25,"discoverSource":26},117413,"library-management-system-frontend","wahidulalamriyad\u002Flibrary-management-system-frontend","wahidulalamriyad",null,"JavaScript",63,8,57,0,2,5,9,43.86,false,"main",true,[],"2026-10-31 10:49:58","2026-11-23 04:28:00","# BookNest — Library Management System (Frontend Version)\n\nCSC 3215 Web Technologies project. Built only with what the lecture and lab slides cover\n(Weeks 1–6): HTML pages and forms, an external CSS file, external JavaScript files,\nJavaScript form validation and DOM manipulation. The PHP + MySQL backend will be added later.\n\n## How to run\n\nNo installation needed. Open `index.html` in Chrome or Firefox\n(double-click it, or use VS Code's Live Server).\n\nEveryone uses the **same login page** with just a username (or email) and password.\nThe role stored in the account decides which dashboard opens.\n\n| Role      | Username    | Password     |\n|-----------|-------------|--------------|\n| Admin     | `admin`     | `admin1234`  |\n| Librarian | `librarian` | `library123` |\n| Student   | `student`   | `student123` |\n| Visitor   | `visitor`   | `visitor123` |\n| Librarian waiting for approval | `jamal` | `jamal1234` (login is refused until an admin approves) |\n\nThe login page also has \"Use\" buttons that fill these in.\n\n### Registration and accounts\n\n- **One registration page** (`register.html`) for Students, Librarians and Visitors.\n  Step 1 asks for the type of user; JavaScript then shows the common fields plus only\n  that type's fieldset (`element.style.display`):\n  - **Student:** Student ID (23-51234-1), department, semester, favourite subjects\n  - **Librarian:** Employee ID (EMP-1234), qualification, years of experience, preferred shift\n  - **Visitor:** NID (10\u002F13\u002F17 digits), occupation, organization, address, interests\n- Minimum age changes by type (Visitor 12, Student 16, Librarian 18).\n- New **librarians start as Pending**; an admin approves them in *Manage Users*.\n- **Admins are not on the public page.** An existing admin adds new admins from *Manage Users*.\n\n> **Frontend only:** all data lives in JavaScript arrays of objects (`js\u002Fdata.js`).\n> Changes work while you stay on a page, and reset when the page reloads or you move to\n> another page. This is expected until the backend stores the data in a database.\n\n## Folder structure (HTML \u002F CSS \u002F JS separation)\n\n```\nlibrary-management-system\u002F\n├── index.html        Home page: catalogue search, who it is for, how it works, hours\n├── login.html        ONE login page for all four user types\n├── register.html     ONE registration page; fields change with the user type\n├── admin.html        Admin dashboard\n├── librarian.html    Librarian dashboard\n├── student.html      Student dashboard\n├── visitor.html      Visitor dashboard\n├── css\u002F\n│   └── style.css     ONE external style sheet linked from every page\n└── js\u002F\n    ├── data.js       Sample data: arrays of objects (users, books, loans, ...)\n    ├── common.js     Shared helpers: showSection, showError, validation, dates, search\n    ├── home.js       Home page search\n    ├── login.js      validateLogin() + switch on role\n    ├── register.js   showTypeFields() + validateRegister()\n    ├── admin.js      Admin features\n    ├── librarian.js  Librarian features\n    ├── student.js    Student features\n    └── visitor.js    Visitor features\n```\n\nEvery page loads its scripts at the end of `\u003Cbody>` in this order:\n`data.js` → `common.js` → the page's own script.\n\n## Features by user\n\nEvery user can **Create, Read, Update, Delete and Search** their own kind of record,\nplus **3 unique features** that no other user has.\n\n| User | CRUD + Search on | Unique feature 1 | Unique feature 2 | Unique feature 3 |\n|---|---|---|---|---|\n| **Admin** | User accounts of all four roles, incl. adding admins and approving pending librarians | **Statistics Report** — counts users, copies, loans, overdue loans and fines with loops; bar charts | **Library Rules Settings** — fine per day, loan period, book limit, renewal rules, with a live preview | **Activity Log Monitor** — scrolling notice board, filter by type\u002Fuser, colour per type (switch), clear log |\n| **Librarian** | Books (title, author, category, ISBN, year, copies, shelf) | **Issue Book** — drop-downs built with `createElement`, checks stock and the student's book limit, auto due date | **Return & Fine** — late days × fine per day, optional damage charge, puts the copy back on the shelf | **Overdue Report** — overdue loans, days late, pending fines, \"Send reminder\" button |\n| **Student** | Book requests (purchase \u002F reserve, priority, reason) — only *Pending* ones can be edited or cancelled | **Due-Date Reminders** — colour-coded cards (green \u002F orange \u002F red) and borrowing history | **Renew Book** — adds 7 days if not overdue and renewals are left | **Reading Goal** — progress bar; add \u002F remove extra books with `push()` \u002F `pop()` like the Lab 04 to-do list |\n| **Visitor** | Their own reading-room visit passes (prefilled from the account), with a 10-person slot limit | **Membership Fee Calculator** — plan (radio) × months (select), discounts (checkbox) | **Opening Hours Checker** — is the library open at a chosen day\u002Ftime; today highlighted | **Section Finder** — subject → floor, zone and shelves (switch), highlights the floor on a building map |\n\nEveryone (including people not logged in, on the home page) can search the book catalogue.\n\n## Where each part comes from in the slides\n\n| Topic in the code | Slide deck |\n|---|---|\n| `\u003C!DOCTYPE html>`, `\u003Chead>`, `\u003Cmeta charset>`, `\u003Cmeta name=\"viewport\">`, `\u003Ctitle>`, `\u003Clink>` | Week 02-03 HTML Forms & DOM |\n| `\u003Cform>`, `\u003Cfieldset>`, `\u003Clegend>`, `\u003Ctable>` layout, `\u003Clabel for>` matching `id` | Week 02-03 lecture, Lab 01 |\n| Input types: text, email, password, number, date, time, tel, radio, checkbox, submit, reset; `\u003Cselect>`, `\u003Ctextarea>` | Week 02-03 lecture, Lab 01 |\n| Password field without `name` so it is not sent in the URL (`method=\"get\"`) | Week 02-03 \"Spot the Bugs\" |\n| Register button disabled until terms are ticked | Week 02-03 \"DHTML in our form\" |\n| External CSS, element \u002F id \u002F class \u002F grouping selectors, `:hover`, `:focus`, `:nth-child` | Week 04 CSS |\n| Box model: margin, padding, border, `box-sizing: border-box`, `max-width` + `margin: 0 auto` | Week 04 CSS, Lab 02 |\n| Header \u002F navigation \u002F content \u002F footer layout, `position: sticky` nav | Week 04 CSS (Exercise 2) |\n| Cards with `border-radius` and `box-shadow`, buttons with `transition` | Week 04 CSS (Exercise 1) |\n| Notice board with `overflow-y: auto` and coloured `border-left`, `transform: scale()` on hover | Week 04 CSS (Exercise 4) |\n| `display: none \u002F block`, `display: flex`, `display: grid` | Week 04 CSS (Display, Looking ahead) |\n| `let` \u002F `const`, functions with `return`, `if \u002F else if \u002F else`, ternary `? :`, `===` | Week 05 JavaScript Intro |\n| Events: `onclick`, `onchange`, `onkeyup`, `onsubmit`, `addEventListener` | Week 05 lecture, Lab 03 |\n| `switch` (fine colours, plans, sections, login redirect) | Week 06 JS DOM |\n| `for`, `for...of`, `while` loops | Week 05–06 |\n| Arrays: `push`, `pop`, `slice`, `concat`, `indexOf`, `join`, `length` | Week 06 JS DOM, Lab 04 |\n| Objects and arrays of objects (`users`, `books`, `issuedBooks`, `libraryRules`) | Week 06 JS DOM, Lab 04 |\n| `getElementById`, `getElementsByName`, `.value`, `.innerHTML`, `.style.property`, `createElement`, `appendChild` | Week 02-03 DOM, Week 06 |\n| `onsubmit=\"return validateForm()\"` — `return false` stops the form | Week 06 Form Validation, Lab 04 |\n| HTML5 input types and `min` \u002F `max` attributes for simple rules, JavaScript for rules that compare fields (password = confirm password) | Week 06 Built-in HTML5 validation |\n| Errors shown in red next to each field with `element.style` | Lab 04 Task 1 |\n| Redrawing tables with a `for` loop + `innerHTML` | Lab 04 Task 2 (to-do list) |\n| `console.log` for checking arrays while testing | Week 05, Week 06 Debugging |\n| `alert()` for the overdue reminder | Week 05 Output |\n\n### Two small extras (explained in comments)\n\n- **Dates:** `common.js` uses the built-in `Date` object only to read today's date and to count\n  days between two `YYYY-MM-DD` texts (`todayString`, `addDays`, `daysBetween`).\n- **`Math.round` \u002F `Math.floor`:** used to round percentages and fines.\n\n## How a CRUD section works (same pattern on every page)\n\n1. **Read** — `renderX()` loops over the array and builds `\u003Ctr>` rows into `innerHTML`.\n2. **Search** — the same `renderX()` skips rows that do not contain the search text\n   (`containsText()` uses `toLowerCase()` and `indexOf()`); it runs on every `onkeyup`.\n3. **Create** — the form's `onsubmit=\"return saveX()\"` validates, builds an object and `push()`es it.\n4. **Update** — the **Edit** button copies the object into the form and sets `editIndex`;\n   saving again changes that object's properties instead of pushing a new one.\n5. **Delete** — `removeAt(array, index)` returns a new array using `slice()` + `concat()`.\n\n## Plan for the backend (later labs)\n\n| Frontend now | Backend later |\n|---|---|\n| Arrays in `data.js` | MySQL tables: `users`, `books`, `issued_books`, `book_requests`, `visit_passes`, `activity_log`, `library_rules` |\n| `validateLogin()` checks the `users` array | `login.php` checks the database, starts `$_SESSION` (Lab 09) |\n| `const currentStudentId = \"U-003\"` | `$_SESSION['user_id']` |\n| `method=\"get\"`, password without `name` | `method=\"post\"` with `name=\"password\"`, validated again in PHP (Lab 08) |\n| `push()` \u002F editing \u002F `removeAt()` | `INSERT` \u002F `UPDATE` \u002F `DELETE` with prepared statements (Lab 11) |\n| Search inside the array | `SELECT ... WHERE ... LIKE ?`, optionally live with AJAX + JSON (Lab 10) |\n","2026-11-24 04:55:37","CREATED_QUERY"]