moved script to the bottom
This commit is contained in:
@@ -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>
|
||||
2
index.js
2
index.js
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user