diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..215a0d2 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: ['https://deinserverhost.de/store/aff.php?aff=4224'] diff --git a/README.md b/README.md index 558f8a7..77b485a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,18 @@ -# CPS-Clicktest -Just a CPS Clicktest. - -# You wanna know how many CPS do you get? -Then [click here](https://example.com/)! - - + +![GitHub package.json version](https://img.shields.io/github/package-json/v/InvalidLenni/CPS-clicktest?style=for-the-badge) +![GitHub issues](https://img.shields.io/github/issues/InvalidLenni/CPS-clicktest?style=for-the-badge) + + + +# Just a CPS Clickertest + +This is the source code of [CPS Clicktest](https://cps-clicktest.vercel.app/). + +## You found Issues? + +Report them [there](https://github.com/InvalidLenni/CPS-Clicktest/issues/new). + +## Thanks to + +- Vercel *-* for hosting. +- Shields *-* for the badges. diff --git a/footer.php b/footer.php new file mode 100644 index 0000000..2bfa863 --- /dev/null +++ b/footer.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/index.html b/index.html index 5760fe4..a7a0fc6 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ - + @@ -13,85 +13,20 @@ - - - + + - - - + + + - - CPS Clicker + CPS Clicktest -

@@ -100,91 +35,100 @@ Score:
Clicks/s: +
+
- - + + diff --git a/package.json b/package.json index 95e7f8b..4728083 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cpsclicktest", "description": "Just a CPS Clicktest.", - "version": "1.0.0", + "version": "1.0.1", "author": { "name": "InvalidLenni", "email": "contact@invalidlenni.de", diff --git a/scripts/cps.js b/scripts/cps.js new file mode 100644 index 0000000..3f1b1aa --- /dev/null +++ b/scripts/cps.js @@ -0,0 +1,57 @@ +var score; +var startTime; +var ended = true; +var durationInP = document.getElementById("durationInP"); +var duration = int(durationInP()); +var timerTxt = document.getElementById("timer"); +var scoreTxt = document.getElementById("score"); +var clicksTxt = document.getElementById("clicks"); +var startBtn = document.getElementById("start"); +var clickArea = document.getElementById("clickarea"); +var show = function(elem) { + elem.style.display = 'inline'; +}; +var hide = function(elem) { + elem.style.display = 'none'; +}; +function startGame() { + hide(startBtn); + hide(durationInP) + score = -1; + ended = false; + startTime = new Date().getTime(); + var timerId = setInterval(function() { + var total = (new Date().getTime() - startTime) / 1000; + console.log(total) + if (total < duration) { + timerTxt.textContent = total.toFixed(3); + clicksTxt.textContent = (score / total).toFixed(2); + } else { + ended = true; + clearInterval(timerId); + endGame(); + } + }, 1); +} + +function endGame() { +var clicsBySeconds = (score / durationInP).toFixed(2); +timerTxt.textContent = durationInP.toFixed(3); +clicksTxt.textContent = clicsBySeconds; +show(startBtn); +show(durationInP) +setTimeout(function() { + alert('You made ' + score + ' clicks in ' + durationInP + + ' seconds. It is ' + clicsBySeconds + + ' clicks by seconds. Try again!'); +}, 10); +} +startBtn.addEventListener("click", function(e) { +startGame(); +}); +clickArea.addEventListener("click", function(e) { +if (!ended) { + score++; + scoreTxt.textContent = score; +} +}); diff --git a/scripts/sw.js b/scripts/sw.js new file mode 100644 index 0000000..1f058c8 --- /dev/null +++ b/scripts/sw.js @@ -0,0 +1,7 @@ +importScripts('https://arc.io/arc-sw-core.js') +importScripts('https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js'); + +workbox.routing.registerRoute( + /.*/, + new workbox.strategies.NetworkFirst() +); \ No newline at end of file