From 474e7757db765a4b034d8b8b45ef7c1f06bec4bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Tue, 3 Jul 2018 00:03:10 +0900 Subject: [PATCH] Add: maestro_section_add_player --- src/web/css/maestro_main.css | 77 ++++ src/web/js/maestro_main.html | 52 +++ src/web/js/maestro_main.js | 247 +++++++++++ src/web/maestro/main_menu.html | 2 + .../module/maestro_section_add_player.html | 50 +++ src/web/module/maestro_section_main.html | 382 +----------------- 6 files changed, 433 insertions(+), 377 deletions(-) create mode 100644 src/web/css/maestro_main.css create mode 100644 src/web/js/maestro_main.html create mode 100644 src/web/js/maestro_main.js create mode 100644 src/web/module/maestro_section_add_player.html diff --git a/src/web/css/maestro_main.css b/src/web/css/maestro_main.css new file mode 100644 index 0000000..9f5881b --- /dev/null +++ b/src/web/css/maestro_main.css @@ -0,0 +1,77 @@ +@charset "utf-8"; + + \ No newline at end of file diff --git a/src/web/js/maestro_main.html b/src/web/js/maestro_main.html new file mode 100644 index 0000000..168a0e3 --- /dev/null +++ b/src/web/js/maestro_main.html @@ -0,0 +1,52 @@ +
+
+
    +
  • 학생 목록
  • +
  • 학생 검색
  • +
  • 마우스 앱 활성화
  • +
  • 키보드 앱 활성화
  • +
+
+ + +
+
+ + + +
+
+ 클릭 연습
+ 더블 클릭 연습
+ +
+
+ +
+
+ 기본 자리
+ 왼손 윗글쇠
+ basic
+ left upper
+ +
+ +
+ + +
diff --git a/src/web/js/maestro_main.js b/src/web/js/maestro_main.js new file mode 100644 index 0000000..ef4c84a --- /dev/null +++ b/src/web/js/maestro_main.js @@ -0,0 +1,247 @@ +let maestroID = -1; +let playerCount = 0; +let playerListPage = 0; +let lastPageNo = 0; + + +$(document).ready(function() { + maestroID = sessionStorage.getItem("maestroID"); + console.log("maestroID : " + maestroID); +}); + +function loadPlayerList() { + let xhr = new XMLHttpRequest(); //new로 생성. + xhr.open('POST', './../server/user/registered_player_count.php', true); + xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + xhr.send("maestro_id=" + maestroID); + 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; + } + + playerCount = replyJSON["Count"]; + lastPageNo = Math.floor( (playerCount + 1) / 10 ); + + console.log("registered player count : " + playerCount); + 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": + if(playerListPage < lastPageNo) + playerListPage += 1; + + loadPlayerListPage(playerListPage); + return; + case "last": + loadPlayerListPage(lastPageNo); + return; + } + + loadPlayerListPage(pageNo); +} + +function loadPlayerListPage(pageNo) { + let pageIndex = pageNo - 1; + let startNo = pageIndex * 10; + let endNo = pageIndex * 10 + 9; + + console.log("startNo : " + startNo); + console.log("endNo : " + endNo); + + 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"]); + } + } +} + +function addPlayerListTitle() { + $("#registered_player_list").empty(); + + $("#registered_player_list").append( + '
  • 이름
  • 입장 코드
  • ' + ); +} + +function updatePlayerListPage(playerList) { + $("#registered_player_list").empty(); + addPlayerListTitle(); + + for(let i = 0; i < playerList.length; i++) { + $("#registered_player_list").append( + "
  • " + + "" + playerList[i]["UserID"] + "" + + "" + + "" + + "" + + "
  • " + ); + } +} + + +function tabClicked(tabNo) { + for(let i = 0; i < 4; i++) { + $("#page-tabs li").filter(":eq(" + i + ")").removeClass("activated"); + } + + let tabIndex = tabNo - 1; + $("#page-tabs li").filter(":eq(" + tabIndex + ")").addClass("activated"); + + switch(tabNo) { + case 1: + $(".player_list").removeClass("hide"); + $(".search").addClass("hide"); + $(".mouse_app_list").addClass("hide"); + $(".typing_app_list").addClass("hide"); + break; + case 2: + $(".player_list").addClass("hide"); + $(".search").removeClass("hide"); + $(".mouse_app_list").addClass("hide"); + $(".typing_app_list").addClass("hide"); + break; + case 3: + $(".player_list").addClass("hide"); + $(".search").addClass("hide"); + $(".mouse_app_list").removeClass("hide"); + $(".typing_app_list").addClass("hide"); + break; + case 4: + $(".player_list").addClass("hide"); + $(".search").addClass("hide"); + $(".mouse_app_list").addClass("hide"); + $(".typing_app_list").removeClass("hide"); + break; + } +} + +function addPlayer() { + // let maestroID = sessionStorage.getItem("maestroID"); + let playerName = $("#add_player_name").val(); + let enterCode = $("#add_player_enter_code").val(); + + if(playerName.length === 0) { + $("#add_player_notice").val("학생 이름을 입력하세요."); + $("#add_player_name").focus(); + } else if(enterCode.length === 0) { + $("#add_player_notice").val("엔터 코드를 입력하세요."); + $("#add_player_enter_code").focus(); + } + + let xhr = new XMLHttpRequest(); //new로 생성. + xhr.open('POST', './../server/user/add_player.php', true); + xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + xhr.send("maestro_id=" + maestroID + "&player_name=" + playerName + "&enter_code=" + enterCode); + 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("update player list"); + loadPlayerListPage(1); + } + } + +} \ No newline at end of file diff --git a/src/web/maestro/main_menu.html b/src/web/maestro/main_menu.html index 335055d..7770c8c 100644 --- a/src/web/maestro/main_menu.html +++ b/src/web/maestro/main_menu.html @@ -6,9 +6,11 @@ + + @@ -343,57 +21,7 @@ function addPlayer() { -
    - -

    추가

    - -

    1명 추가

    - -
    - 학생 이름
    - 입장 코드 - -
    - - - - -

    단체 추가

    - -
    - - -
    - - -
    - - - 목록 -
    -
      -
    -
    - - -
    +