Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions Anusha015/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<!DOCTYPE html>
<html lang="en">
<head>

<title>CreateUser</title>
<meta charset= "UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="ttt.css" rel="stylesheet" type="text/css">

</head>
<script
src="http://code.jquery.com/jquery-3.3.1.js"
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
crossorigin="anonymous">
</script>


<body onload="loadData()">
<h1>Let's play TicTacToe</h1>

<div>
<form>

<h5>SELECT THE NAME OF FIRST PLAYER</h5>
<select id="playera"></select>

<h5>SELECT THE NAME OF SECOND PLAYER</h5>
<select id="playerb"></select>

<p>OR</p>
<input type="text" placeholder="NEW PLAYER" id="player">


<button class="rbtn" onclick="createuser()">Create Player</button>


</form>

<button class="rbtn" onclick="redirect()">Start Game</button>

</div>
</body>
<script>


function createuser(){
var player=document.getElementById("player").value;

var dataToSend={
"Player": player,

}

$.ajax({
url:'http://localhost:57574/api/Scoretics' ,
type: 'POST',
data: dataToSend,
dataType: 'json',
success: function(res){
console.log(res);
alert("PlAYERS CREATED");
}
});


}

function loadData(){
$.ajax({
url:'http://localhost:57574/api/Scoretics',
type:'get',
dataType:'json',
success:function(res){
$.each(res,function(i,item){
$('#playera').append($('<option>', {
value: item.Player,
text : item.Player
}));
$('#playerb').append($('<option>', {
value: item.Player,
text : item.Player
}));
})
}
});
}

function redirect(){

localStorage.setItem("Player1",playera.value);
localStorage.setItem("Player2",playerb.value);


window.location="ttt.html";}

</script>




</html>
69 changes: 69 additions & 0 deletions Anusha015/ttt.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
table,tr,th{

border: 1.75px solid black;
width: 300px;
height: 100px;
border-collapse: collapse;
background-color:darkslateblue;
}


table.center {
margin-left:auto;
margin-right:auto;
}

.block{
display: block;
border :black;
width:100%;
height:100%;
background-color:darkslateblue;
font-size:50px;
font-weight:bold;
color:whitesmoke;

}

body {
text-align: center;
background-color:bisque;
}

form{
padding: 16px;
color:darkslateblue;
font-weight:bolder;
font-size: 22px;
font-style:italic;}
.score
{
background-color: cornsilk;
width:auto;
padding: 12px;
margin: 5px 0 22px 0;
font-size: 22px;
color: black;
}

h1{
color:midnightblue;
font-style:oblique;

}

.rbtn{
font-size: 18px;
background-color:cornflowerblue;

}
.user{
border: none;
width: auto;
padding: 20px;
color:black;
font-family:cursive;
background-color:bisque;
font-size: 25px;

}
152 changes: 152 additions & 0 deletions Anusha015/ttt.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<!DOCTYPE>
<html>
<head>
<title>Tictactoe</title>
<meta charset= "UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="ttt.css" rel="stylesheet" type="text/css">
</head>
<script src ="ttt.js"></script>

<script type="text/javascript"
src="http://code.jquery.com/jquery-3.3.1.js"
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
crossorigin="anonymous">
</script>



<body onload="getplayer();">

<header>
<h1>Let's play TicTacToe</h1>
</header>

<div>
<form>
<h3>SCORE</h3>
<input type="text" placeholder="PlayerA" class="user" id="Playera">
<input type="text" class="score" id="x"/>

<br>
<input type="text" placeholder="PlayerB" class="user" id="Playerb">
<input type= "text" class="score" id="o"/>

</form>

<table class="center">
<tr>
<th><input type= "button" class ="block" id="1" onclick="xo(1)" value=" "/></th>
<th><input type= "button" class = "block" id="2"
onclick="xo(2)" value=" "/></th>
<th><input type= "button" class = "block" id="3" onclick="xo(3)" value=" "/></th>
</tr>
<tr>
<th><input type= "button" class ="block" id="4" onclick="xo(4)" value=" "/></th>
<th><input type= "button" class ="block" id="5" onclick="xo(5)" value=" "/></th>
<th><input type= "button" class ="block" id="6" onclick="xo(6)" value=" "/></th>
</tr>
<tr>
<th><input type= "button" class ="block" id="7" onclick="xo(7)" value=" " /></th>
<th><input type= "button" class ="block" id="8" onclick="xo(8)" value=" "/></th>
<th><input type= "button" class ="block" id="9" onclick="xo(9)" value=" "/></th>
</tr>


</table>
</div>
<br>
<button class="rbtn" onclick="reset();">RESET</button>

<button class="rbtn" onclick="Updatescore();">SAVE SCORES</button>



<script>

function getplayer(){
var a = localStorage.getItem("Player1");
var b = localStorage.getItem("Player2");
document.getElementById("Playera").value=a;
document.getElementById("Playerb").value=b;
getscore();
}

function getscore(){
var a = localStorage.getItem("Player1");
var b = localStorage.getItem("Player2");
$.ajax({

url:'http://localhost:57574/api/Scoretics/'+a,
type: 'GET',
dataType: 'JSON',
success: function(res){
document.getElementById('x').value = res.Score;
}

});
$.ajax({

url:'http://localhost:57574/api/Scoretics/'+b,
type: 'GET',
dataType: 'JSON',
success: function(res){
document.getElementById('o').value = res.Score;
}

});
}


function Updatescore(){


var a = localStorage.getItem("Player1");
var b = localStorage.getItem("Player2");
var scorex=document.getElementById("x").value;
var scoreo=document.getElementById("o").value;


var dataToSend1={
"Player":a,
"Score": scorex

}
$.ajax({
url:'http://localhost:57574/api/Scoretics/'+a,
type: 'PUT',
data: dataToSend1,
dataType: 'json',
success: function(res){
console.log(dataToSend1);

alert("Scores Updated");
}
});

var dataToSend2={
"Player":b,
"Score": scoreo
}

$.ajax({
url:'http://localhost:57574/api/Scoretics/'+b,
type: 'PUT',
data: dataToSend2,
dataType: 'json',
success: function(res){
console.log(dataToSend2);

alert("Scores Updated");
}
});


}


</script>

</body>

</html>
Loading