[TASK] Migrate AdminPanel modules to TypeScript
[Packages/TYPO3.CMS.git] / typo3 / sysext / adminpanel / Resources / Private / TypeScript / Modules / Cache.ts
1 namespace TYPO3 {
2 export class Cache {
3 private buttons: Array<Element>;
4
5 constructor() {
6 this.buttons = Array.from(document.querySelectorAll('[data-typo3-role="clearCacheButton"]'));
7
8 this.buttons.forEach((element: HTMLElement): void => {
9 element.addEventListener('click', (): void => {
10 let url = element.dataset.typo3AjaxUrl;
11 let request = new XMLHttpRequest();
12 request.open('GET', url);
13 request.send();
14 request.onload = (): void => {
15 location.reload();
16 };
17 });
18 });
19 }
20 }
21 }
22
23 ((): void => {
24 window.addEventListener(
25 'load',
26 () => new TYPO3.Cache(),
27 false
28 );
29 })();