replace sweetalert with Notiflix

This commit is contained in:
Jonny_Bro (Nikita) 2023-10-30 22:33:32 +05:00
parent 6ed2453380
commit d91b9c59c2
10 changed files with 19 additions and 4311 deletions

View file

@ -128,7 +128,7 @@ declare module "dbd-soft-ui" {
secretMenuCombination: string[] secretMenuCombination: string[]
} }
}, },
sweetalert: { notify: {
errors: { errors: {
requirePremium: string requirePremium: string
}, },

File diff suppressed because one or more lines are too long

View file

@ -32,7 +32,7 @@
} }
finally { finally {
document.body.removeChild(textarea); document.body.removeChild(textarea);
sweetalert("success", "Copied to clipboard", 3000) Notiflix.Notify.success("Copied to clipboard")
} }
} }
} }

View file

@ -73,17 +73,17 @@ if(req.cookies?.selectedTheme == "dark" || req.cookies?.selectedTheme == "auto"
const swal = params.get('swal'); const swal = params.get('swal');
const result = params.get('result'); const result = params.get('result');
if (swal) { if (swal) {
if (swal === "savedSuccess") sweetalert('success', '<%= req?.locales?.partials?.sweetalert?.success?.settingsSave || 'Successfully saved setttings!' %>', 3000); if (swal === "savedSuccess") Notiflix.Notify.success('<%= req?.locales?.partials?.notify?.success?.settingsSave || 'Successfully saved setttings!' %>');
if (swal === "savedError") sweetalert('error', '<%= req?.locales?.partials?.sweetalert?.errors?.settingsSave || 'Failed to save setttings!' %>', 3000); if (swal === "savedError") Notiflix.Notify.error('<%= req?.locales?.partials?.notify?.errors?.settingsSave || 'Failed to save setttings!' %>');
<% if (req.session.user) { %>if (swal === "logged") sweetalert('success', '<%= req?.locales?.partials?.sweetalert?.success?.login || 'Successfully logged in!' %>', 3000); <% } %> <% if (req.session.user) { %>if (swal === "logged") Notiflix.Notify.success('<%= req?.locales?.partials?.notify?.success?.login || 'Successfully logged in!' %>'); <% } %>
<% if (!req.session.user) { %>if (swal === "loggedout") sweetalert('success', '<%= req?.locales?.partials?.sweetalert?.success?.logout || 'Successfully logged out!' %>', 3000); <% } %> <% if (!req.session.user) { %>if (swal === "loggedout") Notiflix.Notify.success('<%= req?.locales?.partials?.notify?.success?.logout || 'Successfully logged out!' %>'); <% } %>
params.delete('swal'); params.delete('swal');
} }
if (result) { if (result) {
if (result === "true") sweetalert('success', 'Checked for updates!', 3000); if (result === "true") Notiflix.Notify.success('Checked for updates!');
if (result === "false") sweetalert('error', 'Failed to check for updates!', 3000); if (result === "false") Notiflix.Notify.error('Failed to check for updates!');
params.delete('result'); params.delete('result');
} }

View file

@ -126,38 +126,16 @@
yDiff = yDown - yUp; 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) { %> <% if (req.displayLoggedInInfo == true) { %>
window.onload = function () { window.onload = function () {
sweetalert("success", "<%= themeConfig?.sweetalert?.success?.login || 'Successfully signed in.' %>", 2000) Notiflix.Notify.success("<%= themeConfig?.notify?.success?.login || 'Successfully signed in.' %>", { timeout: 2000 })
}; };
<% } %> <% } %>
</script> </script>
<script src="https://cdn.jsdelivr.net/gh/Assistants-Center/DBD-Soft-UI/views/src/js/plugins/chartjs.min.js"></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="js/dashboard/themeselect.js"></script>
<script src="js/plugins/sweetalert2.js"></script> <script src="js/plugins/notiflix-aio-3.2.6.min.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/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/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/perfect-scrollbar.jquery.min.js"></script>

View file

@ -447,7 +447,7 @@
<script> <script>
$(document).ready(function () { $(document).ready(function () {
<% if ( req.query.error === "premiumRequired" ) { %> <% if ( req.query.error === "premiumRequired" ) { %>
sweetalert("error", "<%= themeConfig?.sweetalert?.error?.requirePremium || "Premium is required for this category" %>", 2000); Notiflix.Notify.error("<%= themeConfig?.notify?.error?.requirePremium || "Premium is required for this category" %>");
window.history.replaceState({}, title, window.location.href.split("?")[0]); window.history.replaceState({}, title, window.location.href.split("?")[0]);
<% } %> <% } %>
$(".multiSelect").select2({ closeOnSelect: true }); $(".multiSelect").select2({ closeOnSelect: true });

View file

@ -242,7 +242,7 @@ async function saveChanges() {
window.location.reload() window.location.reload()
} else } else
sweetalert("error", "Failed to save setttings!", 3000) Notiflix.Notify.error("Failed to save setttings!")
return return
} }
@ -252,10 +252,10 @@ async function saveChanges() {
window.history.pushState({}, "", url) window.history.pushState({}, "", url)
window.location.reload() window.location.reload()
} else sweetalert("success", "Successfully saved setttings!", 3000) } else Notiflix.Notify.success("Successfully saved setttings!")
} }
} catch (err) { } catch (err) {
sweetalert("error", "Failed to save setttings!", 3000) Notiflix.Notify.success("Failed to save setttings!")
console.error(`Error: ${err}`) console.error(`Error: ${err}`)
} }
} }

View file

@ -1,22 +0,0 @@
function sweetalert(icons, text, timer) {
var is_mobile =
!!navigator.userAgent.match(/iphone|android|blackberry/gi) || false
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,
})
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff