Use $.getJson instead of fetch

pull/6052/head
Angel Fernando Quiroz Campos 8 months ago
parent beb07770d6
commit 32d3d5de8e
No known key found for this signature in database
GPG Key ID: B284841AE3E562CD
  1. 42
      main/template/default/layout/main.js.tpl

@ -741,14 +741,8 @@ function copyTextToClipBoard(elementId)
function checkSessionTime()
{
fetch('/main/inc/ajax/session_clock.ajax.php?action=time')
.then(response => {
if (!response.ok) {
throw new Error('Server error: ' + response.statusText);
}
return response.json();
})
.then(data => {
$.getJSON(_p.web_ajax + 'session_clock.ajax.php?action=time')
.done(function (data) {
if (data.sessionTimeLeft <= 0) {
if (!document.getElementById('session-checker-overlay')) {
clearInterval(sessionCounterInterval);
@ -793,18 +787,12 @@ function checkSessionTime()
setTimeout(checkSessionTime, 60000);
}
})
.catch(error => console.error('Error:', error));
.fail(function (jqXHR, textStatus) { console.error('Error:', textStatus)} );
}
function extendSession() {
fetch('/main/inc/ajax/online.ajax.php')
.then(response => {
if (!response.ok) {
throw new Error('Server error: ' + response.statusText);
}
return response;
})
.then(data => {
$.getJSON(_p.web_ajax + 'online.ajax.php')
.done(function (data) {
console.log('Session extended');
clearInterval(sessionCounterInterval);
@ -814,7 +802,7 @@ function extendSession() {
counterOverlay.remove();
}
})
.catch(error => console.error('Error:', error));
.fail(function (jqXHR, textStatus) { console.error('Error:', textStatus) });
}
function updateSessionTimeCounter() {
@ -835,9 +823,8 @@ function updateSessionTimeCounter() {
document.getElementById('session-counter').innerHTML = '{{ 'SessionIsClosing' | get_lang | escape('js')}}';
setTimeout(function() {
fetch('/main/inc/ajax/session_clock.ajax.php?action=logout')
.then(response => response.json())
.then(data => {
$.getJSON(_p.web_ajax + 'session_clock.ajax.php?action=logout')
.done(function (data) {
if (!document.getElementById('session-checker-overlay')) {
clearInterval(sessionCounterInterval);
@ -858,8 +845,8 @@ function updateSessionTimeCounter() {
document.body.insertAdjacentHTML('afterbegin', '<div id="session-checker-overlay" style="position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,1);display:flex;justify-content:center;align-items:center;z-index:1000;"><div id="session-checker-modal" style="background:white;padding:20px;border-radius:5px;box-shadow:0010pxrgba(0,0,0,0.5);width:35%;text-align:center;"><p style="margin-bottom:20px;">{{ 'SessionExpiredAt' | get_lang | escape('js')}} ' + dateTimeSessionExpired + '.</p><button class="btn btn-primary" onclick="window.location.pathname = \'/\';">OK</button></div></div>');
}
})
.catch((error) => {
console.error('Error:', error);
.fail(function (jqXHR, textStatus) {
console.error('Error:', textStatus);
});
}, 1000);
@ -877,9 +864,8 @@ function updateSessionTimeCounter() {
document.getElementById('session-counter').innerHTML = '{{ 'SessionIsClosing' | get_lang | escape('js')}}';
setTimeout(function() {
fetch('/main/inc/ajax/session_clock.ajax.php?action=logout')
.then(response => response.json())
.then(data => {
$.getJSON(_p.web_ajax + 'session_clock.ajax.php?action=logout')
.done(function(data) {
if (!document.getElementById('session-checker-overlay')) {
clearInterval(sessionCounterInterval);
@ -900,8 +886,8 @@ function updateSessionTimeCounter() {
document.body.insertAdjacentHTML('afterbegin', '<div id="session-checker-overlay" style="position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,1);display:flex;justify-content:center;align-items:center;z-index:1000;"><div id="session-checker-modal" style="background:white;padding:20px;border-radius:5px;box-shadow:0010pxrgba(0,0,0,0.5);width:35%;text-align:center;"><p style="margin-bottom:20px;">{{ 'SessionExpiredAt' | get_lang | escape('js')}} ' + dateTimeSessionExpired + '.</p><button class="btn btn-primary" onclick="window.location.pathname = \'/\';">OK</button></div></div>');
}
})
.catch((error) => {
console.error('Error:', error);
.fail(function (jqXHR, textStatus) {
console.error('Error:', textStatus);
});
}, 1000);
}

Loading…
Cancel
Save