Version - 1 - 1-38
This commit is contained in:
30
Version - 10/index.html
Normal file
30
Version - 10/index.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<title>HTML</title>
|
||||
|
||||
<!-- HTML -->
|
||||
|
||||
<!-- By MrEidamus & Stanislav Chlup -->
|
||||
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="button1">
|
||||
<img src = "https://i.postimg.cc/rdJG75gD/Pressed.png" id="green">
|
||||
<img src = "https://i.postimg.cc/rdcChfG6/Notpressed.png" id="red">
|
||||
</div>
|
||||
<script src="main.js"></script>
|
||||
<p id="clicks"></p>
|
||||
<p id="dogs"></p>
|
||||
<button id="Reset" onclick="reset()">Reset</button>
|
||||
|
||||
<button id="Bog" onclick="dog()">Dog - 100 clicks!</button>
|
||||
<button id="BigBog" onclick="bigdog()">10 dogs - 1000 clicks!</button>
|
||||
</body>
|
||||
</html>
|
||||
96
Version - 10/main.js
Normal file
96
Version - 10/main.js
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
window.onload = function(){
|
||||
start();
|
||||
}
|
||||
var count = 0;
|
||||
function start(){
|
||||
if (localStorage.getItem('count')==undefined){
|
||||
count=0;
|
||||
}
|
||||
else{
|
||||
count = localStorage.getItem('count');
|
||||
}
|
||||
|
||||
if (localStorage.getItem('dogs')==undefined){
|
||||
dogs=0;
|
||||
}
|
||||
else{
|
||||
dogs = localStorage.getItem('dogs');
|
||||
}
|
||||
|
||||
document.getElementById('clicks').innerHTML='Congratulation you\'ve clicked ' + count + ' times!';
|
||||
|
||||
document.getElementById('dogs').innerHTML='Congratulations you got ' + dogs + ' dogs!';
|
||||
|
||||
var red = document.getElementById('red');
|
||||
var green = document.getElementById('green');
|
||||
var button = document.getElementById('button1');
|
||||
if (/Android|iPhone/i.test(navigator.userAgent)) {
|
||||
|
||||
button.ontouchstart = function(){
|
||||
count++;
|
||||
localStorage.setItem('count',count);
|
||||
document.getElementById('clicks').innerHTML='Congratulation you\'ve clicked ' + count + ' times!';
|
||||
red.style.visibility='hidden';
|
||||
green.style.visibility='visible';
|
||||
}
|
||||
button.ontouchend = function(){
|
||||
red.style.visibility='visible';
|
||||
green.style.visibility='hidden';
|
||||
}
|
||||
}else{
|
||||
button.onmousedown = function(){
|
||||
console.log('click');
|
||||
count++;
|
||||
localStorage.setItem('count',count);
|
||||
document.getElementById('clicks').innerHTML=
|
||||
'Congratulation you\'ve clicked ' + count + ' times!';
|
||||
|
||||
red.style.visibility='hidden';
|
||||
green.style.visibility='visible';
|
||||
}
|
||||
button.onmouseup = function(){
|
||||
red.style.visibility='visible';
|
||||
green.style.visibility='hidden'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function reset(){
|
||||
localStorage.removeItem('count');
|
||||
localStorage.removeItem('dogs')
|
||||
alert('Clicks and dogs successfully reseted!')
|
||||
start();
|
||||
}
|
||||
|
||||
var dogs=0;
|
||||
|
||||
function dog(){
|
||||
if(count>=100){
|
||||
count -= 100;
|
||||
dogs++
|
||||
alert('Congratulations you\'ve bought a dog🐕');
|
||||
localStorage.setItem('dogs',dogs);
|
||||
document.getElementById('dogs').innerHTML='Congratulations you got ' + dogs + ' dogs!';
|
||||
}
|
||||
else{
|
||||
alert('You don\' have enough clicks!');
|
||||
alert('Tip: Click the button')
|
||||
}
|
||||
}
|
||||
|
||||
function bigdog(){
|
||||
if(count >=1000){
|
||||
count -= 1000;
|
||||
|
||||
dogs++
|
||||
|
||||
alert('Congratulations you\'ve bought 10 dogs!')
|
||||
localStorage.setItem('dogs' ,dogs);
|
||||
document.getElementById('dogs').innerHTML='Congratulations you got ' + dogs + ' dogs!';
|
||||
}
|
||||
else{
|
||||
alert('You don\'t have enough click! Try clicking the button');
|
||||
}
|
||||
}
|
||||
42
Version - 10/style.css
Normal file
42
Version - 10/style.css
Normal file
@@ -0,0 +1,42 @@
|
||||
body {
|
||||
font-size: 15pt;
|
||||
}
|
||||
#red{
|
||||
position: absolute;
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
|
||||
|
||||
}
|
||||
#green{
|
||||
position: absolute;
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
visibility: hidden;
|
||||
}
|
||||
#button1{
|
||||
user-select: none;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
margin: -150px 0 0 -150px;
|
||||
}
|
||||
#Reset{
|
||||
user-select: none;
|
||||
width: 75px;
|
||||
height: 50px;
|
||||
background-color: darkred;
|
||||
color: #ffffff;
|
||||
}
|
||||
#Bog{
|
||||
user-select: none;
|
||||
width: 110px;
|
||||
height: 50px;
|
||||
background-color: wheat;
|
||||
}
|
||||
#BigBog{
|
||||
user-select: none;
|
||||
width: 135px;
|
||||
height: 50px;
|
||||
background-color: wheat;
|
||||
}
|
||||
Reference in New Issue
Block a user