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 / sgsettings.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
sgsettings.js
180 lines
1 // phpcs:ignoreFile
2 jQuery(document).ready(function () {
3 sgBackup.initGeneralSettingsSwitchButtons();
4 AMOUNT_OF_BACKUPS_TO_KEEP = jQuery("#amount-of-backups-to-keep").val();
5 sgBackup.saveInitialState();
6 });
7
8 window.onbeforeunload = function () {
9 var msg = 'You haven\'t saved your changes.';
10 var isDirty = false;
11 var value;
12
13 jQuery('.sg-settings-container :input').each(function () {
14
15 if (jQuery(this).attr('type') == 'checkbox') {
16 value = jQuery(this).prop('checked');
17 } else {
18 value = jQuery(this).val();
19 }
20
21 if (jQuery(this).data('initialValue') != value) {
22 isDirty = true;
23 }
24 });
25
26 if (isDirty == true) {
27 return msg;
28 }
29 };
30
31 sgBackup.saveInitialState = function () {
32 jQuery(':input').each(function () {
33 if (jQuery(this).attr('type') == 'checkbox') {
34 value = jQuery(this).prop('checked');
35 } else {
36 value = jQuery(this).val();
37 }
38
39 jQuery(this).data('initialValue', value);
40 });
41 };
42
43 sgBackup.initGeneralSettingsSwitchButtons = function () {
44 jQuery.fn.bootstrapSwitch.defaults.size = 'small';
45 jQuery('.sg-switch').bootstrapSwitch();
46
47 jQuery('.sg-email-switch').on('switchChange.bootstrapSwitch', function (event, state) {
48 var url = jQuery(this).attr('data-remote');
49 if (state) {
50 var isFeatureAvailable = new sgRequestHandler('isFeatureAvailable', {sgFeature: 'NOTIFICATIONS'});
51 isFeatureAvailable.callback = function (response) {
52 if (typeof response.success !== 'undefined') {
53 //If switch is on
54 jQuery('.sg-general-settings').fadeToggle();
55 } else {
56 jQuery('.alert').remove();
57 var alert = sgBackup.alertGenerator(response.error, 'alert-warning');
58 jQuery('.sg-settings-container legend').after(alert);
59 jQuery('.sg-email-switch').bootstrapSwitch('state', false);
60 return false;
61 }
62 }
63
64 isFeatureAvailable.run();
65 } else {
66 var ajaxHandler = new sgRequestHandler(url, {cancel: true});
67 ajaxHandler.callback = function (response) {
68 jQuery('.sg-user-email').remove();
69 jQuery('.sg-general-settings').hide();
70 };
71 ajaxHandler.run();
72 jQuery('#sg-user-email').remove();
73 jQuery('#sg-email').val('');
74 }
75 });
76
77 jQuery('.sg-switch').on('switchChange.bootstrapSwitch', function (event, state) {
78 that = this;
79 var feature = jQuery(this).attr('sgFeatureName');
80 if (feature && feature != 'NOTIFICATIONS') {
81 var isFeatureAvailable = new sgRequestHandler('isFeatureAvailable', {sgFeature: feature});
82 isFeatureAvailable.callback = function (response) {
83 if (state) {
84 if (typeof response.error !== 'undefined') {
85 jQuery('.alert').remove();
86 var alert = sgBackup.alertGenerator(response.error, 'alert-warning');
87 jQuery('.sg-settings-container legend').after(alert);
88 jQuery(that).bootstrapSwitch('state', false);
89 return false;
90 }
91 }
92 }
93
94 isFeatureAvailable.run();
95 }
96 });
97 };
98
99 sgBackup.sgsettings = function () {
100 var settingsForm = jQuery('form[data-type=sgsettings]');
101 var error = [];
102 //Validation
103 jQuery('.alert').remove();
104
105 if (jQuery('.sg-email-switch').is(":checked")) {
106 var emails = jQuery('#sg-email').val().split(",");
107
108 jQuery.each(emails, function (index, value) {
109 value = jQuery.trim(value);
110 if (!sgBackup.isValidEmailAddress(value)) {
111 error.push(BG_SETTINGS_STRINGS.invalidEmailAddress);
112 }
113 });
114 }
115
116 var backupFileName = jQuery('#backup-file-name').val();
117
118 if (typeof amountOfBackups !== 'undefined' && !backupFileName) {
119 error.push(BG_SETTINGS_STRINGS.invalidFileName);
120 }
121
122 var amountOfBackups = jQuery('#amount-of-backups-to-keep').val();
123 if (typeof amountOfBackups !== 'undefined' && (!jQuery.isNumeric(amountOfBackups) || amountOfBackups <= 0)) {
124 error.push(BG_SETTINGS_STRINGS.invalidRetentionNumber);
125 } else if (AMOUNT_OF_BACKUPS_TO_KEEP != amountOfBackups) {
126 if (!confirm(BG_SETTINGS_STRINGS.retentionConfirmationFirstPart + ' ' + amountOfBackups + ' ' + BG_SETTINGS_STRINGS.retentionConfirmationSecondPart)) {
127 return false;
128 }
129 }
130
131 //If any error show it and abort ajax
132 if (error.length) {
133 var alert = sgBackup.alertGenerator(error, 'alert-danger');
134 jQuery('.sg-settings-container legend').after(alert);
135 sgBackup.scrollToElement('.alert');
136 return false;
137 }
138
139 //Before sending
140 var userEmail = jQuery('#sg-email').val();
141 jQuery('#sg-save-settings').attr('disabled', 'disabled');
142 jQuery('#sg-save-settings').html(BG_SETTINGS_STRINGS.savingInProgress);
143
144 //On Success
145 var ajaxHandler = new sgRequestHandler('settings', settingsForm.serialize() + '&token=' + BG_BACKUP_STRINGS.nonce);
146 ajaxHandler.dataIsObject = false;
147 ajaxHandler.callback = function (response) {
148 jQuery('.alert').remove();
149 if (typeof response.success !== 'undefined') {
150 var alert = sgBackup.alertGenerator(BG_SETTINGS_STRINGS.successMessage, 'alert-success');
151 jQuery('.sg-settings-container legend').after(alert);
152 sgBackup.addUserInfo(userEmail);
153 //jQuery('.sg-switch').bootstrapSwitch('state', true, true);
154 jQuery('.sg-general-settings').fadeOut();
155 sgBackup.saveInitialState();
156 } else {
157 //if error
158 var alert = sgBackup.alertGenerator(response, 'alert-danger');
159 jQuery('.sg-settings-container legend').after(alert);
160 }
161
162 //Always
163 jQuery('#sg-save-settings').removeAttr('disabled', 'disabled');
164 jQuery('#sg-save-settings').html(BG_SETTINGS_STRINGS.saveButtonText);
165 sgBackup.scrollToElement('.alert');
166 };
167 ajaxHandler.run();
168 };
169
170 sgBackup.addUserInfo = function (info) {
171 jQuery('.sg-user-info .sg-helper-block').remove();
172 jQuery('.sg-user-info br').remove();
173 jQuery('.sg-user-info').append('<br/><span class="text-muted sg-user-email sg-helper-block">' + info + '</span>');
174 };
175
176 sgBackup.isValidEmailAddress = function (emailAddress) {
177 var pattern = new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,10}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][\d]\.|1[\d]{2}\.|[\d]{1,2}\.))((25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\.){2}(25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\]?$)/i);
178 return pattern.test(emailAddress);
179 }
180