Skip to content

Commit 9d6a497

Browse files
committed
Refactor Functions.addNoCacheToAjaxRequests() function
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent eb07bb5 commit 9d6a497

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

.eslintrc.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@
1717
"es6": true
1818
},
1919
"rules": {
20-
"valid-jsdoc": ["error", {
21-
"prefer": {
22-
"returns": "return"
23-
},
24-
"requireReturn": false,
25-
"requireParamType": false,
26-
"requireReturnDescription": false,
27-
"requireParamDescription": false
28-
}],
2920
"array-bracket-spacing": "error",
3021
"brace-style": "error",
3122
"camelcase": "error",

js/src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import $ from 'jquery';
22
import { AJAX } from './modules/ajax.ts';
3-
import { Functions } from './modules/functions.ts';
3+
import { addNoCacheToAjaxRequests, Functions } from './modules/functions.ts';
44
import { KeyHandlerEvents } from './modules/keyhandler.ts';
55
import { PageSettings } from './modules/page_settings.ts';
66
import { crossFramingProtection } from './modules/cross_framing_protection.ts';
@@ -29,7 +29,7 @@ crossFramingProtection();
2929
AJAX.registerTeardown('main.js', Config.off());
3030
AJAX.registerOnload('main.js', Config.on());
3131

32-
$.ajaxPrefilter(Functions.addNoCacheToAjaxRequests());
32+
$.ajaxPrefilter(addNoCacheToAjaxRequests);
3333

3434
AJAX.registerTeardown('main.js', teardownFunctions());
3535
AJAX.registerOnload('main.js', onloadFunctions());

js/src/modules/functions.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@ window.centralColumnList = [];
6262

6363
/**
6464
* Make sure that ajax requests will not be cached by appending a random variable to their parameters.
65-
* @return {function(JQuery.AjaxSettings, JQuery.AjaxSettings): void}
6665
*/
67-
Functions.addNoCacheToAjaxRequests = () => function (options, originalOptions) {
68-
var nocache = new Date().getTime() + '' + Math.floor(Math.random() * 1000000);
66+
export function addNoCacheToAjaxRequests (options: JQuery.AjaxSettings, originalOptions: JQuery.AjaxSettings): void {
67+
const nocache = new Date().getTime() + '' + Math.floor(Math.random() * 1000000);
6968
if (typeof options.data === 'string') {
7069
options.data += '&_nocache=' + nocache + '&token=' + encodeURIComponent(CommonParams.get('token'));
7170
} else if (typeof options.data === 'object') {
@@ -74,7 +73,7 @@ Functions.addNoCacheToAjaxRequests = () => function (options, originalOptions) {
7473
'token': CommonParams.get('token')
7574
});
7675
}
77-
};
76+
}
7877

7978
/**
8079
* Adds a date/time picker to an element

0 commit comments

Comments
 (0)