diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b6cff1f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+myenv/
+myenv
diff --git a/EgyBooks/static/js/index.js b/EgyBooks/Books/__init__.py
similarity index 100%
rename from EgyBooks/static/js/index.js
rename to EgyBooks/Books/__init__.py
diff --git a/EgyBooks/Books/__pycache__/__init__.cpython-312.pyc b/EgyBooks/Books/__pycache__/__init__.cpython-312.pyc
new file mode 100644
index 0000000..5409dab
Binary files /dev/null and b/EgyBooks/Books/__pycache__/__init__.cpython-312.pyc differ
diff --git a/EgyBooks/Books/__pycache__/admin.cpython-312.pyc b/EgyBooks/Books/__pycache__/admin.cpython-312.pyc
new file mode 100644
index 0000000..a9e6146
Binary files /dev/null and b/EgyBooks/Books/__pycache__/admin.cpython-312.pyc differ
diff --git a/EgyBooks/Books/__pycache__/apps.cpython-312.pyc b/EgyBooks/Books/__pycache__/apps.cpython-312.pyc
new file mode 100644
index 0000000..09c96e9
Binary files /dev/null and b/EgyBooks/Books/__pycache__/apps.cpython-312.pyc differ
diff --git a/EgyBooks/Books/__pycache__/forms.cpython-312.pyc b/EgyBooks/Books/__pycache__/forms.cpython-312.pyc
new file mode 100644
index 0000000..d30a0b4
Binary files /dev/null and b/EgyBooks/Books/__pycache__/forms.cpython-312.pyc differ
diff --git a/EgyBooks/Books/__pycache__/models.cpython-312.pyc b/EgyBooks/Books/__pycache__/models.cpython-312.pyc
new file mode 100644
index 0000000..f9dd691
Binary files /dev/null and b/EgyBooks/Books/__pycache__/models.cpython-312.pyc differ
diff --git a/EgyBooks/Books/__pycache__/urls.cpython-312.pyc b/EgyBooks/Books/__pycache__/urls.cpython-312.pyc
new file mode 100644
index 0000000..42450b1
Binary files /dev/null and b/EgyBooks/Books/__pycache__/urls.cpython-312.pyc differ
diff --git a/EgyBooks/Books/__pycache__/views.cpython-312.pyc b/EgyBooks/Books/__pycache__/views.cpython-312.pyc
new file mode 100644
index 0000000..763c22c
Binary files /dev/null and b/EgyBooks/Books/__pycache__/views.cpython-312.pyc differ
diff --git a/EgyBooks/Books/admin.py b/EgyBooks/Books/admin.py
new file mode 100644
index 0000000..630be19
--- /dev/null
+++ b/EgyBooks/Books/admin.py
@@ -0,0 +1,5 @@
+from django.contrib import admin
+from .models import Book,BorrowedBooks
+# Register your models here.
+admin.site.register(Book)
+admin.site.register(BorrowedBooks)
\ No newline at end of file
diff --git a/EgyBooks/Books/apps.py b/EgyBooks/Books/apps.py
new file mode 100644
index 0000000..ee477ec
--- /dev/null
+++ b/EgyBooks/Books/apps.py
@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class BooksConfig(AppConfig):
+ default_auto_field = 'django.db.models.BigAutoField'
+ name = 'Books'
diff --git a/EgyBooks/Books/forms.py b/EgyBooks/Books/forms.py
new file mode 100644
index 0000000..c01b324
--- /dev/null
+++ b/EgyBooks/Books/forms.py
@@ -0,0 +1,38 @@
+from django import forms
+from . import models
+from django.core.exceptions import ValidationError
+import re
+
+def validate_alpha(value):
+ if not re.match(r'^[a-zA-Z\s]+$', value):
+ raise ValidationError('Only letters are allowed.')
+
+class AddBook(forms.ModelForm):
+ class Meta:
+ model = models.Book
+ fields = ['title', 'author', 'category', 'number_of_pages',
+ 'description', 'book_cover', 'price', 'number_of_copies']
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.fields['title'].widget.attrs.update({'class': 'form_style', 'placeholder': 'Name of the book', 'id': 'nameofthebook', 'required': True})
+ self.fields['author'].widget.attrs.update({'class': 'form_style', 'placeholder': 'Author', 'id': 'author', 'required': True})
+ self.fields['category'].widget.attrs.update({'class': 'form_style', 'placeholder': 'Category', 'id': 'category', 'required': True})
+ self.fields['number_of_pages'].widget.attrs.update({'class': 'form_style', 'placeholder': 'Number of pages', 'id': 'numberofpages', 'required': True})
+ self.fields['description'].widget.attrs.update({'placeholder': 'Description', 'id': 'description', 'required': True})
+ self.fields['book_cover'].widget.attrs.update({'id': 'image', 'accept': 'image/*', 'required': True})
+ self.fields['price'].widget.attrs.update({'class': 'form_style', 'placeholder': 'Price', 'id': 'price', 'required': True})
+ self.fields['number_of_copies'].widget.attrs.update({'class': 'form_style', 'placeholder': 'Number of copies', 'id': 'numberofcopies', 'required': True})
+
+
+
+class BorrowBook(forms.Form):
+ id = forms.IntegerField(min_value=0)
+ author = forms.CharField( validators=[validate_alpha])
+ title = forms.CharField()
+ amount = forms.IntegerField( min_value=1)
+
+
+
+
+
\ No newline at end of file
diff --git a/EgyBooks/Books/migrations/0001_initial.py b/EgyBooks/Books/migrations/0001_initial.py
new file mode 100644
index 0000000..8f638a6
--- /dev/null
+++ b/EgyBooks/Books/migrations/0001_initial.py
@@ -0,0 +1,38 @@
+# Generated by Django 5.0.6 on 2024-05-20 19:46
+
+import Books.models
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Book',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('title', models.CharField(max_length=100, unique=True)),
+ ('author', models.CharField(max_length=100, validators=[Books.models.validate_alpha])),
+ ('category', models.CharField(max_length=100, validators=[Books.models.validate_alpha])),
+ ('number_of_pages', models.PositiveIntegerField()),
+ ('description', models.TextField()),
+ ('book_cover', models.ImageField(upload_to='')),
+ ('price', models.DecimalField(decimal_places=2, max_digits=10)),
+ ('number_of_copies', models.PositiveIntegerField()),
+ ],
+ ),
+ migrations.CreateModel(
+ name='BorrowedBooks',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('number_of_borrowed_books', models.PositiveIntegerField()),
+ ('book', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Books.book')),
+ ],
+ ),
+ ]
diff --git a/EgyBooks/Books/migrations/0002_initial.py b/EgyBooks/Books/migrations/0002_initial.py
new file mode 100644
index 0000000..f9951f9
--- /dev/null
+++ b/EgyBooks/Books/migrations/0002_initial.py
@@ -0,0 +1,27 @@
+# Generated by Django 5.0.6 on 2024-05-20 19:46
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ('Books', '0001_initial'),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='borrowedbooks',
+ name='user',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
+ ),
+ migrations.AddConstraint(
+ model_name='borrowedbooks',
+ constraint=models.UniqueConstraint(fields=('user', 'book'), name='UserBorrowedBook'),
+ ),
+ ]
diff --git a/Website/javascript/index.js b/EgyBooks/Books/migrations/__init__.py
similarity index 100%
rename from Website/javascript/index.js
rename to EgyBooks/Books/migrations/__init__.py
diff --git a/EgyBooks/Books/migrations/__pycache__/0001_initial.cpython-312.pyc b/EgyBooks/Books/migrations/__pycache__/0001_initial.cpython-312.pyc
new file mode 100644
index 0000000..00a42f5
Binary files /dev/null and b/EgyBooks/Books/migrations/__pycache__/0001_initial.cpython-312.pyc differ
diff --git a/EgyBooks/Books/migrations/__pycache__/0002_alter_book_author_alter_book_category.cpython-312.pyc b/EgyBooks/Books/migrations/__pycache__/0002_alter_book_author_alter_book_category.cpython-312.pyc
new file mode 100644
index 0000000..00468a0
Binary files /dev/null and b/EgyBooks/Books/migrations/__pycache__/0002_alter_book_author_alter_book_category.cpython-312.pyc differ
diff --git a/EgyBooks/Books/migrations/__pycache__/0002_borrowedbooks_borrowedbooks_userborrowedbook.cpython-312.pyc b/EgyBooks/Books/migrations/__pycache__/0002_borrowedbooks_borrowedbooks_userborrowedbook.cpython-312.pyc
new file mode 100644
index 0000000..aee6a5f
Binary files /dev/null and b/EgyBooks/Books/migrations/__pycache__/0002_borrowedbooks_borrowedbooks_userborrowedbook.cpython-312.pyc differ
diff --git a/EgyBooks/Books/migrations/__pycache__/0002_initial.cpython-312.pyc b/EgyBooks/Books/migrations/__pycache__/0002_initial.cpython-312.pyc
new file mode 100644
index 0000000..fcf0080
Binary files /dev/null and b/EgyBooks/Books/migrations/__pycache__/0002_initial.cpython-312.pyc differ
diff --git a/EgyBooks/Books/migrations/__pycache__/__init__.cpython-312.pyc b/EgyBooks/Books/migrations/__pycache__/__init__.cpython-312.pyc
new file mode 100644
index 0000000..eb18c93
Binary files /dev/null and b/EgyBooks/Books/migrations/__pycache__/__init__.cpython-312.pyc differ
diff --git a/EgyBooks/Books/models.py b/EgyBooks/Books/models.py
new file mode 100644
index 0000000..9863818
--- /dev/null
+++ b/EgyBooks/Books/models.py
@@ -0,0 +1,33 @@
+from django.db import models
+from django.core.exceptions import ValidationError
+from User.models import CustomUser
+import re
+from django.db.models import UniqueConstraint
+
+# Create your models here.
+
+def validate_alpha(value):
+ if not re.match(r'^[a-zA-Z\s]+$', value):
+ raise ValidationError('Only letters are allowed.')
+
+class Book(models.Model):
+ title = models.CharField(max_length=100, unique=True)
+ author = models.CharField(max_length=100, validators=[validate_alpha])
+ category = models.CharField(max_length=100, validators=[validate_alpha])
+ number_of_pages = models.PositiveIntegerField()
+ description = models.TextField()
+ book_cover = models.ImageField()
+ price = models.DecimalField(max_digits=10, decimal_places=2)
+ number_of_copies = models.PositiveIntegerField()
+
+class BorrowedBooks(models.Model):
+ user = models.ForeignKey(CustomUser, on_delete=models.CASCADE)
+ book = models.ForeignKey(Book, on_delete=models.CASCADE)
+ number_of_borrowed_books = models.PositiveIntegerField()
+ class Meta:
+ constraints = [
+ UniqueConstraint(fields=['user', 'book'], name='UserBorrowedBook')
+ ]
+
+
+
diff --git a/EgyBooks/Books/templates/books/add_book.html b/EgyBooks/Books/templates/books/add_book.html
new file mode 100644
index 0000000..d9542f2
--- /dev/null
+++ b/EgyBooks/Books/templates/books/add_book.html
@@ -0,0 +1,94 @@
+{% extends 'layout.html' %}
+{% load static %}
+
+
+{% block head_block %}
+
+
+{% endblock %}
+
+{% block title %}
+ Add Book
+{% endblock title %}
+
+{% block content %}
+
+{% endblock content %}
\ No newline at end of file
diff --git a/EgyBooks/Books/templates/books/book_page.html b/EgyBooks/Books/templates/books/book_page.html
new file mode 100644
index 0000000..28fb6e3
--- /dev/null
+++ b/EgyBooks/Books/templates/books/book_page.html
@@ -0,0 +1,46 @@
+{% extends 'layout.html' %}
+{% load static %}
+
+
+{% block head_block %}
+
+
+{% endblock %}
+
+{% block title %}
+
+{% endblock title %}
+ EgyBooks | {{ book.title}}
+{% block content %}
+
+
+

+
+
+
{{ book.title }}
+
Category : {{ book.category }}
+
Author : {{ book.author }}
+
Number of Copies : {{ book.number_of_copies }}
+
Number of Pages : {{ book.number_of_pages }}
+
Price : {{ book.price }}
+
{{ book.description }}
+
+
+
+
+{% endblock content %}
\ No newline at end of file
diff --git a/EgyBooks/Books/templates/books/borrow_book.html b/EgyBooks/Books/templates/books/borrow_book.html
new file mode 100644
index 0000000..e0d552e
--- /dev/null
+++ b/EgyBooks/Books/templates/books/borrow_book.html
@@ -0,0 +1,63 @@
+{% extends 'layout.html' %}
+{% load static %}
+
+
+{% block head_block %}
+
+{% endblock %}
+
+{% block title %}
+ Borrow Book | {{ book.title }}
+{% endblock title %}
+
+{% block content %}
+
+{% endblock content %}
\ No newline at end of file
diff --git a/EgyBooks/Books/templates/books/edit_book.html b/EgyBooks/Books/templates/books/edit_book.html
new file mode 100644
index 0000000..6dbeb47
--- /dev/null
+++ b/EgyBooks/Books/templates/books/edit_book.html
@@ -0,0 +1,94 @@
+{% extends 'layout.html' %}
+{% load static %}
+
+
+{% block head_block %}
+
+
+{% endblock %}
+
+{% block title %}
+ Edit Book
+{% endblock title %}
+
+{% block content %}
+
+{% endblock content %}
\ No newline at end of file
diff --git a/EgyBooks/Books/templates/books/view_all.html b/EgyBooks/Books/templates/books/view_all.html
new file mode 100644
index 0000000..e75548e
--- /dev/null
+++ b/EgyBooks/Books/templates/books/view_all.html
@@ -0,0 +1,19 @@
+{% extends 'layout.html' %}
+{% load static %}
+
+
+{% block head_block %}
+
+
+
+{% endblock %}
+
+{% block title %}
+ View All Books
+{% endblock title %}
+
+{% block content %}
+
+
+
+{% endblock content %}
\ No newline at end of file
diff --git a/EgyBooks/Books/tests.py b/EgyBooks/Books/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/EgyBooks/Books/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/EgyBooks/Books/urls.py b/EgyBooks/Books/urls.py
new file mode 100644
index 0000000..f2d0553
--- /dev/null
+++ b/EgyBooks/Books/urls.py
@@ -0,0 +1,15 @@
+from django.urls import path,re_path
+from . import views
+
+app_name = "books"
+
+urlpatterns = [
+ path('add-book/', views.add_book, name='add-book'),
+ path('book-page/', views.book_page, name='book-page'),
+ path('view-all/', views.view_all, name='view-all'),
+ re_path(r'^view-all/.*$', views.view_all, name='view-all'),
+ path('borrow-book/', views.borrow_book, name='borrow-book'),
+ path('borrow-book/', views.borrow_book, name='borrow-book-no-id'),
+ path('edit-book/', views.edit_book, name='edit-book'),
+ path('delete-book/', views.delete_book, name='delete-book'),
+]
diff --git a/EgyBooks/Books/views.py b/EgyBooks/Books/views.py
new file mode 100644
index 0000000..6a4041f
--- /dev/null
+++ b/EgyBooks/Books/views.py
@@ -0,0 +1,86 @@
+from django.shortcuts import render,redirect
+from .models import Book, BorrowedBooks
+from . import forms
+from django.shortcuts import get_object_or_404
+from django.contrib.auth.decorators import login_required
+from django.contrib.admin.views.decorators import staff_member_required
+
+# Create your views here.
+def view_all(request, combination=None):
+ search_param = request.GET.get('search')
+ filter_param = request.GET.get('filter')
+ return render(request, 'books/view_all.html')
+
+@login_required()
+@staff_member_required()
+def add_book(request):
+ if request.method == 'POST':
+ form = forms.AddBook(request.POST, request.FILES)
+ if form.is_valid():
+ newbook = form.save(commit=False)
+ newbook.save()
+ return redirect('books:view-all')
+ else:
+ form = forms.AddBook()
+ return render(request, 'books/add_book.html', { 'form':form })
+
+def book_page(request, book_id):
+ book = get_object_or_404(Book, id = book_id)
+ return render(request, 'books/book_page.html', {'book':book })
+
+@login_required()
+def borrow_book(request, book_id=None):
+ if request.method == 'POST':
+ form = forms.BorrowBook(request.POST)
+ if form.is_valid():
+ author = form.cleaned_data['author']
+ title = form.cleaned_data['title']
+ amount = form.cleaned_data['amount']
+ id = form.cleaned_data['id']
+
+ if Book.objects.filter(id=book_id, author = author, title = title).exists():
+ book = Book.objects.get(author=author, title=title, id=book_id)
+ number_of_copies = book.number_of_copies
+
+ if amount > number_of_copies:
+ form.add_error('amount', "Can't borrow that many copies!")
+ else:
+ book.number_of_copies -= amount
+ book.save()
+ borrowed_book = BorrowedBooks(user = request.user, book=book, number_of_borrowed_books=amount)
+ borrowed_book.save()
+ return redirect('books:view-all')
+ else:
+ form.add_error('id', "Book doesn't exist")
+
+ else:
+ if book_id != None and Book.objects.filter(id=book_id).exists():
+ book = Book.objects.get(id=book_id)
+ form = forms.BorrowBook(initial={'id': book_id, 'author':book.author, 'title':book.title})
+ else:
+ form = forms.BorrowBook()
+
+ if book_id != None and Book.objects.filter(id=book_id).exists():
+ book = Book.objects.get(id=book_id)
+ return render(request, 'books/borrow_book.html', {'book': book, 'form':form })
+
+ return render(request, 'books/borrow_book.html', {'form':form })
+
+@login_required()
+@staff_member_required()
+def edit_book(request, book_id):
+ book = get_object_or_404(Book, id = book_id)
+ form = forms.AddBook(request.POST or None, request.FILES or None, instance=book)
+
+ if form.is_valid():
+ form.save()
+ return redirect('books:book-page', book_id = book.id)
+
+ return render(request, 'books/edit_book.html', {'form' : form, 'book_id':book_id})
+
+@login_required()
+@staff_member_required()
+def delete_book(request, book_id):
+ book = get_object_or_404(Book, id = book_id)
+ book.delete()
+ return redirect("books:view-all")
\ No newline at end of file
diff --git a/EgyBooks/EgyBooks/__pycache__/settings.cpython-312.pyc b/EgyBooks/EgyBooks/__pycache__/settings.cpython-312.pyc
index 3138f75..b6fac4b 100644
Binary files a/EgyBooks/EgyBooks/__pycache__/settings.cpython-312.pyc and b/EgyBooks/EgyBooks/__pycache__/settings.cpython-312.pyc differ
diff --git a/EgyBooks/EgyBooks/__pycache__/urls.cpython-312.pyc b/EgyBooks/EgyBooks/__pycache__/urls.cpython-312.pyc
index 51c9697..25cd9ff 100644
Binary files a/EgyBooks/EgyBooks/__pycache__/urls.cpython-312.pyc and b/EgyBooks/EgyBooks/__pycache__/urls.cpython-312.pyc differ
diff --git a/EgyBooks/EgyBooks/__pycache__/views.cpython-312.pyc b/EgyBooks/EgyBooks/__pycache__/views.cpython-312.pyc
index 4d52695..ee60ede 100644
Binary files a/EgyBooks/EgyBooks/__pycache__/views.cpython-312.pyc and b/EgyBooks/EgyBooks/__pycache__/views.cpython-312.pyc differ
diff --git a/EgyBooks/EgyBooks/settings.py b/EgyBooks/EgyBooks/settings.py
index 492636f..7cb1ab5 100644
--- a/EgyBooks/EgyBooks/settings.py
+++ b/EgyBooks/EgyBooks/settings.py
@@ -27,7 +27,7 @@
ALLOWED_HOSTS = []
-
+AUTH_USER_MODEL = 'User.CustomUser'
# Application definition
INSTALLED_APPS = [
@@ -37,6 +37,9 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
+ 'Books',
+ 'api',
+ 'User',
]
MIDDLEWARE = [
diff --git a/EgyBooks/EgyBooks/urls.py b/EgyBooks/EgyBooks/urls.py
index 27086a6..9ca7b8a 100644
--- a/EgyBooks/EgyBooks/urls.py
+++ b/EgyBooks/EgyBooks/urls.py
@@ -28,6 +28,8 @@
path('admin/', admin.site.urls),
path('',views.homepage),
path('about/', views.about),
-
+ path('books/', include('Books.urls')),
+ path('api/', include('api.urls')),
+ path('user/', include('User.urls')),
]
diff --git a/EgyBooks/User/__init__.py b/EgyBooks/User/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/EgyBooks/User/__pycache__/__init__.cpython-312.pyc b/EgyBooks/User/__pycache__/__init__.cpython-312.pyc
new file mode 100644
index 0000000..4f4d3c9
Binary files /dev/null and b/EgyBooks/User/__pycache__/__init__.cpython-312.pyc differ
diff --git a/EgyBooks/User/__pycache__/admin.cpython-312.pyc b/EgyBooks/User/__pycache__/admin.cpython-312.pyc
new file mode 100644
index 0000000..fc711d1
Binary files /dev/null and b/EgyBooks/User/__pycache__/admin.cpython-312.pyc differ
diff --git a/EgyBooks/User/__pycache__/apps.cpython-312.pyc b/EgyBooks/User/__pycache__/apps.cpython-312.pyc
new file mode 100644
index 0000000..b039f48
Binary files /dev/null and b/EgyBooks/User/__pycache__/apps.cpython-312.pyc differ
diff --git a/EgyBooks/User/__pycache__/forms.cpython-312.pyc b/EgyBooks/User/__pycache__/forms.cpython-312.pyc
new file mode 100644
index 0000000..a848fb6
Binary files /dev/null and b/EgyBooks/User/__pycache__/forms.cpython-312.pyc differ
diff --git a/EgyBooks/User/__pycache__/models.cpython-312.pyc b/EgyBooks/User/__pycache__/models.cpython-312.pyc
new file mode 100644
index 0000000..d8cd109
Binary files /dev/null and b/EgyBooks/User/__pycache__/models.cpython-312.pyc differ
diff --git a/EgyBooks/User/__pycache__/urls.cpython-312.pyc b/EgyBooks/User/__pycache__/urls.cpython-312.pyc
new file mode 100644
index 0000000..956243c
Binary files /dev/null and b/EgyBooks/User/__pycache__/urls.cpython-312.pyc differ
diff --git a/EgyBooks/User/__pycache__/views.cpython-312.pyc b/EgyBooks/User/__pycache__/views.cpython-312.pyc
new file mode 100644
index 0000000..843c805
Binary files /dev/null and b/EgyBooks/User/__pycache__/views.cpython-312.pyc differ
diff --git a/EgyBooks/User/admin.py b/EgyBooks/User/admin.py
new file mode 100644
index 0000000..255edfe
--- /dev/null
+++ b/EgyBooks/User/admin.py
@@ -0,0 +1,11 @@
+from django.contrib import admin
+from django.contrib.auth.admin import UserAdmin
+from .models import CustomUser
+from .forms import CustomUserCreationForm
+
+class CustomUserAdmin(UserAdmin):
+ add_form = CustomUserCreationForm
+ model = CustomUser
+ list_display = ['username', 'email', 'is_staff', 'is_active']
+
+admin.site.register(CustomUser, CustomUserAdmin)
diff --git a/EgyBooks/User/apps.py b/EgyBooks/User/apps.py
new file mode 100644
index 0000000..9edbb3f
--- /dev/null
+++ b/EgyBooks/User/apps.py
@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class UserConfig(AppConfig):
+ default_auto_field = 'django.db.models.BigAutoField'
+ name = 'User'
diff --git a/EgyBooks/User/forms.py b/EgyBooks/User/forms.py
new file mode 100644
index 0000000..62d7434
--- /dev/null
+++ b/EgyBooks/User/forms.py
@@ -0,0 +1,36 @@
+from django import forms
+from django.contrib.auth.forms import UserCreationForm, UserChangeForm
+from .models import CustomUser
+
+class CustomUserCreationForm(UserCreationForm):
+ role = forms.ChoiceField(choices=[('user', 'User'), ('admin', 'Admin')], widget=forms.RadioSelect, label='Role')
+ class Meta(UserCreationForm.Meta):
+ model = CustomUser
+ fields = ('username', 'email',)
+
+ def save(self, commit=True):
+ user = super().save(commit=False)
+
+ role = self.cleaned_data['role']
+ if role == 'admin':
+ user.is_staff = True
+ user.is_superuser = True
+ else:
+ user.is_staff = False
+ user.is_superuser = False
+
+ if commit:
+ user.save()
+ return user
+
+
+class CustomUserUpdateForm(UserChangeForm):
+ class Meta:
+ model = CustomUser
+ fields = ('username','password', 'email')
+
+ def save(self, commit=True):
+ user = super().save(commit=False)
+ if commit:
+ user.save()
+ return user
\ No newline at end of file
diff --git a/EgyBooks/User/migrations/0001_initial.py b/EgyBooks/User/migrations/0001_initial.py
new file mode 100644
index 0000000..c2bf99a
--- /dev/null
+++ b/EgyBooks/User/migrations/0001_initial.py
@@ -0,0 +1,44 @@
+# Generated by Django 5.0.6 on 2024-05-20 19:46
+
+import django.contrib.auth.models
+import django.contrib.auth.validators
+import django.utils.timezone
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ('auth', '0012_alter_user_first_name_max_length'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='CustomUser',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('password', models.CharField(max_length=128, verbose_name='password')),
+ ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
+ ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
+ ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
+ ('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')),
+ ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
+ ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
+ ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
+ ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
+ ('email', models.EmailField(max_length=254, unique=True)),
+ ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')),
+ ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')),
+ ],
+ options={
+ 'verbose_name': 'user',
+ 'verbose_name_plural': 'users',
+ 'abstract': False,
+ },
+ managers=[
+ ('objects', django.contrib.auth.models.UserManager()),
+ ],
+ ),
+ ]
diff --git a/EgyBooks/User/migrations/__init__.py b/EgyBooks/User/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/EgyBooks/User/migrations/__pycache__/0001_initial.cpython-312.pyc b/EgyBooks/User/migrations/__pycache__/0001_initial.cpython-312.pyc
new file mode 100644
index 0000000..4765785
Binary files /dev/null and b/EgyBooks/User/migrations/__pycache__/0001_initial.cpython-312.pyc differ
diff --git a/EgyBooks/User/migrations/__pycache__/__init__.cpython-312.pyc b/EgyBooks/User/migrations/__pycache__/__init__.cpython-312.pyc
new file mode 100644
index 0000000..4cc137a
Binary files /dev/null and b/EgyBooks/User/migrations/__pycache__/__init__.cpython-312.pyc differ
diff --git a/EgyBooks/User/models.py b/EgyBooks/User/models.py
new file mode 100644
index 0000000..416704a
--- /dev/null
+++ b/EgyBooks/User/models.py
@@ -0,0 +1,5 @@
+from django.contrib.auth.models import AbstractUser
+from django.db import models
+
+class CustomUser(AbstractUser):
+ email = models.EmailField(unique=True)
\ No newline at end of file
diff --git a/EgyBooks/User/templates/user/edit_profile.html b/EgyBooks/User/templates/user/edit_profile.html
new file mode 100644
index 0000000..f2303e9
--- /dev/null
+++ b/EgyBooks/User/templates/user/edit_profile.html
@@ -0,0 +1,64 @@
+{% extends 'layout.html' %}
+{% load static %}
+
+
+{% block head_block %}
+
+
+{% endblock %}
+
+{% block title %}
+ EgyBooks | Edit Profile
+{% endblock title %}
+
+{% block content %}
+
+{% endblock content %}
\ No newline at end of file
diff --git a/EgyBooks/User/templates/user/login.html b/EgyBooks/User/templates/user/login.html
new file mode 100644
index 0000000..2929195
--- /dev/null
+++ b/EgyBooks/User/templates/user/login.html
@@ -0,0 +1,54 @@
+{% extends 'layout.html' %}
+{% load static %}
+
+{% block title %}
+ EgyBooks
+{% endblock %}
+
+{% block head_block %}
+
+{% endblock %}
+
+{% block content %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/EgyBooks/User/templates/user/profile.html b/EgyBooks/User/templates/user/profile.html
new file mode 100644
index 0000000..f6e7a06
--- /dev/null
+++ b/EgyBooks/User/templates/user/profile.html
@@ -0,0 +1,69 @@
+{% extends 'layout.html' %}
+{% load static %}
+
+
+{% block head_block %}
+
+
+{% endblock %}
+
+{% block title %}
+ EgyBooks | Profile
+{% endblock title %}
+
+{% block content %}
+
+
My profile
+
+
+
+

+
+
+
+
Account info
+
+
+ Username
+ {{ user.username }}
+
+
+
+
+
+ Email
+ {{ user.email }}
+
+
+
+
+
+ Account Type
+
+ {% if user.is_superuser %}
+ Admin
+ {% else %}
+ User
+ {% endif %}
+
+
+
+
+
+
+
+
+
+
+
Borrowed Books History
+
+
+
+
+
+
+
+{% endblock content %}
\ No newline at end of file
diff --git a/EgyBooks/User/templates/user/register.html b/EgyBooks/User/templates/user/register.html
new file mode 100644
index 0000000..d86f137
--- /dev/null
+++ b/EgyBooks/User/templates/user/register.html
@@ -0,0 +1,83 @@
+{% extends 'layout.html' %}
+{% load static %}
+
+{% block title %}
+ EgyBooks
+{% endblock %}
+
+{% block head_block %}
+
+
+{% endblock %}
+
+{% block content %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/EgyBooks/User/tests.py b/EgyBooks/User/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/EgyBooks/User/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/EgyBooks/User/urls.py b/EgyBooks/User/urls.py
new file mode 100644
index 0000000..7c5f536
--- /dev/null
+++ b/EgyBooks/User/urls.py
@@ -0,0 +1,12 @@
+from django.urls import path,re_path
+from . import views
+
+app_name = "user"
+
+urlpatterns = [
+ path('login/', views.login_user, name='login'),
+ path('register/', views.register, name='register'),
+ path('logout/', views.logout_user, name='logout'),
+ path('profile/', views.profile, name='profile'),
+ path('edit-profile/', views.edit_profile, name='edit-profile'),
+]
\ No newline at end of file
diff --git a/EgyBooks/User/views.py b/EgyBooks/User/views.py
new file mode 100644
index 0000000..a05fd5c
--- /dev/null
+++ b/EgyBooks/User/views.py
@@ -0,0 +1,52 @@
+from django.shortcuts import render
+from django.shortcuts import render, redirect
+from django.contrib.auth.forms import AuthenticationForm
+from .forms import CustomUserCreationForm, CustomUserUpdateForm
+from django.contrib.auth import login, logout
+from django.contrib.auth.decorators import login_required
+
+# Create your views here.
+def register(request):
+ if request.method == "POST":
+ form = CustomUserCreationForm(request.POST)
+ print(form)
+ if form.is_valid():
+ login(request, form.save())
+ return redirect("/")
+ else:
+ form = CustomUserCreationForm()
+
+ return render(request, 'user/register.html', {"form":form})
+
+def login_user(request):
+ if request.method == "POST":
+ form = AuthenticationForm(data=request.POST)
+ if form.is_valid():
+ login(request, form.get_user())
+ return redirect("/")
+ else:
+ form = AuthenticationForm()
+ return render(request, 'user/login.html', {'form':form})
+
+@login_required()
+def logout_user(request):
+ logout(request)
+ return redirect("/")
+
+
+@login_required()
+def profile(request):
+ return render(request, 'user/profile.html')
+
+@login_required()
+def edit_profile(request):
+ print("yes")
+ if request.method == "POST":
+ form = CustomUserUpdateForm(data=request.POST, instance=request.user)
+ if form.is_valid():
+ print("here")
+ form.save()
+ return redirect("/")
+ else:
+ form = CustomUserCreationForm(instance=request.user)
+ return render(request, 'user/edit_profile.html', {'form':form})
\ No newline at end of file
diff --git a/EgyBooks/api/__init__.py b/EgyBooks/api/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/EgyBooks/api/__pycache__/__init__.cpython-312.pyc b/EgyBooks/api/__pycache__/__init__.cpython-312.pyc
new file mode 100644
index 0000000..81de47d
Binary files /dev/null and b/EgyBooks/api/__pycache__/__init__.cpython-312.pyc differ
diff --git a/EgyBooks/api/__pycache__/admin.cpython-312.pyc b/EgyBooks/api/__pycache__/admin.cpython-312.pyc
new file mode 100644
index 0000000..4b3198e
Binary files /dev/null and b/EgyBooks/api/__pycache__/admin.cpython-312.pyc differ
diff --git a/EgyBooks/api/__pycache__/apps.cpython-312.pyc b/EgyBooks/api/__pycache__/apps.cpython-312.pyc
new file mode 100644
index 0000000..2415e8b
Binary files /dev/null and b/EgyBooks/api/__pycache__/apps.cpython-312.pyc differ
diff --git a/EgyBooks/api/__pycache__/models.cpython-312.pyc b/EgyBooks/api/__pycache__/models.cpython-312.pyc
new file mode 100644
index 0000000..74d4326
Binary files /dev/null and b/EgyBooks/api/__pycache__/models.cpython-312.pyc differ
diff --git a/EgyBooks/api/__pycache__/urls.cpython-312.pyc b/EgyBooks/api/__pycache__/urls.cpython-312.pyc
new file mode 100644
index 0000000..3aedabf
Binary files /dev/null and b/EgyBooks/api/__pycache__/urls.cpython-312.pyc differ
diff --git a/EgyBooks/api/__pycache__/views.cpython-312.pyc b/EgyBooks/api/__pycache__/views.cpython-312.pyc
new file mode 100644
index 0000000..90488cc
Binary files /dev/null and b/EgyBooks/api/__pycache__/views.cpython-312.pyc differ
diff --git a/EgyBooks/api/admin.py b/EgyBooks/api/admin.py
new file mode 100644
index 0000000..8c38f3f
--- /dev/null
+++ b/EgyBooks/api/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/EgyBooks/api/apps.py b/EgyBooks/api/apps.py
new file mode 100644
index 0000000..66656fd
--- /dev/null
+++ b/EgyBooks/api/apps.py
@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class ApiConfig(AppConfig):
+ default_auto_field = 'django.db.models.BigAutoField'
+ name = 'api'
diff --git a/EgyBooks/api/migrations/__init__.py b/EgyBooks/api/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/EgyBooks/api/migrations/__pycache__/__init__.cpython-312.pyc b/EgyBooks/api/migrations/__pycache__/__init__.cpython-312.pyc
new file mode 100644
index 0000000..4f36ff0
Binary files /dev/null and b/EgyBooks/api/migrations/__pycache__/__init__.cpython-312.pyc differ
diff --git a/EgyBooks/api/models.py b/EgyBooks/api/models.py
new file mode 100644
index 0000000..71a8362
--- /dev/null
+++ b/EgyBooks/api/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
diff --git a/EgyBooks/api/tests.py b/EgyBooks/api/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/EgyBooks/api/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/EgyBooks/api/urls.py b/EgyBooks/api/urls.py
new file mode 100644
index 0000000..530af61
--- /dev/null
+++ b/EgyBooks/api/urls.py
@@ -0,0 +1,9 @@
+from django.urls import path
+from . import views
+
+app_name = "api"
+
+urlpatterns = [
+ path('get-books-data/', views.get_books_data, name="get-books-data"),
+ path('get-borrowed-books', views.get_borrowed_books, name="get-borrowed-books"),
+]
diff --git a/EgyBooks/api/views.py b/EgyBooks/api/views.py
new file mode 100644
index 0000000..0f8a163
--- /dev/null
+++ b/EgyBooks/api/views.py
@@ -0,0 +1,28 @@
+from django.shortcuts import render
+from django.http import JsonResponse
+from Books.models import Book
+from Books.models import BorrowedBooks
+from django.shortcuts import get_object_or_404
+# Create your views here.
+
+
+def get_books_data(request):
+ data = Book.objects.all().values()
+ return JsonResponse(list(data), safe=False)
+
+
+def get_borrowed_books(request):
+ books = BorrowedBooks.objects.filter(user=request.user)
+
+ books_data = []
+
+ for borrowed_book in books:
+ book_data = {
+ 'id': borrowed_book.book.id,
+ 'title': borrowed_book.book.title,
+ 'author': borrowed_book.book.author,
+ 'number_of_borrowed_books': borrowed_book.number_of_borrowed_books
+ }
+ books_data.append(book_data)
+
+ return JsonResponse(list(books.book), safe=False)
\ No newline at end of file
diff --git a/EgyBooks/db.sqlite3 b/EgyBooks/db.sqlite3
index e69de29..9adfa2b 100644
Binary files a/EgyBooks/db.sqlite3 and b/EgyBooks/db.sqlite3 differ
diff --git a/EgyBooks/media/105998519_3204694966279299_3161075381229918648_n.jpg b/EgyBooks/media/105998519_3204694966279299_3161075381229918648_n.jpg
new file mode 100644
index 0000000..8032ff6
Binary files /dev/null and b/EgyBooks/media/105998519_3204694966279299_3161075381229918648_n.jpg differ
diff --git a/EgyBooks/media/71ByBe40AvL._SL1500_.jpg b/EgyBooks/media/71ByBe40AvL._SL1500_.jpg
new file mode 100644
index 0000000..9560d88
Binary files /dev/null and b/EgyBooks/media/71ByBe40AvL._SL1500_.jpg differ
diff --git a/EgyBooks/media/71ByBe40AvL._SL1500__r2teX8J.jpg b/EgyBooks/media/71ByBe40AvL._SL1500__r2teX8J.jpg
new file mode 100644
index 0000000..9560d88
Binary files /dev/null and b/EgyBooks/media/71ByBe40AvL._SL1500__r2teX8J.jpg differ
diff --git a/EgyBooks/media/71TAVu1IaL._SL1000_.jpg b/EgyBooks/media/71TAVu1IaL._SL1000_.jpg
new file mode 100644
index 0000000..b8829b3
Binary files /dev/null and b/EgyBooks/media/71TAVu1IaL._SL1000_.jpg differ
diff --git a/EgyBooks/media/71irx9oi7qL._SL1500_.jpg b/EgyBooks/media/71irx9oi7qL._SL1500_.jpg
new file mode 100644
index 0000000..9b13cce
Binary files /dev/null and b/EgyBooks/media/71irx9oi7qL._SL1500_.jpg differ
diff --git a/EgyBooks/media/815SgxWKvCL._SL1500_.jpg b/EgyBooks/media/815SgxWKvCL._SL1500_.jpg
new file mode 100644
index 0000000..4b7609b
Binary files /dev/null and b/EgyBooks/media/815SgxWKvCL._SL1500_.jpg differ
diff --git a/EgyBooks/media/81Hc58D0tBL._SL1250_.jpg b/EgyBooks/media/81Hc58D0tBL._SL1250_.jpg
new file mode 100644
index 0000000..d9f4e03
Binary files /dev/null and b/EgyBooks/media/81Hc58D0tBL._SL1250_.jpg differ
diff --git a/EgyBooks/media/81Hc58D0tBL._SL1250__BTt7wgm.jpg b/EgyBooks/media/81Hc58D0tBL._SL1250__BTt7wgm.jpg
new file mode 100644
index 0000000..d9f4e03
Binary files /dev/null and b/EgyBooks/media/81Hc58D0tBL._SL1250__BTt7wgm.jpg differ
diff --git a/EgyBooks/media/81Hc58D0tBL._SL1250__Lle32Bn.jpg b/EgyBooks/media/81Hc58D0tBL._SL1250__Lle32Bn.jpg
new file mode 100644
index 0000000..d9f4e03
Binary files /dev/null and b/EgyBooks/media/81Hc58D0tBL._SL1250__Lle32Bn.jpg differ
diff --git a/EgyBooks/media/81aCMT1zKtL._SL1500_.jpg b/EgyBooks/media/81aCMT1zKtL._SL1500_.jpg
new file mode 100644
index 0000000..0beb9b0
Binary files /dev/null and b/EgyBooks/media/81aCMT1zKtL._SL1500_.jpg differ
diff --git a/EgyBooks/media/81aCMT1zKtL._SL1500__kOY1DYK.jpg b/EgyBooks/media/81aCMT1zKtL._SL1500__kOY1DYK.jpg
new file mode 100644
index 0000000..0beb9b0
Binary files /dev/null and b/EgyBooks/media/81aCMT1zKtL._SL1500__kOY1DYK.jpg differ
diff --git a/EgyBooks/media/9sooy0j0obo11.jpg b/EgyBooks/media/9sooy0j0obo11.jpg
new file mode 100644
index 0000000..8b5990a
Binary files /dev/null and b/EgyBooks/media/9sooy0j0obo11.jpg differ
diff --git a/EgyBooks/media/Screenshot_105.png b/EgyBooks/media/Screenshot_105.png
new file mode 100644
index 0000000..f39539f
Binary files /dev/null and b/EgyBooks/media/Screenshot_105.png differ
diff --git a/EgyBooks/media/image.png b/EgyBooks/media/image.png
new file mode 100644
index 0000000..4ecdf24
Binary files /dev/null and b/EgyBooks/media/image.png differ
diff --git a/EgyBooks/media/image_2.png b/EgyBooks/media/image_2.png
new file mode 100644
index 0000000..ef2647b
Binary files /dev/null and b/EgyBooks/media/image_2.png differ
diff --git a/EgyBooks/media/image_3.png b/EgyBooks/media/image_3.png
new file mode 100644
index 0000000..3354e9f
Binary files /dev/null and b/EgyBooks/media/image_3.png differ
diff --git a/EgyBooks/media/image_3_1.png b/EgyBooks/media/image_3_1.png
new file mode 100644
index 0000000..3354e9f
Binary files /dev/null and b/EgyBooks/media/image_3_1.png differ
diff --git a/EgyBooks/media/image_3_1_i56Wj22.png b/EgyBooks/media/image_3_1_i56Wj22.png
new file mode 100644
index 0000000..3354e9f
Binary files /dev/null and b/EgyBooks/media/image_3_1_i56Wj22.png differ
diff --git a/EgyBooks/media/image_3_7OGmj9T.png b/EgyBooks/media/image_3_7OGmj9T.png
new file mode 100644
index 0000000..3354e9f
Binary files /dev/null and b/EgyBooks/media/image_3_7OGmj9T.png differ
diff --git a/EgyBooks/media/image_3_JkoNgU2.png b/EgyBooks/media/image_3_JkoNgU2.png
new file mode 100644
index 0000000..3354e9f
Binary files /dev/null and b/EgyBooks/media/image_3_JkoNgU2.png differ
diff --git a/EgyBooks/media/levi.jpg b/EgyBooks/media/levi.jpg
new file mode 100644
index 0000000..647f52d
Binary files /dev/null and b/EgyBooks/media/levi.jpg differ
diff --git a/EgyBooks/media/levi_XD5NhA7.jpg b/EgyBooks/media/levi_XD5NhA7.jpg
new file mode 100644
index 0000000..647f52d
Binary files /dev/null and b/EgyBooks/media/levi_XD5NhA7.jpg differ
diff --git a/EgyBooks/media/pxfuel.jpg b/EgyBooks/media/pxfuel.jpg
new file mode 100644
index 0000000..b16f5f2
Binary files /dev/null and b/EgyBooks/media/pxfuel.jpg differ
diff --git a/EgyBooks/static/css/About.css b/EgyBooks/static/css/About.css
index c5fc262..902983c 100644
--- a/EgyBooks/static/css/About.css
+++ b/EgyBooks/static/css/About.css
@@ -18,7 +18,7 @@
justify-content: center;
width: 20vw;
background-color: rgb(88, 47, 14);
- background-image: var(--background-image-url);
+ background-image: var(--bg-image-url);
background-size: cover;
border-radius: 20px;
}
diff --git a/Website/pics/profile_icon.png b/EgyBooks/static/images/profile_icon.png
similarity index 100%
rename from Website/pics/profile_icon.png
rename to EgyBooks/static/images/profile_icon.png
diff --git a/EgyBooks/static/js/BookPage.js b/EgyBooks/static/js/BookPage.js
index b32a004..5dfe3ed 100644
--- a/EgyBooks/static/js/BookPage.js
+++ b/EgyBooks/static/js/BookPage.js
@@ -1,12 +1,3 @@
-var accountType = JSON.parse(localStorage.getItem('userInfo')).account_type;
-var loggedIn = JSON.parse(localStorage.getItem('loggedIn'));
-
-function getUrlParameter(name) {
- const params = new URLSearchParams(window.location.search);
- console.log(params.get(name));
- return params.get(name);
-}
-
document.addEventListener("DOMContentLoaded", function(){
var container = document.getElementById("Book");
var storedBooks = localStorage.getItem('libraryBooks');
diff --git a/EgyBooks/static/js/SignUp.js b/EgyBooks/static/js/SignUp.js
index bd2e9a5..f1f5f0b 100644
--- a/EgyBooks/static/js/SignUp.js
+++ b/EgyBooks/static/js/SignUp.js
@@ -3,23 +3,10 @@ localStorage.setItem("loggedIn",JSON.stringify(false));
function validateForm(){
try{
- var userName = document.getElementById("user_name_text").value;
- var password = document.getElementById("password_text").value;
- var confirmPassword = document.getElementById("confirm_password_text").value;
- var email = document.getElementById("email_text").value;
-
- var accountTypeDiv = document.getElementById("radio_button").querySelectorAll('input[type="radio"]');
- var account_type = "";
-
- console.log(accountTypeDiv);
-
- accountTypeDiv.forEach(function(radioButton) {
- console.log(radioButton);
- if (radioButton.checked) {
- account_type = radioButton.value;
- }
- });
-
+ var userName = document.getElementById("id_username").value;
+ var password = document.getElementById("id_password1").value;
+ var confirmPassword = document.getElementById("id_password2").value;
+ var email = document.getElementById("id_email").value;
}
catch(error){
console.log(error)
@@ -61,49 +48,19 @@ function validateForm(){
return false;
}
- if(localStorage.getItem("userInfo") != null && email == JSON.parse(localStorage.getItem("userInfo")).email){
- alert("Email already exists!");
- return false;
- }
-
- if(localStorage.getItem("userInfo") != null && userName == JSON.parse(localStorage.getItem("userInfo")).username){
- alert("User name already exists!");
- return false;
- }
-
- var userInfo = {
- username: userName,
- password: password,
- email: email,
- account_type: account_type
- };
-
- localStorage.setItem("userInfo", JSON.stringify(userInfo));
-
return true;
}
document.addEventListener("DOMContentLoaded", function(){
console.log("hereDom");
- var form = document.querySelector("form");
+ var form = document.querySelector(".signup-class form");
form.addEventListener("submit", function(event){
event.preventDefault();
if(validateForm()){
- var userInfoString = localStorage.getItem("userInfo");
- var userInfo = JSON.parse(userInfoString);
- var username = userInfo.username;
- var password = userInfo.password;
- var email = userInfo.email;
- var accountType = userInfo.account_type;
- console.log("Username:", username);
- console.log("Password:", password);
- console.log("Email:", email);
- console.log("Account Type:", accountType);
-
- window.location.href = "Login.html";
+ form.submit();
}
})
});
\ No newline at end of file
diff --git a/EgyBooks/static/js/addbook.js b/EgyBooks/static/js/addbook.js
index bf2e456..e63dbbe 100644
--- a/EgyBooks/static/js/addbook.js
+++ b/EgyBooks/static/js/addbook.js
@@ -1,99 +1,24 @@
-let libraryBooks = [];
-
document.addEventListener("DOMContentLoaded", function(){
-
-
- var storedBooks = localStorage.getItem('libraryBooks');
- if (storedBooks) {
- libraryBooks = JSON.parse(storedBooks);
- }
- else {
- libraryBooks = [];
- }
- console.log(libraryBooks);
-
- var form = document.querySelector("form");
-
+ var form = document.querySelector("form.add_book_class");
+ console.log(form);
form.addEventListener('submit', function(event) {
event.preventDefault();
- var fileInput = document.getElementById('image');
- var imageFile = fileInput.files[0];
-
- var reader = new FileReader();
- reader.onload = function(event) {
- var imageDataUrl = event.target.result;
-
- var title = document.getElementById('nameofthebook').value;
- var bookID = document.getElementById('bookID').value;
- var author = document.getElementById('author').value;
- var category = document.getElementById('category').value;
- var pages = document.getElementById('numberofpages').value;
- var description = document.getElementById('description').value;
- var price = document.getElementById('price').value;
- var numberofcopies = document.getElementById('numberofcopies').value;
-
-
- var titleRegex = /^[a-zA-Z][\w\d]*$/;
- if(!titleRegex.test(title)){
- alert("Title can't contain numbers in the start and can't contain special characters!");
- return false;
- }
-
- if(!titleRegex.test(author)){
- alert("author can't contain numbers in the start and can't contain special characters!");
- return false;
- }
-
- var categoryRegex = /^[a-zA-Z][a-zA-Z]*$/
- if(!categoryRegex.test(category)){
- alert("Category can't contain numbers in the start and can't contain special characters!");
- return false;
- }
-
- var idRegex = /^[0-9]+$/;
- if(!idRegex.test(bookID)){
- alert("ID must be numbers only");
- return false;
- }
-
- const bookData = {
- image: imageDataUrl,
- title: title,
- bookID: bookID,
- author: author,
- category:category,
- pages: pages,
- description: description,
- price: price,
- numberofcopies:numberofcopies
- };
-
- saveBookData(bookData);
- };
-
- reader.readAsDataURL(imageFile);
-
-
- });
-})
-
-
-function saveBookData(bookData) {
- var isexist=false;
- libraryBooks.forEach(function (book) {
- if(book.bookID==bookData.bookID){
- book.numberofcopies +=bookData.numberofcopies;
- console.log(book.numberofcopies);
- isexist=true;
+ var author = document.getElementById('author').value;
+ var category = document.getElementById('category').value;
+
+ var letterRegex = /^[a-zA-Z\s]+$/;
+ console.log(author);
+ if(!letterRegex.test(author)){
+ alert("Author can only contain letters!");
+ return false;
}
+ if(!letterRegex.test(category)){
+ alert("Category can only contain letters!");
+ return false;
+ }
+ form.submit();
});
- if(!isexist)
- libraryBooks.push(bookData);
- localStorage.setItem('libraryBooks', JSON.stringify(libraryBooks));
-
- alert('Book added successfully!');
- window.location.href = "ViewBooks.html";
-}
+})
diff --git a/EgyBooks/static/js/borrowBook.js b/EgyBooks/static/js/borrowBook.js
deleted file mode 100644
index 16f8c79..0000000
--- a/EgyBooks/static/js/borrowBook.js
+++ /dev/null
@@ -1,159 +0,0 @@
-const libraryBooks = JSON.parse(localStorage.getItem('libraryBooks')) || [];
-
-document.addEventListener("DOMContentLoaded", function(){
- const params = new URLSearchParams(window.location.search);
- const id = params.get('id');
- const title = params.get('title');
- const author = params.get('author');
-
- document.getElementById("bk_id").value = id;
- document.getElementById("book_author").value = decodeURIComponent(author);
- document.getElementById("quan").value = 1;
- document.getElementById("bk_tit").value = decodeURIComponent(title);
-
- document.querySelector('.btn').addEventListener('click', function(event) {
- event.preventDefault();
- checkAvailability(libraryBooks);
- });
-
- document.querySelector('form').addEventListener('submit', function(event) {
- event.preventDefault();
- if (validateForm(libraryBooks)) {
- const formData = getFormData();
- const queryString = new URLSearchParams(formData).toString();
- const destinationPage = 'profile.html';
- window.location.href = `${destinationPage}?${queryString}`;
- }
- });
-});
-
-function checkAvailability(libraryBooks) {
- try {
- var bookID = document.getElementById("bk_id").value;
- var bookAuthor = document.getElementById("book_author").value;
- var quantity = parseInt(document.getElementById("quan").value);
- var bookTitle = document.getElementById("bk_tit").value;
-
- if (!libraryBooks.length) {
- alert('Library data not found in local storage !');
- return;
- }
- var flag = false;
-
- for (var bookData in libraryBooks) {
- if (libraryBooks[bookData].bookID == bookID &&
- libraryBooks[bookData].author == bookAuthor &&
- libraryBooks[bookData].numberofcopies >= quantity &&
- libraryBooks[bookData].title == bookTitle) {
- alert("Needed quantity of book exists.");
- flag = true;
- break;
- }
- }
-
- if (!flag) {
- alert("Needed quantity of book doesn't available, try lesser quantity");
- }
-
- } catch(error) {
- console.error(error);
- }
-}
-
-function validateForm(libraryBooks) {
- try {
- var bookID = document.getElementById("bk_id").value;
- var bookAuthor = document.getElementById("book_author").value;
- var quantity = parseInt(document.getElementById("quan").value);
- var bookTitle = document.getElementById("bk_tit").value;
-
- var firstName = document.getElementById("f_name").value;
- var middleName = document.getElementById("m_name").value;
- var lastName = document.getElementById("l_name").value;
- var mail = document.getElementById("mail").value;
- var phoneNumber = document.getElementById("ph_no").value;
- var deliveryAddress = document.getElementById("add").value;
- var deliveryDate = document.getElementById("delivered_date").value;
-
- if (!bookID || !bookAuthor || !quantity || !bookTitle) {
- alert("Please fill in all book details.");
- return false;
- }
-
- for (var bookData in libraryBooks) {
- if (libraryBooks[bookData].bookID == bookID &&
- libraryBooks[bookData].author == bookAuthor &&
- libraryBooks[bookData].numberofcopies >= quantity &&
- libraryBooks[bookData].title == bookTitle) {
- libraryBooks[bookData].numberofcopies -= quantity;
- break;
- }
- }
-
- localStorage.setItem("libraryBooks",JSON.stringify(libraryBooks));
-
- var nameExpression = /^[a-zA-Z]{3,10}$/;
- if(!nameExpression.test(firstName) || !nameExpression.test(middleName) || !nameExpression.test(lastName)){
- alert("Name must be between 3 to 10 characters long and can only contain letters.");
- return false;
- }
-
- var phoneNubmerExpression = /^\d{11}$/; // Corrected regular expression
- if(phoneNumber.length !== 11 || !phoneNubmerExpression.test(phoneNumber)){
- alert("Phone number must be exactly 11 digits long.");
- return false;
- }
-
- if(deliveryAddress.length < 4){
- alert("Delivery address must be at least 4 characters long.");
- return false;
- }
-
- const formData = {
- bookID,
- bookAuthor,
- quantity,
- bookTitle,
- firstName,
- middleName,
- lastName,
- mail,
- phoneNumber,
- deliveryAddress,
- deliveryDate
- };
-
- localStorage.setItem("FormData", JSON.stringify(formData));
-
- if (!localStorage.getItem("BorrowedBooks")) {
- localStorage.setItem("BorrowedBooks", JSON.stringify([]));
- }
-
- var borrowedBooksString = localStorage.getItem("BorrowedBooks");
- var borrowedBooks = borrowedBooksString ? JSON.parse(borrowedBooksString) : [];
- borrowedBooks.push({ bookID: bookID, bookTitle: bookTitle, quantity: formData.quantity });
- localStorage.setItem("BorrowedBooks", JSON.stringify(borrowedBooks));
-
- return true;
-
- } catch(error) {
- console.error(error);
- return false;
- }
-}
-
-function getFormData() {
- return {
- bookID: document.getElementById("bk_id").value,
- bookAuthor: document.getElementById("book_author").value,
- quantity: parseInt(document.getElementById("quan").value),
- bookTitle: document.getElementById("bk_tit").value,
- firstName: document.getElementById("f_name").value,
- middleName: document.getElementById("m_name").value,
- lastName: document.getElementById("l_name").value,
- mail: document.getElementById("mail").value,
- phoneNumber: document.getElementById("ph_no").value,
- deliveryAddress: document.getElementById("add").value,
- deliveryDate: document.getElementById("delivered_date").value
- };
-}
diff --git a/EgyBooks/static/js/editbook.js b/EgyBooks/static/js/editbook.js
deleted file mode 100644
index ec8cad2..0000000
--- a/EgyBooks/static/js/editbook.js
+++ /dev/null
@@ -1,173 +0,0 @@
-function getUrlParameter(name) {
- name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
- var regex = new RegExp('[\\?&]' + name + '=([^]*)');
- var results = regex.exec(location.search);
- return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
-}
-
-document.addEventListener("DOMContentLoaded", function(){
- var container = document.getElementById("editBookForm");
- var storedBooks = localStorage.getItem('libraryBooks');
- var id = getUrlParameter('id');
- var books= [];
- if (storedBooks) {
- books = JSON.parse(storedBooks);
- }
- console.log(books);
- books.forEach(function (book) {
- if(book.bookID==id){
- container.innerHTML += generateBookFormHTML(book);
- }
- });
-})
-
-function generateBookFormHTML(book){
- return `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- `
-}
-
-document.addEventListener("DOMContentLoaded", function(){
-
-
- var storedBooks = localStorage.getItem('libraryBooks');
- if (storedBooks) {
- libraryBooks = JSON.parse(storedBooks);
- }
- else {
- libraryBooks = [];
- }
- console.log(libraryBooks);
-
- var form = document.querySelector("form");
-
- form.addEventListener('submit', function(event) {
- event.preventDefault();
-
- var fileInput = document.getElementById('image');
- var imageFile = fileInput.files[0];
-
- var reader = new FileReader();
- reader.onload = function(event) {
- var imageDataUrl = event.target.result;
-
- var title = document.getElementById('nameofthebook').value;
- var bookID = document.getElementById('bookID').value;
- var author = document.getElementById('author').value;
- var category = document.getElementById('category').value;
- var pages = document.getElementById('numberofpages').value;
- var description = document.getElementById('description').value;
- var price = document.getElementById('price').value;
- var numberofcopies = document.getElementById('numberofcopies').value;
-
- var titleRegex = /^[a-zA-Z][\w\d]*$/;
- if(!titleRegex.test(title)){
- alert("Title can't contain numbers in the start and can't contain special characters!");
- return false;
- }
-
- if(!titleRegex.test(author)){
- alert("author can't contain numbers in the start and can't contain special characters!");
- return false;
- }
-
- var categoryRegex = /^[a-zA-Z][a-zA-Z]*$/
- if(!categoryRegex.test(category)){
- alert("Category can't contain numbers in the start and can't contain special characters!");
- return false;
- }
-
- var idRegex = /^[0-9]+$/;
- if(!idRegex.test(bookID)){
- alert("ID must be numbers only");
- return false;
- }
-
- const bookData = {
- image: imageDataUrl,
- title: title,
- bookID: bookID,
- author: author,
- category:category,
- pages: pages,
- description: description,
- price: price,
- numberofcopies:numberofcopies
- };
-
- saveBookData(bookData);
- };
-
- reader.readAsDataURL(imageFile);
-
- });
-})
-
-function saveBookData(bookData) {
- var storedBooks = localStorage.getItem('libraryBooks');
- if (storedBooks) {
- libraryBooks = JSON.parse(storedBooks);
- }
- else {
- libraryBooks = [];
- }
-
- console.log(libraryBooks);
- libraryBooks.forEach(function (book) {
- if(book.bookID==bookData.bookID){
- book.category=bookData.category;
- book.pages=bookData.pages;
- book.description=bookData.description;
- book.price=bookData.price;
- book.numberofcopies=bookData.numberofcopies;
- }
- });
- localStorage.setItem('libraryBooks', JSON.stringify(libraryBooks));
-
- alert('Book editted successfully!');
- window.location.href = "ViewBooks.html";
-}
\ No newline at end of file
diff --git a/EgyBooks/static/js/editprofile.js b/EgyBooks/static/js/editprofile.js
index dcd2710..b31b395 100644
--- a/EgyBooks/static/js/editprofile.js
+++ b/EgyBooks/static/js/editprofile.js
@@ -3,10 +3,10 @@ var userInfoString = localStorage.getItem("userInfo");
function validateForm(){
try{
- var newUserName = document.getElementById("username").value;
- var newPassword = document.getElementById("password").value;
- var newConfirmPassword = document.getElementById("confirm_password").value;
- var newEmail = document.getElementById("email").value;
+ var newUserName = document.getElementById("id_username").value;
+ var newPassword = document.getElementById("id_password1").value;
+ var newConfirmPassword = document.getElementById("id_password2").value;
+ var newEmail = document.getElementById("id_email").value;
}
catch(error){
console.log(error)
@@ -48,38 +48,19 @@ function validateForm(){
return false;
}
- var userInfo = {
- username: newUserName,
- password: newPassword,
- email: newEmail,
- account_type: JSON.parse(userInfoString).account_type
- };
-
- localStorage.setItem("userInfo", JSON.stringify(userInfo));
-
return true;
}
document.addEventListener("DOMContentLoaded", function(){
console.log("hereDom");
- var form = document.querySelector("form");
+ var form = document.querySelector("form.edit_form_class");
form.addEventListener("submit", function(event){
event.preventDefault();
if(validateForm()){
- var userInfoString = localStorage.getItem("userInfo");
- var userInfo = JSON.parse(userInfoString);
- var username = userInfo.newUserName;
- var password = userInfo.newPassword;
- var email = userInfo.newEmail;
- var accountType = userInfo.account_type;
- console.log("Username:", username);
- console.log("Password:", password);
- console.log("Email:", email);
- console.log("Account Type:", accountType);
- window.location.href = "Profile.html";
+ form.submit()
alert("Profile Data Updated!");
}
})
diff --git a/EgyBooks/static/js/navBar.js b/EgyBooks/static/js/navBar.js
index a3ba24c..02ed505 100644
--- a/EgyBooks/static/js/navBar.js
+++ b/EgyBooks/static/js/navBar.js
@@ -1,46 +1,3 @@
-document.addEventListener("DOMContentLoaded",function(){
- var loggedin = JSON.parse(localStorage.getItem("loggedIn"));
- var navigationBarLeftButtons = document.getElementsByClassName("left_buttons")[0];
- if(loggedin === false){
- var profileButton = document.getElementById("profile_button");
- var borrowBookButton = document.getElementById("borrow_book_button");
- borrowBookButton.remove();
- profileButton.remove();
-
- }
-
- try {
- var accountType = JSON.parse(localStorage.getItem("userInfo")).account_type;
- }
- catch {
-
- };
-
- if(loggedin === true){
- var loginButton = document.getElementById("login_button");
- var signupButton = document.getElementById("signup_button");
-
- loginButton.remove();
- signupButton.remove();
-
- var ulElement = document.createElement('ul');
- ulElement.id = 'signout_button';
- ulElement.className = 'nav_bar_button';
-
- var aElement = document.createElement('a');
- aElement.href = 'Signup.html';
- aElement.textContent = 'Sign Out';
-
- ulElement.appendChild(aElement);
- navigationBarLeftButtons.appendChild(ulElement);
- }
-
- if(accountType == "User" || !loggedin){
- var addBooksButton = document.getElementById("add_book_button");
- addBooksButton.remove();
- }
-})
-
var searchInput;
var filterSelect;
//Search bar code
@@ -54,7 +11,7 @@ document.addEventListener("DOMContentLoaded", function(){
filterSelect = document.querySelector('.search_input_container select[name="filter"]');
var extractedSearchAndFilter = extractSearchTextAndFilter();
- const url = `Search.html?search=${encodeURIComponent(extractedSearchAndFilter.searchText)}&filter=${encodeURIComponent(extractedSearchAndFilter.selectedFilter)}`;
+ const url = `${window.location.origin}/books/view-all/?search=${encodeURIComponent(extractedSearchAndFilter.searchText)}&filter=${encodeURIComponent(extractedSearchAndFilter.selectedFilter)}`;
window.location.href = url;
});
@@ -66,5 +23,3 @@ function extractSearchTextAndFilter() {
var selectedFilter = filterSelect.value;
return { searchText: searchText, selectedFilter: selectedFilter };
}
-
-// Action bar Code
diff --git a/EgyBooks/static/js/profile.js b/EgyBooks/static/js/profile.js
index 10d3d97..fc63272 100644
--- a/EgyBooks/static/js/profile.js
+++ b/EgyBooks/static/js/profile.js
@@ -1,33 +1,39 @@
-document.addEventListener("DOMContentLoaded", function() {
- var userInfoString = localStorage.getItem("userInfo");
- var userInfo = JSON.parse(userInfoString);
-
- var username = userInfo.username;
- var email = userInfo.email;
- var password = userInfo.password;
- var accountType = userInfo.account_type;
-
- var usernameElement = document.getElementById("profile-username");
- var emailElement = document.getElementById("profile-email");
- var passwordElement = document.getElementById("profile-password");
- var accountTypeElement = document.getElementById("profile-account-type");
-
- usernameElement.textContent = username;
- emailElement.textContent = email;
- passwordElement.textContent = password;
- accountTypeElement.textContent = accountType;
-
- if (!localStorage.getItem("BorrowedBooks")) {
- localStorage.setItem("BorrowedBooks", JSON.stringify([]));
- }
-
- var borrowedBooksString = localStorage.getItem("BorrowedBooks");
- var borrowedBooks = JSON.parse(borrowedBooksString);
+document.addEventListener("DOMContentLoaded",async function() {
+ var borrowedBooks = await fetchBorrowedBooks();
+ console.log(borrowedBooks)
var borrowedBooksList = document.getElementById("borrowed-books-list");
borrowedBooks.forEach(function(book) {
var listItem = document.createElement("li");
- listItem.textContent = `Book Title: ${book.bookTitle} - Book ID: ${book.bookID} - Quantity: ${book.quantity}`;
+ listItem.textContent = `Book Title: ${book.title} - Book ID: ${book.id} - Quantity: ${book.number_of_borrowed_books}`;
borrowedBooksList.appendChild(listItem);
});
});
+
+async function getBorrowedBooksData() {
+ return new Promise(function(resolve, reject) {
+ var xhr = new XMLHttpRequest();
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState === XMLHttpRequest.DONE) {
+ if (xhr.status === 200) {
+ resolve(JSON.parse(xhr.responseText));
+ } else {
+ reject('Error fetching books data');
+ }
+ }
+ };
+ xhr.open("GET", "/api/get-borrowed-books", true);
+ xhr.send();
+ });
+}
+
+
+async function fetchBorrowedBooks() {
+ try {
+ const data = await getBorrowedBooksData();
+ return data;
+ } catch (error) {
+ console.error(error);
+ return []
+ }
+}
\ No newline at end of file
diff --git a/EgyBooks/static/js/viewbooks.js b/EgyBooks/static/js/viewbooks.js
index 23b80a2..3fda14c 100644
--- a/EgyBooks/static/js/viewbooks.js
+++ b/EgyBooks/static/js/viewbooks.js
@@ -1,37 +1,63 @@
-
document.addEventListener("DOMContentLoaded", function(){
- var books = getBooksData();
- console.log(books);
- var container = document.getElementById("all_books");
- console.log(container);
-
- var isrender=false;
-
- books.forEach(function (book) {
- console.log(book);
- if(book.numberofcopies>0){
- container.innerHTML+= generateBookHTML(book);
- isrender=true;
+ getBooksData().then(function(books) {
+ var container = document.getElementById("all_books");
+ var isRender = false;
+ var searching = false;
+ console.log(books);
+
+ const params = new URLSearchParams(window.location.search);
+
+ searchValue = params.get('search');
+
+ filterValue = params.get('filter');
+
+ if(searchValue != null || filterValue != null)
+ searching = true;
+
+
+ books.forEach(function (book) {
+ if(book.number_of_copies > 0 && !searching){
+ container.innerHTML += generateBookHTML(book);
+ isRender = true;
+ }
+ else{
+ if('title' == filterValue && book.title.toLowerCase().includes(searchValue.toLowerCase())){
+ container.innerHTML+= generateBookHTML(book);
+ isRender=true;
+ }
+ else if('author' == filterValue && book.author.toLowerCase().includes(searchValue.toLowerCase())){
+ container.innerHTML+= generateBookHTML(book);
+ isRender=true;
+ }
+ else if('category' == filterValue && book.category.toLowerCase().includes(searchValue.toLowerCase())){
+ container.innerHTML+= generateBookHTML(book);
+ isRender=true;
+ }
+ }
+ });
+
+ if(!isRender){
+ container.innerHTML +=
+ `
+ there are no books
+ `;
}
+ }).catch(function(error) {
+ console.log('Error fetching books data:', error);
+ alert('Error fetching book data');
});
-
- if(!isrender){
- container.innerHTML+=
- `
- there is no books
- `
- }
-})
+});
function generateBookHTML(book) {
return `
-
-
+
+
Title : ${book.title}
Author : ${book.author}
Category : ${book.category}
+
Book id: ${book.id}
Price : ${book.price}$
@@ -40,12 +66,18 @@ function generateBookHTML(book) {
}
function getBooksData(){
- var booksData = localStorage.getItem('libraryBooks');
- if (booksData) {
- return JSON.parse(booksData);
- } else {
- console.log('Error');
- return [];
- }
+ return new Promise(function(resolve, reject) {
+ var xhr = new XMLHttpRequest();
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState === XMLHttpRequest.DONE) {
+ if (xhr.status === 200) {
+ resolve(JSON.parse(xhr.responseText));
+ } else {
+ reject('Error fetching books data');
+ }
+ }
+ };
+ xhr.open("GET", "/api/get-books-data", true);
+ xhr.send();
+ });
}
-
diff --git a/EgyBooks/templates/about.html b/EgyBooks/templates/about.html
index 9fe5f54..92cde7f 100644
--- a/EgyBooks/templates/about.html
+++ b/EgyBooks/templates/about.html
@@ -3,17 +3,6 @@
{% block head_block %}
-
{% endblock %}
{% block title %}
diff --git a/EgyBooks/templates/home.html b/EgyBooks/templates/home.html
index 3d16989..595d619 100644
--- a/EgyBooks/templates/home.html
+++ b/EgyBooks/templates/home.html
@@ -8,15 +8,6 @@
{% block head_block %}
{% endblock %}
diff --git a/EgyBooks/templates/layout.html b/EgyBooks/templates/layout.html
index 9a86163..70946f0 100644
--- a/EgyBooks/templates/layout.html
+++ b/EgyBooks/templates/layout.html
@@ -22,6 +22,20 @@
+
{% block title %}
@@ -38,17 +52,31 @@
diff --git a/Website/About.html b/Website/About.html
deleted file mode 100644
index efb4574..0000000
--- a/Website/About.html
+++ /dev/null
@@ -1,94 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
- EgyBooks
-
-
-
-
-
-
-
-
-
-

-
-
-
-
-
-
-
-
-
-
-
About us:
-
-
-
-
-
Names:
-
- - Yousef Mostafa
- - Ahmed elsayed
- - Omar Abdelmonem
- - Ahmed Nasser
- - Yassin Ramadan
-
-
IDS:
-
- - 20220413
- - 20220011
- - 20220227
- - 20220045
- - 20220380
-
-
-
-
-
-
-
diff --git a/Website/AddBook.html b/Website/AddBook.html
deleted file mode 100644
index 7125c4e..0000000
--- a/Website/AddBook.html
+++ /dev/null
@@ -1,107 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
EgyBooks | Add book
-
-
-
-
-
-

-
-
-
-
-
-
-
-
-
-
-
diff --git a/Website/BookPage.html b/Website/BookPage.html
deleted file mode 100644
index a5b9bca..0000000
--- a/Website/BookPage.html
+++ /dev/null
@@ -1,68 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Clean Code | EgyBooks
-
-
-
-
-
-
-
-
-

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Website/BorrowBook.html b/Website/BorrowBook.html
deleted file mode 100644
index 7312cae..0000000
--- a/Website/BorrowBook.html
+++ /dev/null
@@ -1,132 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- EgyBooks | Borrow Book
-
-
-
-
-
-
-
-

-
-
-
-
-
-
-
-
-
-
-
diff --git a/Website/EditBook.html b/Website/EditBook.html
deleted file mode 100644
index da83b48..0000000
--- a/Website/EditBook.html
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- EgyBooks | Add book
-
-
-
-
-
-

-
-
-
-
-
-
-
-
-
-
-
diff --git a/Website/EditProfile.html b/Website/EditProfile.html
deleted file mode 100644
index c35337d..0000000
--- a/Website/EditProfile.html
+++ /dev/null
@@ -1,82 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

-
-
-
-
-
-
-
-
-
-
diff --git a/Website/Login.html b/Website/Login.html
deleted file mode 100644
index eaf2964..0000000
--- a/Website/Login.html
+++ /dev/null
@@ -1,82 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- EgyBooks
-
-
-
-
-
-

-
-
-
-
-
-
-
-
Login
-
-
-
-
diff --git a/Website/Profile.html b/Website/Profile.html
deleted file mode 100644
index 4d06167..0000000
--- a/Website/Profile.html
+++ /dev/null
@@ -1,97 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- EgyBooks
-
-
-
-
-
-

-
-
-
-
-
-
-
-
My profile
-
-
-
-

-
-
-
-
Account info
-
-
- Username
-
-
-
-
-
- Email
-
-
-
-
-
- Password
-
-
-
-
-
- Account Type
-
-
-
-
-
-
-
-
-
-
Borrowed Books History
-
-
-
-
-
-
-
-
-
diff --git a/Website/Search.html b/Website/Search.html
deleted file mode 100644
index 41ae283..0000000
--- a/Website/Search.html
+++ /dev/null
@@ -1,72 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- EgyBooks | Add book
-
-
-
-
-
-
-
-

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Website/Signup.html b/Website/Signup.html
deleted file mode 100644
index e05acc0..0000000
--- a/Website/Signup.html
+++ /dev/null
@@ -1,109 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- EgyBooks
-
-
-
-
-
-

-
-
-
-
-
-
-
-
-
diff --git a/Website/ViewBooks.html b/Website/ViewBooks.html
deleted file mode 100644
index 42a5098..0000000
--- a/Website/ViewBooks.html
+++ /dev/null
@@ -1,72 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- EgyBooks | Add book
-
-
-
-
-
-
-
-

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Website/css/About.css b/Website/css/About.css
deleted file mode 100644
index c459b08..0000000
--- a/Website/css/About.css
+++ /dev/null
@@ -1,36 +0,0 @@
-
-.aboutus_book{
- display: flex;
- justify-content: center;
- align-items: center;
-}
-* {
- font-family: "Shadow Into Light", cursive;
-}
-
-
-.book_first_page{
-
- color: rgb(0, 0, 0);
- position: relative;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- width: 20vw;
- background-color: rgb(88, 47, 14);
- background-image: url("../pics/bp.png");
- background-size: cover;
- border-radius: 20px;
-}
-.book_first_page ul,h2{
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
-}
-.aboutus_text{
- margin-top: 10%;
- display: flex;
- justify-content: center;
- color: white;
-}
diff --git a/Website/css/BookPage.css b/Website/css/BookPage.css
deleted file mode 100644
index 86ef52a..0000000
--- a/Website/css/BookPage.css
+++ /dev/null
@@ -1,122 +0,0 @@
-body{
- background-color: #f6f1de;
- color: #582F0E;
-}
-
-.book{
- display: flex;
-}
-
-.bookimg{
- background-size : cover;
- height : 80vh;
- width : 50vw;
- margin : 0vh 3vw 2vh 3vw;
- border-radius: 15px;
-}
-* {
- font-family: "Shadow Into Light", cursive;
-}
-
-.bookdef{
- background-color: #B6AD90;
- border-radius: 30px;
- border-style: solid;
- padding: 3vh 3vw;
- margin: 3vh 3vw;
-}
-
-h1 {
- font-size: 30px;
- margin-bottom: 30px;
- text-align: center;
-}
-
-h2 {
- font-size: 20px;
- margin-bottom: 8px;
-}
-
-h5 {
- font-size: 15px;
- margin-bottom: 8px;
- margin-left: 30px;
-}
-
-p {
- font-size: 15px;
- line-height: 25px;
- margin-bottom: 8px;
- margin-left: 30px;
-}
-
-.btns{
- display:flex;
-}
-
-.borrow{
- background-color: #B6AD90;;
- margin: 0vh 3vw 3.75vh 5vw;
- padding: 1.25vh 2vw 1.25vh 1.5vw;
- border-radius: 10px;
- width: 100px;
- text-align: center;
-}
-.borrow a {
- text-decoration: none;
-}
-
-.edit{
- background-color: #B6AD90;;
- margin: 0vh 3vw 3.75vh 0.8vw;
- padding: 1.25vh 2vw 1.25vh 2vw;
- border-radius: 10px;
- width: 100px;
- text-align: center;
-}
-
-.edit a {
- text-decoration: none;
-}
-
-.delete{
- background-color: #B6AD90;;
- margin: 0vh 0vw 3.75vh 0vw;
- padding: 1.25vh 2vw 1.25vh 1.75vw;
- border-radius: 10px;
- color: #582F0E;
- font-size: 15px;
- font-weight: bold;
- width: 100px;
- text-align: center;
-}
-
-.btnword{
- background-color: #B6AD90;;
- color: #582F0E;
- font-size: 15px;
- font-weight: bold;
-}
-
-.commentword{
- margin-left: 8vw;
-}
-
-.commentbox{
- margin-top: 1.25vh;
- margin-left: 10vw;
- width: 40vw;
- resize: none;
-}
-
-.commentbtn{
- background-color: #B6AD90;;
- margin: 3.75vh 1.5vw 3.75vh 3vw;
- padding: 1.25vh 6vw 1.25vh 1.5vw;
- border-radius: 10px;
- color: #582F0E;
- background-color: #B6AD90;;
- font-size: 15px;
- font-weight: bold;
- width: 5vw;
-}
diff --git a/Website/css/Login_styles.css b/Website/css/Login_styles.css
deleted file mode 100644
index b5d6c2d..0000000
--- a/Website/css/Login_styles.css
+++ /dev/null
@@ -1,94 +0,0 @@
-
-.login-class input[type=text], .login-class input[type=password] {
- width: 100%;
- padding: 15px 20px;
- margin: 8px auto;
- display: inline-block;
- color: black;
- border: 1px solid #bebebe;
- background-color: #f2f4eb;
- border-radius: 4px;
- box-sizing: border-box;
- font-size: 16px;
-}
-
-
-.login-class input[type=text]:focus, .login-class input[type=password]:focus {
- background-color: white;
- border: 3px solid #b9bea6;
- outline: 3px solid #582F0E;
-}
-
-.login-class label[for="username"], .login-class label[for="password"] {
- color: #582F0E;
- font-size: 18px;
-}
-
-
-.login-class input[type=submit], .login-class input[type=reset] {
- background-color: #7F4F24;
- color: #f2f4eb;
- padding: 20px 25px;
- font-size: medium;
- margin: 8px 110px;
- width: 100%;
- max-width: 150px;
- height: 60px;
- font-size: 18px;
- border: none;
- border-radius: 4px;
- cursor: pointer;
- box-sizing: border-box;
-}
-
-
-.login-class input[type=submit]:hover, .login-class input[type=reset]:hover {
- background-color: #582F0E;
-}
-
-.login-class {
- width: 100%;
- max-width: 550px;
- border-radius: 5px;
- background-color: #B6AD90;
- padding: 20px;
- margin: 50px auto;
- display: flex;
- flex-direction: column;
- align-items: center;
- box-sizing: border-box;
-}
-
-
-* {
- font-family: "Shadow Into Light", cursive;
-}
-
-#login-h1 {
- color:#532c0c;
- margin: 35px 0px;
- text-align: center;
- padding: 10px 0;
-}
-
-
-body {
- background-color: #f6f1de;
-}
-
-
-#login-signup {
- text-decoration: none;
- color: #7F4F24;
-}
-
-
-#login-signup:hover {
- text-decoration: underline;
- color: #422208;
-}
-
-
-#para-acc {
- color: #381e09
-}
diff --git a/Website/css/Signup_styles.css b/Website/css/Signup_styles.css
deleted file mode 100644
index 5dec678..0000000
--- a/Website/css/Signup_styles.css
+++ /dev/null
@@ -1,146 +0,0 @@
-* {
- font-family: "Shadow Into Light", cursive;
-}
-
-
-.signup-class input[type=text], .signup-class input[type=password], .signup-class input[type=email] {
- width: 100%;
- padding: 15px 20px;
- margin: 8px auto;
- display: inline-block;
- color: black;
- border: 1px solid #bebebe;
- background-color: #f2f4eb;
- border-radius: 4px;
- box-sizing: border-box;
- font-size: 16px;
-}
-
-
-.signup-class input[type=text]:focus, .signup-class input[type=password]:focus, .signup-class input[type=email]:focus {
- background-color: white;
- border: 3px solid #b9bea6;
- outline: 3px solid #582F0E;
-}
-
-
-.signup-class label[for="username"], .signup-class label[for="password"], .signup-class label[for="confirm password"], .signup-class label[for="email"] {
- color: #582F0E;
- font-size: 18px;
-}
-
-
-.signup-class input[type=submit], .signup-class input[type=reset] {
- background-color: #7F4F24;
- color: #f2f4eb;
- padding: 20px 25px;
- font-size: medium;
- margin: 8px 140px;
- width: 100%;
- max-width: 150px;
- height: 60px;
- font-size: 18px;
- border: none;
- border-radius: 4px;
- cursor: pointer;
- box-sizing: border-box;
-}
-
-
-.signup-class input[type=submit]:hover, .signup-class input[type=reset]:hover {
- background-color: #582F0E;
-}
-
-
-.signup-class {
- width: 100%;
- max-width: 600px;
- border-radius: 5px;
- background-color: #B6AD90;
- padding: 20px;
- margin: 50px auto;
- display: flex;
- flex-direction: column;
- align-items: center;
- box-sizing: border-box;
-}
-
-
-#signup-h1 {
- color:#532c0c;
- margin: 35px 0px;
- text-align: center;
- padding: 10px 0;
-}
-
-
-body {
- background-color: #f6f1de;
-}
-
-
-#login-signup-acc {
- text-decoration: none;
- color: #7F4F24;
-}
-
-
-#login-signup-acc:hover {
- text-decoration: underline;
- color: #422208;
-}
-
-#para-login-acc {
- color: #381e09
-}
-
-
-.signup-class label[for="account type"] {
- color: #582F0E;
- font-size: 18px;
-}
-
-
-.acc-type {
- display: inline-block;
- color: #381e09;
- font-size: 16px;
-}
-
-.acc-type label:hover, .acc-type label:focus-within, .acc-type label:active {
- background: hsla(67, 19%, 72%, 0.7);
- border-radius: 10px;
- padding: 3px;
- cursor: pointer;
-}
-
-
-.acc-type label {
- padding: 5px 0px 5px 2px;
- margin: 5px 0px 5px 5px;
-}
-
-
-.acc-type input[type='radio'] {
- appearance: none;
- width: 15px;
- height: 15px;
- border: 1px solid #582F0E;
- border-radius: 50%;
- outline: none;
- box-shadow: 0 0 5px #582F0E;
- transition: box-shadow 0.3s ease;
- }
-
-.acc-type input[type='radio']:before {
- content: '';
- display: block;
- width: 60%;
- height: 60%;
- margin: 20% auto;
- border-radius: 50%;
-}
-
-.acc-type input[type='radio']:checked:before {
- background: #582F0E;
-}
diff --git a/Website/css/add_book.css b/Website/css/add_book.css
deleted file mode 100644
index d3273a5..0000000
--- a/Website/css/add_book.css
+++ /dev/null
@@ -1,85 +0,0 @@
-.add_book_class{
- margin: 20px;
- padding: 20px;
- background-color: #B6AD90; /* White background */
- border-radius: 10px;
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); /* Drop shadow */
-}
-
-.title {
- color:#532c0c;
- margin: 35px 0px;
- padding: 10px 0;
- font-family: "Shadow Into Light", cursive;
- font-size: 32px;
-
-}
-* {
- font-family: "Shadow Into Light", cursive;
-}
-
-.subtitle{
- color: #582F0E;
- font-size: 18px;
-}
-
-input[type="submit"] {
- background-color: #7F4F24; /* Brown color */
- color: #f2f4eb; /* White text */
- border: none;
- padding: 10px 20px;
- border-radius: 5px;
- cursor: pointer;
- font-size: 18px;
-}
-.form_group {
- display: flex;
- flex-direction: column;
- align-items: baseline;
- margin: 10px;
-}
-
-.form_style {
- width: 290px;
- padding: 15px 20px;
- margin: 8px;
- display: inline-block;
- color: black;
- border: 1px solid #bebebe;
- background-color: #f2f4eb;
- border-radius: 4px;
- box-sizing: border-box;
- font-size: 16px;
-}
-.form_style:focus {
- background-color: white;
- border: 3px solid #b9bea6;
- outline: 3px solid #582F0E;
-}
-
-
-
-body {
- background-color: #f6f1de;
-}
-
-textarea {
- width: 800px;
- height: 300px;
- padding: 15px 20px;
- margin: 8px;
- display: inline-block;
- color: black;
- border: 1px solid #bebebe;
- background-color: #f2f4eb;
- border-radius: 4px;
- box-sizing: border-box;
- font-size: 16px;
- resize: none;
-}
-
-textarea:focus {
- background-color: white;
- border: 3px solid #b9bea6;
- outline: 3px solid #582F0E;
-}
diff --git a/Website/css/all_books.css b/Website/css/all_books.css
deleted file mode 100644
index da784bd..0000000
--- a/Website/css/all_books.css
+++ /dev/null
@@ -1,64 +0,0 @@
-.all_books {
- display: flex;
- flex-wrap: wrap;
- margin: 20px;
- padding: 20px;
- background-color: #B6AD90;
- border-radius: 10px;
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
-}
-.book_block {
- flex: 0 0 17%;
- width: 200px;
- height: 415px;
- background-color: #f5f5f5;
- border: 1px solid #ccc;
- border-radius: 5px;
- overflow: hidden;
- margin: 20px;
-}
-* {
- font-family: "Shadow Into Light", cursive;
-}
-
-.book_block:hover {
- transform: translateY(-20px);
- width: 200px;
- height: 415px;
- background-color: #e6ccb2;
- border: 1px solid #ccc;
- border-radius: 5px;
- overflow: hidden;
- margin: 20px;
-}
-
-.book_link {
- text-decoration: none;
- color: inherit;
-}
-
-.book_image {
- width: 100%;
- height: auto;
- margin-bottom: 10px;
-}
-
-.book_details {
- padding: 10px;
-}
-
-.book_title {
- margin: 0;
- font-size: 1em;
-}
-
-.book_price {
- margin: 5px 0;
- font-size: 0.9em;
- font-weight: bold;
- color: #795548;
-}
-
-body {
- background-color: #f6f1de;
-}
diff --git a/Website/css/book_block.css b/Website/css/book_block.css
deleted file mode 100644
index 94bf780..0000000
--- a/Website/css/book_block.css
+++ /dev/null
@@ -1,49 +0,0 @@
-.book_block {
- width: 200px;
- height: 390px;
- background-color: #f5f5f5;
- border: 1px solid #ccc;
- border-radius: 5px;
- overflow: hidden;
- margin: 20px;
-}
-
-.book_block:hover {
- width: 210px;
- height: 400px;
- background-color: #e6ccb2;
- border: 1px solid #ccc;
- border-radius: 5px;
- overflow: hidden;
- margin: 20px;
-}
-* {
- font-family: "Shadow Into Light", cursive;
-}
-
-.book_link {
- text-decoration: none;
- color: inherit;
-}
-
-.book_image {
- width: 100%;
- height: auto;
- margin-bottom: 10px;
-}
-
-.book_details {
- padding: 10px;
-}
-
-.book_title {
- margin: 0;
- font-size: 1em;
-}
-
-.book_price {
- margin: 5px 0;
- font-size: 0.9em;
- font-weight: bold;
- color: #795548;
-}
diff --git a/Website/css/borrow_book.css b/Website/css/borrow_book.css
deleted file mode 100644
index 12ca881..0000000
--- a/Website/css/borrow_book.css
+++ /dev/null
@@ -1,109 +0,0 @@
-body {
- background-color: #f6f1de;
-}
-.container {
- padding: 20px;
- margin: 100px auto;
- box-sizing: border-box;
- max-width: 900px;
- width: 100%;
- border-radius: 10px;
- background-color: #B6AD90
-}
-* {
- font-family: "Shadow Into Light", cursive;
-}
-
-
-.container header {
- font-size: 25px;
- font-weight: 600;
- color: #582F0E;
-}
-
-.container form {
- position: relative;
- margin-top: 16px;
- min-height: 490px;
-}
-
-.container form .bookDetails {
- margin-top: 30px;
-}
-
-.container form .title {
- display: block;
- font-size: 25px;
- font-weight: 500;
- margin: 6px 0;
- color: #582F0E;
-}
-
-.container form .fields {
- display: flex;
- align-items: center;
- justify-content: space-between;
- flex-wrap: wrap;
-}
-
-form .fields .inputField {
- display: flex;
- width: calc(100% / 3 - 15px);
- flex-direction: column;
- margin: 4px 0;
-}
-
-.inputField input {
- outline: none;
- font-weight: 400;
- color: #7F4F24;
- font-size: 14px;
- border: 1px solid #aaa;
- border-radius: 5px;
- padding: 0 15px;
- height: 42px;
- margin: 8px 0;
- background-color: #f2f4eb;
-}
-
-.inputField input:hover {
- background-color: #fff;
- border: 3px solid #b9bea6;
- outline: 3px solid #582F0E;
-}
-
-.inputField input:is(:focus, :valid) {
- box-shadow: 0 3px 6px rgba(0, 0, 0, 0.13);
-}
-
-.container .form .bookDetails .fields .avaCheck .btn {
- background-color: #582F0E;
- border: none;
- color: #e2ded0;
- padding: 20px 30px;
- font-size: 15px;
- margin: 14px 44px;
- cursor: pointer;
- border-radius: 5px;
- margin-bottom: -2px;
-}
-
-input[type=submit] {
- background-color: #582F0E;
- color: #e2ded0;
- padding: 12px 111px;
- border-radius: 5px;
- cursor: pointer;
- float: right;
- margin-top: 21px;
-}
-
-input[type=reset] {
- background-color: #582F0E;
- color: #e2ded0;
- padding: 12px 111px;
- border-radius: 5px;
- cursor: pointer;
- float: right;
- margin-top: 21px;
-}
\ No newline at end of file
diff --git a/Website/css/core.css b/Website/css/core.css
deleted file mode 100644
index f426a96..0000000
--- a/Website/css/core.css
+++ /dev/null
@@ -1,17 +0,0 @@
-*,*::before,*::after{
- box-sizing: border-box;
-}
-*{
- margin: 0;
- padding: 0;
-}
-body{
- font-family: Arial, sans-serif;
- background-position: center;
- background-repeat: no-repeat;
- background-size : cover;
- height: 100vh;
-}
-* {
- font-family: "Shadow Into Light", cursive;
-}
diff --git a/Website/css/edit_book.css b/Website/css/edit_book.css
deleted file mode 100644
index d3273a5..0000000
--- a/Website/css/edit_book.css
+++ /dev/null
@@ -1,85 +0,0 @@
-.add_book_class{
- margin: 20px;
- padding: 20px;
- background-color: #B6AD90; /* White background */
- border-radius: 10px;
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); /* Drop shadow */
-}
-
-.title {
- color:#532c0c;
- margin: 35px 0px;
- padding: 10px 0;
- font-family: "Shadow Into Light", cursive;
- font-size: 32px;
-
-}
-* {
- font-family: "Shadow Into Light", cursive;
-}
-
-.subtitle{
- color: #582F0E;
- font-size: 18px;
-}
-
-input[type="submit"] {
- background-color: #7F4F24; /* Brown color */
- color: #f2f4eb; /* White text */
- border: none;
- padding: 10px 20px;
- border-radius: 5px;
- cursor: pointer;
- font-size: 18px;
-}
-.form_group {
- display: flex;
- flex-direction: column;
- align-items: baseline;
- margin: 10px;
-}
-
-.form_style {
- width: 290px;
- padding: 15px 20px;
- margin: 8px;
- display: inline-block;
- color: black;
- border: 1px solid #bebebe;
- background-color: #f2f4eb;
- border-radius: 4px;
- box-sizing: border-box;
- font-size: 16px;
-}
-.form_style:focus {
- background-color: white;
- border: 3px solid #b9bea6;
- outline: 3px solid #582F0E;
-}
-
-
-
-body {
- background-color: #f6f1de;
-}
-
-textarea {
- width: 800px;
- height: 300px;
- padding: 15px 20px;
- margin: 8px;
- display: inline-block;
- color: black;
- border: 1px solid #bebebe;
- background-color: #f2f4eb;
- border-radius: 4px;
- box-sizing: border-box;
- font-size: 16px;
- resize: none;
-}
-
-textarea:focus {
- background-color: white;
- border: 3px solid #b9bea6;
- outline: 3px solid #582F0E;
-}
diff --git a/Website/css/edit_profile.css b/Website/css/edit_profile.css
deleted file mode 100644
index 62bfd8f..0000000
--- a/Website/css/edit_profile.css
+++ /dev/null
@@ -1,102 +0,0 @@
-body {
- background-color: #f6f1de;
-}
-* {
- font-family: "Shadow Into Light", cursive;
-}
-
-.container {
- width: 100%;
- max-width: 700px;
- padding: 20px;
- margin: 100px auto;
- box-sizing: border-box;
- background-color: #B6AD90;
- border-radius: 10px;
-}
-
-.container header {
- font-size: 25px;
- font-weight: 600;
- color: #582F0E;
-}
-
-.container form {
- position: relative;
- margin-top: 16px;
- min-height: 425px;
-}
-
-.container form .form .persoanlDetials {
- margin-top: 30px;
-}
-
-.container form .title {
- display: block;
- margin-bottom: 8px;
- font-size: 16px;
- font-weight: 500;
- margin: 6px 0;
-}
-
-.container form .fields {
- display: flex;
- align-items: center;
- justify-content: space-between;
- flex-wrap: wrap;
-}
-
-form .fields .inputField {
- display: flex;
- width: calc(100% / 1 - 15px);
- flex-direction: column;
- margin: 4px 0;
-}
-
-.inputField label {
- font-size: 18px;
- font-weight: 500;
- color: #7F4F24;
-}
-
-.inputField input {
- outline: none;
- font-weight: 400;
- font-size: 14px;
- border: 3px solid #b9bea6;
- background-color: #f2f4eb;
- border-radius: 5px;
- padding: 0 15px;
- height: 42px;
- margin: 8px 0;
-}
-
-.inputField input:hover {
- background-color: #fff;
- border: 3px solid #b9bea6;
- outline: 3px solid #582F0E;
-}
-
-.inputField input:is(:focus, :valid) {
- box-shadow: 0 3px 6px rgba(0, 0, 0, 0.13);
-}
-
-input[type=submit] {
- background-color: #582F0E;
- color: white;
- padding: 12px 111px;
- border-radius: 5px;
- cursor: pointer;
- float: right;
- margin-top: 21px;
-}
-
-input[type=reset] {
- background-color: #582F0E;
- color: white;
- padding: 12px 111px;
- border-radius: 5px;
- cursor: pointer;
- float: right;
- margin-top: 21px;
-}
diff --git a/Website/css/introtext.css b/Website/css/introtext.css
deleted file mode 100644
index 93f234d..0000000
--- a/Website/css/introtext.css
+++ /dev/null
@@ -1,25 +0,0 @@
-
-.intro_text{
- height: 100vh;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- margin: 25px;
- background-image: url("../pics/29660.jpg");
- border-radius: 50px;
- background-size: cover;
-}
-.header_text{
- display: flex;
- justify-content: center;
- color: white;
-}
-.para_text{
- display: flex;
- justify-content: center;
- color: rgb(255, 255, 255);
-}
-* {
- font-family: "Shadow Into Light", cursive;
-}
diff --git a/Website/css/nav_bar.css b/Website/css/nav_bar.css
deleted file mode 100644
index c937744..0000000
--- a/Website/css/nav_bar.css
+++ /dev/null
@@ -1,87 +0,0 @@
-.nav_bar_actions{
- display: flex;
- flex-direction: row;
- background-color: rgb(69, 39, 17);
- justify-content: space-between;
- border: 1px solid black;
-}
-
-.nav_bar_icon{
- height: 2.6em;
-}
-
-.nav_bar_button {
- text-align: center;
- padding: 0px;
- margin: 0px;
- --color: rgb(182, 173, 144);
- font-size: larger;
- display: inline-block;
- width: 8em;
- height: 2.6em;
- line-height: 2.5em;
- position: relative;
- overflow: hidden;
- border: 1px solid black;
- transition: color .25s;
- z-index: 1;
- border-radius: 6px;
- color: var(--color);
- }
-
- .nav_bar_button a{
- color: rgb(255, 255, 255);
- text-decoration: none;
- }
-
- .nav_bar_button:before {
- content: "";
- position: absolute;
- z-index: -1;
- background: var(--color);
- height: 150px;
- width: 200px;
- border-radius: 50%;
- }
-
- .nav_bar_button:hover {
- color: #000000;
- }
-
- .nav_bar_button:hover a{
- color: black;
- }
-
- .nav_bar_button:before {
- top: 100%;
- left: 100%;
- transition: all .7s;
- }
-
- .nav_bar_button:hover:before {
- top: -30px;
- left: -30px;
- }
-
- .nav_bar_button:active:before {
- background: rgb(101, 109, 74);
- transition: background 0s;
- }
-
- .center_buttons {
- display: flex;
- flex-direction: row;
-}
-
-.left_buttons{
- display: flex;
- margin-right: auto;
-}
-
-.right_buttons{
- display: flex;
- margin-left: auto;
-}
-* {
- font-family: "Shadow Into Light", cursive;
-}
diff --git a/Website/css/profile_styles.css b/Website/css/profile_styles.css
deleted file mode 100644
index ede61d1..0000000
--- a/Website/css/profile_styles.css
+++ /dev/null
@@ -1,142 +0,0 @@
-body {
- background-color: #f6f1de;
-}
-
-.profile-icon{
- width: 150px;
- height: 150px;
- border-radius: 50%;
- overflow: hidden;
- background-color: #f1edd5;
- margin: 25px 0px 15px 25px;
- border: 2px solid #C2C5AA;
- outline: 1px solid #5a3313;
-}
-
-
-.profile-icon img {
- width: 100%;
- height: auto;
-}
-
-
-#profile-h1 {
- width: 200px;
- background-color: #ebe3b7;
- border-radius: 50px;
- color: #5a3313;
- padding: 15px;
- text-align: center;
- font-size: 28px;
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
- margin: 25px auto 20px;
-}
-
-.profile-container {
- width: 100%;
- max-width: 1000px;
- border-radius: 5px;
- background-color: #B6AD90;
- padding: 30px;
- margin: 50px auto;
- display: flex;
- flex-direction: column;
- box-sizing: border-box;
-}
-
-
-* {
- font-family: "Shadow Into Light", cursive;
-}
-
-.profile-info {
- display: flex;
- align-items: center;
- margin-bottom: 20px;
-}
-
-#profile-h2 {
- color: #5a3313;
- margin: 40px 80px 10px 70px;
- border-bottom: 5px solid #d5cea7;
- border-radius: 4px;
- text-align: center;
-}
-
-.info-item {
- margin: 20px 20px 10px 80px;
- font-size: 18px;
- color: #502604;
- font-weight: bold;
-}
-
-
-.info-item {
- display: flex;
- align-items: center;
-}
-
-.info-label {
- margin-top: 10px;
- font-size: 18px;
- min-width: 120px;
-}
-
-.info-data {
- color: rgba(80, 38, 4, 0.6);
- margin-left: 100px;
-}
-
-#profile-h3 {
- color: #5a3313;
- width: 200px;
- margin: 20px 20px 20px 10px;
- border-bottom: 5px solid #d5cea7;
- border-radius: 4px;
- text-align: center;
-}
-
-li {
- margin: 10px;
- color: #432105;
- font-size: 18px;
-}
-
-.borrowed-books a {
- color: #5a3313;
- text-decoration: none;
- border: 3px solid #d5cea7;
- border-radius: 8px;
- background-color: #f1edd5;;
- font-weight: bold;
-}
-
-.borrowed-books a:hover {
- color: #422208;;
- text-decoration: underline;
- background-color: #f1edd5;
- font-weight: bold;
-}
-
-
-.edit-profile {
- margin-top: 60px;
-}
-
-.edit-profile a{
- color: #5a3313;
- text-decoration: none;
- border: 5px solid #d5cea7;
- font-size: 18px;
- border-radius: 8px;
- font-weight: bold;
- background-color: #f1edd5;;;
-}
-
-
-.edit-profile a:hover {
- color: #422208;;
- text-decoration: underline;
- background-color: #f1edd5;
- font-weight: bold;
-}
diff --git a/Website/css/search_bar.css b/Website/css/search_bar.css
deleted file mode 100644
index 190beaa..0000000
--- a/Website/css/search_bar.css
+++ /dev/null
@@ -1,54 +0,0 @@
-
-.search_input_container {
- position: relative;
-}
-
-/* Additional styling for the SVG if needed */
-.search_icon {
- display: flex;
- justify-content: center;
- cursor: pointer;
-}
-
-.search_bar {
- position: relative;
- margin: 15px;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .search_icon{
- display: flex;
- justify-content: center;
- }
-
- .input {
- width: 150px;
- padding: 10px 0px 10px 40px;
- border-radius: 9999px;
- border: solid 1px #333;
- transition: all .2s ease-in-out;
- outline: none;
- opacity: 0.8;
- }
-
- .search_bar svg {
- position: absolute;
- top: 50%;
- left: 10px;
- transform: translate(0, -50%);
- }
-
- .input:focus {
- opacity: 1;
- width: 250px;
- }
- .filter{
- border-radius: 999px;
- border-width: 0.25px ;
- text-align: center;
- }
- * {
- font-family: "Shadow Into Light", cursive;
-}
-
diff --git a/Website/index.html b/Website/index.html
deleted file mode 100644
index 00a1713..0000000
--- a/Website/index.html
+++ /dev/null
@@ -1,90 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- EgyBooks
-
-
-
-
-
-
-
-
-
-

-
-
-
-
-
-
-
-
-
-
-
-
- EgyBooks is an online library website that helps people search for books
- and borrow them
-
-
-
-
-
-
-
-
diff --git a/Website/javascript/BookPage.js b/Website/javascript/BookPage.js
deleted file mode 100644
index b32a004..0000000
--- a/Website/javascript/BookPage.js
+++ /dev/null
@@ -1,100 +0,0 @@
-var accountType = JSON.parse(localStorage.getItem('userInfo')).account_type;
-var loggedIn = JSON.parse(localStorage.getItem('loggedIn'));
-
-function getUrlParameter(name) {
- const params = new URLSearchParams(window.location.search);
- console.log(params.get(name));
- return params.get(name);
-}
-
-document.addEventListener("DOMContentLoaded", function(){
- var container = document.getElementById("Book");
- var storedBooks = localStorage.getItem('libraryBooks');
- var id = getUrlParameter('id');
- document.getElementById("Btns").innerHTML = btns(id);
- if(accountType == "User" || !loggedIn){
- document.getElementById("del").style.display= "none";
- document.getElementById("edit").style.display= "none";
- }
- if(!loggedIn){
- document.getElementById("borrow").style.display = "none";
- }
- var books= [];
- if (storedBooks) {
- books = JSON.parse(storedBooks);
- }
- books.forEach(function (book) {
- if(book.bookID == id){
- container.innerHTML += bookdefinition(book);
- document.getElementById("del").addEventListener("click", function(){
- book.numberofcopies = 0;
- localStorage.setItem('libraryBooks', JSON.stringify(books));
- window.location.href = "ViewBooks.html";
- });
- }
- });
- localStorage.setItem('libraryBooks', JSON.stringify(books));
-
- // Add event listener for the borrow button
- document.getElementById("borrow").addEventListener("click", function(){
- var book = books.find(book => book.bookID == id);
- redirectToBorrowPage(id, book);
- });
-});
-
-function btns(id){
- return `
-
-
-
-
-
-
-
-
- `;
-}
-
-function btnsWithBook(id, book) {
- return `
-
-
-
-
-
-
-
-
- `;
-}
-
-function redirectToBorrowPage(id, book) {
- localStorage.setItem('borrowBookInfo', JSON.stringify({ id: id, book: book }));
- window.location.href = `BorrowBook.html?id=${id}&title=${encodeURIComponent(book.title)}&author=${encodeURIComponent(book.author)}`;
-}
-
-
-function bookdefinition(book){
- return `
-
-

-
-
-
${book.title}
-
Category : ${book.category}
-
Author : ${book.author}
-
Number of Copies : ${book.numberofcopies}
-
Number of Pages : ${book.pages}
-
Price : ${book.price}
-
${book.description}
-
- `;
-}
diff --git a/Website/javascript/Login.js b/Website/javascript/Login.js
deleted file mode 100644
index fbe8c93..0000000
--- a/Website/javascript/Login.js
+++ /dev/null
@@ -1,34 +0,0 @@
-localStorage.setItem("loggedIn",JSON.stringify(false));
-
-function validateForm(){
- var userInfoString = localStorage.getItem("userInfo");
- var userInfo = JSON.parse(userInfoString);
- var userName = document.getElementById("login_username").value;
- var password = document.getElementById("login_password").value;
-
- console.log(userInfo.userName);
- console.log(userInfo.password);
- console.log(userName);
- console.log(password);
-
- if(userInfo.username === userName && userInfo.password === password){
- alert("Logged in!");
- localStorage.setItem("loggedIn", JSON.stringify(true));
- return true;
- }
-
- alert("User doesn't exist");
- return false;
-}
-
-
-document.addEventListener("DOMContentLoaded",function(){
- var form = document.querySelector("form");
-
- form.addEventListener("submit", function(event){
- event.preventDefault();
- if(validateForm()){
- window.location.href = "index.html";
- }
- })
-})
\ No newline at end of file
diff --git a/Website/javascript/SignUp.js b/Website/javascript/SignUp.js
deleted file mode 100644
index bd2e9a5..0000000
--- a/Website/javascript/SignUp.js
+++ /dev/null
@@ -1,109 +0,0 @@
-localStorage.setItem("loggedIn",JSON.stringify(false));
-
-function validateForm(){
-
- try{
- var userName = document.getElementById("user_name_text").value;
- var password = document.getElementById("password_text").value;
- var confirmPassword = document.getElementById("confirm_password_text").value;
- var email = document.getElementById("email_text").value;
-
- var accountTypeDiv = document.getElementById("radio_button").querySelectorAll('input[type="radio"]');
- var account_type = "";
-
- console.log(accountTypeDiv);
-
- accountTypeDiv.forEach(function(radioButton) {
- console.log(radioButton);
- if (radioButton.checked) {
- account_type = radioButton.value;
- }
- });
-
- }
- catch(error){
- console.log(error)
- return false;
- }
-
- console.log("here");
- if(confirmPassword != password){
- alert("Password Doesn't match!")
- return false;
- }
-
- var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
- if (!emailRegex.test(email)) {
- alert("Invalid email format!");
- return false;
- }
-
- if(password.length < 8){
- alert("The password must be longer than 8 characters!")
- return false;
- }
-
-
- if(password.length >= 30){
- alert("The password must be smaller than 30 characters!")
- return false;
- }
-
-
- if(userName.length >= 20){
- alert("The username must be smaller than 20 characters!")
- return false;
- }
-
- var usernameRegex = /^[a-zA-Z][\w\d]*$/;
- if(!usernameRegex.test(userName)){
- alert("User name can't contain numbers in the start and can't contain special characters!")
- return false;
- }
-
- if(localStorage.getItem("userInfo") != null && email == JSON.parse(localStorage.getItem("userInfo")).email){
- alert("Email already exists!");
- return false;
- }
-
- if(localStorage.getItem("userInfo") != null && userName == JSON.parse(localStorage.getItem("userInfo")).username){
- alert("User name already exists!");
- return false;
- }
-
- var userInfo = {
- username: userName,
- password: password,
- email: email,
- account_type: account_type
- };
-
- localStorage.setItem("userInfo", JSON.stringify(userInfo));
-
- return true;
-}
-
-document.addEventListener("DOMContentLoaded", function(){
- console.log("hereDom");
-
- var form = document.querySelector("form");
-
- form.addEventListener("submit", function(event){
- event.preventDefault();
-
- if(validateForm()){
- var userInfoString = localStorage.getItem("userInfo");
- var userInfo = JSON.parse(userInfoString);
- var username = userInfo.username;
- var password = userInfo.password;
- var email = userInfo.email;
- var accountType = userInfo.account_type;
- console.log("Username:", username);
- console.log("Password:", password);
- console.log("Email:", email);
- console.log("Account Type:", accountType);
-
- window.location.href = "Login.html";
- }
- })
-});
\ No newline at end of file
diff --git a/Website/javascript/addbook.js b/Website/javascript/addbook.js
deleted file mode 100644
index bf2e456..0000000
--- a/Website/javascript/addbook.js
+++ /dev/null
@@ -1,99 +0,0 @@
-
-let libraryBooks = [];
-
-document.addEventListener("DOMContentLoaded", function(){
-
-
- var storedBooks = localStorage.getItem('libraryBooks');
- if (storedBooks) {
- libraryBooks = JSON.parse(storedBooks);
- }
- else {
- libraryBooks = [];
- }
- console.log(libraryBooks);
-
- var form = document.querySelector("form");
-
- form.addEventListener('submit', function(event) {
- event.preventDefault();
-
- var fileInput = document.getElementById('image');
- var imageFile = fileInput.files[0];
-
- var reader = new FileReader();
- reader.onload = function(event) {
- var imageDataUrl = event.target.result;
-
- var title = document.getElementById('nameofthebook').value;
- var bookID = document.getElementById('bookID').value;
- var author = document.getElementById('author').value;
- var category = document.getElementById('category').value;
- var pages = document.getElementById('numberofpages').value;
- var description = document.getElementById('description').value;
- var price = document.getElementById('price').value;
- var numberofcopies = document.getElementById('numberofcopies').value;
-
-
- var titleRegex = /^[a-zA-Z][\w\d]*$/;
- if(!titleRegex.test(title)){
- alert("Title can't contain numbers in the start and can't contain special characters!");
- return false;
- }
-
- if(!titleRegex.test(author)){
- alert("author can't contain numbers in the start and can't contain special characters!");
- return false;
- }
-
- var categoryRegex = /^[a-zA-Z][a-zA-Z]*$/
- if(!categoryRegex.test(category)){
- alert("Category can't contain numbers in the start and can't contain special characters!");
- return false;
- }
-
- var idRegex = /^[0-9]+$/;
- if(!idRegex.test(bookID)){
- alert("ID must be numbers only");
- return false;
- }
-
- const bookData = {
- image: imageDataUrl,
- title: title,
- bookID: bookID,
- author: author,
- category:category,
- pages: pages,
- description: description,
- price: price,
- numberofcopies:numberofcopies
- };
-
- saveBookData(bookData);
- };
-
- reader.readAsDataURL(imageFile);
-
-
- });
-})
-
-
-function saveBookData(bookData) {
- var isexist=false;
- libraryBooks.forEach(function (book) {
- if(book.bookID==bookData.bookID){
- book.numberofcopies +=bookData.numberofcopies;
- console.log(book.numberofcopies);
- isexist=true;
- }
- });
- if(!isexist)
- libraryBooks.push(bookData);
- localStorage.setItem('libraryBooks', JSON.stringify(libraryBooks));
-
- alert('Book added successfully!');
- window.location.href = "ViewBooks.html";
-}
-
diff --git a/Website/javascript/borrowBook.js b/Website/javascript/borrowBook.js
deleted file mode 100644
index 16f8c79..0000000
--- a/Website/javascript/borrowBook.js
+++ /dev/null
@@ -1,159 +0,0 @@
-const libraryBooks = JSON.parse(localStorage.getItem('libraryBooks')) || [];
-
-document.addEventListener("DOMContentLoaded", function(){
- const params = new URLSearchParams(window.location.search);
- const id = params.get('id');
- const title = params.get('title');
- const author = params.get('author');
-
- document.getElementById("bk_id").value = id;
- document.getElementById("book_author").value = decodeURIComponent(author);
- document.getElementById("quan").value = 1;
- document.getElementById("bk_tit").value = decodeURIComponent(title);
-
- document.querySelector('.btn').addEventListener('click', function(event) {
- event.preventDefault();
- checkAvailability(libraryBooks);
- });
-
- document.querySelector('form').addEventListener('submit', function(event) {
- event.preventDefault();
- if (validateForm(libraryBooks)) {
- const formData = getFormData();
- const queryString = new URLSearchParams(formData).toString();
- const destinationPage = 'profile.html';
- window.location.href = `${destinationPage}?${queryString}`;
- }
- });
-});
-
-function checkAvailability(libraryBooks) {
- try {
- var bookID = document.getElementById("bk_id").value;
- var bookAuthor = document.getElementById("book_author").value;
- var quantity = parseInt(document.getElementById("quan").value);
- var bookTitle = document.getElementById("bk_tit").value;
-
- if (!libraryBooks.length) {
- alert('Library data not found in local storage !');
- return;
- }
- var flag = false;
-
- for (var bookData in libraryBooks) {
- if (libraryBooks[bookData].bookID == bookID &&
- libraryBooks[bookData].author == bookAuthor &&
- libraryBooks[bookData].numberofcopies >= quantity &&
- libraryBooks[bookData].title == bookTitle) {
- alert("Needed quantity of book exists.");
- flag = true;
- break;
- }
- }
-
- if (!flag) {
- alert("Needed quantity of book doesn't available, try lesser quantity");
- }
-
- } catch(error) {
- console.error(error);
- }
-}
-
-function validateForm(libraryBooks) {
- try {
- var bookID = document.getElementById("bk_id").value;
- var bookAuthor = document.getElementById("book_author").value;
- var quantity = parseInt(document.getElementById("quan").value);
- var bookTitle = document.getElementById("bk_tit").value;
-
- var firstName = document.getElementById("f_name").value;
- var middleName = document.getElementById("m_name").value;
- var lastName = document.getElementById("l_name").value;
- var mail = document.getElementById("mail").value;
- var phoneNumber = document.getElementById("ph_no").value;
- var deliveryAddress = document.getElementById("add").value;
- var deliveryDate = document.getElementById("delivered_date").value;
-
- if (!bookID || !bookAuthor || !quantity || !bookTitle) {
- alert("Please fill in all book details.");
- return false;
- }
-
- for (var bookData in libraryBooks) {
- if (libraryBooks[bookData].bookID == bookID &&
- libraryBooks[bookData].author == bookAuthor &&
- libraryBooks[bookData].numberofcopies >= quantity &&
- libraryBooks[bookData].title == bookTitle) {
- libraryBooks[bookData].numberofcopies -= quantity;
- break;
- }
- }
-
- localStorage.setItem("libraryBooks",JSON.stringify(libraryBooks));
-
- var nameExpression = /^[a-zA-Z]{3,10}$/;
- if(!nameExpression.test(firstName) || !nameExpression.test(middleName) || !nameExpression.test(lastName)){
- alert("Name must be between 3 to 10 characters long and can only contain letters.");
- return false;
- }
-
- var phoneNubmerExpression = /^\d{11}$/; // Corrected regular expression
- if(phoneNumber.length !== 11 || !phoneNubmerExpression.test(phoneNumber)){
- alert("Phone number must be exactly 11 digits long.");
- return false;
- }
-
- if(deliveryAddress.length < 4){
- alert("Delivery address must be at least 4 characters long.");
- return false;
- }
-
- const formData = {
- bookID,
- bookAuthor,
- quantity,
- bookTitle,
- firstName,
- middleName,
- lastName,
- mail,
- phoneNumber,
- deliveryAddress,
- deliveryDate
- };
-
- localStorage.setItem("FormData", JSON.stringify(formData));
-
- if (!localStorage.getItem("BorrowedBooks")) {
- localStorage.setItem("BorrowedBooks", JSON.stringify([]));
- }
-
- var borrowedBooksString = localStorage.getItem("BorrowedBooks");
- var borrowedBooks = borrowedBooksString ? JSON.parse(borrowedBooksString) : [];
- borrowedBooks.push({ bookID: bookID, bookTitle: bookTitle, quantity: formData.quantity });
- localStorage.setItem("BorrowedBooks", JSON.stringify(borrowedBooks));
-
- return true;
-
- } catch(error) {
- console.error(error);
- return false;
- }
-}
-
-function getFormData() {
- return {
- bookID: document.getElementById("bk_id").value,
- bookAuthor: document.getElementById("book_author").value,
- quantity: parseInt(document.getElementById("quan").value),
- bookTitle: document.getElementById("bk_tit").value,
- firstName: document.getElementById("f_name").value,
- middleName: document.getElementById("m_name").value,
- lastName: document.getElementById("l_name").value,
- mail: document.getElementById("mail").value,
- phoneNumber: document.getElementById("ph_no").value,
- deliveryAddress: document.getElementById("add").value,
- deliveryDate: document.getElementById("delivered_date").value
- };
-}
diff --git a/Website/javascript/editbook.js b/Website/javascript/editbook.js
deleted file mode 100644
index ec8cad2..0000000
--- a/Website/javascript/editbook.js
+++ /dev/null
@@ -1,173 +0,0 @@
-function getUrlParameter(name) {
- name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
- var regex = new RegExp('[\\?&]' + name + '=([^]*)');
- var results = regex.exec(location.search);
- return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
-}
-
-document.addEventListener("DOMContentLoaded", function(){
- var container = document.getElementById("editBookForm");
- var storedBooks = localStorage.getItem('libraryBooks');
- var id = getUrlParameter('id');
- var books= [];
- if (storedBooks) {
- books = JSON.parse(storedBooks);
- }
- console.log(books);
- books.forEach(function (book) {
- if(book.bookID==id){
- container.innerHTML += generateBookFormHTML(book);
- }
- });
-})
-
-function generateBookFormHTML(book){
- return `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- `
-}
-
-document.addEventListener("DOMContentLoaded", function(){
-
-
- var storedBooks = localStorage.getItem('libraryBooks');
- if (storedBooks) {
- libraryBooks = JSON.parse(storedBooks);
- }
- else {
- libraryBooks = [];
- }
- console.log(libraryBooks);
-
- var form = document.querySelector("form");
-
- form.addEventListener('submit', function(event) {
- event.preventDefault();
-
- var fileInput = document.getElementById('image');
- var imageFile = fileInput.files[0];
-
- var reader = new FileReader();
- reader.onload = function(event) {
- var imageDataUrl = event.target.result;
-
- var title = document.getElementById('nameofthebook').value;
- var bookID = document.getElementById('bookID').value;
- var author = document.getElementById('author').value;
- var category = document.getElementById('category').value;
- var pages = document.getElementById('numberofpages').value;
- var description = document.getElementById('description').value;
- var price = document.getElementById('price').value;
- var numberofcopies = document.getElementById('numberofcopies').value;
-
- var titleRegex = /^[a-zA-Z][\w\d]*$/;
- if(!titleRegex.test(title)){
- alert("Title can't contain numbers in the start and can't contain special characters!");
- return false;
- }
-
- if(!titleRegex.test(author)){
- alert("author can't contain numbers in the start and can't contain special characters!");
- return false;
- }
-
- var categoryRegex = /^[a-zA-Z][a-zA-Z]*$/
- if(!categoryRegex.test(category)){
- alert("Category can't contain numbers in the start and can't contain special characters!");
- return false;
- }
-
- var idRegex = /^[0-9]+$/;
- if(!idRegex.test(bookID)){
- alert("ID must be numbers only");
- return false;
- }
-
- const bookData = {
- image: imageDataUrl,
- title: title,
- bookID: bookID,
- author: author,
- category:category,
- pages: pages,
- description: description,
- price: price,
- numberofcopies:numberofcopies
- };
-
- saveBookData(bookData);
- };
-
- reader.readAsDataURL(imageFile);
-
- });
-})
-
-function saveBookData(bookData) {
- var storedBooks = localStorage.getItem('libraryBooks');
- if (storedBooks) {
- libraryBooks = JSON.parse(storedBooks);
- }
- else {
- libraryBooks = [];
- }
-
- console.log(libraryBooks);
- libraryBooks.forEach(function (book) {
- if(book.bookID==bookData.bookID){
- book.category=bookData.category;
- book.pages=bookData.pages;
- book.description=bookData.description;
- book.price=bookData.price;
- book.numberofcopies=bookData.numberofcopies;
- }
- });
- localStorage.setItem('libraryBooks', JSON.stringify(libraryBooks));
-
- alert('Book editted successfully!');
- window.location.href = "ViewBooks.html";
-}
\ No newline at end of file
diff --git a/Website/javascript/editprofile.js b/Website/javascript/editprofile.js
deleted file mode 100644
index dcd2710..0000000
--- a/Website/javascript/editprofile.js
+++ /dev/null
@@ -1,86 +0,0 @@
-var userInfoString = localStorage.getItem("userInfo");
-
-function validateForm(){
-
- try{
- var newUserName = document.getElementById("username").value;
- var newPassword = document.getElementById("password").value;
- var newConfirmPassword = document.getElementById("confirm_password").value;
- var newEmail = document.getElementById("email").value;
- }
- catch(error){
- console.log(error)
- return false;
- }
-
- console.log("here");
- if(newConfirmPassword != newPassword){
- alert("Password Doesn't match!")
- return false;
- }
-
- var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
- if (!emailRegex.test(newEmail)) {
- alert("Invalid email format!");
- return false;
- }
-
- if(newPassword.length < 8){
- alert("The password must be longer than 8 characters!")
- return false;
- }
-
-
- if(newPassword.length >= 30){
- alert("The password must be smaller than 30 characters!")
- return false;
- }
-
-
- if(newUserName.length >= 20){
- alert("The username must be smaller than 20 characters!")
- return false;
- }
-
- var usernameRegex = /^[a-zA-Z][\w\d]*$/;
- if(!usernameRegex.test(newUserName)){
- alert("User name can't contain numbers in the start and can't contain special characters!")
- return false;
- }
-
- var userInfo = {
- username: newUserName,
- password: newPassword,
- email: newEmail,
- account_type: JSON.parse(userInfoString).account_type
- };
-
- localStorage.setItem("userInfo", JSON.stringify(userInfo));
-
- return true;
-}
-
-document.addEventListener("DOMContentLoaded", function(){
- console.log("hereDom");
-
- var form = document.querySelector("form");
-
- form.addEventListener("submit", function(event){
- event.preventDefault();
-
- if(validateForm()){
- var userInfoString = localStorage.getItem("userInfo");
- var userInfo = JSON.parse(userInfoString);
- var username = userInfo.newUserName;
- var password = userInfo.newPassword;
- var email = userInfo.newEmail;
- var accountType = userInfo.account_type;
- console.log("Username:", username);
- console.log("Password:", password);
- console.log("Email:", email);
- console.log("Account Type:", accountType);
- window.location.href = "Profile.html";
- alert("Profile Data Updated!");
- }
- })
-});
diff --git a/Website/javascript/navBar.js b/Website/javascript/navBar.js
deleted file mode 100644
index a3ba24c..0000000
--- a/Website/javascript/navBar.js
+++ /dev/null
@@ -1,70 +0,0 @@
-document.addEventListener("DOMContentLoaded",function(){
- var loggedin = JSON.parse(localStorage.getItem("loggedIn"));
- var navigationBarLeftButtons = document.getElementsByClassName("left_buttons")[0];
- if(loggedin === false){
- var profileButton = document.getElementById("profile_button");
- var borrowBookButton = document.getElementById("borrow_book_button");
- borrowBookButton.remove();
- profileButton.remove();
-
- }
-
- try {
- var accountType = JSON.parse(localStorage.getItem("userInfo")).account_type;
- }
- catch {
-
- };
-
- if(loggedin === true){
- var loginButton = document.getElementById("login_button");
- var signupButton = document.getElementById("signup_button");
-
- loginButton.remove();
- signupButton.remove();
-
- var ulElement = document.createElement('ul');
- ulElement.id = 'signout_button';
- ulElement.className = 'nav_bar_button';
-
- var aElement = document.createElement('a');
- aElement.href = 'Signup.html';
- aElement.textContent = 'Sign Out';
-
- ulElement.appendChild(aElement);
- navigationBarLeftButtons.appendChild(ulElement);
- }
-
- if(accountType == "User" || !loggedin){
- var addBooksButton = document.getElementById("add_book_button");
- addBooksButton.remove();
- }
-})
-
-var searchInput;
-var filterSelect;
-//Search bar code
-document.addEventListener("DOMContentLoaded", function(){
- const searchForm = document.querySelector('.search_bar form');
-
- searchForm.addEventListener('submit', function(event) {
- event.preventDefault();
-
- searchInput = document.querySelector('.search_input_container input[type="text"]');
- filterSelect = document.querySelector('.search_input_container select[name="filter"]');
-
- var extractedSearchAndFilter = extractSearchTextAndFilter();
- const url = `Search.html?search=${encodeURIComponent(extractedSearchAndFilter.searchText)}&filter=${encodeURIComponent(extractedSearchAndFilter.selectedFilter)}`;
-
- window.location.href = url;
- });
-
-});
-
-function extractSearchTextAndFilter() {
- var searchText = searchInput.value.trim();
- var selectedFilter = filterSelect.value;
- return { searchText: searchText, selectedFilter: selectedFilter };
-}
-
-// Action bar Code
diff --git a/Website/javascript/profile.js b/Website/javascript/profile.js
deleted file mode 100644
index 10d3d97..0000000
--- a/Website/javascript/profile.js
+++ /dev/null
@@ -1,33 +0,0 @@
-document.addEventListener("DOMContentLoaded", function() {
- var userInfoString = localStorage.getItem("userInfo");
- var userInfo = JSON.parse(userInfoString);
-
- var username = userInfo.username;
- var email = userInfo.email;
- var password = userInfo.password;
- var accountType = userInfo.account_type;
-
- var usernameElement = document.getElementById("profile-username");
- var emailElement = document.getElementById("profile-email");
- var passwordElement = document.getElementById("profile-password");
- var accountTypeElement = document.getElementById("profile-account-type");
-
- usernameElement.textContent = username;
- emailElement.textContent = email;
- passwordElement.textContent = password;
- accountTypeElement.textContent = accountType;
-
- if (!localStorage.getItem("BorrowedBooks")) {
- localStorage.setItem("BorrowedBooks", JSON.stringify([]));
- }
-
- var borrowedBooksString = localStorage.getItem("BorrowedBooks");
- var borrowedBooks = JSON.parse(borrowedBooksString);
- var borrowedBooksList = document.getElementById("borrowed-books-list");
-
- borrowedBooks.forEach(function(book) {
- var listItem = document.createElement("li");
- listItem.textContent = `Book Title: ${book.bookTitle} - Book ID: ${book.bookID} - Quantity: ${book.quantity}`;
- borrowedBooksList.appendChild(listItem);
- });
-});
diff --git a/Website/javascript/search.js b/Website/javascript/search.js
deleted file mode 100644
index 55981e6..0000000
--- a/Website/javascript/search.js
+++ /dev/null
@@ -1,68 +0,0 @@
-var searchValue;
-var filterValue;
-
-document.addEventListener("DOMContentLoaded", function() {
- const params = new URLSearchParams(window.location.search);
-
- searchValue = params.get('search');
-
- filterValue = params.get('filter');
-
- var books = getBooksData();
- var container = document.getElementById("all_books");
-
- var isrender=false;
-
- books.forEach(function (book) {
- if(book.numberofcopies>0) {
- if('title' == filterValue && book.title.toLowerCase().includes(searchValue.toLowerCase())){
- container.innerHTML+= generateBookHTML(book);
- isrender=true;
- }
- else if('author' == filterValue && book.author.toLowerCase().includes(searchValue.toLowerCase())){
- container.innerHTML+= generateBookHTML(book);
- isrender=true;
-
- }
- else if('category' == filterValue && book.category.toLowerCase().includes(searchValue.toLowerCase())){
- container.innerHTML+= generateBookHTML(book);
- isrender=true;
-
- }
- }
- });
-
- if(!isrender){
- container.innerHTML+=
- `
- there is no books
- `
- }
-
-});
-
-function getBooksData(){
- var booksData = localStorage.getItem('libraryBooks');
- if (booksData) {
- return JSON.parse(booksData);
- } else {
- console.log('Error');
- return [];
- }
-}
-
-function generateBookHTML(book) {
- return `
-
- `;
-}
\ No newline at end of file
diff --git a/Website/javascript/viewbooks.js b/Website/javascript/viewbooks.js
deleted file mode 100644
index 23b80a2..0000000
--- a/Website/javascript/viewbooks.js
+++ /dev/null
@@ -1,51 +0,0 @@
-
-document.addEventListener("DOMContentLoaded", function(){
- var books = getBooksData();
- console.log(books);
- var container = document.getElementById("all_books");
- console.log(container);
-
- var isrender=false;
-
- books.forEach(function (book) {
- console.log(book);
- if(book.numberofcopies>0){
- container.innerHTML+= generateBookHTML(book);
- isrender=true;
- }
- });
-
- if(!isrender){
- container.innerHTML+=
- `
- there is no books
- `
- }
-})
-
-function generateBookHTML(book) {
- return `
-
- `;
-}
-
-function getBooksData(){
- var booksData = localStorage.getItem('libraryBooks');
- if (booksData) {
- return JSON.parse(booksData);
- } else {
- console.log('Error');
- return [];
- }
-}
-
diff --git a/Website/pics/EditProfilePic.png b/Website/pics/EditProfilePic.png
deleted file mode 100644
index b81d87a..0000000
Binary files a/Website/pics/EditProfilePic.png and /dev/null differ
diff --git a/Website/pics/bookPage.jpg b/Website/pics/bookPage.jpg
deleted file mode 100644
index 34be1d9..0000000
Binary files a/Website/pics/bookPage.jpg and /dev/null differ
diff --git a/Website/pics/clean code image.jpg b/Website/pics/clean code image.jpg
deleted file mode 100644
index eea0934..0000000
Binary files a/Website/pics/clean code image.jpg and /dev/null differ
diff --git a/Website/pics/library_background.jpg b/Website/pics/library_background.jpg
deleted file mode 100644
index 6da6f22..0000000
Binary files a/Website/pics/library_background.jpg and /dev/null differ
diff --git a/Website/pics/premium_photo-1674727219372-4ba6644106bc.avif b/Website/pics/premium_photo-1674727219372-4ba6644106bc.avif
deleted file mode 100644
index 3317619..0000000
Binary files a/Website/pics/premium_photo-1674727219372-4ba6644106bc.avif and /dev/null differ