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