summaryrefslogtreecommitdiff
path: root/index.html
diff options
context:
space:
mode:
authorHorus2020-10-18 02:38:06 +0200
committerHorus2020-10-18 02:38:06 +0200
commit59cef9f008bad510dd9ba953f8a30291ff6f0257 (patch)
tree7a490927b0d222f189e08654ea4fec542bcb771e /index.html
parent8a6a88a42eeb7ac65f4837758820e391c0da04d3 (diff)
downloadbpm -59cef9f008bad510dd9ba953f8a30291ff6f0257.tar.gz
add logo images.
Diffstat (limited to 'index.html')
-rw-r--r--index.html86
1 files changed, 0 insertions, 86 deletions
diff --git a/index.html b/index.html
deleted file mode 100644
index 17aac81..0000000
--- a/index.html
+++ /dev/null
@@ -1,86 +0,0 @@
-<!doctype html>
-<head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <meta name="description" content="Berechnet die Preise für Pizza im Verhältnis zum Flächeninhalt. Lieber zwei kleine oder eine große Pizza kaufen?">
- <link rel='stylesheet' type='text/css' href="/css/bootstrap.min.css">
- <link rel='icon' href="https://iamfabulous.de/favicon.ico">
- <title>Beats per Minute</title>
- <style>
- html {
- width: 100%;
- }
- .main {
- margin-top: 1rem;
- }
- </style>
-</head>
-<body class="container main text-center">
- <span id="countBpm">
- <div class="jumbotron">
- <h1>Hier klicken um die BPMs zu zählen:</h1>
- <h2><span id="showBpm">0</span> BPM</h2>
- </div>
- <button class="btn btn-primary">Click</button>
- </span>
- <button id="reset" class="btn btn-secondary">Reset</button>
-
-<script>
- function median(values){
- if ( values.length === 0 ) {
- return 0;
- }
-
- values.sort(function(a,b){
- return a-b;
- });
-
- var half = Math.floor(values.length / 2);
-
- if (values.length % 2) {
- return values[half];
- }
-
- return (values[half - 1] + values[half]) / 2.0;
- }
- function reset() {
- lastClick = 0;
- bpm = [];
- document.getElementById("showBpm").innerHTML = 0;
- }
- function display(bpm) {
- /* slice() copies by value, not by reference, so the median() doesn't mess with the array */
- document.getElementById("showBpm").innerHTML = Math.round(median(bpm.slice()));
- }
- window.addEventListener("load",function() {
- var lastClick = 0;
- var bpm = [];
- document.getElementById("countBpm").addEventListener("click", function(e){
- var d = new Date();
- var t = d.getTime();
- var seconds = ( t - lastClick ) / 1000;
-
- if ( 0 != lastClick ) {
-
- if ( seconds > 10 ) {
- // reset after 10 seconds delay
- reset();
- } else {
- var _bpm = 60 / seconds
- bpm.push( _bpm );
- if ( bpm.length > 10 ) {
- // keep only last 10 clicks
- bpm.shift();
- }
- display(bpm);
- }
-
- }
- lastClick = t;
- });
- document.getElementById("reset").addEventListener("click", function(e){
- reset();
- })
- });
-</script>
-</body>