Skip to content

Commit

Permalink
feat: Revert "feat: sine wave!"
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the applause button now sends clap counts again rather than an offset
  • Loading branch information
ColinEberhardt committed Nov 7, 2018
1 parent 25fb09d commit c5886e5
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/applause-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,14 @@ const getClaps = url =>
}
}).then(response => response.text());


const WAVELENGTH = 60 * 5;
const secondsForClap = a => (WAVELENGTH * Math.asin(a / 10)) / (Math.PI * 2);

const computeRequest = clapCount => {
const requiredSeconds = secondsForClap(clapCount);
const serverSeconds = (Date.now() / 1000) % 60;
const delta = requiredSeconds - serverSeconds;
return delta;
}

const updateClaps = (claps, url) =>
// TODO: polyfill for IE (not edge)
fetch(`${API}/update-claps` + (url ? `?url=${url}` : ""), {
method: "POST",
headers: {
"Content-Type": "text/plain"
},
body: JSON.stringify(computeRequest(claps))
body: JSON.stringify(claps)
}).then(response => response.text());

const arrayOfSize = size => new Array(size).fill(undefined);
Expand Down

0 comments on commit c5886e5

Please sign in to comment.