location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_read_timeout 96000;
proxy_cache_bypass $http_upgrade;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/domens.lv/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domens.lv/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.domens.lv) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = domens.lv) {
return 301 https://$host$request_uri;
} # managed by Certbot
// change the number of online
socket.on('numberOfOnline', size => {
document.querySelector('.online').innerHTML = `${size.toLocaleString()} čatotāji`
});
// event listener for search
document.querySelector('#start').addEventListener('click', () => {
// searching for someone to talk to
socket.emit('start', socket.id);
});
// display searching message
socket.on('searching', msg => {
// add the searching message to our html
conversation.innerHTML = `<div class="message">${msg}</div>`;
});
// found someone
// start of their chat
socket.on('chatStart', msg => {
// add the message to our html that a user has found
conversation.innerHTML = `<div class="message">${msg}</div>`;
// remove the hide class of stop button
document.querySelector('#stop').classList.remove('hide');
// event listener for form submit
document.querySelector('.form').addEventListener('submit', e => {
e.preventDefault();
submitMessage();
});
// event listener when user press enter key
document.querySelector('#text').onkeydown = e => {
// enter key is pressed without shift key
if(e.keyCode === 13 && !e.shiftKey) {
e.preventDefault();
submitMessage();
}
}
// event listener when user is typing
document.querySelector('#text').addEventListener('input', e => {
if(!alreadyTyping) {
// emit message to server that a stranger is typing
socket.emit('typing', 'Svešinieks raksta...');
alreadyTyping = true;
}
// check if user is not typing
if(e.target.value === '') {
socket.emit('doneTyping');
alreadyTyping = false;
}
});
// event listener when textarea is not focused
document.querySelector('#text').addEventListener('blur', () => {
socket.emit('doneTyping');
alreadyTyping = false;
});
// event listener when textarea is clicked
//document.querySelector('#text').addEventListener('click', e => {
// check if value is not empty
//if(e.target.value !== '') {
// emit message to server that a stranger is typing
// socket.emit('typing', 'Stranger is typing...');
// alreadyTyping = true;
//}
//});
// receive the message from server then add it to html
socket.on('newMessageToClient', data => {
const notStranger = data.id === socket.id;
// scroll to the bottom of the conversation
conversation.scrollTo(0, conversation.scrollHeight);
});
// message when someome is typing
socket.on('strangerIsTyping', msg => {
// add the message to html
conversation.innerHTML += conversation.innerHTML = `<div class="message typing">${msg}</div>`;
// scroll conversation to bottom
conversation.scrollTo(0, conversation.scrollHeight);
});
// remove the Stranger is typing... message
socket.on('strangerIsDoneTyping', () => {
const typing = document.querySelector('.typing');
Question
Blumish
Sveiki!
Nekādi netieku skaidrībā kas par problēmu. Visādi izmēģinājos!
Digitalocen droplet
Nginx default
Nginc conf
script.js
Index.html
Paldies!
Edited by BlumishLink to comment
Share on other sites
7 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.