PluginProbe
Statify / trunk
Statify vtrunk
2.0.2 2.0.1 trunk 0.7 0.8 0.9 1.0 1.2.8 1.3.0 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 All 32 releases
statify / js / settings.js

settings.js in Statify trunk, at js/settings.js

53 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function () {
2 'use strict';
3
4 function initResetButton() {
5 const resetButton = document.getElementById('statify-reset-data');
6
7 if (!resetButton) {
8 return;
9 }
10
11 resetButton.addEventListener('click', (e) => {
12 e.preventDefault();
13
14 if (
15 // eslint-disable-next-line no-alert
16 !confirm(
17 wp.i18n.__(
18 'Are you sure you want to delete all statistics data? This action cannot be undone!',
19 'statify'
20 )
21 )
22 ) {
23 return;
24 }
25
26 const button = this;
27 const originalText = button.textContent;
28
29 button.disabled = true;
30 button.textContent = wp.i18n.__('Resetting…', 'statify');
31
32 wp.apiFetch({
33 path: '/statify/v1/reset',
34 method: 'POST',
35 })
36 .then((data) => {
37 // eslint-disable-next-line no-alert
38 alert(data.message);
39 button.textContent = originalText;
40 button.disabled = false;
41 })
42 .catch((error) => {
43 // eslint-disable-next-line no-alert
44 alert(wp.i18n.__('Error:', 'statify') + error.message);
45 button.disabled = false;
46 button.textContent = originalText;
47 });
48 });
49 }
50
51 document.addEventListener('DOMContentLoaded', initResetButton);
52 })();
53