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