Fixed Scoreboard

This commit is contained in:
Yaman 2015-07-08 03:08:33 -04:00
parent 3bc4dbb765
commit bb98c7a82f
2 changed files with 83 additions and 48 deletions

View File

@ -1,44 +1,63 @@
@font-face {
font-family: 'Lato';
src: url('../static/resources/fonts/lato-light.woff');
font-family: 'Lato';
src: url('../static/resources/fonts/lato-light.woff');
}
html {
background-image: url("../static/resources/images/bg.png")
}
td {
min-width: 100px;
height: 100px;
background-color: #2C3134;
transition: background-color 2s ease;
}
.player {
transition: background-color 0s ease
}
.main {
margin-left:40%;
margin-right:40%;
margin-top: 10%;
min-width:20%;
min-height:60%;
background:#e7e7e7;
box-shadow: 5px 5px 10px #229ad2;
border-radius: 25px;
}
.form {
font-family: Lato;
font-size: 20px;
margin-left:5%;
}
.scoreboard {
font-family: Lato;
font-size: 20px;
color: #ffffff;
position: fixed;
padding: 5px 10px 5px 10px;
margin-left: 45%;
margin-right: 45%;
z-index: 1;
background-color: #000;
opacity: 0.7;
html {
background-image: url("../static/resources/images/bg.png");
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
}
td {
min-width: 100px;
height: 100px;
background-color: #2C3134;
transition: background-color 2s ease;
}
.player {
transition: background-color 0s ease;
}
.main {
margin-left:40%;
margin-right:40%;
margin-top: 10%;
min-width:20%;
min-height:60%;
background:#e7e7e7;
box-shadow: 5px 5px 10px #229ad2;
border-radius: 25px;
}
.form {
font-family: Lato;
font-size: 20px;
margin-left:5%;
}
.scoreboard {
font-family: Lato;
font-size: 20px;
color: #ffffff;
position: fixed;
padding: 5px 10px 5px 10px;
margin-left: 45%;
margin-right: 45%;
z-index: 1;
background-color: #000;
opacity: 0.7;
}
#redscore {
color: #E62E2E;
background-color: #E62E2E;
}
#bluescore {
color: #4343D8;
background-color: #4343D8;
}

View File

@ -39,11 +39,7 @@ document.getElementsByClassName('play')[0].onclick = function startGame() {
var login = document.getElementById("login");
login.parentNode.removeChild(login);
var scoreboard = document.getElementsByTagName('body')[0].appendChild(document.createElement("DIV"));
scoreboard.className = 'scoreboard';
scoreboard.appendChild(document.createTextNode(""));
scoreboard.appendChild(document.createElement("BR"));
scoreboard.appendChild(document.createTextNode(""));
scoreboardCreate();
updateScore();
tableCreate();
createPlayer();
@ -85,7 +81,27 @@ function serverTransfer(coordinate,team,turn,username) {
);
}
// Creation of Table
// Creation of Scoreboard
function scoreboardCreate() {
var scoreboard = document.getElementsByTagName('body')[0].appendChild(document.createElement("DIV"));
scoreboard.className = 'scoreboard';
var redScore = scoreboard.appendChild(document.createElement("SPAN"));
redScore.id = "redscore";
var redNumber = scoreboard.appendChild(document.createElement("SPAN"));
redNumber.id = "rednumber";
redScore.appendChild(document.createTextNode("___"));
redNumber.appendChild(document.createTextNode(""));
scoreboard.appendChild(document.createElement("BR"));
var blueScore = scoreboard.appendChild(document.createElement("SPAN"));
blueScore.id = "bluescore";
var blueNumber = scoreboard.appendChild(document.createElement("SPAN"));
blueNumber.id = "bluenumber";
blueScore.appendChild(document.createTextNode("___"));
blueNumber.appendChild(document.createTextNode(""));
}
// Creation of Table
function tableCreate() {
var body = document.body
@ -189,6 +205,6 @@ function updateScore() {
document.getElementsByClassName('red').length,
document.getElementsByClassName('blue').length
];
document.getElementsByClassName('scoreboard')[0].childNodes[0].nodeValue = "Red: " + score[0];
document.getElementsByClassName('scoreboard')[0].childNodes[2].nodeValue = "Blue: " + score[1];
document.getElementById('rednumber').childNodes[0].nodeValue = " : " + score[0];
document.getElementById('bluenumber').childNodes[0].nodeValue = " : " + score[1];
}