Piotr Czajkowski 4 years ago
parent
commit
756df24646
3 changed files with 5 additions and 7 deletions
  1. 3 3
      html/results.html
  2. 2 2
      server.go
  3. 0 2
      static/processResults.js

+ 3 - 3
html/results.html

@@ -1,4 +1,4 @@
-<!doctype html>
+<!DOCTYPE html>
 <html>
 	<head>
 		<title>Search results for "{{.SearchPhrase}}"</title>
@@ -11,9 +11,9 @@
 				cursor: pointer;
 			}
 		</style>
-		<script src="./processResults.js"></script>
+		<script type="text/javascript" src="/static/processResults.js"></script>
 	</head>
-	<body>
+	<body onload="app.sortTable()">
 		<a href="/">Search again</a>
 		<div>Filter: 
 			<input id="filter" type="text" name="name" onchange="app.filterTable(this.value)" autocomplete="off">

+ 2 - 2
server.go

@@ -37,8 +37,7 @@ func displaySearchResults(w http.ResponseWriter, r *http.Request) {
 		}
 
 		if len(searchResults.Results) > 0 {
-			funcs := template.FuncMap{"add": add}
-			t := template.Must(template.New("results.html").Funcs(funcs).ParseFiles("./html/results.html"))
+			t := template.Must(template.New("results.html").ParseFiles("./html/results.html"))
 			t.Execute(w, searchResults)
 		} else {
 			errorPage.Execute(w, "Nothing found!")
@@ -86,5 +85,6 @@ func main() {
 	http.HandleFunc("/", serveIndex)
 	http.HandleFunc("/q", displaySearchResults)
 	http.HandleFunc("/tms", displayTMs)
+	http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
 	log.Fatal(http.ListenAndServe(hostname, nil))
 }

+ 0 - 2
html/processResults.js → static/processResults.js

@@ -61,5 +61,3 @@ app.sortTable = function() {
 	})));
 
 };
-
-app.sortTable();