add simple counter via localStorage

This commit is contained in:
Alexander Mahr 2024-12-29 20:42:53 +01:00
parent 444b92d1e7
commit be0786db68

View file

@ -4,50 +4,37 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta content="width=device-width,initial-scale=1.0" name="viewport"> <meta content="width=device-width,initial-scale=1.0" name="viewport">
</head> </head>
<style> <style>
@keyframes wobble { @keyframes wobble {
0% { 0% {
transform: scale(0.1); transform: scale(0.1);
/* transform: rotate(-5deg); opacity:0.0
transform: rotate(5deg);*/
opacity:0.0
} }
22% { 100% {
transform: scale(2.0);
/*/ transform: rotate(-5deg);*/
opacity:1.0
}
99% {
transform: scale(1.0); transform: scale(1.0);
/*/ transform: rotate(-5deg);*/ opacity:1.0
opacity:0.0
} }
} }
</style> </style>
<body style=" background: radial-gradient(#111, #000);"> <body>
<h1> SUPER</h1> <h1>Webview</h1>
<script> <script>
var count=0; window.addEventListener("error",(error)=>{
window.addEventListener("load",()=>{ document.body.innerHTML = "<h1>error</h1><pre>" +
function insert(){ error.filename +
count++; "\nline:" + error.lineno +
var h2 = document.createElement("h2"); "\n"+error.message +"</pre>";
h2.textContent=" "+ count + ". javascript works" },false);
h2.style.color="#"+Math.random().toString(16).slice(3,9);
// h2.style.transform="rotate("+((Math.random()*3600)|0)/10+"deg)";
h2.style.fontSize=""+Math.random()*20+"pt";
h2.style.textAlign="center";
h2.style.animation="wobble 5s ease-in-out infinite alternate"
document.body.insertBefore(h2,document.body.children[(document.body.children.length*Math.random())|0])
// h2.scrollIntoView({"behavior":"smooth"});
if(document.body.children.length>15){
document.body.children[(document.body.children.length*Math.random())|0].remove();
}
setTimeout(()=>{window.requestAnimationFrame(insert);},100);
} window.addEventListener("load",()=>{
insert(); var count = localStorage.getItem("app-opened-count")|| 0;
},false); count++;
</script> localStorage.setItem("app-opened-count",count);
var h2 = document.createElement("h2");
h2.textContent = "Javascript works! (app was opened " + count + " times)";
h2.style.animation="wobble 1s ease-in-out 0s 1 forwards normal running"
document.body.appendChild(h2);
},false);
</script>
</body> </body>
</html> </html>