Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
ac50892318 | ||
|
f611ea610f | ||
|
0ff126e3b4 |
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
DuckRevamp/*
|
||||
server/node_modules/*
|
|
@ -1,52 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="images/DuckIcon.png" />
|
||||
<title>Dancing Duck</title>
|
||||
<meta http-equiv="Cache-control" content="public">
|
||||
<style>
|
||||
#customAlert {
|
||||
display: none;
|
||||
z-index: 1;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
background-color: white;
|
||||
border: 2px solid black;
|
||||
border-radius: 10px;
|
||||
width: 75%;
|
||||
height: 75%;
|
||||
color: black !important;
|
||||
}
|
||||
#customAlert > button {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
width: auto !important;
|
||||
height: auto !important;
|
||||
}
|
||||
#customAlert > * {
|
||||
margin: auto;
|
||||
padding: auto;
|
||||
color: black !important;
|
||||
}
|
||||
#customAlert > img {
|
||||
display: inline-block;
|
||||
object-fit: contain;
|
||||
height: 100%;
|
||||
width: 100%
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body onload="setup();" style="font-family:arial; background-color:black;color:white;">
|
||||
<script src="/socket.io/socket.io.js"></script>
|
||||
<script src="js/client.js"></script>
|
||||
<div id="customAlert"></div>
|
||||
<h1 style="text-align:center"><a title="Das E steht für Reichtum">(E)</a>nt<a title="Das e steht für einfach mal die Fr**se halten">e</a></h1>
|
||||
<div style="display: flex; justify-content: center; align-items: center;">
|
||||
<p style="text-align: right"> It hurts when IP<br>Umdrehungen: <a id="countE" title="Zahl kann je nach Zeit unterschiedlich sein.">0</a><br>Shots pro Person: <a id="countS">0</a></p>
|
||||
<img title="DUCK DUCK DUCK DUCK DUCK DUCK DUCK GOOSE DUCK DUCK DUCK DUCK DUCK DUCK DUCK" src="images/dancing-duckdancing.gif">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,3 +0,0 @@
|
|||
cd /var/www/DancingDuck
|
||||
git pull origin master
|
||||
systemctl restart duckSite.service
|
Before Width: | Height: | Size: 143 KiB After Width: | Height: | Size: 143 KiB |
Before Width: | Height: | Size: 398 KiB After Width: | Height: | Size: 398 KiB |
26
index.html
Normal file
26
index.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewpoint" content="width=device-width, initial-scale=1.0">
|
||||
<title>Dancing Duck</title>
|
||||
<link rel="icon" href="images/DuckIcon.png"/>
|
||||
<link rel="stylesheet" href="styles/styles.css"/>
|
||||
</head>
|
||||
<body onload="setup();">
|
||||
<script src="/socket.io/socket.io.js"></script>
|
||||
<script src="js/client.js"></script>
|
||||
<script src="js/Chat.js"></script>
|
||||
<div class="header">
|
||||
<h1><a title="Das E in Ente steht für Reichtum">E</a>nt<a title="Das e in Ente steht für: Einfach mal die Fresse halten!">e</a></h1>
|
||||
</div>
|
||||
<div class="mainBody">
|
||||
<div class="texts">
|
||||
<div class="textMainBody"><h1>It hurts when IP</h1></div>
|
||||
<div class="textMainBody"><h1>Umdrehungen: 0</h1></div>
|
||||
<div class="textMainBody"><h1>Shots pro Person: 0</h1></div>
|
||||
</div>
|
||||
<div class="imgMainBody"><img title="DUCK DUCK DUCK DUCK DUCK DUCK DUCK GOOSE DUCK DUCK DUCK DUCK DUCK DUCK DUCK" src="images/dancing-duckdancing.gif" alt="THE ALL MIGHTY DUCK"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
7
js/Chat.js
Normal file
7
js/Chat.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
function openForm() {
|
||||
document.getElementById("myForm").style.display = "block";
|
||||
}
|
||||
|
||||
function closeForm() {
|
||||
document.getElementById("myForm").style.display = "none";
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
2191551
|
4045
server/package-lock.json
generated
4045
server/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -1,22 +0,0 @@
|
|||
{
|
||||
"name": "server",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"dev": "nodemon server.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"axios": "^0.24.0",
|
||||
"cheerio": "^1.0.0-rc.10",
|
||||
"express": "^4.17.3",
|
||||
"global-agent": "^3.0.0",
|
||||
"nodemon": "^2.0.15",
|
||||
"reddit-image-fetcher": "^2.0.10",
|
||||
"reddit.images": "^1.0.7",
|
||||
"socket.io": "^4.4.1"
|
||||
}
|
||||
}
|
222
server/server.js
222
server/server.js
|
@ -1,222 +0,0 @@
|
|||
// Start Date: 2021/10/11 15:00:00
|
||||
|
||||
const port = 3000;
|
||||
|
||||
/*
|
||||
const axios = require('axios');
|
||||
const cheerio = require('cheerio');
|
||||
*/
|
||||
|
||||
const RIF = require('reddit-image-fetcher');
|
||||
/*
|
||||
const GPA = require('global-agent');
|
||||
const NPA = GPA.createGlobalProxyAgent();
|
||||
NPA.HTTP_PROXY = 'http://webproxy.bs.ptb.de:8080';
|
||||
NPA.HTTPS_PROXY = 'http://webproxy.bs.ptb.de:8080';
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const cSave = __dirname+'/count.save';
|
||||
|
||||
const http = require('http');
|
||||
const express = require('express');
|
||||
const socketio = require('socket.io');
|
||||
const { exec } = require('child_process');
|
||||
|
||||
const app = express();
|
||||
const clientPath = __dirname+'/../client';
|
||||
console.log('Serving static from ' + clientPath);
|
||||
app.use(express.static(clientPath));
|
||||
|
||||
const server = http.createServer(app);
|
||||
const io = socketio(server);
|
||||
|
||||
app.post('/receiveUpdate', (req, res) => {
|
||||
res.status(200).json({success:true});
|
||||
let updater = exec(`sh ${__dirname}/../gitUpdate.sh`, (error, stdout, stderr) => {
|
||||
console.log(stdout);
|
||||
console.error(stderr);
|
||||
if (error !== null) {
|
||||
console.error(`exec error: ${error}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(r => {
|
||||
setTimeout(r, ms);
|
||||
});
|
||||
}
|
||||
|
||||
function saveCount() {
|
||||
let actualCount = Math.floor((new Date() - new Date("2021/10/11 15:00:00")) / 5600);
|
||||
if (duckCount < actualCount || typeof duckCount != "number") { duckCount = actualCount; }
|
||||
console.log("Newly Calculated: "+actualCount+"; Saved Count: "+duckCount);
|
||||
fs.writeFile(cSave, duckCount.toString(), e=>{if(e){console.log("Error writing to SAVE file on", new Date());}});
|
||||
}
|
||||
|
||||
server.on('error', err => {
|
||||
console.error('Server error:', err);
|
||||
});
|
||||
|
||||
server.on('close', saveCount);
|
||||
|
||||
server.listen(port, () => {
|
||||
console.log('Server Started on Port '+port);
|
||||
fs.readFile(cSave, {encoding: 'utf-8'}, (e,d)=>{
|
||||
if(e){console.log("Error reading from SAVE file on", new Date());return;}
|
||||
console.log("Loaded Count:", d);
|
||||
duckCount = parseInt(d);
|
||||
});
|
||||
setInterval(()=>{duckCount++;},5600);
|
||||
setInterval(saveCount,336000);
|
||||
// setTimeout(()=>{console.clear();},10000);
|
||||
});
|
||||
|
||||
let duckCount = 0;
|
||||
let duckClients = Array();
|
||||
|
||||
io.on('connection', socket => {
|
||||
let id = -1;
|
||||
|
||||
console.log("New Client has connected.");
|
||||
while (true) {
|
||||
let current = Math.floor(Math.random()*89+10);
|
||||
let isUsed = false;
|
||||
for (let i = 0; i < duckClients.length; i++) {
|
||||
if (duckClients[i].uid == current) {
|
||||
isUsed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isUsed) {
|
||||
id = current;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (id != -1) {
|
||||
console.log('Handing ID', id);
|
||||
socket.emit('connected', duckCount, id);
|
||||
duckClients.push({socket, id});
|
||||
}
|
||||
|
||||
socket.on('disconnect', () => {
|
||||
for (let i = 0; i < duckClients.length; i++) {
|
||||
if (duckClients[i].socket == socket) {
|
||||
console.log("Disconnecting DUCK User. ID", duckClients[i].id);
|
||||
duckClients.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('updateCount', c => {
|
||||
duckCount = c;
|
||||
saveCount();
|
||||
});
|
||||
|
||||
socket.on('saveCount', saveCount);
|
||||
|
||||
socket.on('duckUpdate', (c, p)=>{
|
||||
// console.log("Received Update Task.");
|
||||
if (c < duckCount) {
|
||||
// console.log("Searching Client with ID:", p);
|
||||
for (let i = 0; i < duckClients.length; i++) {
|
||||
if (duckClients[i].id == p) {
|
||||
// console.log("Updating Client with ID:", p);
|
||||
duckClients[i].socket.emit('update', duckCount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('duckRIF', async (s, t) => {
|
||||
let imgSrc = "", subreddit = "";
|
||||
if (s.length > 0) {
|
||||
console.log("Spreading Reddit-Image(/-s) (from subs.: '" + s.join(', ') + "') after:", t, "ms.");
|
||||
let gotResult = false;
|
||||
|
||||
await RIF.fetch({
|
||||
type: 'custom',
|
||||
total: 50,
|
||||
subreddit: s
|
||||
}).then(r=>{
|
||||
gotResult = true;
|
||||
if (r && r != null) {
|
||||
if (r.length > 0) {
|
||||
const index = Math.floor(r.length * Math.random());
|
||||
if (!r[index].NSFW && r[index].image != "") {
|
||||
imgSrc = r[index].image;
|
||||
subreddit = r[index].subreddit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}).catch(e=>{
|
||||
gotResult = true;
|
||||
consle.log("Error on 'RIF':",e);
|
||||
});
|
||||
|
||||
while (!gotResult) {
|
||||
await sleep(100);
|
||||
}
|
||||
|
||||
/*
|
||||
let data;
|
||||
axios.get(
|
||||
"https://reddit.com/r/" + s
|
||||
).then(r => {
|
||||
data = r.data;
|
||||
gotResult = true;
|
||||
}).catch(e => {
|
||||
gotResult = true;
|
||||
console.log("Error on 'Axios':", e);
|
||||
});
|
||||
|
||||
const $ = cheerio.load(data);
|
||||
const urlMeme = $("._2_tDEnGMLxpM6uOa2kaDB3.ImageBox-image.media-element._1XWObl-3b9tPy64oaG6fax");
|
||||
const indexValue = Math.floor(Math.random()*urlMeme.length);
|
||||
imgSrc = urlMeme[indexValue].attribs.src;
|
||||
*/
|
||||
}
|
||||
|
||||
if (imgSrc != "") {
|
||||
duckClients.forEach(c => {
|
||||
c.socket.emit('message', imgSrc, subreddit, t);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('duckMessage', (inID, outName, msg) => {
|
||||
let inName = inID;
|
||||
for (let i = 0; i < duckClients.length; i++) {
|
||||
if (duckClients[i].id == inID && duckClients[i].nickname) {
|
||||
inName = duckClients[i].nickname;
|
||||
break;
|
||||
}
|
||||
}
|
||||
let outID = outName;
|
||||
for (let i = 0; i < duckClients.length; i++) {
|
||||
if (duckClients[i].nickname == outName) {
|
||||
outID = duckClients[i].id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < duckClients.length; i++) {
|
||||
if (duckClients[i].id == outID) {
|
||||
duckClients[i].socket.emit('receiveMessage', inName, msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('duckRename', (id, nn) => {
|
||||
for (let i = 0; i < duckClients.length; i++) {
|
||||
if (duckClients[i].id == id) {
|
||||
duckClients[i].nickname = nn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
102
styles/styles.css
Normal file
102
styles/styles.css
Normal file
|
@ -0,0 +1,102 @@
|
|||
#customAlert{
|
||||
display: none;
|
||||
z-index: 1;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
background-color:darkgray;
|
||||
border: 2px hidden;
|
||||
border-radius: 5px;
|
||||
width: 75%;
|
||||
height: 75%;
|
||||
color: darkgrey;
|
||||
}
|
||||
body{
|
||||
background-color: #272727 ;
|
||||
}
|
||||
.header{
|
||||
text-align: center;
|
||||
margin: 5px 3px 5px 3px;
|
||||
background-color: #272727;
|
||||
border-radius: 15%;
|
||||
border-style: solid;
|
||||
border-color: #272727;
|
||||
text-size-adjust: auto;
|
||||
color: aliceblue;
|
||||
|
||||
}
|
||||
|
||||
.mainBody{
|
||||
display:flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.textMainBody{
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.texts{
|
||||
display: block;
|
||||
text-align: right;
|
||||
color: aliceblue;
|
||||
}
|
||||
|
||||
.imgMainBody{
|
||||
height: auto;
|
||||
width: auto;
|
||||
padding: 10%;
|
||||
}
|
||||
|
||||
img{
|
||||
height: 600px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
|
||||
|
||||
{box-sizing: border-box;}
|
||||
|
||||
/* Button used to open the chat form - fixed at the bottom of the page */
|
||||
.open-button {
|
||||
background-color: #555;
|
||||
color: white;
|
||||
padding: 16px 20px;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
opacity: 0.8;
|
||||
position: fixed;
|
||||
bottom: 23px;
|
||||
right: 28px;
|
||||
width: 280px;
|
||||
}
|
||||
|
||||
/* The popup chat - hidden by default */
|
||||
.form-popup {
|
||||
display: none;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
right: 15px;
|
||||
border: 3px solid #f1f1f1;
|
||||
z-index: 9;
|
||||
}
|
||||
|
||||
/* Add styles to the form container */
|
||||
.form-container {
|
||||
max-width: 300px;
|
||||
padding: 10px;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
/* Full-width textarea */
|
||||
.form-container textarea {
|
||||
width: 100%;
|
||||
padding: 15px;
|
||||
margin: 5px 0 22px 0;
|
||||
border: none;
|
||||
background: #f1f1f1;
|
||||
resize: none;
|
||||
min-height: 200px;
|
||||
}
|
Loading…
Reference in New Issue
Block a user