Compare commits

..

No commits in common. "2fa431886cca21509eb90f5cdec16a450ab4f01b" and "d65b76cbc56cc571533172e2fcb39ff91c047376" have entirely different histories.

5 changed files with 138 additions and 193 deletions

4
.gitignore vendored
View File

@ -1,7 +1,5 @@
node_modules node_modules
package-lock.json package-lock.json
shared-storage shared-storage
storage_*
storage storage
chatBot/.env chatBot/.env
chatBot/commands/ai.js

17
app.js
View File

@ -2,12 +2,13 @@ import Hyperswarm from 'hyperswarm';
import crypto from 'hypercore-crypto'; import crypto from 'hypercore-crypto';
import b4a from 'b4a'; import b4a from 'b4a';
import ServeDrive from 'serve-drive'; import ServeDrive from 'serve-drive';
import Localdrive from 'localdrive';
import fs from 'fs';
import Hyperdrive from 'hyperdrive'; import Hyperdrive from 'hyperdrive';
import Corestore from 'corestore'; import Corestore from 'corestore';
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
const storagePath = `./storage/storage_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`; const store = new Corestore('./storage');
const store = new Corestore(storagePath);
const drive = new Hyperdrive(store); const drive = new Hyperdrive(store);
await drive.ready(); await drive.ready();
@ -20,18 +21,10 @@ let peerCount = 0;
let currentRoom = null; let currentRoom = null;
const eventEmitter = new EventEmitter(); const eventEmitter = new EventEmitter();
// Define servePort at the top level
let servePort;
// Function to get a random port between 1337 and 2223
function getRandomPort() {
return Math.floor(Math.random() * (65535 - 49152 + 1)) + 49152;
}
async function initialize() { async function initialize() {
swarm = new Hyperswarm(); swarm = new Hyperswarm();
servePort = getRandomPort(); const servePort = 1337;
const serve = new ServeDrive({ port: servePort, get: ({ key, filename, version }) => drive }); const serve = new ServeDrive({ port: servePort, get: ({ key, filename, version }) => drive });
await serve.ready(); await serve.ready();
console.log('Listening on http://localhost:' + serve.address().port); console.log('Listening on http://localhost:' + serve.address().port);
@ -136,7 +129,7 @@ function registerUser(e) {
reader.onload = async (event) => { reader.onload = async (event) => {
const buffer = new Uint8Array(event.target.result); const buffer = new Uint8Array(event.target.result);
await drive.put(`/icons/${regUsername}.png`, buffer); await drive.put(`/icons/${regUsername}.png`, buffer);
userAvatar = `http://localhost:${servePort}/icons/${regUsername}.png`; // Set the correct URL userAvatar = `http://localhost:1337/icons/${regUsername}.png`; // Set the correct URL
registeredUsers[regUsername] = userAvatar; registeredUsers[regUsername] = userAvatar;
localStorage.setItem('registeredUsers', JSON.stringify(registeredUsers)); localStorage.setItem('registeredUsers', JSON.stringify(registeredUsers));
continueRegistration(regUsername); continueRegistration(regUsername);

View File

@ -10,8 +10,12 @@
</head> </head>
<body> <body>
<header> <header>
<pear-ctrl></pear-ctrl> <div>LinkUp</div>
<div id="linkup-text">LinkUp</div> <div class="window-controls">
<button id="minimize-button">-</button>
<button id="maximize-button">+</button>
<button id="close-button">x</button>
</div>
</header> </header>
<main> <main>
<div id="sidebar"> <div id="sidebar">

View File

@ -7,10 +7,8 @@
"type": "desktop", "type": "desktop",
"gui": { "gui": {
"backgroundColor": "#1F2430", "backgroundColor": "#1F2430",
"height": 547, "height": 540,
"minWidth": 955, "width": 720
"minHeight": 547,
"width": 955
} }
}, },
"license": "Apache-2.0", "license": "Apache-2.0",

296
style.css
View File

@ -12,131 +12,49 @@ body {
transition: background-color 0.3s ease, color 0.3s ease; transition: background-color 0.3s ease, color 0.3s ease;
} }
pear-ctrl[data-platform="darwin"] { float: right; margin-top: 4px; } #messages-container {
height: 45vh; /* Adjust as needed */
overflow-y: auto;
}
pear-ctrl { /* body {
margin-top: 9px;
margin-left: 9px;
position: absolute;
}
pear-ctrl:after {
content: '';
display: block;
height: 1.8rem;
position: fixed;
z-index: -1;
left: 0;
top: 0;
width: 100%;
background-color: #B0D94413;
filter: drop-shadow(2px 10px 6px #888);
}
main {
display: flex; display: flex;
flex: 1; } */
overflow: hidden;
/* Ensure no overflow in main */ #sidebar {
}
#sidebar {
width: 200px; width: 200px;
background-color: #2f3136; background-color: #2f3136;
color: white; color: white;
height: 100%; height: 100vh;
padding: 10px; padding: 10px;
box-sizing: border-box; box-sizing: border-box;
} }
#content { #room-list {
flex: 1; list-style: none;
display: flex; padding: 0;
flex-direction: column; margin-bottom: 20px;
height: 100%; }
#room-list li {
padding: 10px; padding: 10px;
} cursor: pointer;
margin-bottom: 5px;
#register, white-space: nowrap;
#setup,
#chat {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 2rem;
background-color: #1f1f1f;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}
#chat {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden; overflow: hidden;
padding: 1rem; text-overflow: ellipsis;
background-color: #1e1e1e; }
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3); #room-list li:hover {
width: 100%; background-color: #40444b;
} }
#messages-container { #content {
flex: 1; flex: 1;
overflow-y: auto; padding: 10px;
/* Allow vertical scrolling */ }
overflow-x: hidden;
/* Hide horizontal scrolling */ #sidebar button {
width: 100%;
}
#messages-container::-webkit-scrollbar {
width: 8px;
/* Set the width of the scrollbar */
}
#messages-container::-webkit-scrollbar-thumb {
background-color: #b0d944;
/* Set the color of the scrollbar thumb */
border-radius: 10px;
/* Round the corners of the scrollbar thumb */
}
#messages-container::-webkit-scrollbar-track {
background: #2e2e2e;
/* Set the color of the scrollbar track */
}
#message-form {
display: flex;
margin-top: 1rem;
margin-right: 1rem;
width: 100%;
}
#message {
flex: 1;
margin-right: 0.5rem;
padding-right: 0.5rem;
height: 1.5rem;
/* Initial single line height */
overflow-y: hidden;
/* Hide scrollbar */
}
#message:focus {
height: auto;
/* Allow the textarea to grow dynamically when focused */
}
#message:empty {
height: 1.5rem;
/* Ensure single line height when empty */
}
#sidebar button {
width: 100%; width: 100%;
padding: 10px; padding: 10px;
margin-bottom: 10px; margin-bottom: 10px;
@ -146,13 +64,13 @@ main {
color: white; color: white;
font-size: 14px; font-size: 14px;
border-radius: 5px; border-radius: 5px;
} }
#sidebar button:hover { #sidebar button:hover {
background-color: #5b6eae; background-color: #5b6eae;
} }
#remove-room-btn { #remove-room-btn {
margin-top: 10px; margin-top: 10px;
padding: 10px; padding: 10px;
background-color: #f04747; background-color: #f04747;
@ -160,20 +78,21 @@ main {
color: white; color: white;
cursor: pointer; cursor: pointer;
border-radius: 5px; border-radius: 5px;
} }
#remove-room-btn:hover { #remove-room-btn:hover {
background-color: #c03535; background-color: #c03535;
} }
.hidden { .hidden {
display: none; display: none;
} }
/* Header styles */ /* Header styles */
header { header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center;
padding: 1rem; padding: 1rem;
background-color: #1f1f1f; background-color: #1f1f1f;
color: #fff; color: #fff;
@ -182,12 +101,9 @@ header {
-webkit-app-region: drag; -webkit-app-region: drag;
} }
#linkup-text {
margin-left: auto;
}
.window-controls { .window-controls {
display: flex; display: flex;
align-items: center;
-webkit-app-region: no-drag; -webkit-app-region: no-drag;
} }
@ -214,28 +130,22 @@ textarea {
border: 1px solid #b0d944; border: 1px solid #b0d944;
background-color: #333; background-color: #333;
color: #b0d944; color: #b0d944;
padding: 0.5rem; padding: 0.75rem;
/* Reduced padding */
font-family: 'Roboto Mono', monospace; font-family: 'Roboto Mono', monospace;
font-size: 1rem; font-size: 1rem;
line-height: 1.25rem; line-height: 1.5rem;
/* Adjusted line height */
border-radius: 4px; border-radius: 4px;
transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease; transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
resize: none; resize: none; /* Prevent resizing */
/* Prevent resizing */ overflow-y: hidden; /* Hide scrollbar */
overflow-y: hidden;
/* Hide scrollbar */
} }
textarea { textarea {
height: auto; height: auto; /* Allow the textarea to grow dynamically */
/* Allow the textarea to grow dynamically */
} }
textarea:focus { textarea:focus {
outline: none; outline: none; /* Remove focus outline */
/* Remove focus outline */
} }
textarea::placeholder { textarea::placeholder {
@ -294,7 +204,6 @@ main {
} }
#header { #header {
width: 100%;
margin-bottom: 1rem; margin-bottom: 1rem;
} }
@ -320,19 +229,9 @@ main {
#details { #details {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center;
padding: 1rem; padding: 1rem;
background-color: #2b2b2b; background-color: #2b2b2b;
border-radius: 4px; border-radius: 4px;
width: 100%;
box-sizing: border-box;
/* Added to ensure box model includes padding */
}
#details>div {
display: flex;
flex-direction: column;
/* Allow peers count to stack */
} }
#submit-button { #submit-button {
@ -343,20 +242,17 @@ main {
flex: 1; flex: 1;
min-height: 200px; min-height: 200px;
overflow-y: auto; overflow-y: auto;
padding: 0.5rem; padding: 1rem;
/* Reduced padding */
background-color: #262626; background-color: #262626;
border-radius: 4px; border-radius: 4px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: 100%;
} }
#message-form { #message-form {
display: flex; display: flex;
margin-top: 1rem; margin-top: 1rem;
margin-right: 1rem; margin-right: 1rem;
width: 100%;
} }
#message { #message {
@ -386,18 +282,14 @@ main {
.message { .message {
display: flex; display: flex;
align-items: center; align-items: center;
margin-bottom: 0.5rem; margin-bottom: 1rem;
/* Reduced margin */
} }
.message img { .message img {
width: 32px; width: 40px;
/* Reduced size */ height: 40px;
height: 32px;
/* Reduced size */
border-radius: 50%; border-radius: 50%;
margin-right: 0.5rem; margin-right: 0.75rem;
/* Reduced margin */
border: 2px solid #b0d944; border: 2px solid #b0d944;
} }
@ -405,17 +297,13 @@ main {
max-width: 70%; max-width: 70%;
background-color: #2e2e2e; background-color: #2e2e2e;
padding: 0.5rem; padding: 0.5rem;
/* Reduced padding */ border-radius: 10px;
border-radius: 8px;
/* Reduced border radius */
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
} }
.message-header { .message-header {
font-weight: bold; font-weight: bold;
color: #b0d944; color: #b0d944;
font-size: 0.9rem;
/* Reduced font size */
} }
.message-time { .message-time {
@ -423,3 +311,67 @@ main {
font-size: 0.75rem; font-size: 0.75rem;
margin-left: 0.5rem; margin-left: 0.5rem;
} }
/* Button and input styles */
button,
input,
textarea {
border: 1px solid #b0d944;
background-color: #333;
color: #b0d944;
padding: 0.75rem;
font-family: 'Roboto Mono', monospace;
font-size: 1rem;
line-height: 1.5rem;
border-radius: 4px;
transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
resize: none; /* Prevent resizing */
overflow-y: hidden; /* Hide scrollbar */
}
textarea {
height: auto; /* Allow the textarea to grow dynamically */
}
textarea:focus {
outline: none; /* Remove focus outline */
}
textarea::placeholder {
color: #a0a0a0;
}
/* Chat container styles */
#chat {
display: flex;
flex-direction: column;
flex: 1;
width: 100%;
padding: 1rem;
background-color: #1e1e1e;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
overflow: hidden;
}
#message-form {
display: flex;
margin-top: 1rem;
margin-right: 1rem;
}
#message {
flex: 1;
margin-right: 0.5rem;
padding-right: 0.5rem;
height: 1.5rem; /* Initial single line height */
overflow-y: hidden; /* Hide scrollbar */
}
#message:focus {
height: auto; /* Allow the textarea to grow dynamically when focused */
}
#message:empty {
height: 1.5rem; /* Ensure single line height when empty */
}