mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Set a timeout on server launch to display warn
This commit is contained in:
parent
af10353119
commit
47e2635b20
@ -606,7 +606,9 @@
|
||||
function send_command(server_id, command) {
|
||||
/* this getCookie function is in base.html */
|
||||
const token = getCookie("_xsrf");
|
||||
|
||||
setTimeout(warn('WebSockets are required for Crafty to work. This websocket connection has been closed. Are you using a reverse proxy?',
|
||||
'https://wiki.craftycontrol.com/en/4/docs/Reverse%20Proxy%20Examples',
|
||||
'wssError'), 5);
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
headers: { 'X-XSRFToken': token },
|
||||
@ -623,6 +625,51 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function warn(message, link = null, className = null) {
|
||||
var closeEl = document.createElement('span');
|
||||
var strongEL = document.createElement('strong');
|
||||
var msgEl = document.createElement('div');
|
||||
|
||||
closeEl.innerHTML = '×';
|
||||
strongEL.textContent = 'Warning: ';
|
||||
msgEl.append(strongEL, message);
|
||||
|
||||
|
||||
closeEl.style.marginLeft = '15px';
|
||||
closeEl.style.fontWeight = 'bold';
|
||||
closeEl.style.float = 'right';
|
||||
closeEl.style.fontSize = '22px';
|
||||
closeEl.style.lineHeight = '20px';
|
||||
closeEl.style.cursor = 'pointer';
|
||||
|
||||
closeEl.addEventListener('click', function () { this.parentElement.style.display = 'none'; });
|
||||
|
||||
var parentEl = document.createElement('div');
|
||||
|
||||
parentEl.style.padding = '20px';
|
||||
parentEl.style.backgroundColor = '#f7970f';
|
||||
|
||||
parentEl.appendChild(closeEl);
|
||||
parentEl.appendChild(msgEl);
|
||||
if (link) {
|
||||
let linkEl = document.createElement('a')
|
||||
linkEl.href = link;
|
||||
linkEl.innerHTML = "See our documentation for details.";
|
||||
linkEl.style.color = 'white';
|
||||
linkEl.style.textDecoration = 'underline';
|
||||
linkEl.target = "_blank";
|
||||
|
||||
parentEl.appendChild(linkEl);
|
||||
}
|
||||
|
||||
if (className) {
|
||||
parentEl.classList.add(className);
|
||||
}
|
||||
|
||||
document.querySelector('.warnings').appendChild(parentEl);
|
||||
}
|
||||
|
||||
function send_kill(server_id) {
|
||||
/* this getCookie function is in base.html */
|
||||
const token = getCookie("_xsrf");
|
||||
|
Loading…
Reference in New Issue
Block a user