diff --git a/src/web/css/maestro_main.css b/src/web/css/maestro_main.css index 85817b0..49098ec 100644 --- a/src/web/css/maestro_main.css +++ b/src/web/css/maestro_main.css @@ -45,16 +45,18 @@ list-style: none; } -#registered_player_list > li { - display: inline-block; - vertical-align: middle; - text-align: center; +#registered_player_list { + list-style: none; } #registered_player_list > li > span { line-height: normal; } +#registered_player_list > li > .player_id { + display: none; +} + #registered_player_list .player_id { background-color: #ffffff; } @@ -78,6 +80,10 @@ text-align: center; } +#player_list_navigator > span { + line-height: normal; +} + #player_list_navigator a { cursor: pointer; } diff --git a/src/web/js/maestro_main.js b/src/web/js/maestro_main.js index 1b7fb5f..f263f68 100644 --- a/src/web/js/maestro_main.js +++ b/src/web/js/maestro_main.js @@ -4,7 +4,10 @@ let playerListPage = 0; let lastPageNo = 0; let addPlayerList; -let searchPlayerList +let searchPlayerList; + +let addPlayerListNavigator; +let searchPlayerListNavigator; $(document).ready(function() { @@ -45,113 +48,9 @@ function loadPlayerList() { } playerCount = replyJSON["Count"]; - lastPageNo = Math.floor( (playerCount + 1) / 10 ); loadPlayerListPage(1); - addPlayerListPages(); - } - } -} - -function addPlayerListPages() { - $("#player_list_pages").empty(); - - for(let pageNo = 1; pageNo < lastPageNo + 1; pageNo++) { - $("#player_list_pages").append( - " " + pageNo + " " - ); - } -} - -function onClickPlayerListPage(pageNo) { - console.log(pageNo); - - switch(pageNo) { - case "first": - playerListPage = 1; - loadPlayerListPage(playerListPage); - return; - - case "prev": - if(playerListPage > 1) - playerListPage -= 1; - loadPlayerListPage(playerListPage); - return; - - case "next": - console.log("playerListPage : " + playerListPage); - console.log("lastPageNo : " + lastPageNo); - if(playerListPage < lastPageNo) - playerListPage += 1; - loadPlayerListPage(playerListPage); - return; - - case "last": - loadPlayerListPage(lastPageNo); - return; - } - - loadPlayerListPage(pageNo); -} - -function loadPlayerListPage(pageNo) { - playerListPage = pageNo; - - let pageIndex = pageNo - 1; - let startNo = pageIndex * 10; - let endNo = pageIndex * 10 + 9; - - let xhr = new XMLHttpRequest(); //new로 생성. - xhr.open('POST', './../server/user/registered_player_list_page.php', true); - xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - xhr.send("maestro_id=" + maestroID + "&start_no=" + startNo + "&end_no=" + endNo); - xhr.onload = function() { - if(xhr.readyState === 4 && xhr.status === 200) { - // console.log(xhr.responseText); - // console.log(xhr.responseText.length); - if(xhr.responseText.length === 0 || xhr.responseText === null) { - console.log("no data from server"); - return; - } - - let replyJSON = JSON.parse(xhr.responseText); - // console.log(replyJSON); - - if(replyJSON === null) { - console.log("no data from server"); - return; - } - - if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) { - console.log(replyJSON["ERROR"]); - return; - } - - if(replyJSON["RESULT"] === "fail") { - console.log(replyJSON["RESULT"]); - return; - } - - // console.log(replyJSON["PlayerList"]); - // updatePlayerListPage(replyJSON["PlayerList"]); - addPlayerList.updatePlayerList(replyJSON["PlayerList"]); - } - } -} - -function updatePlayerList(playerList) { - for(let i = 0; i < 10; i++) { - let listIndex = i + 1; // index 0 : list title - - if(i < playerList.length) { - $("#registered_player_list .player_id").filter(":eq(" + i + ")").empty(); - $("#registered_player_list .player_id").filter(":eq(" + i + ")").append(playerList[i]["UserID"]); - $("#registered_player_list .player_name").filter(":eq(" + listIndex + ")").val(playerList[i]["Name"]); - $("#registered_player_list .player_entercode").filter(":eq(" + listIndex + ")").val(playerList[i]["EnterCode"]); - } else { - $("#registered_player_list .player_id").filter(":eq(" + i + ")").empty(); - $("#registered_player_list .player_name").filter(":eq(" + listIndex + ")").val(""); - $("#registered_player_list .player_entercode").filter(":eq(" + listIndex + ")").val(""); + addPlayerListNavigator.addPlayerListPages(playerCount); } } } @@ -239,7 +138,6 @@ function addPlayer() { return; } - console.log("update player list"); loadPlayerListPage(1); } } diff --git a/src/web/js/player_list.js b/src/web/js/player_list.js index 6b41ec2..748c36e 100644 --- a/src/web/js/player_list.js +++ b/src/web/js/player_list.js @@ -89,8 +89,6 @@ class PlayerList { if(playerID === null || playerID === "") return; - console.log(playerID); - let xhr = new XMLHttpRequest(); //new로 생성. xhr.open('POST', './../server/user/delete_player.php', true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); @@ -126,7 +124,51 @@ class PlayerList { loadPlayerListPage(1); } } - } +} + +function loadPlayerListPage(pageNo) { + playerListPage = pageNo; + + let pageIndex = pageNo - 1; + let startNo = pageIndex * 10; + let endNo = pageIndex * 10 + 9; + + let xhr = new XMLHttpRequest(); //new로 생성. + xhr.open('POST', './../server/user/registered_player_list_page.php', true); + xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + xhr.send("maestro_id=" + maestroID + "&start_no=" + startNo + "&end_no=" + endNo); + xhr.onload = function() { + if(xhr.readyState === 4 && xhr.status === 200) { + // console.log(xhr.responseText); + // console.log(xhr.responseText.length); + if(xhr.responseText.length === 0 || xhr.responseText === null) { + console.log("no data from server"); + return; + } + + let replyJSON = JSON.parse(xhr.responseText); + // console.log(replyJSON); + + if(replyJSON === null) { + console.log("no data from server"); + return; + } + + if(replyJSON["ERROR"] !== undefined || replyJSON["RESULT"] === undefined) { + console.log(replyJSON["ERROR"]); + return; + } + + if(replyJSON["RESULT"] === "fail") { + console.log(replyJSON["RESULT"]); + return; + } + + // console.log(replyJSON["PlayerList"]); + // updatePlayerListPage(replyJSON["PlayerList"]); + addPlayerList.updatePlayerList(replyJSON["PlayerList"]); + } + } } \ No newline at end of file diff --git a/src/web/js/player_list_navigator.js b/src/web/js/player_list_navigator.js new file mode 100644 index 0000000..eb8e118 --- /dev/null +++ b/src/web/js/player_list_navigator.js @@ -0,0 +1,51 @@ +class PlayerListNavigator { + + constructor(pageNoArea) { + let self = this; + this.pageNoArea = pageNoArea; + // console.log(parent); + } + + addPlayerListPages(playerCount) { + lastPageNo = Math.ceil( (playerCount + 1) / 10 ); + + $(this.pageNoArea).empty(); + + for(let pageNo = 1; pageNo < lastPageNo + 1; pageNo++) { + $(this.pageNoArea).append( + " " + pageNo + " " + ); + } + } + +} + + + +function onClickPlayerListPage(pageNo) { + switch(pageNo) { + case "first": + playerListPage = 1; + loadPlayerListPage(playerListPage); + return; + + case "prev": + if(playerListPage > 1) + playerListPage -= 1; + loadPlayerListPage(playerListPage); + return; + + case "next": + if(playerListPage < lastPageNo) + playerListPage += 1; + loadPlayerListPage(playerListPage); + return; + + case "last": + loadPlayerListPage(lastPageNo); + return; + } + + loadPlayerListPage(pageNo); +} + diff --git a/src/web/maestro/main_menu.html b/src/web/maestro/main_menu.html index 2d89a8d..025a871 100644 --- a/src/web/maestro/main_menu.html +++ b/src/web/maestro/main_menu.html @@ -12,6 +12,7 @@ + @@ -127,10 +130,10 @@ $(document).ready(function() {
- << - < - - > - >> + + + + +
diff --git a/src/web/module/maestro_section_main.html b/src/web/module/maestro_section_main.html index f5fa85c..ae125ad 100644 --- a/src/web/module/maestro_section_main.html +++ b/src/web/module/maestro_section_main.html @@ -3,7 +3,7 @@ $(document).ready(function() { $("#section_add_player").load("./../module/maestro_section_add_player.html"); $("#search").load("./../module/maestro_section_search.html"); - loadPlayerList(); + // loadPlayerList(); }); diff --git a/src/web/module/maestro_section_search.html b/src/web/module/maestro_section_search.html index ff90baa..ac2e9c1 100644 --- a/src/web/module/maestro_section_search.html +++ b/src/web/module/maestro_section_search.html @@ -1,6 +1,5 @@