mirror of
				https://github.com/DerTyp7/shop-ejs-expressjs.git
				synced 2025-10-31 05:17:09 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			246 lines
		
	
	
		
			7.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			246 lines
		
	
	
		
			7.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| <!DOCTYPE html>
 | |
| <html lang="en">
 | |
| <head>
 | |
|     <%- include('partials/head'); %>
 | |
| </head>
 | |
| <body>
 | |
|     <header>
 | |
|        <%- include('partials/header'); %>
 | |
|     </header>
 | |
| 
 | |
|     <div class="filtersDIV">
 | |
|         <select id="cat-select" class="left" onchange="updateFilters();">
 | |
|             <option value="0">Kategorie: Alle</option>
 | |
|             <% for(var i=0; i < categories.length; i++) { var cat = categories[i]; %>
 | |
|                 <option <%=Cat == cat.id ? "selected" : ""%> value="<%=cat.id%>">Kategorie: <%=cat.name %></option>
 | |
|             <% } %>
 | |
|         </select>
 | |
| 
 | |
|         <select id="brand-select" class="center" onchange="updateFilters();">
 | |
|             <option value="0">Hersteller: Alle</option>
 | |
|             <% for(var i=0; i < brands.length; i++) { var brand = brands[i]; %>
 | |
|                 <option <%=Brand == brand.id ? "selected" : ""%> value="<%=brand.id%>">Hersteller: <%=brand.name %></option>
 | |
|             <% } %>
 | |
|         </select>
 | |
| 
 | |
|         <select id="sort-select" class="right" onchange="updateFilters();">
 | |
|             <option <%=sort == 0 ? "selected" : ""%> value="0">Sortierung: Standart</option>
 | |
|             <option <%=sort == 1 ? "selected" : ""%> value="1">Sortierung: Preis aufsteigend</option>
 | |
|             <option <%=sort == 2 ? "selected" : ""%> value="2">Sortierung: Preis absteigend</option>
 | |
|             <option <%=sort == 3 ? "selected" : ""%> value="3">Sortierung: Meistverkauft</option>
 | |
|             <option <%=sort == 4 ? "selected" : ""%> value="4">Sortierung: A-Z</option>
 | |
|             <option <%=sort == 5 ? "selected" : ""%> value="5">Sortierung: Z-A</option>
 | |
|         </select>
 | |
|     </div>
 | |
|         
 | |
|     <% if (products.length == 0) { %>
 | |
|         <h2 class="noProductsH">Keine Produkte gefunden</h2>
 | |
|     <% } else { %>
 | |
|         <div class="productsResInfDIV">
 | |
|             <h2 class="productsResInfH">Suchergebnisse</h2>
 | |
|         </div>
 | |
| 
 | |
|         <div class="allProductsDIV">
 | |
|             <% for(var i=0; i < products.length; i++) {
 | |
|                 var prod = products[i];
 | |
|                 if (!prod.img) { prod.img = "/images/examples.jpg"; } 
 | |
|                 //if (!prod.rating) { prod.rating = 0; } %>
 | |
|                 <div class="productDIV">
 | |
|                     <div class="productData">
 | |
|                         <a href="/product/<%=prod.id %>"><h4 style="color: Navy;"><%=prod.name %></h4></a>
 | |
| 
 | |
|                         <h4><%=prod.price.toFixed(2) %><small><small>€</small></small></h4>
 | |
|                         <h4><%
 | |
|                             if (prod.rating) {
 | |
|                                 prod.rating = Math.round(prod.rating/2)
 | |
|                                 for (var i2=0; i2 < prod.rating; i2++) { 
 | |
|                                     %>★<% 
 | |
|                                 }
 | |
|                                 for (var i2=prod.rating; i2 < 5; i2++) {
 | |
|                                     %>☆<%
 | |
|                                 }
 | |
|                             } else {
 | |
|                             %>Keine Bewertungen<%
 | |
|                             }
 | |
|                         %></h4>
 | |
|                         
 | |
|                         <%
 | |
|                             var col;
 | |
|                             if (prod.quantity > 5) {
 | |
|                                 col = "green";
 | |
|                             } else if (prod.quantity > 0) {
 | |
|                                 col = "orange";
 | |
|                             } else {
 | |
|                                 col = "red";
 | |
|                             }
 | |
|                         %>
 | |
|                         <h4 style="color: <%=col %>">
 | |
|                             <%=prod.quantity %> auf Lager
 | |
|                         </h4>
 | |
|                     </div>
 | |
|                     <div class="productImage">
 | |
|                         <img src="<%=prod.img %>">
 | |
|                     </div>
 | |
|                     <div class="productInfo"><%=prod.description %></div>
 | |
|                 </div>
 | |
|             <% } %>
 | |
|         </div>
 | |
|     <% } %>
 | |
| </body>
 | |
| </html>
 | |
| 
 | |
| <script type="text/javascript">
 | |
|     var cat = document.getElementById("cat-select");
 | |
|     var sort = document.getElementById("sort-select");
 | |
|     var brand = document.getElementById("brand-select");
 | |
|     function updateFilters() {
 | |
|         window.open('/search/<%=search %>/?cat='+cat.value+'&sort='+sort.value+'&brand='+brand.value,'_self')
 | |
|     }
 | |
| 
 | |
|     function openProduct(id, newWindow) {
 | |
|         window.open('/product/'+id, newWindow ? '_blank' : '_self')
 | |
|     }
 | |
| </script>
 | |
| 
 | |
| <style type="text/css">
 | |
|     html, body{
 | |
|         height: 100% !important;
 | |
|         display: block !important;
 | |
|         min-height: 100vh;
 | |
|         flex-direction:unset !important;
 | |
|     }
 | |
| 
 | |
|     /* PRODUCT COLUMN */
 | |
|     .productDIV {
 | |
|         font-size: 16px;
 | |
|         margin: 10px;
 | |
|         padding: 5px;
 | |
|         display: inline-block;
 | |
|         background-color: white;
 | |
| 
 | |
|         border-style: solid;
 | |
|         border-width: 1px;
 | |
|         border-radius: 3px;
 | |
|         border-color: grey;
 | |
| 
 | |
|         box-shadow: 1px 1px 10px grey;
 | |
| 
 | |
|         position: relative;
 | |
| 
 | |
|         height: 250px;
 | |
|     } 
 | |
| 
 | |
|     /* IMAGE */
 | |
|     .productImage > img {
 | |
|         position: absolute;
 | |
|         max-width: 100%;
 | |
|         max-height: 100%;
 | |
|         margin: auto;
 | |
|         top: 0;
 | |
|         left: 0;
 | |
|         right: 0;
 | |
|         bottom: 0;
 | |
|     }
 | |
|     .productImage {
 | |
|         width: calc(50% - 15px);
 | |
|         height: calc(100% - 120px);
 | |
|         position: absolute;
 | |
|         left: 10px;
 | |
|         bottom: 10px;
 | |
|     }
 | |
|     .productDIV > h4 {
 | |
|         padding: 0px;
 | |
|         margin: 0px;
 | |
|     }
 | |
| 
 | |
|     /* DESCRIPTION */
 | |
|     .productInfo {
 | |
|         width: calc(50% - 15px);
 | |
|         height: calc(100% - 60px);
 | |
|         position: absolute;
 | |
|         overflow-y: hidden;
 | |
|         overflow-x: hidden;
 | |
|         right: 10px;
 | |
|         bottom: 10px;
 | |
|     }
 | |
| 
 | |
|     /* PRICE ETC */
 | |
|     .productData {
 | |
|         width: calc(100% - 20px);
 | |
|         height: 90px;
 | |
|         position: absolute;
 | |
|         left: 10px;
 | |
|         top: 10px;
 | |
|     }
 | |
|     .productData > h4 {
 | |
|         margin: 0px;
 | |
|         color: LightSlateGray;
 | |
|     }
 | |
|     a, a:hover, a:focus, a:active > .allProductsDIV {
 | |
|         text-decoration: none;
 | |
|         color: inherit;
 | |
|     }
 | |
| 
 | |
|     /* FILTERS */
 | |
|     .filtersDIV {
 | |
|         margin-top: 20px;
 | |
|         position: absolute;
 | |
|         left: calc(10% + 10px);
 | |
|         width: calc(80% - 20px);
 | |
|         height: 30px;
 | |
|     } 
 | |
|     .filtersDIV > select {
 | |
|         position: absolute;
 | |
|     }
 | |
|     .filtersDIV > .right {
 | |
|         right: 0;
 | |
|     }
 | |
|     .filtersDIV > .center {
 | |
|         transform: translateX(-49%);
 | |
|         left: 50%;
 | |
|     }
 | |
|     .filtersDIV > .left {
 | |
|         left: 0;
 | |
|     }
 | |
| 
 | |
|     /* SEARCH INFO */
 | |
|     .productsResInfDIV {
 | |
|         position: relative;
 | |
|         left: calc(10% + 10px);
 | |
|         width: calc(80% - 20px);
 | |
|         margin-top: 50px;
 | |
|     }
 | |
|     .noProductsH {
 | |
|         margin-top: 50px;
 | |
|         text-align: center;
 | |
|     }
 | |
| 
 | |
|     /* PRODUCTS GRID */
 | |
|     .allProductsDIV {
 | |
|         font-size: 0;
 | |
|         margin: 0px;
 | |
|         width: calc(80% - 20px);
 | |
|         left: 10%;
 | |
|         position: absolute;
 | |
|         padding: 10px;
 | |
|         background-color: white;
 | |
| 
 | |
|         display: grid;
 | |
|     }
 | |
| 
 | |
|     @media (max-width: 400px) {
 | |
|         .allProductsDIV {
 | |
|             grid-template-columns: 1fr;
 | |
|         }
 | |
|     }
 | |
|     @media (min-width: 800px) {
 | |
|         .allProductsDIV {
 | |
|             grid-template-columns: 1fr 1fr;
 | |
|         }
 | |
|     }
 | |
|     @media (min-width: 1200px) {
 | |
|         .allProductsDIV {
 | |
|             grid-template-columns: 1fr 1fr 1fr;
 | |
|         }
 | |
|     }
 | |
| </style> | 
