PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 1.6.9.1
JetBackup – Backup, Restore & Migrate v1.6.9.1
3.1.22.4 3.1.22.3 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.8.1 1.4.9 1.5.0 1.5.1 1.5.1.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.10 1.6.11 1.6.12 1.6.13 1.6.15 1.6.5.1 1.6.8.8 1.6.9 1.6.9.1 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7.5 2.0.8.7 2.0.9.11 2.0.9.14 2.0.9.15 2.0.9.6 2.0.9.7 2.0.9.9 3.1.10.7 3.1.11.1 3.1.12.3 3.1.13.4 3.1.14.17 3.1.15.4 3.1.16.1 3.1.17.5 3.1.18.10 3.1.18.8 3.1.18.9 3.1.19.8 3.1.20.3 3.1.21.3 3.1.7.9 3.1.9.2 trunk 1.1.90 1.1.91 1.2.0 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2
backup / public / js / sgschedule.js
backup / public / js Last commit date
Chart.bundle.min.js 8 years ago bootstrap-switch.min.js 10 years ago bootstrap.min.js 5 years ago deactivationSurvey.js 5 years ago jquery-ui.js 9 years ago jquery.fileupload.js 8 years ago jquery.iframe-transport.js 8 years ago jquery.rateyo.js 6 years ago jquery.validate.min.js 5 years ago jstree.checkbox.js 8 years ago jstree.min.js 8 years ago jstree.types.js 8 years ago jstree.wholerow.js 8 years ago less.min.js 10 years ago main.js 4 years ago popup.js 5 years ago sgNoticeDismiss.js 6 years ago sgbackup.js 3 years ago sgcloud.js 3 years ago sglicense.js 6 years ago sglogin.js 6 years ago sgrequesthandler.js 10 years ago sgrequesthandler.wordpress.js 10 years ago sgschedule.js 3 years ago sgsettings.js 3 years ago
sgschedule.js
252 lines
1 // phpcs:ignoreFile
2 BG_SCHEDULE_INTERVAL_HOURLY = 0;
3 BG_SCHEDULE_INTERVAL_DAILY = 1;
4 BG_SCHEDULE_INTERVAL_WEEKLY = 2;
5 BG_SCHEDULE_INTERVAL_MONTHLY = 3;
6 BG_SCHEDULE_INTERVAL_YEARLY = 4;
7
8 jQuery(document).ready(
9 function () {
10 sgBackup.initTablePagination('sg-schedule');
11 sgBackup.initScheduleCreation();
12 }
13 );
14
15 sgBackup.initScheduleCreation = function () {
16 sgBackup.initScheduleSwitchButtons();
17 sgBackup.initManulBackupRadioInputs();
18 sgBackup.initManualBackupTooltips();
19 sgBackup.toggleDaySelection();
20 sgBackup.initIntervalSelection();
21 }
22
23 sgBackup.removeSchedule = function (id) {
24 var ajaxHandler = new sgRequestHandler('schedule', {remove: true, id: id, token: BG_BACKUP_STRINGS.nonce});
25
26 if (!confirm(BG_SCHEDULE_STRINGS.confirm)) {
27 return false;
28 }
29
30 ajaxHandler.callback = function (response) {
31 jQuery('.alert').remove();
32
33 if (typeof response.success !== 'undefined') {
34 location.reload();
35 } else {
36 //if error
37 var alert = sgBackup.alertGenerator(BG_SCHEDULE_STRINGS.deletionError, 'alert-danger');
38 jQuery('.sg-schedule-container legend').after(alert);
39 }
40
41 sgBackup.scrollToElement('.alert');
42 };
43 ajaxHandler.run();
44 }
45
46 sgBackup.initIntervalSelection = function () {
47 if (jQuery('#sg-schedule-interval').val() == BG_SCHEDULE_INTERVAL_WEEKLY) {
48 jQuery('#sg-schedule-day-of-week-select').show();
49 } else if (jQuery('#sg-schedule-interval').val() == BG_SCHEDULE_INTERVAL_MONTHLY) {
50 jQuery('#sg-schedule-day-of-month-select').show();
51 } else if (jQuery('#sg-schedule-interval').val() == BG_SCHEDULE_INTERVAL_HOURLY) {
52 jQuery('#sg-schedule-timezone').hide();
53 }
54
55 jQuery('#sg-schedule-interval').on(
56 'change', function () {
57 jQuery('#sg-schedule-timezone').show();
58 if (jQuery(this).val() == BG_SCHEDULE_INTERVAL_WEEKLY) {
59 jQuery('#sg-schedule-month-of-year-select').hide();
60 jQuery('#sg-schedule-day-of-month-select').hide();
61 jQuery('#sg-schedule-day-of-week-select').show();
62 } else if (jQuery(this).val() == BG_SCHEDULE_INTERVAL_MONTHLY) {
63 jQuery('#sg-schedule-month-of-year-select').hide();
64 jQuery('#sg-schedule-day-of-week-select').hide();
65 jQuery('#sg-schedule-day-of-month-select').show();
66 sgBackup.updateDaysOfMonth();
67 } else if (jQuery('#sg-schedule-interval').val() == BG_SCHEDULE_INTERVAL_HOURLY) {
68 jQuery('#sg-schedule-timezone').hide();
69 } else if (jQuery('#sg-schedule-interval').val() == BG_SCHEDULE_INTERVAL_DAILY) {
70 sgBackup.toggleDaySelection();
71 } else {
72 jQuery('#sg-schedule-month-of-year-select').show();
73 jQuery('#sg-schedule-day-of-week-select').hide();
74 jQuery('#sg-schedule-day-of-month-select').show();
75 sgBackup.updateDaysOfMonth();
76 }
77 }
78 );
79 }
80
81 sgBackup.toggleDaySelection = function () {
82 jQuery('#sg-schedule-day-of-week-select').hide();
83 jQuery('#sg-schedule-day-of-month-select').hide();
84 jQuery('#sg-schedule-month-of-year-select').hide();
85 }
86
87 sgBackup.updateDaysOfMonth = function () {
88 let year = new Date().getFullYear();
89 let interval = jQuery('#sg-schedule-interval').val();
90 let month = '';
91
92 if (interval == BG_SCHEDULE_INTERVAL_MONTHLY) {
93 month = new Date().getMonth() + 1;
94 } else {
95 month = parseInt(jQuery('#sg-schedule-month-of-year').val());
96 }
97
98 let days = sgBackup.daysInMonth(year, month);
99
100 jQuery("#sg-schedule-day-of-month option").show();
101
102 jQuery("#sg-schedule-day-of-month option").each(
103 function () {
104 if (jQuery(this).val() > days) {
105 jQuery(this).hide();
106 }
107 }
108 );
109 }
110
111 sgBackup.prependErrorMsg = function (alert) {
112 if (typeof jQuery('#sg-schedule-id').val() === 'undefined') {
113 jQuery('.sg-schedule-container legend').after(alert);
114 } else {
115 jQuery('#sg-modal .modal-header').prepend(alert);
116 }
117 }
118
119 //SGSchedule AJAX callback
120 sgBackup.schedule = function () {
121 var error = [];
122 var scheduleForm = jQuery('form[data-type=schedule]');
123
124 //Validation
125 jQuery('.alert').remove();
126 if (jQuery('input[type=radio][name=backupType]:checked').val() == 2) {
127 if (jQuery('.sg-custom-option:checked').length <= 0) {
128 error.push(BG_SCHEDULE_STRINGS.invalidBackupOption);
129 }
130 //Check if any file is selected
131 if (jQuery('input[type=checkbox][name=backupFiles]:checked').length > 0) {
132 if (jQuery('.sg-custom-backup-files input:checkbox:checked').length <= 0) {
133 error.push(BG_SCHEDULE_STRINGS.invalidDirectorySelected);
134 }
135 }
136 }
137 //Check if any cloud is selected
138 if (jQuery('input[type=checkbox][name=backupCloud]:checked').length > 0) {
139 if (jQuery('.sg-custom-backup-cloud input:checkbox:checked').length <= 0) {
140 error.push(BG_SCHEDULE_STRINGS.invalidCloud);
141 }
142 }
143 //If any error show it and abort ajax
144 if (error.length) {
145 var alert = sgBackup.alertGenerator(error, 'alert-danger');
146 sgBackup.prependErrorMsg(alert);
147 sgBackup.scrollToElement('.alert');
148 return false;
149 }
150
151 //Before sending
152 jQuery('#sg-save-schedule').attr('disabled', 'disabled');
153 jQuery('#sg-save-schedule').html(BG_SCHEDULE_STRINGS.savingInProgress);
154
155 //On Success
156 var ajaxHandler = new sgRequestHandler('schedule', scheduleForm.serialize() + '&token=' + BG_BACKUP_STRINGS.nonce);
157 ajaxHandler.dataIsObject = false;
158 ajaxHandler.callback = function (response) {
159 jQuery('.alert').remove();
160 if (typeof response.success !== 'undefined') {
161 var alert = sgBackup.alertGenerator(BG_SCHEDULE_STRINGS.successMessage, 'alert-success');
162 sgBackup.prependErrorMsg(alert);
163 location.reload();
164 } else {
165 //if error
166 var alert = sgBackup.alertGenerator(response, 'alert-danger');
167 sgBackup.prependErrorMsg(alert);
168 }
169
170 //Always
171 jQuery('#sg-save-schedule').removeAttr('disabled', 'disabled');
172 jQuery('#sg-save-schedule').html(BG_SCHEDULE_STRINGS.saveButtonText);
173 sgBackup.scrollToElement('.alert');
174 };
175 ajaxHandler.run();
176 };
177
178 sgBackup.initScheduleSwitchButtons = function () {
179 jQuery('.sg-switch').bootstrapSwitch();
180 if (jQuery('#sg-backup-page-content-schedule .sg-switch').is(':checked')) {
181 jQuery('#sg-backup-page-content-schedule .sg-schedule-settings').show();
182 }
183 jQuery('.sg-switch').on(
184 'switchChange.bootstrapSwitch', function (event, state) {
185 var url = jQuery(this).attr('data-remote');
186 if (state) {
187 var isFeatureAvailable = new sgRequestHandler('isFeatureAvailable', {sgFeature: "SCHEDULE"});
188 isFeatureAvailable.callback = function (response) {
189 jQuery('.alert').remove();
190 if (typeof response.success !== 'undefined') {
191 //Show or Hide settings panel
192 jQuery('.sg-schedule-settings').fadeIn();
193 } else {
194 var alert = sgBackup.alertGenerator(response.error, 'alert-warning');
195 jQuery('.sg-schedule-container legend').after(alert);
196 jQuery('.sg-switch').bootstrapSwitch('state', false);
197 }
198 }
199
200 isFeatureAvailable.run();
201 } else {
202 var ajaxHandler = new sgRequestHandler('schedule', {remove: true, token: BG_BACKUP_STRINGS.nonce});
203 ajaxHandler.run();
204 jQuery('.sg-schedule-settings').fadeOut();
205 }
206 }
207 );
208 };
209
210 sgBackup.initManulBackupRadioInputs = function () {
211 jQuery('input[type=radio][name=backupType]').off('change').on(
212 'change', function () {
213 jQuery('.sg-custom-backup').fadeToggle();
214 jQuery('.sg-custom-backup').children().find('input[class^=sg-custom]').removeAttr('checked');
215 jQuery('.sg-custom-backup-files').hide();
216 }
217 );
218 jQuery('input[type=checkbox][name=backupFiles], input[type=checkbox][name=backupCloud], input[type=checkbox][name=backupDatabase]').off('change').on(
219 'change', function () {
220 var sgCheckBoxWrapper = jQuery(this).closest('.checkbox').find('.sg-checkbox');
221 sgCheckBoxWrapper.fadeToggle();
222 if (jQuery(this).attr('name') == 'backupFiles') {
223 sgCheckBoxWrapper.find('input[type=checkbox]').attr('checked', 'checked');
224 }
225 }
226 );
227 jQuery('input[type=radio][name=backupDBType]').off('change').on(
228 'change', function () {
229 var sgCheckBoxWrapper = jQuery(this).closest('.checkbox').find('.sg-custom-backup-tables');
230 if (jQuery('input[type=radio][name=backupDBType]:checked').val() == '2') {
231 sgCheckBoxWrapper.find('input[type=checkbox]').not("[disabled]").prop('checked', true)
232 sgCheckBoxWrapper.fadeIn();
233 } else {
234 sgCheckBoxWrapper.fadeOut();
235 sgCheckBoxWrapper.find('input[type=checkbox][current="true"]').not("[disabled]").prop('checked', true)
236 sgCheckBoxWrapper.find('input[type=checkbox][current="false"]').prop('checked', false)
237 }
238 }
239 )
240 }
241
242 sgBackup.initManualBackupTooltips = function () {
243 jQuery('[for=cloud-ftp]').tooltip();
244 jQuery('[for=cloud-dropbox]').tooltip();
245 jQuery('[for=cloud-gdrive]').tooltip();
246 jQuery('[for=cloud-one-drive]').tooltip();
247 jQuery('[for=cloud-p-cloud]').tooltip();
248 jQuery('[for=cloud-box]').tooltip();
249 jQuery('[for=cloud-amazon]').tooltip();
250 jQuery('[for=cloud-backup-guard]').tooltip();
251 }
252