2020-08-12 00:36:09 +00:00
<!DOCTYPE html>
2024-01-28 17:58:02 +00:00
< html lang = "{{ data['lang_page'] }}" class = "{{data['user_data'].get('theme', 'default')}}" data-username = "{{data['user_data'].get('username', None)}}" >
2020-09-22 22:23:14 +00:00
2022-01-21 22:50:04 +00:00
< head >
<!-- Required meta tags -->
< meta charset = "utf-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1, shrink-to-fit=no" >
{% block meta %}{% end %}
< title > {% block title %}{{ _('Default') }}{% end %}< / title >
<!-- plugins:css -->
< link rel = "stylesheet" href = "/static/assets/vendors/mdi/css/materialdesignicons.min.css" >
< link rel = "stylesheet" href = "/static/assets/vendors/flag-icon-css/css/flag-icon.min.css" >
< link rel = "stylesheet" href = "/static/assets/vendors/ti-icons/css/themify-icons.css" >
< link rel = "stylesheet" href = "/static/assets/vendors/typicons/typicons.css" >
2023-02-03 20:59:52 +00:00
< link rel = "stylesheet" href = "/static/assets/vendors/fontawesome6/css/all.css" >
2024-01-30 21:44:00 +00:00
< link rel = "stylesheet" type = "text/css" href = "https://fonts.googleapis.com/css?family=Sarabun" media = "screen" >
2023-08-09 21:47:53 +00:00
< link rel = "stylesheet" type = "text/css" href = "https://cdn.datatables.net/v/bs4/dt-1.10.22/fh-3.1.7/r-2.2.6/sc-2.0.3/sp-1.2.2/datatables.min.css" / >
2022-01-21 22:50:04 +00:00
< link rel = "stylesheet" href = "/static/assets/vendors/css/vendor.bundle.base.css" >
< link rel = "stylesheet" href = "/static/assets/css/crafty.css" >
2023-10-21 15:32:48 +00:00
< link rel = "stylesheet" href = "/static/assets/css/crafty-toggle-btn.css" >
2023-08-09 21:47:53 +00:00
2023-03-06 03:00:09 +00:00
< link rel = "manifest" href = "/static/assets/crafty.webmanifest" >
2022-08-04 23:45:44 +00:00
< meta name = "mobile-web-app-capable" content = "yes" >
2022-08-07 17:23:45 +00:00
< meta name = "apple-mobile-web-app-capable" content = "yes" >
< meta name = "mobile-web-app-capable" content = "yes" / >
< meta name = "apple-mobile-web-app-status-bar-style" content = "black" >
2023-03-09 01:50:32 +00:00
< meta name = "apple-mobile-web-app-title" content = "Crafty" >
2022-08-04 23:45:44 +00:00
< link rel = "apple-touch-icon" href = "../static/assets/images/Crafty_4-0.png" >
2023-03-07 03:54:26 +00:00
< link rel = "shortcut icon" sizes = "192x192" href = "../static/assets/images/Crafty_4-0.png" >
2022-08-04 23:45:44 +00:00
2022-01-21 22:50:04 +00:00
<!-- endinject -->
2022-06-02 17:41:16 +00:00
<!-- Plugin css for this page -->
2023-10-18 18:55:16 +00:00
< script src = "../static/assets/vendors/js/jquery.min.js" > < / script >
2022-06-02 17:41:16 +00:00
<!-- End Plugin css for this page -->
2022-05-31 00:57:19 +00:00
2022-01-21 22:50:04 +00:00
<!-- Layout styles -->
< link rel = "stylesheet" href = "/static/assets/css/dark/style.css" >
<!-- End Layout styles -->
< link rel = "shortcut icon" type = "image/svg+xml" href = "/static/assets/images/logo_small.svg" >
< link rel = "alternate icon" href = "/static/assets/images/favicon.png" / >
< link rel = "stylesheet" href = "/static/assets/css/crafty.css" >
2022-02-27 17:26:54 +00:00
<!-- Alpine.js - The modern jQuery alternative -->
2023-10-18 19:51:19 +00:00
< script defer src = "../static/assets/vendors/js/cdn.min.js" > < / script >
2022-02-27 17:26:54 +00:00
<!-- End Alpine.js -->
2022-06-22 22:58:06 +00:00
<!-- Bootstrap Toggle -->
2023-10-18 18:55:16 +00:00
< link href = "../static/assets/vendors/css/bootstrap-toggle.min.css" rel = "stylesheet" >
< script defer src = "../static/assets/vendors/js/bootstrap-toggle.min.js" > < / script >
< script src = "../static/assets/vendors/js/chart.min.js" > < / script >
< script src = "../static/assets/vendors/js/hammer.min.js" > < / script >
< script src = "../static/assets/vendors/js/chartjs-plugin-zoom.min.js" > < / script >
2022-06-22 22:58:06 +00:00
<!-- End Bootstrap Toggle -->
2022-01-21 22:50:04 +00:00
< / head >
2022-09-25 16:45:22 +00:00
< body >
2022-01-21 22:50:04 +00:00
< div class = "container-scroller" >
2022-10-04 21:03:42 +00:00
<!-- partial:partials/_navbar.html -->
< nav class = "navbar default-layout col-lg-12 col-12 p-0 fixed-top d-flex flex-row" >
< div class = "text-center navbar-brand-wrapper d-flex align-items-top justify-content-center" >
< a class = "navbar-brand brand-logo" href = "/panel/dashboard" >
< img src = "/static/assets/images/logo_long.svg" alt = "logo" / > < / a >
< a class = "navbar-brand brand-logo-mini" href = "/panel/dashboard" >
< img src = "/static/assets/images/logo_small.svg" alt = "logo" / > < / a >
2022-01-21 22:50:04 +00:00
< / div >
2022-10-04 21:03:42 +00:00
< div class = "navbar-menu-wrapper d-flex align-items-center" >
< style >
body:not(.sidebar-icon-only) .navbar-toggler .mdi-chevron-double-right {
display: none;
}
body.sidebar-icon-only .navbar-toggler .mdi-chevron-double-left {
display: none;
}
< / style >
< button class = "navbar-toggler navbar-toggler align-self-center" type = "button" data-toggle = "minimize" >
< span class = "mdi mdi-chevron-double-left" > < / span >
< span class = "mdi mdi-chevron-double-right" > < / span >
< / button >
2023-11-05 17:06:57 +00:00
< span class = "badge-pill badge-outline-primary" id = "server-name-nav" style = "display: none;" > < / span >
2022-10-04 21:03:42 +00:00
{% include notify.html %}
2023-08-09 21:47:53 +00:00
< button class = "navbar-toggler navbar-toggler-right d-lg-none align-self-center" type = "button" data-toggle = "offcanvas" >
2022-10-04 21:03:42 +00:00
< span class = "mdi mdi-menu" > < / span >
< / button >
< / div >
< / nav >
2020-12-17 13:39:29 +00:00
2022-10-04 21:10:03 +00:00
< div class = "container-fluid page-body-wrapper" >
{% include main_menu.html %}
2020-08-12 00:36:09 +00:00
2022-10-04 21:10:03 +00:00
< div class = "main-panel" >
2020-08-12 00:36:09 +00:00
2022-10-04 21:10:03 +00:00
< div class = "warnings" >
< noscript class = "noscript-warning" style = "padding: 20px; background-color: rgb(247, 151, 15);" >
< div > {% raw translate('base', 'doesNotWorkWithoutJavascript', data['lang']) %}< / div >
< / noscript >
< / div >
2022-10-04 21:03:42 +00:00
2022-10-04 21:10:03 +00:00
{% block content %}
{% end %}
2022-10-04 21:03:42 +00:00
2022-10-04 21:10:03 +00:00
{% include footer.html %}
2022-10-04 21:03:42 +00:00
2022-10-04 21:10:03 +00:00
< / div >
<!-- main - panel ends -->
2022-10-04 21:03:42 +00:00
2022-10-04 21:10:03 +00:00
< / div >
<!-- page - body - wrapper ends -->
2022-01-21 22:50:04 +00:00
< / div >
2020-08-23 22:43:28 +00:00
2021-02-27 12:05:04 +00:00
2022-01-21 22:50:04 +00:00
< style >
.notifications {
position: fixed;
width: 200px;
top: 70px;
right: 0px;
}
2021-02-27 12:05:04 +00:00
2022-01-21 22:50:04 +00:00
.notification {
position: relative;
2023-10-08 09:40:25 +00:00
margin-right: 1rem;
2022-09-26 02:23:37 +00:00
background: var(--card-banner-bg);
2023-10-08 09:55:11 +00:00
-webkit-transition: right 0.75s, opacity 0.75s, top 0.75s;
-moz-transition: right 0.75s, opacity 0.75s, top 0.75s;
-o-transition: right 0.75s, opacity 0.75s, top 0.75s;
2022-01-21 22:50:04 +00:00
transition: right 0.75s, opacity 0.75s, top 0.75s;
2023-10-08 09:40:25 +00:00
right: -20rem;
2022-01-21 22:50:04 +00:00
opacity: 0.1;
2023-10-08 09:40:25 +00:00
}
.toast-header {
background-color: var(--card-banner-bg);
color: var(--base-text);
}
.toast-body {
background-color: var(--dropdown-bg);
color: var(--base-text);
}
.notification img {
max-height: 20px;
}
.notification strong {
line-height: 20px;
2022-01-21 22:50:04 +00:00
}
2020-08-12 00:36:09 +00:00
2022-01-21 22:50:04 +00:00
.notification.active {
right: 0rem;
opacity: 1;
}
.notification.remove {
right: 0rem;
opacity: 0.1;
2023-10-08 09:55:11 +00:00
top: -2rem;
2022-01-21 22:50:04 +00:00
}
.notification span {
line-height: 20px;
2023-10-08 09:55:11 +00:00
font-size: 15px;
2022-01-21 22:50:04 +00:00
user-select: none;
2023-10-08 09:55:11 +00:00
cursor: pointer;
2022-01-21 22:50:04 +00:00
}
< / style >
2023-10-08 09:55:11 +00:00
< div class = "notifications" > < / div >
2023-10-08 09:40:25 +00:00
2022-01-21 22:50:04 +00:00
< script src = "/static/assets/vendors/js/vendor.bundle.base.js" > < / script >
< script src = "/static/assets/js/shared/off-canvas.js" > < / script >
< script src = "/static/assets/js/shared/hoverable-collapse.js" > < / script >
< script src = "/static/assets/js/shared/misc.js" > < / script >
2023-10-18 18:55:16 +00:00
< script type = "text/javascript" src = "../static/assets/vendors/js/datatables.min.js" > < / script >
< script src = "../static/assets/vendors/js/bootbox.min.js" > < / script >
2022-01-21 22:50:04 +00:00
< script type = "text/javascript" src = "/static/assets/js/motd.js" > < / script >
< script >
2022-06-15 23:37:53 +00:00
/**
* Returns a random number between min (inclusive) and max (exclusive)
*/
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
/**
* Returns a random integer between min (inclusive) and max (inclusive).
* The value is no lower than min (or the next integer greater than min
* if min isn't an integer) and no greater than max (or the next integer
* lower than max if max isn't an integer).
* Using Math.round() will give you a non-uniform distribution!
*/
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
2022-01-21 22:50:04 +00:00
$.extend($.fn.dataTable.defaults, {
2022-06-15 21:10:48 +00:00
// {{ '\nlanguage:' }} {% raw translate('datatables', 'i18n', data['lang']) %}
2022-08-07 15:04:56 +00:00
})
2021-01-11 19:51:38 +00:00
2022-01-21 22:50:04 +00:00
//used to get cookies from browser - this is part of tornados xsrf protection - it's for extra security
function getCookie(name) {
var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
return r ? r[1] : undefined;
2020-08-24 23:11:17 +00:00
}
2021-03-26 13:57:50 +00:00
// tool tips
2020-08-24 23:11:17 +00:00
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
2020-09-23 01:42:41 +00:00
2021-03-26 13:57:50 +00:00
// Notify
2022-01-21 22:50:04 +00:00
$(document).ready(function () {
$("#notificationDropdown").click(function () {
$.get("/ajax/announcements", function (data) {
2020-09-23 01:42:41 +00:00
console.log(data);
bootbox.alert({
2022-01-21 22:50:04 +00:00
title: "Notifications",
message: data,
2020-09-23 01:42:41 +00:00
});
});
});
});
2020-12-17 13:39:29 +00:00
2022-06-15 21:10:48 +00:00
let usingWebSockets = false;
let webSocket = null;
2023-08-10 16:40:32 +00:00
let websocketTimeoutId = null;
2021-03-26 13:57:50 +00:00
// {% if request.protocol == 'https' %}
2022-06-15 21:10:48 +00:00
usingWebSockets = true;
2022-01-21 22:50:04 +00:00
let listenEvents = [];
2022-06-15 21:10:48 +00:00
let wsOpen = false;
/**
* @type {number | null} reconnectorId An interval ID for the reconnector.
*/
let reconnectorId = null;
2022-06-15 23:37:53 +00:00
let failedConnectionCounter = 0; // https://stackoverflow.com/a/37038217/15388424
2022-06-15 21:10:48 +00:00
const wsPageQueryParams = 'page_query_params=' + encodeURIComponent(location.search)
const wsPage = 'page=' + encodeURIComponent(location.pathname)
const sendWssError = () => wsOpen || warn(
'WebSockets are required for Crafty to work. This websocket connection has been closed. Are you using a reverse proxy?',
2024-01-28 17:58:02 +00:00
link='https://docs.craftycontrol.com/pages/getting-started/proxies/',
link_msg="See our documentation for details",
className='wssError'
2022-06-15 21:10:48 +00:00
)
function startWebSocket() {
console.log('%c[Crafty Controller] %cConnecting the WebSocket', 'font-weight: 900; color: #800080;', 'font-weight: 900; color: #eee;');
try {
var wsInternal = new WebSocket('wss://' + location.host + '/ws?' + wsPage + '& ' + wsPageQueryParams);
wsInternal.onopen = function () {
console.log('opened WebSocket connection:', wsInternal)
wsOpen = true;
2022-06-15 23:37:53 +00:00
failedConnectionCounter = 0;
2022-06-15 21:10:48 +00:00
if (typeof reconnectorId === 'number') {
document.querySelectorAll('.wssError').forEach(el => el.remove())
clearInterval(reconnectorId);
reconnectorId = null;
}
};
wsInternal.onmessage = function (rawMessage) {
var message = JSON.parse(rawMessage.data);
console.log('got message: ', message)
listenEvents
.filter(listenedEvent => listenedEvent.event == message.event)
.forEach(listenedEvent => listenedEvent.callback(message.data))
};
wsInternal.onerror = function (errorEvent) {
console.error('WebSocket Error', errorEvent);
};
wsInternal.onclose = function (closeEvent) {
wsOpen = false;
console.log('Closed WebSocket', closeEvent);
2023-08-10 16:40:32 +00:00
if (!document.hidden) {
if (typeof reconnectorId !== 'number') {
setTimeout(sendWssError, 7000);
}
console.info("Reconnecting with a timeout of", (getRandomArbitrary(0, 2 ** failedConnectionCounter - 1) + 5) * 1000, "milliseconds");
// Discard old websocket and create a new one in 5 seconds
wsInternal = null
reconnectorId = setTimeout(startWebSocket, (getRandomArbitrary(0, 2 ** failedConnectionCounter - 1) + 5) * 1000)
2022-06-15 23:37:53 +00:00
2023-08-10 16:40:32 +00:00
failedConnectionCounter++;
}
2022-06-15 21:10:48 +00:00
};
2022-01-21 22:50:04 +00:00
2022-06-15 21:10:48 +00:00
webSocket = {
on: function (event, callback) {
console.log('registered ' + event + ' event');
listenEvents.push({ event: event, callback: callback })
},
emit: function (event, data) {
var message = {
event: event,
data: data
}
wsInternal.send(JSON.stringify(message));
2023-08-11 09:32:38 +00:00
},
close: function (code, reason) {
wsInternal.close(code, reason);
},
getStatus: function () {
return wsInternal.readyState;
2022-06-15 21:10:48 +00:00
}
2020-12-17 13:39:29 +00:00
}
2022-06-15 21:10:48 +00:00
} catch (error) {
console.error('Error while making websocket helpers', error);
usingWebSockets = false;
2020-12-17 13:39:29 +00:00
}
2022-01-21 22:50:04 +00:00
}
2022-06-15 21:10:48 +00:00
startWebSocket();
2021-03-26 13:57:50 +00:00
// {% else %}
2022-01-21 22:50:04 +00:00
warn('WebSockets are not supported in Crafty if not using the https protocol')
2021-03-26 13:57:50 +00:00
// {% end%}
2020-12-17 13:39:29 +00:00
2023-08-10 16:40:32 +00:00
// Managing Connexions for Multi Tab opened to reduce bandwith usage
document.addEventListener("visibilitychange", () => {
2023-08-11 09:32:38 +00:00
if (document.visibilityState == "hidden") {
2023-08-10 16:40:32 +00:00
websocketTimeoutId = setTimeout(() => {
webSocket.close(1000, "Closed due to Inactivity");
console.log('%c[Crafty Controller] %cClose Websocket due to Tab not active after 5s', 'font-weight: 900; color: #800080;', 'font-weight: 900; color: #eee;');
2023-08-11 15:20:44 +00:00
}, 10000);
2023-08-10 16:40:32 +00:00
} else {
clearTimeout(websocketTimeoutId)
if (webSocket.getStatus() == WebSocket.CLOSED) {
startWebSocket();
}
}
});
2022-01-21 22:50:04 +00:00
if (webSocket) {
webSocket.on('send_start_error', function (start_error) {
var x = document.querySelector('.bootbox');
if (x) {
x.remove()
}
var x = document.querySelector('.modal-backdrop');
if (x) {
x.remove()
}
bootbox.alert({
message: start_error.error,
callback: function () {
location.reload();
}
})
});
2022-03-13 12:29:26 +00:00
webSocket.on('support_status_update', function (logs) {
2022-05-24 01:23:29 +00:00
if (logs.percent >= 100) {
2022-03-13 12:29:26 +00:00
document.getElementById('logs_progress_bar').innerHTML = '100%';
document.getElementById('logs_progress_bar').style.width = '100%';
2022-05-24 01:23:29 +00:00
} else {
document.getElementById('logs_progress_bar').innerHTML = logs.percent + '%';
2022-03-13 12:29:26 +00:00
document.getElementById('logs_progress_bar').style.width = logs.percent + '%';
}
});
2022-01-21 22:50:04 +00:00
webSocket.on('send_logs_bootbox', function (server_id) {
var x = document.querySelector('.bootbox');
if (x) {
x.remove()
2022-01-14 01:42:53 +00:00
}
2022-01-21 22:50:04 +00:00
var x = document.querySelector('.modal-backdrop');
if (x) {
x.remove()
2021-11-23 21:11:23 +00:00
}
2023-11-30 17:50:50 +00:00
bootbox.confirm({
2022-01-21 22:50:04 +00:00
title: "{{ translate('notify', 'downloadLogs', data['lang']) }}",
message: "{{ translate('notify', 'finishedPreparing', data['lang']) }}",
buttons: {
2023-11-30 17:50:50 +00:00
confirm: {
2022-01-21 22:50:04 +00:00
label: 'Download',
className: 'btn-info'
}
},
2023-11-30 17:50:50 +00:00
callback: function (result) {
2024-01-30 21:10:49 +00:00
if (result) {
2023-11-30 17:50:50 +00:00
location.href = "/panel/download_support_package";
2023-12-07 13:31:50 +00:00
} else {
bootbox.close();
2023-11-30 17:50:50 +00:00
}
2022-01-21 22:50:04 +00:00
}
});
});
webSocket.on('send_eula_bootbox', function (server_id) {
var x = document.querySelector('.bootbox');
if (x) {
x.remove()
}
var x = document.querySelector('.modal-backdrop');
if (x) {
x.remove()
}
bootbox.confirm({
2022-06-08 21:56:22 +00:00
title: "{% raw translate('error', 'eulaTitle', data['lang']) %}",
2022-09-01 18:18:04 +00:00
message: "{% raw translate('error', 'eulaMsg', data['lang']) %}< a href = 'https://www.minecraft.net/en-us/eula' target = '_blank' > Minecraft EULA< / a > ",
2022-01-21 22:50:04 +00:00
buttons: {
confirm: {
label: 'Yes',
className: 'btn-info'
},
cancel: {
label: 'No',
className: 'btn-secondary'
}
},
callback: function (result) {
if (result == true) {
eulaAgree(server_id.id)
}
else {
location.reload()
}
}
})
});
}
2023-07-13 14:39:25 +00:00
async function eulaAgree(server_id, command) {
2022-05-24 01:23:29 +00:00
//< !--this getCookie function is in base.html-- >
2023-09-04 23:22:11 +00:00
const token = getCookie("_xsrf");
2021-11-23 21:11:23 +00:00
2023-07-13 14:39:25 +00:00
let res = await fetch(`/api/v2/servers/${server_id}/action/eula/`, {
method: 'POST',
headers: {
'X-XSRFToken': token
},
2021-11-23 21:11:23 +00:00
});
2023-07-13 14:39:25 +00:00
let responseData = await res.json();
if (responseData.status === "ok") {
window.location.reload();
} else {
bootbox.alert({
title: responseData.error,
message: responseData.error_data
});
}
2021-11-23 21:11:23 +00:00
}
2021-08-07 18:25:47 +00:00
2024-01-28 17:58:02 +00:00
function warn(message, link = null, link_msg=null, className = null, bg_color="#f7970f") {
2020-12-17 13:39:29 +00:00
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';
2021-02-27 12:07:16 +00:00
closeEl.style.float = 'right';
2021-02-27 12:05:04 +00:00
closeEl.style.fontSize = '22px';
2021-02-27 12:07:16 +00:00
closeEl.style.lineHeight = '20px';
2020-12-17 13:39:29 +00:00
closeEl.style.cursor = 'pointer';
2022-01-21 22:50:04 +00:00
closeEl.addEventListener('click', function () { this.parentElement.style.display = 'none'; });
2020-12-17 13:39:29 +00:00
var parentEl = document.createElement('div');
parentEl.style.padding = '20px';
2024-01-28 17:58:02 +00:00
parentEl.style.backgroundColor = bg_color;
2020-12-17 13:39:29 +00:00
parentEl.appendChild(closeEl);
parentEl.appendChild(msgEl);
2022-05-24 01:23:29 +00:00
if (link) {
let linkEl = document.createElement('a')
linkEl.href = link;
2024-02-02 22:41:07 +00:00
linkEl.innerHTML = link_msg;
2024-01-30 21:10:49 +00:00
//linkEl.style.color = 'white';
2022-05-24 01:23:29 +00:00
linkEl.style.textDecoration = 'underline';
linkEl.target = "_blank";
parentEl.appendChild(linkEl);
}
2020-12-17 13:39:29 +00:00
2022-06-15 21:10:48 +00:00
if (className) {
parentEl.classList.add(className);
}
2020-12-17 13:39:29 +00:00
document.querySelector('.warnings').appendChild(parentEl);
}
2021-02-27 12:05:04 +00:00
function closeNotification(element) {
2023-10-08 09:55:11 +00:00
element.parentElement.classList.add('remove');
2021-02-27 12:05:04 +00:00
setTimeout(function () {
element.parentElement.remove();
}, 500);
}
function notify(message) {
2022-02-27 17:26:54 +00:00
console.log(`notify(${message})`);
2023-10-08 09:40:25 +00:00
var intId = getRandomInt(0, 100);
var toastDiv = document.createElement('div');
toastDiv.setAttribute("id", "toast_" + intId);
toastDiv.setAttribute("class", "notification toast");
toastDiv.setAttribute("role", "alert");
toastDiv.setAttribute("aria-lived", "assertive");
toastDiv.setAttribute("aria-atomic", "true");
toastDiv.setAttribute("data-delay", "3000");
toastDiv.setAttribute("data-animation", "true");
toastDiv.setAttribute("data-autohide", "false");
var toastHeaderDiv = document.createElement('div');
toastHeaderDiv.setAttribute("class", "toast-header");
var toastHeaderImg = document.createElement('img');
toastHeaderImg.setAttribute("src", "/static/assets/images/logo_small.svg");
toastHeaderImg.setAttribute("class", "mr-auto");
toastHeaderImg.setAttribute("alt", "logo");
toastHeaderDiv.appendChild(toastHeaderImg);
var toastHeaderTitle = document.createElement('strong');
toastHeaderTitle.setAttribute("class", "mr-auto");
toastHeaderTitle.innerHTML = " Crafty Controller ";
toastHeaderDiv.appendChild(toastHeaderTitle);
var toastHeaderCloseSpan = document.createElement('span');
toastHeaderCloseSpan.setAttribute("class", "fa-solid fa-xmark");
toastHeaderCloseSpan.setAttribute("aria-hidden", "true");
toastHeaderCloseSpan.addEventListener('click', function () { closeNotification(this.parentElement) });
2023-10-08 09:55:11 +00:00
toastHeaderDiv.appendChild(toastHeaderCloseSpan);
2023-10-08 09:40:25 +00:00
var toastBodyDiv = document.createElement('div');
toastBodyDiv.setAttribute("class", "toast-body");
toastBodyDiv.textContent = message;
toastDiv.appendChild(toastHeaderDiv);
toastDiv.appendChild(toastBodyDiv);
document.querySelector('.notifications').appendChild(toastDiv);
$('#toast_' + intId).toast('show');
2021-02-27 12:05:04 +00:00
setTimeout(function () {
2023-10-08 09:40:25 +00:00
toastDiv.classList.add('active');
2021-02-27 12:05:04 +00:00
}, 200);
setTimeout(function (element) {
2023-10-09 16:57:11 +00:00
closeNotification(element.parentElement);
2023-10-08 09:40:25 +00:00
}, 7500, toastHeaderCloseSpan);
2021-02-27 12:05:04 +00:00
`
< div class = "notification" >
< p > Hello, World! This text should overflow< / p >
< span > × < / span >
< / div >
`
}
webSocket.on('notification', notify);
2022-02-27 17:26:54 +00:00
document.addEventListener('alpine:init', () => {
console.log('%c[Crafty Controller] %cAlpine.js pre-initialization!', 'font-weight: 900; color: #800080;', 'color: #eee;');
2023-08-10 16:40:32 +00:00
});
2022-02-27 17:26:54 +00:00
document.addEventListener('alpine:initialized', () => {
console.log('%c[Crafty Controller] %cAlpine.js initialized!', 'font-weight: 900; color: #800080;', 'color: #eee;');
2023-08-10 16:40:32 +00:00
});
2022-02-27 17:26:54 +00:00
2022-01-21 22:50:04 +00:00
$(document).ready(function () {
2022-02-27 17:26:54 +00:00
console.log('%c[Crafty Controller] %cReady for JS!', 'font-weight: 900; color: #800080;', 'font-weight: 900; color: #eee;');
2024-01-28 17:58:02 +00:00
if ($(document.documentElement).data("username") === "anti-lockout-user"){
warn(
'⚠️ You are in a recovery account. Access is limited!',
link='/logout',
link_msg="Click here to log out after you change your password. ⚠️",
2024-02-02 21:13:59 +00:00
className='anti-lockout',
2024-02-01 03:00:45 +00:00
bg_color='#6887dc'
2024-01-28 17:58:02 +00:00
)
}
2022-01-21 22:50:04 +00:00
$('#support_logs').click(function () {
2022-01-15 04:53:44 +00:00
var dialog = bootbox.dialog({
2022-06-08 22:11:21 +00:00
message: "< p class = 'text- center mb - 0' > < i class = 'fa fa - spin fa - cog' > < / i > {{ translate('notify', 'preparingLogs', data['lang']) }}< / p > ",
2022-01-15 04:53:44 +00:00
closeButton: false
2022-01-21 22:50:04 +00:00
});
setTimeout(function () {
location.href = "/panel/support_logs";
}, 6000);
2022-01-15 04:53:44 +00:00
});
2022-01-21 22:50:04 +00:00
});
2023-03-06 03:00:09 +00:00
$(document).ready(() => {
if ('serviceWorker' in navigator) {
2023-08-09 21:47:53 +00:00
navigator.serviceWorker.register('/static/assets/js/shared/service-worker.js', { scope: '/' })
2023-03-06 03:00:09 +00:00
.then(function (registration) {
console.log('Service Worker Registered');
});
}
});
2022-01-21 22:50:04 +00:00
< / script >
2022-01-15 04:53:44 +00:00
2022-01-21 22:50:04 +00:00
{% block js %}
<!-- Custom js for base.html page partial pages -->
<!-- End custom js for base.html page -->
{% end %}
2020-08-12 00:36:09 +00:00
2022-01-21 22:50:04 +00:00
< / body >
2020-08-23 22:43:28 +00:00
2023-12-07 13:31:50 +00:00
< / html >