Refactor Functions.addNoCacheToAjaxRequests() function
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
eb07bb575d
commit
9d6a497ea7
@ -17,15 +17,6 @@
|
||||
"es6": true
|
||||
},
|
||||
"rules": {
|
||||
"valid-jsdoc": ["error", {
|
||||
"prefer": {
|
||||
"returns": "return"
|
||||
},
|
||||
"requireReturn": false,
|
||||
"requireParamType": false,
|
||||
"requireReturnDescription": false,
|
||||
"requireParamDescription": false
|
||||
}],
|
||||
"array-bracket-spacing": "error",
|
||||
"brace-style": "error",
|
||||
"camelcase": "error",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import $ from 'jquery';
|
||||
import { AJAX } from './modules/ajax.ts';
|
||||
import { Functions } from './modules/functions.ts';
|
||||
import { addNoCacheToAjaxRequests, Functions } from './modules/functions.ts';
|
||||
import { KeyHandlerEvents } from './modules/keyhandler.ts';
|
||||
import { PageSettings } from './modules/page_settings.ts';
|
||||
import { crossFramingProtection } from './modules/cross_framing_protection.ts';
|
||||
@ -29,7 +29,7 @@ crossFramingProtection();
|
||||
AJAX.registerTeardown('main.js', Config.off());
|
||||
AJAX.registerOnload('main.js', Config.on());
|
||||
|
||||
$.ajaxPrefilter(Functions.addNoCacheToAjaxRequests());
|
||||
$.ajaxPrefilter(addNoCacheToAjaxRequests);
|
||||
|
||||
AJAX.registerTeardown('main.js', teardownFunctions());
|
||||
AJAX.registerOnload('main.js', onloadFunctions());
|
||||
|
||||
@ -62,10 +62,9 @@ window.centralColumnList = [];
|
||||
|
||||
/**
|
||||
* Make sure that ajax requests will not be cached by appending a random variable to their parameters.
|
||||
* @return {function(JQuery.AjaxSettings, JQuery.AjaxSettings): void}
|
||||
*/
|
||||
Functions.addNoCacheToAjaxRequests = () => function (options, originalOptions) {
|
||||
var nocache = new Date().getTime() + '' + Math.floor(Math.random() * 1000000);
|
||||
export function addNoCacheToAjaxRequests (options: JQuery.AjaxSettings, originalOptions: JQuery.AjaxSettings): void {
|
||||
const nocache = new Date().getTime() + '' + Math.floor(Math.random() * 1000000);
|
||||
if (typeof options.data === 'string') {
|
||||
options.data += '&_nocache=' + nocache + '&token=' + encodeURIComponent(CommonParams.get('token'));
|
||||
} else if (typeof options.data === 'object') {
|
||||
@ -74,7 +73,7 @@ Functions.addNoCacheToAjaxRequests = () => function (options, originalOptions) {
|
||||
'token': CommonParams.get('token')
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a date/time picker to an element
|
||||
|
||||
Loading…
Reference in New Issue
Block a user