diff --git a/View/src/CSS/Admin2.css b/View/src/CSS/Admin2.css index 1f0e8b40..8fa28928 100644 --- a/View/src/CSS/Admin2.css +++ b/View/src/CSS/Admin2.css @@ -24,7 +24,7 @@ li { a { color: white; - text-decoration: none !important; + text-decoration: none; } a:hover { color: white; @@ -55,6 +55,11 @@ button { font-weight: bolder; } +.link{ + color: rgba(0, 201, 255, 1); + text-decoration: underline; +} + .current { background: rgb(146, 254, 157); background: -moz-linear-gradient( diff --git a/View/src/JS/dashboard.js b/View/src/JS/dashboard.js index 7b382577..4c6ca5ff 100644 --- a/View/src/JS/dashboard.js +++ b/View/src/JS/dashboard.js @@ -1,98 +1,108 @@ -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 }, - ] - }]*/ - - 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 }, - ] +function dashboard () { + var xhr = new XMLHttpRequest(); + xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayersEmail', true); + xhr.responseType = 'text'; + xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + var playersEmail = xhr.onload = function () { + console.log(xhr.responseText); + return JSON.parse(xhr.responseText); + }; + xhr.send(null); + 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'); + var playersPseudo = xhr.onload = function () { + return JSON.parse(xhr.responseText); } + data = []; - 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 (playersEmail[0] != null) { + v1 = {} + v1.type="line"; + v1.xValueFormatString=playersPseudo[0]; + v1.dataPoints=[]; + var xhr = new XMLHttpRequest(); + xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&joueur='. playersEmail[0], true); + xhr.responseType = 'text'; + xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + var score = xhr.onload = function () { + return JSON.parse(xhr.responseText); + }; + xhr.send(null); + for (i = 0; i < score.length; i++) { + v1.dataPoints.push({x:i+1,y:score[i]}); + } + data.push(v1); } - ///dataPoints=[{x:0,y:0},{x:1,y:300}] - - - - ///v3={type:"line",xValueFormatString:"test",dataPoints}; - - data = []; + if (playersEmail[1] != null) { + v2 = {} + v2.type="line"; + v2.xValueFormatString=playersPseudo[1]; + v2.dataPoints=[]; + var xhr = new XMLHttpRequest(); + xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&joueur='. playersEmail[1], true); + xhr.responseType = 'text'; + xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + var score = xhr.onload = function () { + return JSON.parse(xhr.responseText); + }; + xhr.send(null); + for (i = 0; i < score.length; i++) { + v2.dataPoints.push({x:i+1,y:score[i]}); + } + data.push(v2); + } - v = {} - v.type="line"; - v.xValueFormatString="test"; - v.dataPoints=[]; - v.dataPoints.push({x:0,y:0}); - v.dataPoints.push({x:0.5,y:300}); + if (playersEmail[2] != null) { + v3 = {} + v3.type="line"; + v3.xValueFormatString=playersPseudo[2]; + v3.dataPoints=[]; + var xhr = new XMLHttpRequest(); + xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&joueur='. playersEmail[2], true); + xhr.responseType = 'text'; + xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + var score = xhr.onload = function () { + return JSON.parse(xhr.responseText); + }; + xhr.send(null); + for (i = 0; i < score.length; i++) { + v3.dataPoints.push({x:i+1,y:score[i]}); + } + data.push(v3); + } - data.push(v); + if (playersEmail[3] != null) { + v4 = {} + v4.type="line"; + v4.xValueFormatString=playersPseudo[3]; + v4.dataPoints=[]; + var xhr = new XMLHttpRequest(); + xhr.open('POST', 'http://82.165.180.114/Scripted/index.php?action=getPlayerScore&joueur='. playersEmail[3], true); + xhr.responseType = 'text'; + xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + var score = xhr.onload = function () { + return JSON.parse(xhr.responseText); + }; + xhr.send(null); + for (i = 0; i < score.length; i++) { + v4.dataPoints.push({x:i+1,y:score[i]}); + } + data.push(v4); + } - 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 },]; + // data = []; - data.push(v); - ///data.push(v3); - console.log(data); + // v4 = {} + // v4.type="line"; + // v4.xValueFormatString='playersPseudo'; + // v4.dataPoints=[]; + // v4.dataPoints.push({x:1,y:100}); + // data.push(v4); + // console.log(data); var chart = new CanvasJS.Chart("chartContainer", { animationEnabled: true, @@ -102,7 +112,7 @@ text: "Score" }, axisX: { - title: "Temps", + title: "Enigme", valueFormatString: "####", interval: 1 }, @@ -120,4 +130,11 @@ data }); chart.render(); - } \ No newline at end of file +} + +window.addEventListener("load", start); +function start(){ + dashboard(); + setInterval('dashboard()', 10000); + +} diff --git a/View/src/pages/Admin/DetailEnigme.php b/View/src/pages/Admin/DetailEnigme.php index 6997e29c..f6dc9894 100644 --- a/View/src/pages/Admin/DetailEnigme.php +++ b/View/src/pages/Admin/DetailEnigme.php @@ -94,16 +94,16 @@