This commit is contained in:
+40
-40
@@ -23,9 +23,9 @@ var doc = `{
|
||||
"host": "{{.Host}}",
|
||||
"basePath": "{{.BasePath}}",
|
||||
"paths": {
|
||||
"/api/v1/statistics/games/last-played": {
|
||||
"/api/v1/statistics/soundtracks/last-played": {
|
||||
"get": {
|
||||
"description": "Returns the most recently played games",
|
||||
"description": "Returns the most recently played soundtracks",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -35,7 +35,7 @@ var doc = `{
|
||||
"tags": [
|
||||
"statistics"
|
||||
],
|
||||
"summary": "Get last played games",
|
||||
"summary": "Get last played soundtracks",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
@@ -50,7 +50,7 @@ var doc = `{
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/backend.GameWithSongs"
|
||||
"$ref": "#/definitions/backend.SoundtrackWithSongs"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -75,9 +75,9 @@ var doc = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/statistics/games/least-played": {
|
||||
"/api/v1/statistics/soundtracks/least-played": {
|
||||
"get": {
|
||||
"description": "Returns the top N least played games with their songs",
|
||||
"description": "Returns the top N least played soundtracks with their songs",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -87,7 +87,7 @@ var doc = `{
|
||||
"tags": [
|
||||
"statistics"
|
||||
],
|
||||
"summary": "Get least played games",
|
||||
"summary": "Get least played soundtracks",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
@@ -102,7 +102,7 @@ var doc = `{
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/backend.GameWithSongs"
|
||||
"$ref": "#/definitions/backend.SoundtrackWithSongs"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -127,9 +127,9 @@ var doc = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/statistics/games/most-played": {
|
||||
"/api/v1/statistics/soundtracks/most-played": {
|
||||
"get": {
|
||||
"description": "Returns the top N most played games with their songs",
|
||||
"description": "Returns the top N most played soundtracks with their songs",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -139,7 +139,7 @@ var doc = `{
|
||||
"tags": [
|
||||
"statistics"
|
||||
],
|
||||
"summary": "Get most played games",
|
||||
"summary": "Get most played soundtracks",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
@@ -154,7 +154,7 @@ var doc = `{
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/backend.GameWithSongs"
|
||||
"$ref": "#/definitions/backend.SoundtrackWithSongs"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -179,9 +179,9 @@ var doc = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/statistics/games/never-played": {
|
||||
"/api/v1/statistics/soundtracks/never-played": {
|
||||
"get": {
|
||||
"description": "Returns all games that have never been played (times_played = 0)",
|
||||
"description": "Returns all soundtracks that have never been played (times_played = 0)",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -191,14 +191,14 @@ var doc = `{
|
||||
"tags": [
|
||||
"statistics"
|
||||
],
|
||||
"summary": "Get never played games",
|
||||
"summary": "Get never played soundtracks",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/backend.GameWithSongs"
|
||||
"$ref": "#/definitions/backend.SoundtrackWithSongs"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -214,9 +214,9 @@ var doc = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/statistics/games/oldest-played": {
|
||||
"/api/v1/statistics/soundtracks/oldest-played": {
|
||||
"get": {
|
||||
"description": "Returns the least recently played games (that have been played at least once)",
|
||||
"description": "Returns the least recently played soundtracks (that have been played at least once)",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -226,7 +226,7 @@ var doc = `{
|
||||
"tags": [
|
||||
"statistics"
|
||||
],
|
||||
"summary": "Get oldest played games",
|
||||
"summary": "Get oldest played soundtracks",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
@@ -241,7 +241,7 @@ var doc = `{
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/backend.GameWithSongs"
|
||||
"$ref": "#/definitions/backend.SoundtrackWithSongs"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -824,7 +824,7 @@ var doc = `{
|
||||
},
|
||||
"/music/all/order": {
|
||||
"get": {
|
||||
"description": "Returns a list of all games in order",
|
||||
"description": "Returns a list of all soundtracks in order",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -857,7 +857,7 @@ var doc = `{
|
||||
},
|
||||
"/music/all/random": {
|
||||
"get": {
|
||||
"description": "Returns a list of all games in random order",
|
||||
"description": "Returns a list of all soundtracks in random order",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -1197,7 +1197,7 @@ var doc = `{
|
||||
},
|
||||
"/sync": {
|
||||
"get": {
|
||||
"description": "Starts syncing games with only new changes",
|
||||
"description": "Starts syncing soundtracks with only new changes",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -1226,7 +1226,7 @@ var doc = `{
|
||||
},
|
||||
"/sync/full": {
|
||||
"get": {
|
||||
"description": "Starts a full sync of all games",
|
||||
"description": "Starts a full sync of all soundtracks",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -1236,7 +1236,7 @@ var doc = `{
|
||||
"tags": [
|
||||
"sync"
|
||||
],
|
||||
"summary": "Sync all games fully",
|
||||
"summary": "Sync all soundtracks fully",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Start syncing soundtracks full",
|
||||
@@ -1279,7 +1279,7 @@ var doc = `{
|
||||
},
|
||||
"/sync/reset": {
|
||||
"get": {
|
||||
"description": "Resets the games database by deleting all games and songs",
|
||||
"description": "Resets the soundtracks database by deleting all soundtracks and songs",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -1369,19 +1369,19 @@ var doc = `{
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"backend.GameWithSongs": {
|
||||
"backend.SoundtrackWithSongs": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"game_id": {
|
||||
"soundtrack_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"game_last_played": {
|
||||
"soundtrack_last_played": {
|
||||
"type": "string"
|
||||
},
|
||||
"game_name": {
|
||||
"soundtrack_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"game_played": {
|
||||
"soundtrack_played": {
|
||||
"type": "integer"
|
||||
},
|
||||
"songs": {
|
||||
@@ -1398,10 +1398,10 @@ var doc = `{
|
||||
"file_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"game_id": {
|
||||
"soundtrack_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"game_name": {
|
||||
"soundtrack_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"path": {
|
||||
@@ -1418,25 +1418,25 @@ var doc = `{
|
||||
"backend.StatisticsSummary": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"avg_game_plays": {
|
||||
"avg_soundtrack_plays": {
|
||||
"type": "number"
|
||||
},
|
||||
"max_game_plays": {
|
||||
"max_soundtrack_plays": {
|
||||
"type": "integer"
|
||||
},
|
||||
"min_game_plays": {
|
||||
"min_soundtrack_plays": {
|
||||
"type": "integer"
|
||||
},
|
||||
"never_played_games": {
|
||||
"never_played_soundtracks": {
|
||||
"type": "integer"
|
||||
},
|
||||
"played_games": {
|
||||
"played_soundtracks": {
|
||||
"type": "integer"
|
||||
},
|
||||
"total_game_plays": {
|
||||
"total_soundtrack_plays": {
|
||||
"type": "integer"
|
||||
},
|
||||
"total_games": {
|
||||
"total_soundtracks": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
|
||||
+42
-42
@@ -4,9 +4,9 @@
|
||||
"contact": {}
|
||||
},
|
||||
"paths": {
|
||||
"/api/v1/statistics/games/last-played": {
|
||||
"/api/v1/statistics/soundtracks/last-played": {
|
||||
"get": {
|
||||
"description": "Returns the most recently played games",
|
||||
"description": "Returns the most recently played soundtracks",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -16,7 +16,7 @@
|
||||
"tags": [
|
||||
"statistics"
|
||||
],
|
||||
"summary": "Get last played games",
|
||||
"summary": "Get last played soundtracks",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
@@ -31,7 +31,7 @@
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/backend.GameWithSongs"
|
||||
"$ref": "#/definitions/backend.SoundtrackWithSongs"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -56,9 +56,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/statistics/games/least-played": {
|
||||
"/api/v1/statistics/soundtracks/least-played": {
|
||||
"get": {
|
||||
"description": "Returns the top N least played games with their songs",
|
||||
"description": "Returns the top N least played soundtracks with their songs",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -68,7 +68,7 @@
|
||||
"tags": [
|
||||
"statistics"
|
||||
],
|
||||
"summary": "Get least played games",
|
||||
"summary": "Get least played soundtracks",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
@@ -83,7 +83,7 @@
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/backend.GameWithSongs"
|
||||
"$ref": "#/definitions/backend.SoundtrackWithSongs"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -108,9 +108,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/statistics/games/most-played": {
|
||||
"/api/v1/statistics/soundtracks/most-played": {
|
||||
"get": {
|
||||
"description": "Returns the top N most played games with their songs",
|
||||
"description": "Returns the top N most played soundtracks with their songs",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -120,7 +120,7 @@
|
||||
"tags": [
|
||||
"statistics"
|
||||
],
|
||||
"summary": "Get most played games",
|
||||
"summary": "Get most played soundtracks",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
@@ -135,7 +135,7 @@
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/backend.GameWithSongs"
|
||||
"$ref": "#/definitions/backend.SoundtrackWithSongs"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -160,9 +160,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/statistics/games/never-played": {
|
||||
"/api/v1/statistics/soundtracks/never-played": {
|
||||
"get": {
|
||||
"description": "Returns all games that have never been played (times_played = 0)",
|
||||
"description": "Returns all soundtracks that have never been played (times_played = 0)",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -172,14 +172,14 @@
|
||||
"tags": [
|
||||
"statistics"
|
||||
],
|
||||
"summary": "Get never played games",
|
||||
"summary": "Get never played soundtracks",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/backend.GameWithSongs"
|
||||
"$ref": "#/definitions/backend.SoundtrackWithSongs"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -195,9 +195,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/statistics/games/oldest-played": {
|
||||
"/api/v1/statistics/soundtracks/oldest-played": {
|
||||
"get": {
|
||||
"description": "Returns the least recently played games (that have been played at least once)",
|
||||
"description": "Returns the least recently played soundtracks (that have been played at least once)",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -207,7 +207,7 @@
|
||||
"tags": [
|
||||
"statistics"
|
||||
],
|
||||
"summary": "Get oldest played games",
|
||||
"summary": "Get oldest played soundtracks",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
@@ -222,7 +222,7 @@
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/backend.GameWithSongs"
|
||||
"$ref": "#/definitions/backend.SoundtrackWithSongs"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -249,7 +249,7 @@
|
||||
},
|
||||
"/api/v1/statistics/songs/least-played": {
|
||||
"get": {
|
||||
"description": "Returns the top N least played songs with their game info",
|
||||
"description": "Returns the top N least played songs with their soundtrack info",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -301,7 +301,7 @@
|
||||
},
|
||||
"/api/v1/statistics/songs/most-played": {
|
||||
"get": {
|
||||
"description": "Returns the top N most played songs with their game info",
|
||||
"description": "Returns the top N most played songs with their soundtrack info",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -805,7 +805,7 @@
|
||||
},
|
||||
"/music/all/order": {
|
||||
"get": {
|
||||
"description": "Returns a list of all games in order",
|
||||
"description": "Returns a list of all soundtracks in order",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -838,7 +838,7 @@
|
||||
},
|
||||
"/music/all/random": {
|
||||
"get": {
|
||||
"description": "Returns a list of all games in random order",
|
||||
"description": "Returns a list of all soundtracks in random order",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -1178,7 +1178,7 @@
|
||||
},
|
||||
"/sync": {
|
||||
"get": {
|
||||
"description": "Starts syncing games with only new changes",
|
||||
"description": "Starts syncing soundtracks with only new changes",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -1207,7 +1207,7 @@
|
||||
},
|
||||
"/sync/full": {
|
||||
"get": {
|
||||
"description": "Starts a full sync of all games",
|
||||
"description": "Starts a full sync of all soundtracks",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -1217,7 +1217,7 @@
|
||||
"tags": [
|
||||
"sync"
|
||||
],
|
||||
"summary": "Sync all games fully",
|
||||
"summary": "Sync all soundtracks fully",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Start syncing soundtracks full",
|
||||
@@ -1260,7 +1260,7 @@
|
||||
},
|
||||
"/sync/reset": {
|
||||
"get": {
|
||||
"description": "Resets the games database by deleting all games and songs",
|
||||
"description": "Resets the soundtracks database by deleting all soundtracks and songs",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -1350,19 +1350,19 @@
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"backend.GameWithSongs": {
|
||||
"backend.SoundtrackWithSongs": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"game_id": {
|
||||
"soundtrack_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"game_last_played": {
|
||||
"soundtrack_last_played": {
|
||||
"type": "string"
|
||||
},
|
||||
"game_name": {
|
||||
"soundtrack_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"game_played": {
|
||||
"soundtrack_played": {
|
||||
"type": "integer"
|
||||
},
|
||||
"songs": {
|
||||
@@ -1379,10 +1379,10 @@
|
||||
"file_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"game_id": {
|
||||
"soundtrack_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"game_name": {
|
||||
"soundtrack_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"path": {
|
||||
@@ -1399,25 +1399,25 @@
|
||||
"backend.StatisticsSummary": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"avg_game_plays": {
|
||||
"avg_soundtrack_plays": {
|
||||
"type": "number"
|
||||
},
|
||||
"max_game_plays": {
|
||||
"max_soundtrack_plays": {
|
||||
"type": "integer"
|
||||
},
|
||||
"min_game_plays": {
|
||||
"min_soundtrack_plays": {
|
||||
"type": "integer"
|
||||
},
|
||||
"never_played_games": {
|
||||
"never_played_soundtracks": {
|
||||
"type": "integer"
|
||||
},
|
||||
"played_games": {
|
||||
"played_soundtracks": {
|
||||
"type": "integer"
|
||||
},
|
||||
"total_game_plays": {
|
||||
"total_soundtrack_plays": {
|
||||
"type": "integer"
|
||||
},
|
||||
"total_games": {
|
||||
"total_soundtracks": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
|
||||
+31
-31
@@ -8,9 +8,9 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
var games_added []string
|
||||
var soundtracks_added []string
|
||||
|
||||
func FindGameWebHandler(w http.ResponseWriter, r *http.Request) {
|
||||
func FindSoundtrackWebHandler(w http.ResponseWriter, r *http.Request) {
|
||||
err := r.ParseForm()
|
||||
if err != nil {
|
||||
http.Error(w, "Bad Request", http.StatusBadRequest)
|
||||
@@ -20,81 +20,81 @@ func FindGameWebHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
search(search_term)
|
||||
|
||||
component := FoundGames(games_added)
|
||||
component := FoundSoundtracks(soundtracks_added)
|
||||
err = component.Render(r.Context(), w)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
log.Fatalf("Error rendering in FindGameWebHandler: %e", err)
|
||||
log.Fatalf("Error rendering in FindSoundtrackWebHandler: %e", err)
|
||||
}
|
||||
}
|
||||
|
||||
func search(searchText string) {
|
||||
games_added = nil
|
||||
games := backend.GetAllSoundtracks()
|
||||
for _, game := range games {
|
||||
if is_match_exact(searchText, game) {
|
||||
add_game(game)
|
||||
soundtracks_added = nil
|
||||
soundtracks := backend.GetAllSoundtracks()
|
||||
for _, soundtrack := range soundtracks {
|
||||
if is_match_exact(searchText, soundtrack) {
|
||||
add_soundtrack(soundtrack)
|
||||
}
|
||||
}
|
||||
for _, game := range games {
|
||||
if is_match_contains(clean_term(searchText), clean_term(game)) {
|
||||
add_game(game)
|
||||
for _, soundtrack := range soundtracks {
|
||||
if is_match_contains(clean_term(searchText), clean_term(soundtrack)) {
|
||||
add_soundtrack(soundtrack)
|
||||
}
|
||||
}
|
||||
for _, game := range games {
|
||||
if is_match_regex(clean_term(searchText), clean_term(game)) {
|
||||
add_game(game)
|
||||
for _, soundtrack := range soundtracks {
|
||||
if is_match_regex(clean_term(searchText), clean_term(soundtrack)) {
|
||||
add_soundtrack(soundtrack)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func is_match_exact(search_term string, game_name string) bool {
|
||||
func is_match_exact(search_term string, soundtrack_name string) bool {
|
||||
search_term = strings.ToLower(search_term)
|
||||
game_name = strings.ToLower(game_name)
|
||||
soundtrack_name = strings.ToLower(soundtrack_name)
|
||||
|
||||
if search_term == "" {
|
||||
return true
|
||||
} else if strings.Contains(game_name, search_term) {
|
||||
} else if strings.Contains(soundtrack_name, search_term) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func is_match_contains(search_term string, game_name string) bool {
|
||||
func is_match_contains(search_term string, soundtrack_name string) bool {
|
||||
if search_term == "" {
|
||||
return true
|
||||
} else if strings.Contains(game_name, search_term) {
|
||||
} else if strings.Contains(soundtrack_name, search_term) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func is_match_regex(search_term string, game_name string) bool {
|
||||
func is_match_regex(search_term string, soundtrack_name string) bool {
|
||||
if search_term == "" {
|
||||
return true
|
||||
} else if compile_regex(search_term).MatchString(game_name) {
|
||||
} else if compile_regex(search_term).MatchString(soundtrack_name) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func add_game(game string) {
|
||||
if !check_if_game_exists(game) {
|
||||
games_added = append(games_added, game)
|
||||
func add_soundtrack(soundtrack string) {
|
||||
if !check_if_soundtrack_exists(soundtrack) {
|
||||
soundtracks_added = append(soundtracks_added, soundtrack)
|
||||
}
|
||||
}
|
||||
|
||||
func check_if_game_exists(gameName string) bool {
|
||||
game_exists := false
|
||||
for _, child := range games_added {
|
||||
if child == gameName {
|
||||
game_exists = true
|
||||
func check_if_soundtrack_exists(soundtrackName string) bool {
|
||||
soundtrack_exists := false
|
||||
for _, child := range soundtracks_added {
|
||||
if child == soundtrackName {
|
||||
soundtrack_exists = true
|
||||
}
|
||||
}
|
||||
return game_exists
|
||||
return soundtrack_exists
|
||||
}
|
||||
|
||||
func compile_regex(search_term string) *regexp.Regexp {
|
||||
|
||||
+7
-7
@@ -4,14 +4,14 @@ templ HelloForm() {
|
||||
@Base() {
|
||||
<button id="dark-mode-toggle">🌙</button>
|
||||
<div id="search-container">
|
||||
<input id="search_term" name="search_term" type="text" hx-post="/find" hx-trigger="keyup changed delay:0.25s" hx-target="#games-container"/>
|
||||
<input id="search_term" name="search_term" type="text" hx-post="/find" hx-trigger="keyup changed delay:0.25s" hx-target="#soundtracks-container"/>
|
||||
<button type="button" id="clear" name="clear">Clear</button>
|
||||
</div>
|
||||
<div id="games-container"></div>
|
||||
<div id="soundtracks-container"></div>
|
||||
<script>
|
||||
document.addEventListener('readystatechange', () => {
|
||||
if (document.readyState == 'complete') {
|
||||
htmx.ajax('POST', '/find', '#games-container');
|
||||
htmx.ajax('POST', '/find', '#soundtracks-container');
|
||||
document.getElementById("search_term").focus();
|
||||
|
||||
// Initialize dark mode from localStorage (default to dark)
|
||||
@@ -38,17 +38,17 @@ templ HelloForm() {
|
||||
|
||||
document.getElementById("clear").addEventListener("click", function (event) {
|
||||
document.getElementById("search_term").value = "";
|
||||
htmx.ajax('POST', '/find', '#games-container');
|
||||
htmx.ajax('POST', '/find', '#soundtracks-container');
|
||||
document.getElementById("search_term").focus();
|
||||
});
|
||||
</script>
|
||||
}
|
||||
}
|
||||
|
||||
templ FoundGames(games []string) {
|
||||
for _, game := range games {
|
||||
templ FoundSoundtracks(soundtracks []string) {
|
||||
for _, soundtrack := range soundtracks {
|
||||
<div class="bg-green-100 p-4 shadow-md rounded-lg mt-6">
|
||||
<p class="game-text">{ game }</p>
|
||||
<p class="soundtrack-text">{ soundtrack }</p>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user