File: /home/xedaptot/ai.naniguide.com/public/core/js/app.js
$(function(){
initJs($('body'));
// Main menu js
initMainMenu();
// SessionGuard: mark when the user starts a sign-out so the global 401
// handler below doesn't fight the browser navigation already underway.
// Covers both the POST form submit (refactor user-menu) and the GET <a>
// fallback that some legacy menus still use.
document.addEventListener('submit', function (e) {
if (e.target && e.target.id === 'mc-logout-form') window.__acelleSignOutClicked = true;
}, true);
document.addEventListener('click', function (e) {
var a = e.target && e.target.closest && e.target.closest('a[href$="/logout"]');
if (a) window.__acelleSignOutClicked = true;
}, true);
// Default jQuery Exception
$( document ).ajaxError(function( event, request, settings ) {
if (settings.globalError === false) return;
// abort ajax
if (request.statusText === 'abort') {
console.log('User abort!');
return;
}
// 401 Unauthenticated — session expired (idle) or just destroyed by
// Sign Out. Suppress the raw body so neither this global handler nor
// any per-call .fail() can alert(JSON). Then reload — the server's
// auth middleware redirects to the right login page.
if (request.status === 401) {
try { request.responseText = ''; } catch (e) {}
try { request.responseJSON = null; } catch (e) {}
if (window.__acelleSignOutClicked) return;
if (/\/(login|admin\/login|rui\/admin\/login)(\?|$)/.test(location.pathname)) return;
location.reload();
return;
}
if (request.responseText) {
alert(request.responseText);
} else {
console.log(request);
}
});
// Top quota button
$(document).on('click', '.top-quota-button', function(e) {
e.preventDefault();
var url = $(this).attr("data-url");
console.log(url);
var quotaPopup = new Popup({
url: url
});
quotaPopup.load();
});
});