");
ntfContainer.addClass(`wpd-notices-container wpd-notice wpd-notice-${options.type}`);
ntfContainer.html(`
${options.text}`);
$(".wpd-notices-container", "body").remove();
$("body").append(ntfContainer);
setTimeout(() => {
ntfContainer.remove();
}, options.timeout);
}
/*=== NOTIFICATION END ===*/
/*=== EMAIL TEMPLATES ACCORDION START ===*/
const hashRegex = /#(wpd\-[a-zA-z0-9\-\_]+)/;
let urlHash = location.href.match(hashRegex);
let accordionitem = null;
let browserSupportsHash = false;
if ("onhashchange" in window) {
browserSupportsHash = true;
}
if (browserSupportsHash) {
window.addEventListener("hashchange", wpdOnhashchange, false);
}
if (urlHash != null) {
accordionitem = $('.wpd-accordion-title[data-wpd-selector="' + urlHash[1] + '"');
wpdAccordion(accordionitem);
}
$('body').on('click', '.wpd-accordion-title', function (e) {
e.preventDefault();
e.stopPropagation();
accordionitem = $(this);
if (!browserSupportsHash) {
wpdAccordion(accordionitem);
}
urlHash = location.href.match(hashRegex);
const selector = accordionitem.attr("data-wpd-selector");
if (urlHash != null) {
if (urlHash[1] === selector) {
window.history.replaceState({}, "", location.href.replace("#" + selector, ""));
if (browserSupportsHash) {
wpdAccordion(accordionitem);
}
} else {
window.history.replaceState({}, "", location.href.replace(urlHash[1], selector));
if (browserSupportsHash) {
window.dispatchEvent(new HashChangeEvent("hashchange"));
}
}
} else {
location.href = location.href.indexOf("#") >= 0 ? location.href.substring(0, location.href.lastIndexOf("#") + 1) + selector : location.href + "#" + selector;
}
});
function wpdAccordion(accordionitem) {
if (accordionitem != null) {
$(accordionitem).parent().siblings('.wpd-accordion-item').removeClass('wpd-accordion-current');
$(accordionitem).parent().siblings('.wpd-accordion-item').find('.wpd-accordion-content').slideUp(0);
$(accordionitem).siblings('.wpd-accordion-content').slideToggle(0);
$(accordionitem).parent().toggleClass('wpd-accordion-current');
return false;
}
}
function wpdOnhashchange() {
urlHash = location.href.match(hashRegex);
if (urlHash != null) {
accordionitem = $('.wpd-accordion-title[data-wpd-selector="' + urlHash[1] + '"');
wpdAccordion(accordionitem);
}
}
/*=== EMAIL TEMPLATES ACCORDION START ===*/
});
//========================= DASHBOARD =====================//
var wpdSpinner = '
';
var wpdStatUserPage = 1;
function wpd_stat_brief() {
jQuery.ajax({
type: 'POST',
url: ajaxurl,
data: {
action: 'wpd_stat_brief',
security: wpdiscuzObj.wpdOptionNonce,
}
}).done(function (r) {
if (r.success) {
jQuery('.wpd-stat-brief .wpd-stat-brief-all strong').text(r.data.all);
jQuery('.wpd-stat-brief .wpd-stat-brief-inline strong').text(r.data.inline);
jQuery('.wpd-stat-brief .wpd-stat-brief-threads strong').text(r.data.threads);
jQuery('.wpd-stat-brief .wpd-stat-brief-replies strong').text(r.data.replies);
jQuery('.wpd-stat-brief .wpd-stat-brief-users strong').text(r.data.users);
jQuery('.wpd-stat-brief .wpd-stat-brief-guests strong').text(r.data.guests);
}
}).fail(function (jqXHR, textStatus, errorThrown) {
console.log(errorThrown);
el.addClass('wpd_not_clicked');
});
}
function wpd_stat_subs(el, body) {
body.html(wpdSpinner);
jQuery.ajax({
type: 'POST',
url: ajaxurl,
data: {
action: 'wpd_stat_subs',
security: wpdiscuzObj.wpdOptionNonce,
}
}).done(function (r) {
body.html(r);
el.addClass('wpd_not_clicked');
}).fail(function (jqXHR, textStatus, errorThrown) {
console.log(errorThrown);
el.addClass('wpd_not_clicked');
});
}
function wpd_stat_graph(el, body) {
body.html(wpdSpinner);
var interval = Cookies.get('wpd_stat_graph_interval');
if (!interval) {
interval = 'today';
}
jQuery('.wpd-stat-graph .wpd-box-toggle .wpd-graph-tools span').removeClass('wpd_tool_active');
jQuery('[data-interval=' + interval + ']').addClass('wpd_tool_active');
jQuery.ajax({
type: 'POST',
url: ajaxurl,
data: {
action: 'wpd_stat_graph',
interval: interval,
security: wpdiscuzObj.wpdOptionNonce,
}
}).done(function (r) {
if (r.success) {
body.html(r.data.el);
body.parent().find('.wpd-box-toggle .dashicons-admin-generic, .wpd-box-info').show();
var wpdchart = document.getElementById('wpdChart');
wpdchart.height = 250;
Chart.defaults.global.defaultFontSize = 9;
Chart.defaults.global.defaultFontColor = '#333';
new Chart(wpdchart, {
type: 'bar',
data: {
labels: r.data.labels,
datasets: [
{
label: '',
data: r.data.all,
backgroundColor: '#46C08F',
borderColor: '#46C08F'
},
{
label: '',
data: r.data.inline,
backgroundColor: '#0498F9',
borderColor: '#0498F9'
}
]
},
options: {
maintainAspectRatio: false,
legend: {
labels: {
usePointStyle: true,
}
},
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
} else {
body.html("Something is wrong");
}
el.addClass('wpd_not_clicked');
}).fail(function (jqXHR, textStatus, errorThrown) {
console.log(errorThrown);
el.addClass('wpd_not_clicked');
});
}
function wpd_stat_user(el, body) {
body.html(wpdSpinner);
jQuery('.wpd-stat-user .wpd-box-toggle .dashicons-arrow-left, .wpd-stat-user .wpd-box-toggle .dashicons-arrow-right').removeClass('wpd_not_clicked');
var orderby = Cookies.get('wpd_stat_user_orderby');
if (!orderby) {
orderby = 'comments';
}
var order = Cookies.get('wpd_stat_user_order');
if (!order) {
order = 'desc';
}
jQuery.ajax({
type: 'POST',
url: ajaxurl,
data: {
action: 'wpd_stat_user',
orderby: orderby,
order: order,
page: wpdStatUserPage,
security: wpdiscuzObj.wpdOptionNonce,
}
}).done(function (r) {
if (r.success) {
body.html(r.data.body);
body.parent().find('.wpd-box-toggle .dashicons-arrow-left, .wpd-box-toggle .dashicons-arrow-right').show();
el.addClass('wpd_not_clicked');
jQuery('.wpd-stat-user .wpd-box-toggle .dashicons-arrow-left, .wpd-stat-user .wpd-box-toggle .dashicons-arrow-right').addClass('wpd_not_clicked');
if (wpdStatUserPage > 1) {
jQuery('.wpd-stat-user .wpd-box-toggle .dashicons-arrow-left').css('visibility', 'visible');
} else {
jQuery('.wpd-stat-user .wpd-box-toggle .dashicons-arrow-left').css('visibility', 'hidden');
}
if (r.data.more) {
jQuery('.wpd-stat-user .wpd-box-toggle .dashicons-arrow-right').css('visibility', 'visible');
} else {
jQuery('.wpd-stat-user .wpd-box-toggle .dashicons-arrow-right').css('visibility', 'hidden');
}
} else {
body.html(r.data);
}
}).fail(function (jqXHR, textStatus, errorThrown) {
console.log(errorThrown);
el.addClass('wpd_not_clicked');
});
}
//========================= /DASHBOARD =====================//