MTG localstorage player count
This commit is contained in:
parent
7ac4b3b806
commit
74d6a4fa69
BIN
MTG/icons/mstile-150x150.png
Normal file
BIN
MTG/icons/mstile-150x150.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.6 KiB |
259
MTG/index.html
259
MTG/index.html
@ -12,142 +12,10 @@
|
||||
<meta name="msapplication-TileColor" content="#da532c">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
<title>MTG Life Counter</title>
|
||||
<style>
|
||||
*, *:after, *:before {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
body{
|
||||
background-color: darkslategray;
|
||||
}
|
||||
main{
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
#name{
|
||||
font-size: xx-large;
|
||||
display: flex;
|
||||
margin: 0 0 20px;
|
||||
padding: 10px 0;
|
||||
opacity: 0.9;
|
||||
background-color: #EEE;
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #EEE), color-stop(100%, #CCC));
|
||||
background-image: -webkit-linear-gradient(top, #EEE, #AAA);
|
||||
background-image: -moz-linear-gradient(top, #EEE, #AAA);
|
||||
background-image: -ms-linear-gradient(top, #EEE, #AAA);
|
||||
background-image: -o-linear-gradient(top, #EEE, #AAA);
|
||||
background-image: linear-gradient(top, #EEE, #AAA);
|
||||
border: 1px solid #999;
|
||||
border-bottom: 1px solid #BBB;
|
||||
-webkit-border-radius: 30px;
|
||||
-moz-border-radius: 30px;
|
||||
border-radius: 30px;
|
||||
text-shadow: 0 1px 0 #EEE;
|
||||
background-color: #EEE;
|
||||
width: 400px;
|
||||
justify-content: center;
|
||||
}
|
||||
.life{
|
||||
opacity: 0.9;
|
||||
background-color: #EEE;
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #EEE), color-stop(100%, #CCC));
|
||||
background-image: -webkit-linear-gradient(top, #EEE, #AAA);
|
||||
background-image: -moz-linear-gradient(top, #EEE, #AAA);
|
||||
background-image: -ms-linear-gradient(top, #EEE, #AAA);
|
||||
background-image: -o-linear-gradient(top, #EEE, #AAA);
|
||||
background-image: linear-gradient(top, #EEE, #AAA);
|
||||
border: 1px solid #999;
|
||||
border-bottom: 1px solid #BBB;
|
||||
-webkit-border-radius: 30px;
|
||||
-moz-border-radius: 30px;
|
||||
border-radius: 30px;
|
||||
color: #333;
|
||||
padding: 8px 0;
|
||||
text-shadow: 0 1px 0 #EEE;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 300px;
|
||||
font-size: 5rem;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.player{
|
||||
padding: 20px
|
||||
}
|
||||
|
||||
.buttons-left{
|
||||
display: block;
|
||||
font-size: 3em;
|
||||
line-height: 1.3em;
|
||||
text-align: center;
|
||||
height: 65px;
|
||||
width: 65px;
|
||||
position: fixed;
|
||||
bottom: 0px;
|
||||
left: 0px;
|
||||
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif;
|
||||
color: #333;
|
||||
text-shadow: 0 1px 0 #EEE;
|
||||
opacity: 0.2;
|
||||
background-color: #EEE;
|
||||
user-select: none;
|
||||
-webkit-border-top-right-radius: 30px;
|
||||
-moz-border-radius-topright: 30px;
|
||||
border-top-right-radius: 30px;
|
||||
}
|
||||
.buttons-right{
|
||||
display: block;
|
||||
font-size: 3em;
|
||||
line-height: 1.3em;
|
||||
text-align: center;
|
||||
height: 65px;
|
||||
width: 65px;
|
||||
position: fixed;
|
||||
bottom: 0px;
|
||||
right: 0px;
|
||||
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif;
|
||||
color: #333;
|
||||
text-shadow: 0 1px 0 #EEE;
|
||||
opacity: 0.2;
|
||||
background-color: #EEE;
|
||||
user-select: none;
|
||||
-webkit-border-top-left-radius: 30px;
|
||||
-moz-border-radius-topleft: 30px;
|
||||
border-top-left-radius: 30px;
|
||||
}
|
||||
|
||||
.buttons-top{
|
||||
display: block;
|
||||
font-size: 3em;
|
||||
line-height: 1.3em;
|
||||
text-align: center;
|
||||
height: 65px;
|
||||
width: 65px;
|
||||
position: fixed;
|
||||
top: 0px;
|
||||
right: 0px;
|
||||
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif;
|
||||
color: #333;
|
||||
text-shadow: 0 1px 0 #EEE;
|
||||
opacity: 0.2;
|
||||
background-color: #EEE;
|
||||
user-select: none;
|
||||
-webkit-border-bottom-left-radius: 30px;
|
||||
-moz-border-radius-bottomleft: 30px;
|
||||
border-bottom-left-radius: 30px;
|
||||
}
|
||||
#lifeCount{
|
||||
padding: 10px
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div onclick="removePlayer()" id="removePlayer" class="buttons-top">−</div>
|
||||
<div id="player1" class="player">
|
||||
<div id="name" contenteditable="true">
|
||||
Player 1</div>
|
||||
@ -225,128 +93,13 @@ padding: 10px
|
||||
|
||||
|
||||
</main>
|
||||
<div onclick="reset()" id="reset" class="buttons-left">↺</div>
|
||||
<div id="buttonWrapper">
|
||||
<div onclick="removePlayer()" id="removePlayer" class="buttons-left">−</div>
|
||||
<div onclick="reset()" id="reset" class="buttons-middle">↺</div>
|
||||
<div onclick="addPlayer()" id="addPlayer" class="buttons-right">+</div>
|
||||
|
||||
<script>
|
||||
for (i=2; i<9; i++){document.getElementById("player"+i).style.display = "none" }
|
||||
const startLife = 20;
|
||||
var playerCount = 1;
|
||||
let lifeIncrease1 = () => {
|
||||
let counter = Number(this.document.getElementById("lifeCount1").innerHTML);
|
||||
counter++;
|
||||
document.getElementById("lifeCount1").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeDecrease1 = () => {
|
||||
let counter = Number(document.getElementById("lifeCount1").innerHTML);
|
||||
counter--;
|
||||
document.getElementById("lifeCount1").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeIncrease2 = () => {
|
||||
let counter = Number(this.document.getElementById("lifeCount2").innerHTML);
|
||||
counter++;
|
||||
document.getElementById("lifeCount2").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeDecrease2 = () => {
|
||||
let counter = Number(document.getElementById("lifeCount2").innerHTML);
|
||||
counter--;
|
||||
document.getElementById("lifeCount2").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeIncrease3 = () => {
|
||||
let counter = Number(this.document.getElementById("lifeCount3").innerHTML);
|
||||
counter++;
|
||||
document.getElementById("lifeCount3").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeDecrease3 = () => {
|
||||
let counter = Number(document.getElementById("lifeCount3").innerHTML);
|
||||
counter--;
|
||||
document.getElementById("lifeCount3").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeIncrease4 = () => {
|
||||
let counter = Number(this.document.getElementById("lifeCount4").innerHTML);
|
||||
counter++;
|
||||
document.getElementById("lifeCount4").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeDecrease4 = () => {
|
||||
let counter = Number(document.getElementById("lifeCount4").innerHTML);
|
||||
counter--;
|
||||
document.getElementById("lifeCount4").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeIncrease5 = () => {
|
||||
let counter = Number(this.document.getElementById("lifeCount5").innerHTML);
|
||||
counter++;
|
||||
document.getElementById("lifeCount5").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeDecrease5 = () => {
|
||||
let counter = Number(document.getElementById("lifeCount5").innerHTML);
|
||||
counter--;
|
||||
document.getElementById("lifeCount5").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeIncrease6 = () => {
|
||||
let counter = Number(this.document.getElementById("lifeCount6").innerHTML);
|
||||
counter++;
|
||||
document.getElementById("lifeCount6").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeDecrease6 = () => {
|
||||
let counter = Number(document.getElementById("lifeCount6").innerHTML);
|
||||
counter--;
|
||||
document.getElementById("lifeCount6").innerHTML = counter;
|
||||
};
|
||||
let lifeIncrease7 = () => {
|
||||
let counter = Number(this.document.getElementById("lifeCount7").innerHTML);
|
||||
counter++;
|
||||
document.getElementById("lifeCount7").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeDecrease7 = () => {
|
||||
let counter = Number(document.getElementById("lifeCount7").innerHTML);
|
||||
counter--;
|
||||
document.getElementById("lifeCount7").innerHTML = counter;
|
||||
};
|
||||
let lifeIncrease8 = () => {
|
||||
let counter = Number(this.document.getElementById("lifeCount8").innerHTML);
|
||||
counter++;
|
||||
document.getElementById("lifeCount8").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeDecrease8 = () => {
|
||||
let counter = Number(document.getElementById("lifeCount8").innerHTML);
|
||||
counter--;
|
||||
document.getElementById("lifeCount8").innerHTML = counter;
|
||||
};
|
||||
let reset = () => {
|
||||
for (i=1; i<9; i++){
|
||||
document.getElementById("lifeCount"+i).innerHTML = 20
|
||||
}
|
||||
</div>
|
||||
|
||||
}
|
||||
|
||||
let addPlayer = () => {
|
||||
if (playerCount != 8){
|
||||
playerCount++;
|
||||
document.getElementById("player"+playerCount).style.display = "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let removePlayer = () => {
|
||||
if (playerCount != 1){
|
||||
document.getElementById("player"+playerCount).style.display = "none";
|
||||
playerCount--;
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
134
MTG/script.js
Normal file
134
MTG/script.js
Normal file
@ -0,0 +1,134 @@
|
||||
window.onunload = function(){
|
||||
localStorage.setItem('playerCount', playerCount)
|
||||
};
|
||||
window.onload = function(){
|
||||
localStorage.getItem('playerCount')
|
||||
};
|
||||
|
||||
|
||||
|
||||
const startLife = 20;
|
||||
let playerCount;
|
||||
if (!localStorage.getItem('playerCount')) {playerCount = 1; localStorage.setItem('playerCount', playerCount);}
|
||||
playerCount = localStorage.getItem('playerCount');
|
||||
let playerCount1 = Number(playerCount)+1;
|
||||
for (i=playerCount1; i<9; i++){document.getElementById("player"+i).style.display = "none" }
|
||||
|
||||
let lifeIncrease1 = () => {
|
||||
let counter = Number(this.document.getElementById("lifeCount1").innerHTML);
|
||||
counter++;
|
||||
document.getElementById("lifeCount1").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeDecrease1 = () => {
|
||||
let counter = Number(document.getElementById("lifeCount1").innerHTML);
|
||||
counter--;
|
||||
document.getElementById("lifeCount1").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeIncrease2 = () => {
|
||||
let counter = Number(this.document.getElementById("lifeCount2").innerHTML);
|
||||
counter++;
|
||||
document.getElementById("lifeCount2").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeDecrease2 = () => {
|
||||
let counter = Number(document.getElementById("lifeCount2").innerHTML);
|
||||
counter--;
|
||||
document.getElementById("lifeCount2").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeIncrease3 = () => {
|
||||
let counter = Number(this.document.getElementById("lifeCount3").innerHTML);
|
||||
counter++;
|
||||
document.getElementById("lifeCount3").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeDecrease3 = () => {
|
||||
let counter = Number(document.getElementById("lifeCount3").innerHTML);
|
||||
counter--;
|
||||
document.getElementById("lifeCount3").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeIncrease4 = () => {
|
||||
let counter = Number(this.document.getElementById("lifeCount4").innerHTML);
|
||||
counter++;
|
||||
document.getElementById("lifeCount4").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeDecrease4 = () => {
|
||||
let counter = Number(document.getElementById("lifeCount4").innerHTML);
|
||||
counter--;
|
||||
document.getElementById("lifeCount4").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeIncrease5 = () => {
|
||||
let counter = Number(this.document.getElementById("lifeCount5").innerHTML);
|
||||
counter++;
|
||||
document.getElementById("lifeCount5").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeDecrease5 = () => {
|
||||
let counter = Number(document.getElementById("lifeCount5").innerHTML);
|
||||
counter--;
|
||||
document.getElementById("lifeCount5").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeIncrease6 = () => {
|
||||
let counter = Number(this.document.getElementById("lifeCount6").innerHTML);
|
||||
counter++;
|
||||
document.getElementById("lifeCount6").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeDecrease6 = () => {
|
||||
let counter = Number(document.getElementById("lifeCount6").innerHTML);
|
||||
counter--;
|
||||
document.getElementById("lifeCount6").innerHTML = counter;
|
||||
};
|
||||
let lifeIncrease7 = () => {
|
||||
let counter = Number(this.document.getElementById("lifeCount7").innerHTML);
|
||||
counter++;
|
||||
document.getElementById("lifeCount7").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeDecrease7 = () => {
|
||||
let counter = Number(document.getElementById("lifeCount7").innerHTML);
|
||||
counter--;
|
||||
document.getElementById("lifeCount7").innerHTML = counter;
|
||||
};
|
||||
let lifeIncrease8 = () => {
|
||||
let counter = Number(this.document.getElementById("lifeCount8").innerHTML);
|
||||
counter++;
|
||||
document.getElementById("lifeCount8").innerHTML = counter;
|
||||
};
|
||||
|
||||
let lifeDecrease8 = () => {
|
||||
let counter = Number(document.getElementById("lifeCount8").innerHTML);
|
||||
counter--;
|
||||
document.getElementById("lifeCount8").innerHTML = counter;
|
||||
};
|
||||
let reset = () => {
|
||||
for (i=1; i<9; i++){
|
||||
document.getElementById("lifeCount"+i).innerHTML = 20
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let addPlayer = () => {
|
||||
if (playerCount != 8){
|
||||
playerCount++;
|
||||
document.getElementById("player"+playerCount).style.display = "";
|
||||
localStorage.setItem('playerCount', playerCount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let removePlayer = () => {
|
||||
if (playerCount != 1){
|
||||
document.getElementById("player"+playerCount).style.display = "none";
|
||||
playerCount--;
|
||||
localStorage.setItem('playerCount', playerCount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
140
MTG/style.css
Normal file
140
MTG/style.css
Normal file
@ -0,0 +1,140 @@
|
||||
*, *:after, *:before {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
body{
|
||||
background-color: darkslategray;
|
||||
width:100vw;
|
||||
height: 100vhs;
|
||||
}
|
||||
main{
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
#name{
|
||||
font-size: xx-large;
|
||||
display: flex;
|
||||
margin: 0 0 20px;
|
||||
padding: 10px 0;
|
||||
opacity: 0.9;
|
||||
background-color: #EEE;
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #EEE), color-stop(100%, #CCC));
|
||||
background-image: -webkit-linear-gradient(top, #EEE, #AAA);
|
||||
background-image: -moz-linear-gradient(top, #EEE, #AAA);
|
||||
background-image: -ms-linear-gradient(top, #EEE, #AAA);
|
||||
background-image: -o-linear-gradient(top, #EEE, #AAA);
|
||||
background-image: linear-gradient(top, #EEE, #AAA);
|
||||
border: 1px solid #999;
|
||||
border-bottom: 1px solid #BBB;
|
||||
-webkit-border-radius: 30px;
|
||||
-moz-border-radius: 30px;
|
||||
border-radius: 30px;
|
||||
text-shadow: 0 1px 0 #EEE;
|
||||
background-color: #EEE;
|
||||
width: 400px;
|
||||
justify-content: center;
|
||||
}
|
||||
.life{
|
||||
opacity: 0.9;
|
||||
background-color: #EEE;
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #EEE), color-stop(100%, #CCC));
|
||||
background-image: -webkit-linear-gradient(top, #EEE, #AAA);
|
||||
background-image: -moz-linear-gradient(top, #EEE, #AAA);
|
||||
background-image: -ms-linear-gradient(top, #EEE, #AAA);
|
||||
background-image: -o-linear-gradient(top, #EEE, #AAA);
|
||||
background-image: linear-gradient(top, #EEE, #AAA);
|
||||
border: 1px solid #999;
|
||||
border-bottom: 1px solid #BBB;
|
||||
-webkit-border-radius: 30px;
|
||||
-moz-border-radius: 30px;
|
||||
border-radius: 30px;
|
||||
color: #333;
|
||||
padding: 8px 0;
|
||||
text-shadow: 0 1px 0 #EEE;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 50%;
|
||||
font-size: 5rem;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.player{
|
||||
padding: 20px
|
||||
}
|
||||
|
||||
.buttons-left{
|
||||
|
||||
font-size: 3em;
|
||||
line-height: 1.3em;
|
||||
text-align: center;
|
||||
height: 65px;
|
||||
width: 100%;
|
||||
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif;
|
||||
color: #333;
|
||||
text-shadow: 0 1px 0 #EEE;
|
||||
opacity: 0.2;
|
||||
background-color: #EEE;
|
||||
user-select: none;
|
||||
-webkit-border-top-left-radius: 30px;
|
||||
-moz-border-radius-topleft: 30px;
|
||||
border-top-left-radius: 30px;
|
||||
-webkit-border-top-right-radius: 30px;
|
||||
-moz-border-radius-topright: 30px;
|
||||
border-top-right-radius: 30px;
|
||||
}
|
||||
.buttons-right{
|
||||
|
||||
font-size: 3em;
|
||||
line-height: 1.3em;
|
||||
text-align: center;
|
||||
height: 65px;
|
||||
width: 100%;
|
||||
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif;
|
||||
color: #333;
|
||||
text-shadow: 0 1px 0 #EEE;
|
||||
opacity: 0.2;
|
||||
background-color: #EEE;
|
||||
user-select: none;
|
||||
-webkit-border-top-left-radius: 30px;
|
||||
-moz-border-radius-topleft: 30px;
|
||||
border-top-left-radius: 30px;
|
||||
-webkit-border-top-right-radius: 30px;
|
||||
-moz-border-radius-topright: 30px;
|
||||
border-top-right-radius: 30px;
|
||||
}
|
||||
.buttons-middle{
|
||||
|
||||
font-size: 3em;
|
||||
line-height: 1.3em;
|
||||
text-align: center;
|
||||
height: 65px;
|
||||
width: 100%;
|
||||
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif;
|
||||
color: #333;
|
||||
text-shadow: 0 1px 0 #EEE;
|
||||
opacity: 0.2;
|
||||
background-color: #EEE;
|
||||
user-select: none;
|
||||
-webkit-border-top-left-radius: 30px;
|
||||
-moz-border-radius-topleft: 30px;
|
||||
border-top-left-radius: 30px;
|
||||
-webkit-border-top-right-radius: 30px;
|
||||
-moz-border-radius-topright: 30px;
|
||||
border-top-right-radius: 30px;
|
||||
|
||||
}
|
||||
#buttonWrapper{
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
}
|
||||
#lifeCount{
|
||||
padding: 10px;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user