mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°3786 - Add pause at the end of the page unload async request to follow the guideline used in N°2763
This commit is contained in:
@@ -115,10 +115,11 @@ function OnUnload(sTransactionId, sObjClass, iObjKey, sToken)
|
||||
// IMPORTANT: the ajax request MUST BE synchronous to be executed in this context
|
||||
$.ajax({
|
||||
url: GetAbsoluteUrlAppRoot()+'pages/ajax.render.php',
|
||||
async: false,
|
||||
async: true,
|
||||
method: 'POST',
|
||||
data: {operation: 'on_form_cancel', transaction_id: sTransactionId, obj_class: sObjClass, obj_key: iObjKey, token: sToken }
|
||||
});
|
||||
CombodoGlobalToolbox.Pause(1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
17
js/utils.js
17
js/utils.js
@@ -725,6 +725,23 @@ const CombodoGlobalToolbox = {
|
||||
sOutput = sOutput.replace(/<script/g, '<script WARNING: scripts are not allowed in tooltips');
|
||||
|
||||
return sOutput;
|
||||
},
|
||||
/**
|
||||
* Pause the JS activity for iDuration milliseconds
|
||||
*
|
||||
* @see N°2763 for the original code idea
|
||||
* @return {void}
|
||||
* @param iDuration {integer} Duration in milliseconds
|
||||
* @constructor
|
||||
*/
|
||||
Pause: function (iDuration) {
|
||||
const oDate = new Date();
|
||||
let oCurrentDate = null;
|
||||
|
||||
do {
|
||||
oCurrentDate = new Date();
|
||||
}
|
||||
while ((oCurrentDate - oDate) < iDuration);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user