dashboard-core/theme/dbd-soft-ui/views/partials/scripts.ejs
Jonny_Bro (Nikita) 08275381dc integrate theme
2023-06-19 14:21:58 +05:00

172 lines
No EOL
6.3 KiB
Text

<!-- Core JS Files -->
<script src="https://cdn.jsdelivr.net/npm/jquery.skeleton.loader@1.2.0/dist/jquery.scheletrone.min.js"></script>
<script src="https://code.jquery.com/ui/1.13.1/jquery-ui.min.js"
integrity="sha256-eTyxS0rkjpLEo16uXTS0uVCS4815lc40K2iVpWDvdSY=" crossorigin="anonymous"></script>
<script>
function login(url) {
<% if (!req.session.user) { %>
const newWindow = window.open('/discord', 'Log in with discord', `directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no, width=500, height=800`);
newWindow.focus();
setInterval(() => {
if (newWindow.closed) window.location.href = `${url}?swal=logged`;
}, 500);
<% } else { %>
window.location.href = `${url}?swal=alreadyloggedin`;
<% } %>
}
$('.account').click(function (e) {
e.preventDefault();
login(e.currentTarget.href)
});
$('.theme').click(function () {
$('.theme').removeClass('active');
$(this).addClass('active');
const theme = $(this).attr('data-theme');
setCookie('selectedTheme', theme, 365);
location.reload();
});
const sidenav = document.getElementById('sidenav-main');
function hideSidenav() {
body.classList.remove(className);
setTimeout(function () {
sidenav.classList.remove('bg-white');
}, 100);
sidenav.classList.remove('bg-transparent');
}
function showSidenav() {
try {
body.classList.add(className);
sidenav.classList.add('bg-white');
sidenav.classList.remove('bg-transparent');
iconSidenav.classList.remove('d-none');
} catch (error) {
}
}
<% if (!themeConfig?.sidebar?.gestures?.disabled) { %>
document.addEventListener('touchstart', handleTouchStart, false);
document.addEventListener('touchmove', handleTouchMove, false);
document.addEventListener('touchend', handleTouchEnd, false);
const SWIPE_BLOCK_ELEMS = [
'swipBlock',
'handle',
'drag-ruble'
]
let xDown = null;
let yDown = null;
let xDiff = null;
let yDiff = null;
let timeDown = null;
const TIME_THRESHOLD = <%= themeConfig?.sidebar?.gestures?.gestureTimer || 200 %>;
const DIFF_THRESHOLD = <%= themeConfig?.sidebar?.gestures?.gestureSensitivity || 50 %>;
function handleTouchEnd() {
let timeDiff = Date.now() - timeDown;
if (Math.abs(xDiff) > Math.abs(yDiff)) {
if (Math.abs(xDiff) > DIFF_THRESHOLD && timeDiff < TIME_THRESHOLD) {
if (xDiff > 0) {
hideSidenav()
xDown = null;
yDown = null;
timeDown = null;
} else {
showSidenav()
xDown = null;
yDown = null;
timeDown = null;
}
}
}
xDown = null;
yDown = null;
timeDown = null;
}
function containsClassName(evntarget, classArr) {
for (var i = classArr.length - 1; i >= 0; i--) {
if (evntarget.classList.contains(classArr[i])) {
return true;
}
}
}
function handleTouchStart(evt) {
let touchStartTarget = evt.target;
if (containsClassName(touchStartTarget, SWIPE_BLOCK_ELEMS)) {
return;
}
timeDown = Date.now()
xDown = evt.touches[0].clientX;
yDown = evt.touches[0].clientY;
xDiff = 0;
yDiff = 0;
}
function handleTouchMove(evt) {
if (!xDown || !yDown) {
return;
}
var xUp = evt.touches[0].clientX;
var yUp = evt.touches[0].clientY;
xDiff = xDown - xUp;
yDiff = yDown - yUp;
}
<% } %>
function sweetalert(icons, text, timer) {
var is_mobile = !!navigator.userAgent.match(/iphone|android|blackberry/ig);
let pos = 'top-end';
if (is_mobile) pos = 'bottom-end';
const Toast = Swal.mixin({
toast: true,
position: pos,
showConfirmButton: false,
timer: timer,
timerProgressBar: true,
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
}
})
Toast.fire({
icon: icons,
title: text
})
}
<% if (req.displayLoggedInInfo == true) { %>
window.onload = function () {
sweetalert("success", "<%= themeConfig?.sweetalert?.success?.login || 'Successfully signed in.' %>", 2000)
};
<% } %>
</script>
<script src="https://cdn.jsdelivr.net/gh/Assistants-Center/DBD-Soft-UI/views/src/js/plugins/chartjs.min.js"></script>
<script src="js/dashboard/sweetalert.js"></script>
<script src="js/dashboard/themeselect.js"></script>
<script src="https://cdn.jsdelivr.net/gh/Assistants-Center/DBD-Soft-UI/views/src/js/custom.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/Assistants-Center/DBD-Soft-UI/views/src/js/sidebarmenu.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/Assistants-Center/DBD-Soft-UI/views/src/js/perfect-scrollbar.jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/Assistants-Center/DBD-Soft-UI/views/src/js/core/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/Assistants-Center/DBD-Soft-UI/views/src/js/core/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/Assistants-Center/DBD-Soft-UI/views/src/js/plugins/perfect-scrollbar.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/Assistants-Center/DBD-Soft-UI/views/src/js/plugins/smooth-scrollbar.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/Assistants-Center/DBD-Soft-UI/views/src/js/core/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://kit.fontawesome.com/5c57f03f9b.js" crossorigin="anonymous"></script>
<script src="https://kit.fontawesome.com/42d5adcbca.js" crossorigin="anonymous"></script>