Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
7ih authored May 21, 2021
1 parent 0000ccf commit 746387f
Showing 1 changed file with 15 additions and 27 deletions.
42 changes: 15 additions & 27 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ var DEBUG = window.location.hash === '#DEBUG',
uidCookieKey = 'tetherId',
uid,
playerRGB = [20, 20, 200],
hslVal = 0,
shouldUnmuteImmediately = false,
cookieExpiryDate = new Date();

Expand Down Expand Up @@ -229,10 +228,6 @@ function rgbWithOpacity(rgb, opacity) {
return 'rgba(' + rgbStrings.join(',') + ',' + opacity.toFixed(2) + ')';
}

function hsl(hsl) {
return 'hsl(' + hsl + ', 100%, 50%)';
}

function draw(opts) {
for (var defaultKey in draw.defaults) {
if (!(defaultKey in opts)) opts[defaultKey] = draw.defaults[defaultKey];
Expand Down Expand Up @@ -396,13 +391,12 @@ function initCanvas() {
) {
saveCookie(lastDayCookieKey, currentDate.getTime());
saveCookie(streakCountCookieKey, 0);
} else if (later48Hours > Number(new Date()) && Number(new Date()) > later24Hours) {
} else if (later48Hours > Number(Date.now()) > later24Hours) {
saveCookie(streakCountCookieKey, (streak += 1));
saveCookie(lastDayCookieKey, currentDate.getTime());
} else if (Number(new Date()) < later24Hours) {
} else if (Number(Date.now()) < later24Hours) {
} else {
saveCookie(streakCountCookieKey, 0);
saveCookie(lastDayCookieKey, currentDate.getTime());
}

switch (streak) {
Expand Down Expand Up @@ -433,7 +427,7 @@ function initCanvas() {
break;
default:
case 10:
playerRGB = "Rainbow";
playerRGB = [223, 41, 53];
console.log('Congrats on your 10 day streak!!');
break;
}
Expand Down Expand Up @@ -503,18 +497,14 @@ function timeToNextClaim() {
var deadline = lastDate.getTime() + 86400000;
var timeRemaining = deadline - new Date();
var formattedTime = new Date(timeRemaining);

if(formattedTime > 0) {
return `${
formattedTime.getHours() > 9 ? '' : '0'
}${formattedTime.getHours()}:${
formattedTime.getMinutes() > 9 ? '' : '0'
}${formattedTime.getMinutes()}:${
formattedTime.getSeconds() > 9 ? '' : '0'
}${formattedTime.getSeconds()}`;
} else {
return 'Right Now!'
}

return `${
formattedTime.getHours() > 9 ? '' : '0'
}${formattedTime.getHours()}:${
formattedTime.getMinutes() > 9 ? '' : '0'
}${formattedTime.getMinutes()}:${
formattedTime.getSeconds() > 9 ? '' : '0'
}${formattedTime.getSeconds()}`;
}

function edgesOfCanvas() {
Expand Down Expand Up @@ -671,11 +661,7 @@ Mass.prototype = {
},

getCurrentColor: function () {
if(this.rgb === 'Rainbow') {
if(hslVal !== 360) hslVal++;
else hslVal = 0;
}
return this.rgb === 'Rainbow' ? hsl(hslVal) : rgbWithOpacity(this.rgb, this.getOpacity());
return rgbWithOpacity(this.rgb, this.getOpacity());
},

draw: function () {
Expand Down Expand Up @@ -933,7 +919,9 @@ function Cable(tether, player) {
draw({
type: 'line',
stroke: true,
strokeStyle: `${playerRGB === 'Rainbow' ? `${hsl(hslVal)}` : `rgba(${playerRGB[0] ?? 20}, ${playerRGB[1] ?? 20}, ${playerRGB[2] ?? 200}, 1)`}`,
strokeStyle: `rgba(${playerRGB[0] ?? 20}, ${playerRGB[1] ?? 20}, ${
playerRGB[2] ?? 200
}, 1)`,
linePaths: [self.line()],
});

Expand Down

0 comments on commit 746387f

Please sign in to comment.