moved script to the bottom

This commit is contained in:
slawk0
2024-08-21 23:51:43 +02:00
parent 4e40b4f74f
commit d41a898c3e
2 changed files with 16 additions and 14 deletions

View File

@@ -17,19 +17,6 @@
</style>
<script src="/socket.io/socket.io.js"></script>
<script>
const socket = io();
document.getElementById('form').addEventListener('submit', (e) => {
e.preventDefault();
if (input.value) {
socket.emit('chat message', input.value);
input.value = '';
}
});
</script>
</head>
<body>
<ul id="messages"></ul>
@@ -38,6 +25,21 @@
<input id="input" autocomplete="off" />
<button>Send</button>
</form>
<script src="/socket.io/socket.io.js"></script>
<script>
const socket = io();
const form = document.getElementById('form');
const input = document.getElementById('input');
form.addEventListener('submit', (e) => {
e.preventDefault();
if (input.value) {
socket.emit('chat message', input.value);
input.value = '';
}
});
</script>
</body>
</html>

View File

@@ -20,7 +20,7 @@ app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname, 'public')));
app.use('/static', express.static('frontend'));
app.use('/socket', express.static('node_modules/socket.io/client-dist'));
app.use('/socket.io', express.static('node_modules/socket.io/client-dist'));
app.use(session({
secret: process.env.SESSION_SECRET,
resave: true,