Tried to add the contact form --> js is not working atm
This commit is contained in:
		
							parent
							
								
									f536885785
								
							
						
					
					
						commit
						01fadc2ccf
					
				
					 5 changed files with 143 additions and 15 deletions
				
			
		
							
								
								
									
										26
									
								
								py/static/contact.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								py/static/contact.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,26 @@ | ||||||
|  | 
 | ||||||
|  | document.addEventListener('DOMContentLoaded', function() { | ||||||
|  |   const contactForm = document.getElementById('contactForm'); | ||||||
|  | 
 | ||||||
|  |   if (contactForm) { | ||||||
|  |     contactForm.addEventListener('submit', function(event) { | ||||||
|  |       event.preventDefault(); // Prevent the form from submitting the traditional way
 | ||||||
|  | 
 | ||||||
|  |       // Generate a random ticket number
 | ||||||
|  |       const ticketNumber = Math.floor(Math.random() * 1000000); // Generates a random number between 0 and 999999
 | ||||||
|  | 
 | ||||||
|  |       // Retrieve form values
 | ||||||
|  |       const name = encodeURIComponent(document.getElementById('name').value); | ||||||
|  |       const email = encodeURIComponent(document.getElementById('email').value); | ||||||
|  |       const message = encodeURIComponent(document.getElementById('message').value); | ||||||
|  | 
 | ||||||
|  |       // Construct the mailto link
 | ||||||
|  |       const subject = `Support Ticket #${ticketNumber}`; | ||||||
|  |       const body = `Name: ${name}%0AEmail: ${email}%0AMessage:%0A${message}`; | ||||||
|  |       const mailtoLink = `mailto:example@example.com?subject=${subject}&body=${body}`; | ||||||
|  | 
 | ||||||
|  |       // Open the default mail client
 | ||||||
|  |       window.location.href = mailtoLink; | ||||||
|  |     }); | ||||||
|  |   } | ||||||
|  | }); | ||||||
|  | @ -250,3 +250,44 @@ header a:hover { | ||||||
| .input button:hover { | .input button:hover { | ||||||
|     background-color: var(--input-button-hover-color); |     background-color: var(--input-button-hover-color); | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | /* Form styling */ | ||||||
|  | form { | ||||||
|  |     max-width: 600px; | ||||||
|  |     margin: 0 auto; | ||||||
|  |     background: var(--input-background-color); /* Use the input background color variable */ | ||||||
|  |     padding: 20px; | ||||||
|  |     border-radius: 2em; /* Match the border radius used in other sections */ | ||||||
|  |     box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); /* Subtle shadow for depth */ | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | form label { | ||||||
|  |     color: var(--text-color); /* Use the text color variable */ | ||||||
|  |     display: block; /* Ensure labels are block elements */ | ||||||
|  |     margin-bottom: 5px; /* Add some space below labels */ | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | form input, | ||||||
|  | form textarea { | ||||||
|  |     color: var(--text-color); /* Use the text color variable */ | ||||||
|  |     background-color: var(--history-background-color); /* Use a contrasting background */ | ||||||
|  |     border: 1px solid var(--input-button-color); /* Use the input button color for borders */ | ||||||
|  |     border-radius: 4px; | ||||||
|  |     width: 100%; | ||||||
|  |     padding: 10px; | ||||||
|  |     margin-bottom: 15px; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | form button { | ||||||
|  |     background-color: var(--input-button-color); /* Use the input button color */ | ||||||
|  |     color: var(--background-color); /* Use the background color for text */ | ||||||
|  |     border: none; | ||||||
|  |     padding: 10px 20px; | ||||||
|  |     border-radius: 4px; | ||||||
|  |     cursor: pointer; | ||||||
|  |     transition: background-color 0.3s; /* Smooth transition for hover effect */ | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | form button:hover { | ||||||
|  |     background-color: var(--input-button-hover-color); /* Use the hover color variable */ | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -1,13 +1,44 @@ | ||||||
| <!DOCTYPE html> |     <!DOCTYPE html> | ||||||
| <html lang="en"> |     <html lang="en"> | ||||||
| 
 | 
 | ||||||
| <head> |     <head> | ||||||
|     <meta charset="UTF-8"> |         <meta charset="UTF-8"> | ||||||
|     <meta name="viewport" content="width=device-width, initial-scale=1.0"> |         <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||||||
|     <link rel="stylesheet" href="/static/styles.css"> |         <link rel="stylesheet" href="/static/styles.css"> | ||||||
|     <title>AI Assistant</title> |         <title>AI Assistant</title> | ||||||
| </head> |         <script src="/static/contact-form.js" type="text/javascript" defer></script> | ||||||
| <body> |     </head> | ||||||
|  |     <body> | ||||||
|  |         <header> | ||||||
|  |             <ul> | ||||||
|  |                 <li> | ||||||
|  |                     <a href="/"> | ||||||
|  |                         <img src="/static/img/logo.png" alt="logo.png"> | ||||||
|  |                     </a> | ||||||
|  |                 </li> | ||||||
|  |                 <li> | ||||||
|  |                     <a href="/contact">Contact</a> | ||||||
|  |                 </li> | ||||||
|  |                 <li> | ||||||
|  |                     <a href="/faq">FAQ</a> | ||||||
|  |                 </li> | ||||||
|  |             </ul> | ||||||
|  |         </header> | ||||||
|  |         <section id="contact"> | ||||||
|  |           <h2>Contact Us</h2> | ||||||
|  |           <p>This contact form has an invalid mail until our mailserver is configured</p> | ||||||
|  |           <form id="contactForm"> | ||||||
|  |             <label for="name">Name:</label> | ||||||
|  |             <input type="text" id="name" name="name" required /> | ||||||
| 
 | 
 | ||||||
| </body> |             <label for="email">Email:</label> | ||||||
| </html> |             <input type="email" id="email" name="email" required /> | ||||||
|  | 
 | ||||||
|  |             <label for="message">Message:</label> | ||||||
|  |             <textarea id="message" name="message" rows="5" required></textarea> | ||||||
|  | 
 | ||||||
|  |             <button type="submit">Send Message</button> | ||||||
|  |           </form> | ||||||
|  |         </section> | ||||||
|  |     </body> | ||||||
|  |     </html> | ||||||
|  |  | ||||||
|  | @ -0,0 +1,30 @@ | ||||||
|  |     <!DOCTYPE html> | ||||||
|  |     <html lang="en"> | ||||||
|  | 
 | ||||||
|  |     <head> | ||||||
|  |         <meta charset="UTF-8"> | ||||||
|  |         <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||||||
|  |         <link rel="stylesheet" href="/static/styles.css"> | ||||||
|  |         <title>AI Assistant</title> | ||||||
|  |     </head> | ||||||
|  | 
 | ||||||
|  |     <body> | ||||||
|  |         <header> | ||||||
|  |             <ul> | ||||||
|  |                 <li> | ||||||
|  |                     <a href="/"> | ||||||
|  |                         <img src="/static/img/logo.png" alt="logo.png"> | ||||||
|  |                     </a> | ||||||
|  |                 </li> | ||||||
|  |                 <li> | ||||||
|  |                     <a href="/contact">Contact</a> | ||||||
|  |                 </li> | ||||||
|  |                 <li> | ||||||
|  |                     <a href="/faq.html">FAQ</a> | ||||||
|  |                 </li> | ||||||
|  |             </ul> | ||||||
|  |         </header> | ||||||
|  | 
 | ||||||
|  |     </body> | ||||||
|  | 
 | ||||||
|  |     </html> | ||||||
|  | @ -12,15 +12,15 @@ | ||||||
|         <header> |         <header> | ||||||
|             <ul> |             <ul> | ||||||
|                 <li> |                 <li> | ||||||
|                     <a href="/static/templates/index.html"> |                     <a href="/"> | ||||||
|                         <img src="/static/img/logo.png" alt="logo.png"> |                         <img src="/static/img/logo.png" alt="logo.png"> | ||||||
|                     </a> |                     </a> | ||||||
|                 </li> |                 </li> | ||||||
|                 <li> |                 <li> | ||||||
|                     <a href="/static/template/contact.html">Contact</a> |                     <a href="/contact">Contact</a> | ||||||
|                 </li> |                 </li> | ||||||
|                 <li> |                 <li> | ||||||
|                     <a href="/static/template/faq.html">FAQ</a> |                     <a href="/faq.html">FAQ</a> | ||||||
|                 </li> |                 </li> | ||||||
|             </ul> |             </ul> | ||||||
|         </header> |         </header> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue