diff --git a/Config/Config.php b/Config/Config.php index c0d58393..7ea4d7af 100644 --- a/Config/Config.php +++ b/Config/Config.php @@ -53,5 +53,5 @@ $error = ""; // Server $serverAdress = "82.165.180.114"; -$playerNumberPerGame = 3; +$playerNumberPerGame = 2; $nbEnigmePerGame = 1; \ No newline at end of file diff --git a/View/src/JS/dashboard.js b/View/src/JS/dashboard.js index 3f9f146e..4558fbd5 100644 --- a/View/src/JS/dashboard.js +++ b/View/src/JS/dashboard.js @@ -1,97 +1,66 @@ window.onload = function () { - /*data = [{ - type: "line", - xValueFormatString: "Pierre", - dataPoints: [ - { x: 0, y: 0 }, - { x: 1, y: 50 }, - { x: 2, y: 100 }, - { x: 3, y: 150 }, - { x: 4, y: 150 }, - { x: 5, y: 200 }, - ] - }, - { - type: "line", - xValueFormatString: "Noe", - dataPoints: [ - { x: 0, y: 0 }, - { x: 1, y: 100 }, - { x: 2, y: 100 }, - { x: 3, y: 200 }, - { x: 4, y: 250 }, - { x: 5, y: 300 }, - ] - }, - { - type: "line", - xValueFormatString: "Nathan", - dataPoints: [ - { x: 0, y: 0 }, - { x: 1, y: 75 }, - { x: 2, y: 100 }, - { x: 3, y: 150 }, - { x: 4, y: 200 }, - { x: 5, y: 250 }, - ] - }]*/ + var xhr = new XMLHttpRequest(); + xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayersPseudo', true); + xhr.responseType = 'text'; + xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + xhr.onload = function () { + var players = JSON.parse(xhr.responseText); + // if (players[0] != null) { + // var player1 = players[0]; + // } + // if (players[1] != null) { + // var player2 = players[1]; + // } + // if (players[2] != null) { + // var player3 = players[2]; + // } + // if (players[3] != null) { + // var player4 = players[3]; + // } + }; + xhr.send(null); + data = []; - v1 = { - type: "line", - xValueFormatString: "Pierre", - dataPoints: [ - { x: 0, y: 0 }, - { x: 1, y: 50 }, - { x: 2, y: 100 }, - { x: 3, y: 150 }, - { x: 4, y: 150 }, - { x: 5, y: 200 }, - ] + if (players[0] != null) { + v = {} + v.type="line"; + v.xValueFormatString=players[0]; + v.dataPoints=[]; } + // v.dataPoints.push({x:0,y:0}); + // v.dataPoints.push({x:0.5,y:300}); + // data.push(v); - - v2 = { - type: "line", - xValueFormatString: "Noe", - dataPoints: [ - { x: 0, y: 0 }, - { x: 1, y: 100 }, - { x: 2, y: 100 }, - { x: 3, y: 200 }, - { x: 4, y: 250 }, - { x: 5, y: 300 }, - ] + if (players[1] != null) { + v = {} + v.type="line"; + v.xValueFormatString=players[1]; + v.dataPoints=[]; } + // v.dataPoints.push({x:0,y:0}); + // v.dataPoints.push({x:0.5,y:300}); + // data.push(v); - ///dataPoints=[{x:0,y:0},{x:1,y:300}] - - - - ///v3={type:"line",xValueFormatString:"test",dataPoints}; - - data = []; - - v = {} - v.type="line"; - v.xValueFormatString="test"; - v.dataPoints=[]; - v.dataPoints.push({x:0,y:0}); - v.dataPoints.push({x:0.5,y:300}); - - data.push(v); + if (players[2] != null) { + v = {} + v.type="line"; + v.xValueFormatString=players[2]; + v.dataPoints=[]; + } + // v.dataPoints.push({x:0,y:0}); + // v.dataPoints.push({x:0.5,y:300}); + // data.push(v); - v = {} - v.type="line"; - v.xValueFormatString="toto"; - v.dataPoints=[{ x: 0, y: 0 }, - { x: 1, y: 100 }, - { x: 2, y: 100 }, - { x: 3, y: 200 }, - { x: 4, y: 250 }, - { x: 5, y: 300 },]; + if (players[3] != null) { + v = {} + v.type="line"; + v.xValueFormatString=players[3]; + v.dataPoints=[]; + } + // v.dataPoints.push({x:0,y:0}); + // v.dataPoints.push({x:0.5,y:300}); + // data.push(v); - data.push(v); - ///data.push(v3); console.log(data); var chart = new CanvasJS.Chart("chartContainer", { @@ -102,7 +71,7 @@ window.onload = function () { text: "Score" }, axisX: { - title: "Temps", + title: "Enigme", valueFormatString: "####", interval: 1 },