diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e4194d8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/isc_rest.log diff --git a/main.go b/main.go index cbf1b94..86bd75d 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,7 @@ func main() { models.ConnectDatabase() - f, _ := os.OpenFile("isc_rest.log", os.O_RDWR|os.O_APPEND, 0660) + f, _ := os.OpenFile("isc_rest.log", os.O_RDWR|os.O_APPEND|os.O_CREATE, 0660) utils.GinWriter = io.MultiWriter(f, os.Stdout) router.Use( gin.LoggerWithWriter(utils.GinWriter, "/update"), @@ -40,6 +40,7 @@ func main() { "./templates/modals/delete_clan.html", "./templates/modals/add_clan.html", "./templates/modals/edit_clan.html", + "./templates/modals/add_player.html", "./templates/components/header.html", } tmpl, err := template.ParseFiles(files...) diff --git a/static/index.js b/static/index.js index bb2c1fd..f268b54 100644 --- a/static/index.js +++ b/static/index.js @@ -9,6 +9,24 @@ function setupClanButtons(dropdownId, delBtnId, editBtnId) { }); } +function setupPlayerButtons(dropdownId, listId, delBtnId, editBtnId, addBtnId) { + const dropdown = document.getElementById(dropdownId); + const deleteButton = document.getElementById(delBtnId); + const editButton = document.getElementById(editBtnId); + const addButton = document.getElementById(addBtnId); + + dropdown.addEventListener('change', function () { + deleteButton.disabled = !this.value; + editButton.disabled = !this.value && (dropdown.selectedIndex !== -1); + addButton.disabled = !this.value && (dropdown.selectedIndex !== -1); + }); + + dropdown.addEventListener('change', function () { + deleteButton.disabled = (this.selectedIndex !== -1); + editButton.disabled = (this.selectedIndex !== -1); + }); +} + function getClanLists(event) { const button = event.relatedTarget; const clanListId = button.getAttribute('data-bs-list'); @@ -22,4 +40,33 @@ function getClanLists(event) { const otherClanList = document.querySelector(otherClanListId); return [clanList, otherClanList]; +} + +function getPlayerLists(event) { + const button = event.relatedTarget; + const playerListId = button.getAttribute('data-bs-list'); + const playerList = document.querySelector(playerListId); + + let otherPlayerListId; + if (playerListId === '#home-player-list') + otherPlayerListId = '#opponent-player-list' + else + otherPlayerListId = '#home-player-list' + const otherPlayerList = document.querySelector(otherPlayerListId); + + return [playerList, otherPlayerList]; +} + +function getSelectedClan(event) { + const button = event.relatedTarget; + const playerListId = button.getAttribute('data-bs-list'); + + let clanListId; + if (playerListId === '#home-player-list') + clanListId = '#home-clan' + else + clanListId = '#opponent-clan' + const clanList = document.querySelector(clanListId); + + return clanList.options[clanList.selectedIndex]; } \ No newline at end of file diff --git a/templates/components/home_player_bar.html b/templates/components/home_player_bar.html index ac9cb17..2e2080d 100644 --- a/templates/components/home_player_bar.html +++ b/templates/components/home_player_bar.html @@ -12,11 +12,23 @@