initial commit and all the project done because I'm dumb
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
*.mp4
|
||||
LEEME.txt
|
||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 160 KiB |
@@ -0,0 +1,17 @@
|
||||
var streamlabsToken = ""
|
||||
var streamlootsToken = ""
|
||||
|
||||
var initialHours = 3
|
||||
var initialMinutes = 30
|
||||
var initialSeconds = 40
|
||||
|
||||
var secondsPerSub = 300
|
||||
|
||||
var secondsPerDono = 300
|
||||
var quantityDono = 5
|
||||
|
||||
var secondsPerChest = 300
|
||||
var quantityChest = 10
|
||||
|
||||
var secondsPerBits = 300
|
||||
var quantityBits = 500
|
||||
@@ -0,0 +1,52 @@
|
||||
body, body * {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#container {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
#textDiv {
|
||||
background-color: #bea0af;
|
||||
width: 420px;
|
||||
height: 150px;
|
||||
border-radius: 20px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
}
|
||||
|
||||
p {
|
||||
color: #3c3341;
|
||||
font-size: 4rem;
|
||||
font-family: 'Manrope', sans-serif;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
img {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
canvas {
|
||||
width: 420px;
|
||||
height: 150px;
|
||||
border-radius: 20px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
z-index: 2;
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Manrope:wght@600&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
<title>Subathon Timer</title>
|
||||
</head>
|
||||
<body onload="start()">
|
||||
<div id="container">
|
||||
<div id="textDiv">
|
||||
<p id="timeText">00:00:00</p>
|
||||
</div>
|
||||
<img src="assets/background.svg" alt="">
|
||||
<canvas id="canvas"></canvas>
|
||||
</div>
|
||||
<script src='https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js' type='text/javascript'></script>
|
||||
<script src="config.js"></script>
|
||||
<script src="js/timeFunc.js"></script>
|
||||
<script src="js/script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,76 @@
|
||||
const start = () => {
|
||||
screenWidth = window.innerWidth;
|
||||
screenHeight = window.innerHeight;
|
||||
|
||||
endingTime = new Date(Date.now());
|
||||
endingTime = timeFunc.addHours(endingTime, initialHours);
|
||||
endingTime = timeFunc.addMinutes(endingTime, initialMinutes);
|
||||
endingTime = timeFunc.addSeconds(endingTime, initialSeconds);
|
||||
|
||||
timeText = document.getElementById("timeText");
|
||||
|
||||
const getNextTime = () => {
|
||||
let currentTime = new Date(Date.now());
|
||||
let differenceTime = endingTime - currentTime;
|
||||
let time = `${timeFunc.getHours(differenceTime)}:${timeFunc.getMinutes(differenceTime)}:${timeFunc.getSeconds(differenceTime)}`;
|
||||
if (time === "00:00:00") {
|
||||
clearInterval(inter);
|
||||
time = "¡FIN!";
|
||||
console.log(time);
|
||||
}
|
||||
timeText.innerText = time;
|
||||
}
|
||||
|
||||
const inter = setInterval(() => {
|
||||
getNextTime();
|
||||
}, 100);
|
||||
|
||||
|
||||
|
||||
socket = io(`https://sockets.streamlabs.com?token=${streamlabsToken}`, {transports: ['websocket']})
|
||||
|
||||
socket.on("connect", () => {
|
||||
console.log("Socket Connected");
|
||||
});
|
||||
|
||||
socket.on("event", (event) => {
|
||||
console.log(event);
|
||||
if (event.type == "subscription" || event.type == "resub") {
|
||||
endingTime = timeFunc.addSeconds(endingTime, secondsPerSub);
|
||||
}
|
||||
else if (event.type == "donation") {
|
||||
if (parseInt(event.message[0].amount) >= quantityDono) {
|
||||
endingTime = timeFunc.addSeconds(endingTime, secondsPerDono);
|
||||
}
|
||||
}
|
||||
else if (event.type == "bits") {
|
||||
if (parseInt(event.message[0].amount) >= quantityBits) {
|
||||
endingTime = timeFunc.addSeconds(endingTime, secondsPerBits);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("disconnect", () => {
|
||||
console.log("Socket Disconnected");
|
||||
});
|
||||
|
||||
|
||||
|
||||
evtSourceStreamLoots = new EventSource(`https://widgets.streamloots.com/alerts/${streamlootsToken}/media-stream`);
|
||||
|
||||
evtSourceStreamLoots.onmessage = async (event) => {
|
||||
data = await JSON.parse(event.data);
|
||||
if (data.data.type == "purchase") {
|
||||
if (typeof(data.data.fields[0].value) == "number") {
|
||||
if (data.data.fields[0].value >= quantityChest) {
|
||||
endingTime = timeFunc.addSeconds(endingTime, secondsPerChest);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (data.data.fields[1].value >= quantityChest) {
|
||||
endingTime = timeFunc.addSeconds(endingTime, secondsPerChest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
timeFunc = {
|
||||
addHours(time, h) {
|
||||
time.setTime(time.getTime() + (h * 60 * 60 * 1000));
|
||||
return time;
|
||||
},
|
||||
|
||||
addMinutes(time, m) {
|
||||
time.setTime(time.getTime() + (m * 60 * 1000));
|
||||
return time;
|
||||
},
|
||||
|
||||
addSeconds (time, s) {
|
||||
time.setTime(time.getTime() + (s * 1000));
|
||||
return time;
|
||||
},
|
||||
|
||||
getHours(time) {
|
||||
let hours;
|
||||
if (typeof time !== 'number') {
|
||||
hours = time.getHours().toString();
|
||||
}
|
||||
else {
|
||||
hours = Math.floor(time / (1000 * 60 * 60)).toString();
|
||||
}
|
||||
hours = (hours.length < 2) ? `0${hours}` : hours;
|
||||
return hours;
|
||||
},
|
||||
|
||||
getMinutes(time) {
|
||||
let minutes;
|
||||
if (typeof time !== 'number') {
|
||||
minutes = time.getMinutes().toString();
|
||||
}
|
||||
else {
|
||||
minutes = Math.floor((time % (1000 * 60 * 60)) / (1000 * 60)).toString();
|
||||
}
|
||||
minutes = (minutes.length < 2) ? `0${minutes}` : minutes;
|
||||
return minutes;
|
||||
},
|
||||
|
||||
getSeconds(time) {
|
||||
let seconds;
|
||||
if (typeof time !== 'number') {
|
||||
seconds = time.getSeconds().toString();
|
||||
}
|
||||
else {
|
||||
seconds = Math.floor((time % (1000 * 60)) / 1000).toString();
|
||||
}
|
||||
seconds = (seconds.length < 2) ? `0${seconds}` : seconds;
|
||||
return seconds;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user