ReUp of correct files, made a mistake

merged with an older version (I think), so here the correct files again
This commit is contained in:
Lea
2023-03-01 12:25:05 +01:00
committed by GitHub
parent 1612e5f6ba
commit 386fee2a84
7 changed files with 499 additions and 250 deletions
+104 -43
View File
@@ -39,21 +39,39 @@ resetBtn.addEventListener("click", function(){
endingTime = timeFunc.addHours(timeNow, initialHours);
endingTime = timeFunc.addMinutes(timeNow, initialMinutes);
endingTime = timeFunc.addSeconds(timeNow, initialSeconds);
window.localStorage.removeItem('initialHours');
window.localStorage.removeItem('initialMinutes');
window.localStorage.removeItem('initialSeconds');
logMessage("Core", "Timer Reset.");
});
startBtn.addEventListener("click", function(){
if(paused == true){
initialHours = window.localStorage.getItem('initialHours')
initialMinutes = window.localStorage.getItem('initialMinutes')
initialSeconds = window.localStorage.getItem('initialSeconds')
if(paused){
var initialHoursLocal = window.localStorage.getItem('initialHours')
if(initialHoursLocal !== null) {
initialHours = initialHoursLocal;
logMessage("Core", "Found initialHours in localStorage.")
} else {
initialHours = initialHoursConfig;
}
var initialMinutesLocal = window.localStorage.getItem('initialMinutes')
if(initialMinutesLocal !== null) {
initialMinutes = initialMinutesLocal;
logMessage("Core", "Found initialMinutes in localStorage.")
} else {
initialMinutes = initialMinutesConfig;
}
var initialSecondsLocal = window.localStorage.getItem('initialSeconds')
if(initialSecondsLocal !== null) {
initialSeconds = initialSecondsLocal;
logMessage("Core", "Found initialSeconds in localStorage.")
} else {
initialSeconds = initialSecondsConfig;
}
}
let timeNow = new Date(Date.now());
@@ -70,41 +88,18 @@ startBtn.addEventListener("click", function(){
});
Mousetrap.bind('ctrl+alt+p', function(e) {
Mousetrap.bind(pauseShort, function(e) {
paused = true;
logMessage("Core", "Timer was paused");
document.getElementById("startPage").style.visibility = "visible";
document.getElementById("container").style.visibility = "hidden";
});
Mousetrap.bind('ctrl+alt+h', async function(e){
if(happy_hour == true && happy_hour_active == false){
logMessage("Core","Happy Hour activated");
happy_hour_active = true;
document.getElementById("HappyHourText").innerHTML = "Happy Hour Activated!";
document.getElementById("HappyHourText").animate({opacity: [ 0, 1 ], easing: [ 'ease-in', 'ease-out' ],}, 500);
document.getElementById("HappyHourText").style.opacity = "1";
document.getElementById("HappyHourHTML").animate({top: [ "-200px", "-250px" ], easing: [ 'ease-in', 'ease-out' ],}, 500);
document.getElementById("HappyHourHTML").style.top = "-250px";
document.getElementById("container").style.backgroundImage = "-webkit-linear-gradient(-45deg, transparent 33%, rgba(0, 0, 0, .1) 33%, rgba(0,0, 0, .1) 66%, transparent 66%), -webkit-linear-gradient(top, rgba(255, 255, 255, .25), rgba(0, 0, 0, .25)), url(https://drive.google.com/uc?id=1oduFlPg84O1DliM5FsLvJJsnwZ4m1Vpm), -webkit-linear-gradient(left, #0074cc, #a700cc)";
await sleep(10000)
document.getElementById("HappyHourText").animate({opacity: [ 1, 0 ], easing: [ 'ease-in', 'ease-out' ],}, 500);
document.getElementById("HappyHourText").style.opacity = "0";
Mousetrap.bind(happyHourShort, async function(e){
if(happy_hour){
happyHourFunc()
}
else if(happy_hour == true && happy_hour_active == true){
logMessage("Core", "Happy Hour deactivated")
happy_hour_active = false;
document.getElementById("HappyHourText").innerHTML = "Happy Hour Deactivated";
document.getElementById("HappyHourText").animate({opacity: [ 0, 1 ], easing: [ 'ease-in', 'ease-out' ],}, 500);
document.getElementById("HappyHourText").style.opacity = "1";
document.getElementById("HappyHourHTML").animate({top: [ "-200px", "-250px" ], easing: [ 'ease-in', 'ease-out' ],}, 500);
document.getElementById("HappyHourHTML").style.top = "-250px";
document.getElementById("container").style.backgroundImage = "-webkit-linear-gradient(-45deg, transparent 33%, rgba(0, 0, 0, .1) 33%, rgba(0,0, 0, .1) 66%, transparent 66%), -webkit-linear-gradient(top, rgba(255, 255, 255, .25), rgba(0, 0, 0, .25)), -webkit-linear-gradient(left, #0074cc, #a700cc)";
await sleep(5000)
document.getElementById("HappyHourText").animate({opacity: [ 1, 0 ], easing: [ 'ease-in', 'ease-out' ],}, 500);
document.getElementById("HappyHourText").style.opacity = "0";
}
else if(happy_hour == false){
else {
logMessage("Core", "Happy Hour is not available")
document.getElementById("HappyHourText").innerHTML = "Happy Hour error";
document.getElementById("HappyHourText").animate({opacity: [ 0, 1 ], easing: [ 'ease-in', 'ease-out' ],}, 500);
@@ -117,6 +112,36 @@ Mousetrap.bind('ctrl+alt+h', async function(e){
}
});
async function happyHourFunc(){
if(!happy_hour_active){
logMessage("Core","Happy Hour activated");
happy_hour_active = true;
document.getElementById("HappyHourText").innerHTML = "Happy Hour Activated!";
document.getElementById("HappyHourText").animate({opacity: [ 0, 1 ], easing: [ 'ease-in', 'ease-out' ],}, 500);
document.getElementById("HappyHourText").style.opacity = "1";
document.getElementById("HappyHourHTML").animate({top: [ "-200px", "-250px" ], easing: [ 'ease-in', 'ease-out' ],}, 500);
document.getElementById("HappyHourHTML").style.top = "-250px";
document.getElementById("container").style.backgroundImage = "-webkit-linear-gradient(-45deg, transparent 33%, rgba(0, 0, 0, .1) 33%, rgba(0,0, 0, .1) 66%, transparent 66%), -webkit-linear-gradient(top, rgba(255, 255, 255, .25), rgba(0, 0, 0, .25)), url(https://drive.google.com/uc?id=1oduFlPg84O1DliM5FsLvJJsnwZ4m1Vpm), -webkit-linear-gradient(left, #0074cc, #a700cc)";
await sleep(10000)
document.getElementById("HappyHourText").animate({opacity: [ 1, 0 ], easing: [ 'ease-in', 'ease-out' ],}, 500);
document.getElementById("HappyHourText").style.opacity = "0";
}
else if(happy_hour_active){
logMessage("Core", "Happy Hour deactivated")
clearTimeout(happyHourFunc)
happy_hour_active = false;
document.getElementById("HappyHourText").innerHTML = "Happy Hour Deactivated";
document.getElementById("HappyHourText").animate({opacity: [ 0, 1 ], easing: [ 'ease-in', 'ease-out' ],}, 500);
document.getElementById("HappyHourText").style.opacity = "1";
document.getElementById("HappyHourHTML").animate({top: [ "-200px", "-250px" ], easing: [ 'ease-in', 'ease-out' ],}, 500);
document.getElementById("HappyHourHTML").style.top = "-250px";
document.getElementById("container").style.backgroundImage = "-webkit-linear-gradient(-45deg, transparent 33%, rgba(0, 0, 0, .1) 33%, rgba(0,0, 0, .1) 66%, transparent 66%), -webkit-linear-gradient(top, rgba(255, 255, 255, .25), rgba(0, 0, 0, .25)), -webkit-linear-gradient(left, #0074cc, #a700cc)";
await sleep(5000)
document.getElementById("HappyHourText").animate({opacity: [ 1, 0 ], easing: [ 'ease-in', 'ease-out' ],}, 500);
document.getElementById("HappyHourText").style.opacity = "0";
}
}
let countdownEnded = false;
let users = [];
@@ -128,6 +153,15 @@ endingTime = timeFunc.addHours(endingTime, initialHours);
endingTime = timeFunc.addMinutes(endingTime, initialMinutes);
endingTime = timeFunc.addSeconds(endingTime, initialSeconds);
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
var randomHappyBool = false
var scheduleHappyBool = false
const getNextTime = () => {
let currentTime = new Date(Date.now());
@@ -138,10 +172,19 @@ const getNextTime = () => {
countdownEnded = true;
time = "00:00:00";
}
if(paused == false){
if(!paused){
window.localStorage.setItem('initialHours', timeFunc.getHours(differenceTime));
window.localStorage.setItem('initialMinutes', timeFunc.getMinutes(differenceTime));
window.localStorage.setItem('initialSeconds', timeFunc.getSeconds(differenceTime));
if(randHappy && happy_hour && !randomHappyBool){
randomHappyBool = true
setTimeout(randomHappy,1000)
}
if(scheduleHappy && happy_hour && !scheduleHappyBool){
scheduleHappyBool = true
scheduleHappyFunc()
}
}
timeText.innerText = time;
@@ -151,6 +194,30 @@ let countdownUpdater = setInterval(() => {
getNextTime();
}, 1);
function randomHappy(){
if(!happy_hour_active){
if((getRandomInt(0,10000) == 127)){
logMessage("RandomHappy","It's not rigged!")
happyHourFunc()
setTimeout(happyHourFunc, 3600000)
}
setTimeout(randomHappy,1000)
}
}
function scheduleHappyFunc(){
let now = new Date()
if(now.getDay() == scheduleHappyDay){
if(now.getUTCHours() == scheduleHappyHour){
if(now.getUTCMinutes() == 00){
logMessage("Schedule","It's time!")
happyHourFunc()
setTimeout(happyHourFunc, 3600000)
setTimeout(scheduleHappyFunc, 36000000)
}
}
}
}
var firstSub = true;
var endingTimeBeforeCounter;
@@ -182,16 +249,10 @@ const addTimeInternal = async () => {
firstSub = true;
let addedTime = document.createElement("p");
if(happy_hour == true && happy_hour_active == true) {
if(happy_hour_active) {
addedTime.classList = "gold";
}
else if(happy_hour == true && happy_hour_active == false) {
addedTime.classList = "addedTime";
}
else if(happy_hour == false && happy_hour_active == true) {
addedTime.classList = "addedTime";
}
else if(happy_hour == false && happy_hour_active == false) {
else {
addedTime.classList = "addedTime";
}
addedTime.innerText = `+${s}s`;