Compare commits
	
		
			2 Commits
		
	
	
		
			c3e1d80b8f
			...
			e94199f9eb
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					e94199f9eb | ||
| 
						 | 
					e4274d1107 | 
@@ -7,14 +7,14 @@
 | 
				
			|||||||
        <link rel="stylesheet" type="text/css" href="assets/style.css">
 | 
					        <link rel="stylesheet" type="text/css" href="assets/style.css">
 | 
				
			||||||
    </head>
 | 
					    </head>
 | 
				
			||||||
    <body>
 | 
					    <body>
 | 
				
			||||||
        <form class="search-grid" action="{{ .SearchFormAction }}">
 | 
					        <form id="search-form" class="search-grid" action="{{ .SearchFormAction }}">
 | 
				
			||||||
            <div class="search-logo">
 | 
					            <div class="search-logo">
 | 
				
			||||||
                <img als="girl_juice" src="assets/girl_juice.png" />
 | 
					                <img als="girl_juice" src="assets/girl_juice.png" />
 | 
				
			||||||
                <h2 class="phrases"></h2>
 | 
					                <h2 class="phrases"></h2>
 | 
				
			||||||
                <img als="girl_juice" src="assets/girl_juice.png" />
 | 
					                <img als="girl_juice" src="assets/girl_juice.png" />
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <input name="{{ .SearchInputName }}" type="text" class="grid-item" class="search" placeholder="{{ .SearchPlaceholder }}" />
 | 
					            <input id="search-input" name="{{ .SearchInputName }}" type="text" class="grid-item" class="search" placeholder="{{ .SearchPlaceholder }}" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <div class="cards" id="stores">
 | 
					            <div class="cards" id="stores">
 | 
				
			||||||
                {{range $Store := .Stores }}
 | 
					                {{range $Store := .Stores }}
 | 
				
			||||||
@@ -61,7 +61,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            document.addEventListener('DOMContentLoaded', function() {
 | 
					            document.addEventListener('DOMContentLoaded', function() {
 | 
				
			||||||
                Array.from(document.querySelectorAll('input')).forEach(element => {
 | 
					                Array.from(document.querySelectorAll('input')).forEach(element => {
 | 
				
			||||||
                    console.log(element)
 | 
					 | 
				
			||||||
                    element.focus();
 | 
					                    element.focus();
 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
@@ -93,5 +92,7 @@
 | 
				
			|||||||
                animateMarquee();
 | 
					                animateMarquee();
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        </script>
 | 
					        </script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <script src="scripts/search.js"></script>
 | 
				
			||||||
    </body>
 | 
					    </body>
 | 
				
			||||||
</html>
 | 
					</html>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										38
									
								
								frontend/scripts/search.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								frontend/scripts/search.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,38 @@
 | 
				
			|||||||
 | 
					console.log("adding features to search...");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const form = document.getElementById("search-form");
 | 
				
			||||||
 | 
					const input = document.getElementById("search-input");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const searchEngines = {
 | 
				
			||||||
 | 
					    "g": {
 | 
				
			||||||
 | 
					        action: "https://www.google.com/search/",
 | 
				
			||||||
 | 
					        name: "q",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "d": {
 | 
				
			||||||
 | 
					        action: "https://duckduckgo.com/",
 | 
				
			||||||
 | 
					        name: "q",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "y": {
 | 
				
			||||||
 | 
					        action: "https://yandex.com/search/",
 | 
				
			||||||
 | 
					        name: "text",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "lure": {
 | 
				
			||||||
 | 
					        action: "https://lure.sh/pkgs",
 | 
				
			||||||
 | 
					        name: "q",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// https://stackoverflow.com/a/3809435/16804841
 | 
				
			||||||
 | 
					const expression = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi;
 | 
				
			||||||
 | 
					const urlRegex = new RegExp(expression);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					form.addEventListener("submit", event => {
 | 
				
			||||||
 | 
					    s = input.value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // check if url
 | 
				
			||||||
 | 
					    if (s.match(urlRegex)) {
 | 
				
			||||||
 | 
					        event.preventDefault();
 | 
				
			||||||
 | 
					        window.open(s, "_self");
 | 
				
			||||||
 | 
					        return
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
							
								
								
									
										1
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								main.go
									
									
									
									
									
								
							@@ -48,6 +48,7 @@ func main() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	e := echo.New()
 | 
						e := echo.New()
 | 
				
			||||||
	e.Static("/assets", "frontend/assets")
 | 
						e.Static("/assets", "frontend/assets")
 | 
				
			||||||
 | 
						e.Static("/scripts", "frontend/scripts")
 | 
				
			||||||
	e.GET("/", getIndex)
 | 
						e.GET("/", getIndex)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// this is for me to later setup the ctl such that I can config the running program on the command line
 | 
						// this is for me to later setup the ctl such that I can config the running program on the command line
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user