From 82d01c81a9aec2f403aeaea89bdacfca989eee9f Mon Sep 17 00:00:00 2001 From: arielfayol37 Date: Thu, 23 Nov 2023 12:30:17 -0600 Subject: [PATCH] added loading page beforeUnload() --- README.md | 12 ------------ astros/templates/astros/layout.html | 8 +++++++- deimos/templates/deimos/layout.html | 8 +++++++- phobos/static/phobos/js/create_question.js | 7 +++++++ phobos/templates/phobos/layout.html | 9 ++++++++- 5 files changed, 29 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 2fafd774..cff6ef77 100644 --- a/README.md +++ b/README.md @@ -3,18 +3,6 @@ Web platform for Physics Assigments System. This is the README file for the Dr_R web application built using Django. The application is designed to provide different functionalities for students (Deimos), instructors (Phobos), and general users (Astros). -### Distinctiveness and Complexity -"It’s different from the other projects and it was complex to build." Haha - -Jokes aside, it is a *physics* learning management system which differs a lot from other projects because of functionalities like comparing algebraic expressions and units; dynamic question creation page which acts as a GUI compiler that has to test various user input and take care of different formats like floats, multiple choice questions, latex equation, variables etc; -a semantic search engine; etc etc - -### Files -One of the submission requirements was to explain what is in every file I created but this project is relatively huge compared to previous projects, so I created a separate md file for essential documentation. Filename: documentation.md - -## PreRequisites -Having Python installed on your machine and your PATH environment variable having a path to your Python's Scripts folder. - ## Installation 1. Clone the repository: diff --git a/astros/templates/astros/layout.html b/astros/templates/astros/layout.html index 87987bdc..9cbc2167 100644 --- a/astros/templates/astros/layout.html +++ b/astros/templates/astros/layout.html @@ -72,6 +72,12 @@ var loader = document.querySelector('#preloader'); window.addEventListener('load', ()=>{ loader.classList.add('hide'); - }) + }); + document.querySelectorAll('a').forEach(function(link) { + link.addEventListener('click', function(e) { + // Your logic here + loader.classList.remove('hide'); + }); + }); \ No newline at end of file diff --git a/deimos/templates/deimos/layout.html b/deimos/templates/deimos/layout.html index beb77124..be0b550b 100644 --- a/deimos/templates/deimos/layout.html +++ b/deimos/templates/deimos/layout.html @@ -61,6 +61,12 @@ var loader = document.querySelector('#preloader'); window.addEventListener('load', ()=>{ loader.classList.add('hide'); - }) + }); + document.querySelectorAll('a').forEach(function(link) { + link.addEventListener('click', function(e) { + // Your logic here + loader.classList.remove('hide'); + }); + }); \ No newline at end of file diff --git a/phobos/static/phobos/js/create_question.js b/phobos/static/phobos/js/create_question.js index 1121febd..97b18807 100644 --- a/phobos/static/phobos/js/create_question.js +++ b/phobos/static/phobos/js/create_question.js @@ -1,6 +1,13 @@ document.addEventListener('DOMContentLoaded', () => { const preloader = document.querySelector('#preloader'); + + window.addEventListener('beforeunload', function (event) { + // Your logic here + preloader.classList.remove('hide'); + event.returnValue = true; // Chrome requires returnValue to be set + }); + const form = document.querySelector('#question-form'); const allQuestionBlocks = form.querySelector("#all-question-blocks"); let currentAction = form.getAttribute('action'); diff --git a/phobos/templates/phobos/layout.html b/phobos/templates/phobos/layout.html index a9f7abd0..9674597c 100644 --- a/phobos/templates/phobos/layout.html +++ b/phobos/templates/phobos/layout.html @@ -66,6 +66,13 @@ var loader = document.querySelector('#preloader'); window.addEventListener('load', ()=>{ loader.classList.add('hide'); - }) + }); + document.querySelectorAll('a').forEach(function(link) { + link.addEventListener('click', function(e) { + // Your logic here + loader.classList.remove('hide'); + }); + }); + \ No newline at end of file