Skip to content

Commit 59e1843

Browse files
committed
Autosave, autoload and cryptomining
1 parent d681ad3 commit 59e1843

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

index.html

+4-5
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
</head>
99

1010
<body>
11-
<h1>Jeff's Bingo</h1>
11+
<h1>Jeff's Bingo (Now with autosave)</h1>
12+
13+
<ul id="bingo"></ul>
1214

1315
<nav>
1416
<button id="newgrid" onclick="randomLoad()">Random card</button>
1517
</nav>
1618

17-
<ul id="bingo"></ul>
18-
19-
2019
<script type="text/javascript" src="./textFit.min.js"></script>
2120
<script type="text/javascript" src="./tailwind.js"></script>
2221
<script type="application/json" id="bingodata">
@@ -59,7 +58,7 @@ <h1>Jeff's Bingo</h1>
5958
]
6059
</script>
6160
<script type="text/javascript">
62-
randomLoad()
61+
loadBingo()
6362
</script>
6463
</body>
6564
</html>

tailwind.css

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ nav > button {
2121
border-radius: 15px;
2222
}
2323

24+
#autosave {
25+
text-align: center;
26+
color: white;
27+
font-size: 3rem;
28+
background-color: rgba(0,0,0,0.5);
29+
}
30+
2431
#bingo {
2532
--cell-size: 10rem;
2633
list-style: none;
@@ -48,7 +55,6 @@ nav > button {
4855
background-size: 215%;
4956
background-position: center;
5057
}
51-
5258
#bingo > li.active {
5359
background-image: url('stamp.png');
5460
background-size: contain;

tailwind.js

+24-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,29 @@ function randomLoad(){
1212
li.innerText = s;
1313
bingo.appendChild(li);
1414
textFit(li, {alignHoriz: true, alignVert: true, multiLine: true, alignVertWithFlexbox: true});
15-
li.addEventListener("click", function(){this.classList.toggle("active")})
15+
li.addEventListener(
16+
"click",
17+
toggleBingoCell
18+
)
1619
});
20+
storeBingo()
21+
}
22+
23+
function toggleBingoCell(){
24+
this.classList.toggle("active")
25+
storeBingo()
26+
}
27+
28+
function storeBingo(){
29+
localStorage.setItem("bingo", document.querySelector("#bingo").innerHTML)
30+
}
31+
32+
function loadBingo(){
33+
let bingo = localStorage.getItem("bingo")
34+
// If we don't run textFit first the css they add is not loaded, and we don't have css for .textFitAlignVertFlex
35+
randomLoad() // The user won't notice we load a random bingo first
36+
if (bingo) {
37+
document.querySelector("#bingo").innerHTML = bingo
38+
document.querySelectorAll('#bingo > li').forEach((e) => e.addEventListener("click", toggleBingoCell))
39+
}
1740
}

0 commit comments

Comments
 (0)