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 / main.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
main.js
471 lines
1 sgBackup = {};
2 sgBackup.isModalOpen = false;
3 SG_CURRENT_ACTIVE_AJAX = '';
4 SG_NOTICE_EXECUTION_TIMEOUT = 'timeout_error';
5 SG_NOTICE_EXECUTION_FREE_TIMEOUT = 'timeout_free_error';
6 SG_NOTICE_MIGRATION_ERROR = 'migration_error';
7 SG_NOTICE_NOT_WRITABLE_ERROR = 'restore_notwritable_error';
8
9 jQuery(window).load(function() {
10 if (jQuery('.sg-active-action-id').length == 0) {
11 sgBackup.showReviewModal();
12 }
13 });
14
15 jQuery(document).ready( function() {
16 jQuery('span[data-toggle=tooltip]').tooltip();
17
18 sgBackup.init();
19
20 jQuery('.sg-badge-warning').on('click', function () {
21 var url = jQuery(this).attr('target-url');
22 if (url) {
23 window.open(url, '_blank');
24 }
25 });
26
27 jQuery("#rateYo").rateYo({
28 rating: 5,
29 fullStar: true,
30 spacing: "3px",
31 starWidth: "16px",
32 starHeight: "16px",
33 rating: 4.5,
34 ratedFill: "#ffffff"
35 });
36
37 if (typeof SG_AJAX_REQUEST_FREQUENCY === 'undefined'){
38 SG_AJAX_REQUEST_FREQUENCY = 2000;
39 }
40
41 sgBackup.hideAjaxSpinner();
42 var notice = "";
43 jQuery('.notice-dismiss').on('click', function() {
44 if (jQuery(this).parent().attr('data-notice-id') == SG_NOTICE_EXECUTION_TIMEOUT) {
45 notice = SG_NOTICE_EXECUTION_TIMEOUT;
46 }
47 else if (jQuery(this).parent().attr('data-notice-id') == SG_NOTICE_EXECUTION_FREE_TIMEOUT) {
48 notice = SG_NOTICE_EXECUTION_TIMEOUT;
49 }
50 else if (jQuery(this).parent().attr('data-notice-id') == SG_NOTICE_MIGRATION_ERROR) {
51 notice = SG_NOTICE_MIGRATION_ERROR;
52 }
53 else if (jQuery(this).parent().attr('data-notice-id') == SG_NOTICE_NOT_WRITABLE_ERROR) {
54 notice = SG_NOTICE_NOT_WRITABLE_ERROR
55 }
56 var sgNoticeClosedHandler = new sgRequestHandler('hideNotice', {notice: notice, token: BG_BACKUP_STRINGS.nonce});
57 sgNoticeClosedHandler.run();
58 });
59
60 //send awake requests only if there is an active action
61 if (jQuery('.sg-active-action-id').length>0) {
62 setInterval(sgBackup.awake, SG_AJAX_REQUEST_FREQUENCY);
63 }
64 });
65
66 sgBackup.awake = function(){
67 var awakeAjaxHandler = new sgRequestHandler('awake', {token: BG_BACKUP_STRINGS.nonce});
68 awakeAjaxHandler.run();
69 }
70
71 //SG init
72 sgBackup.init = function(){
73 sgBackup.initModals();
74 };
75
76 //SG Modal popup logic
77 sgBackup.initModals = function(){
78
79 jQuery('[data-toggle="modal"][href], [data-toggle="modal"][data-remote]').off('click').on('click', function(e) {
80 var param = '';
81 if (typeof jQuery(this).attr('data-sgbp-params') !== 'undefined'){
82 param = jQuery(this).attr('data-sgbp-params');
83 }
84
85 e.preventDefault();
86 var btn = jQuery(this),
87 url = btn.attr('data-remote'),
88 modalName = btn.attr('data-modal-name'),
89 backupType = btn.attr('sg-data-backup-type'),
90 modal = jQuery('#sg-modal');
91 if( modal.length == 0 ) {
92 modal = jQuery('' +
93 '<div class="modal fade" id="sg-modal" tabindex="-1" role="dialog" aria-hidden="true"></div>' +
94 '');
95 body.append(modal);
96 }
97 sgBackup.showAjaxSpinner('#sg-content-wrapper');
98 if (typeof sgBackup.disableUi == 'function') {
99 sgBackup.disableUi();
100 }
101
102 var ajaxHandler = new sgRequestHandler(url, {
103 param: param,
104 backupType: backupType,
105 token: BG_BACKUP_STRINGS.nonce
106 });
107
108 ajaxHandler.type = 'GET';
109 ajaxHandler.dataType = 'html';
110 ajaxHandler.callback = function(data, error) {
111 sgBackup.hideAjaxSpinner();
112 if (typeof sgBackup.enableUi == 'function') {
113 sgBackup.enableUi();
114 }
115 if (error===false) {
116 jQuery('#sg-modal').append(data);
117 }
118 modal.on('hide.bs.modal', function() {
119 if(SG_CURRENT_ACTIVE_AJAX != '') {
120 if (!confirm(BG_MAIN_STRINGS.confirmCancel)) {
121 return false;
122 }
123 SG_CURRENT_ACTIVE_AJAX.abort();
124 SG_CURRENT_ACTIVE_AJAX = '';
125 }
126 });
127 modal.one('hidden.bs.modal', function() {
128 modal.html('');
129 }).modal('show');
130 sgBackup.didOpenModal(modalName, param);
131 };
132
133 if (modalName == 'ftp-settings' || modalName == 'amazon-settings') {
134 var storage = 'FTP';
135 if (modalName == 'amazon-settings') {
136 storage = 'AMAZON';
137 }
138 error = false;
139 var isFeatureAvailable = new sgRequestHandler('isFeatureAvailable', {sgFeature: storage});
140 isFeatureAvailable.callback = function(response) {
141 if (typeof response.error !== 'undefined') {
142 var alert = sgBackup.alertGenerator(response.error, 'alert-warning');
143 jQuery('.sg-cloud-container legend').after(alert);
144 that.bootstrapSwitch('state', false);
145 sgBackup.hideAjaxSpinner();
146 }
147 else {
148 ajaxHandler.run();
149 }
150 }
151
152 isFeatureAvailable.run();
153 }
154 else {
155 ajaxHandler.run();
156 }
157 });
158 };
159
160 sgBackup.toggleSftpSettings = function() {
161 jQuery('#ftpPort').val('22');
162 jQuery('#sg-sftp-key-file-block').show();
163 jQuery('#sg-browse-key-file-block').hide();
164
165 if (jQuery('#sg-connect-with-key-file').is(':checked') && connectioType=='sftp') {
166 jQuery('#sg-browse-key-file-block').show();
167 }
168 }
169
170 sgBackup.toggleFtpSettings = function() {
171 jQuery('#ftpPort').val('21');
172 jQuery('#sg-sftp-key-file-block').hide();
173 }
174
175 // Show/hide some fields that are needed/not needed for ftp/sftp
176 sgBackup.toggleNeededFtpFields = function(connectioType) {
177 if(connectioType == 'sftp') {
178 sgBackup.toggleSftpSettings();
179
180 }
181 else if(connectioType == 'ftp') {
182 sgBackup.toggleFtpSettings();
183 }
184 }
185
186 sgBackup.didOpenModal = function(modalName, param){
187 if(modalName == 'manual-backup' || modalName == 'manual-restore'){
188 sgBackup.initManulBackupRadioInputs();
189 sgBackup.initManualBackupTooltips();
190 jQuery('#fileSystemTreeContainer').jstree({ 'core' : {
191
192 'data' : {
193 'url' : function (node) {
194 return getAjaxUrl();
195 },
196 'data' : function (node) {
197 var path = node.id;
198 return { action:"backup_guard_getBackupContent", path:path, backupName:param, token: BG_BACKUP_STRINGS.nonce };
199 }
200 }
201 },
202 "plugins" : ["wholerow", "checkbox", "types"],
203 "checkbox" : {
204 "keep_selected_style" : false
205 },
206 "types": {
207 "file": {
208 "icon": "bg-file-icon"
209 },
210 "folder": {
211 "icon": "bg-folder-icon"
212 },
213 "default":{
214 "icon": "bg-no-icon"
215 }
216 }
217 });
218 }
219 else if(modalName == 'import'){
220 sgBackup.initImportTooltips();
221 jQuery('#modal-import-2').hide();
222 jQuery('#modal-import-3').hide();
223 jQuery('#switch-modal-import-pages-back').hide();
224 jQuery('#uploadSgbpFile').hide();
225 if(jQuery('#modal-import-1').length == 0) {
226 sgBackup.toggleDownloadFromPCPage();
227 }
228 sgBackup.initFileUpload();
229 }
230 else if(modalName == 'ftp-settings'){
231 connectioType = jQuery('#sg-connection-method').val();
232 sgBackup.toggleNeededFtpFields(connectioType);
233
234 jQuery('#sg-connection-method').on('change', function(){
235 connectioType = jQuery(this).val();
236 sgBackup.toggleNeededFtpFields(connectioType);
237 });
238
239 jQuery('#sg-connect-with-key-file').on('click', function(){
240 if(jQuery(this).is(':checked')) {
241 jQuery('#sg-browse-key-file-block').show();
242 }
243 else {
244 jQuery('#sg-browse-key-file-block').hide();
245 }
246 })
247
248 sgBackup.initSFTPKeyFileSelection();
249
250 jQuery('#sg-modal').on('hidden.bs.modal', function () {
251 if(sgBackup.isFtpConnected != true) {
252 jQuery('input[data-storage=FTP]').bootstrapSwitch('state', false);
253 }
254 })
255 }
256 else if(modalName == 'amazon-settings') {
257 jQuery('#sg-modal').on('hidden.bs.modal', function () {
258 if(sgBackup.isAmazonConnected != true) {
259 jQuery('input[data-storage=AMAZON]').bootstrapSwitch('state', false);
260 }
261 });
262 jQuery("#bucketType").on("change", function(){
263 jQuery("#bucketType option").each(function()
264 {
265 var name = jQuery(this).val();
266 jQuery(".form-group-"+name).css("display","none");
267 // Add $(this).val() to your list
268 });
269 var selected = jQuery("#bucketType").val();
270 jQuery(".form-group-"+selected).css("display","block");
271 })
272 }
273 else if(modalName == 'manual-review'){
274 var action = 'setReviewPopupState';
275 jQuery('#sgLeaveReview').click(function(){
276 var reviewUrl = jQuery(this).attr('data-review-url');
277 //Never show again
278 var reviewState = 2;
279 var ajaxHandler = new sgRequestHandler(action, {reviewState: reviewState, token: BG_BACKUP_STRINGS.nonce});
280 ajaxHandler.run();
281 window.open(reviewUrl);
282 });
283
284 jQuery('#sgDontAskAgain').click(function(){
285 //Never show again
286 var reviewState = 2;
287 var ajaxHandler = new sgRequestHandler(action, {reviewState: reviewState, token: BG_BACKUP_STRINGS.nonce});
288 ajaxHandler.run();
289 });
290
291 jQuery('#sgAskLater').click(function(){
292 var reviewState = 0;
293 var ajaxHandler = new sgRequestHandler(action, {reviewState: reviewState, token: BG_BACKUP_STRINGS.nonce});
294 ajaxHandler.run();
295 });
296 }
297 else if(modalName == 'create-schedule') {
298 sgBackup.initScheduleCreation();
299 }
300 };
301
302 sgBackup.isAnyOpenModal = function(){
303 return jQuery('#sg-modal').length;
304 };
305
306 sgBackup.alertGenerator = function(content, alertClass){
307 var sgalert = '';
308 sgalert+='<div class="alert alert-dismissible '+alertClass+'">';
309 sgalert+='<button type="button" class="close" data-dismiss="alert">×</button>';
310 if(jQuery.isArray(content)){
311 jQuery.each(content, function(index, value) {
312 sgalert+=value+'<br/>';
313 });
314 }
315 else if(content != ''){
316 sgalert+=content.replace('[','').replace(']','').replace('"','');
317 }
318 sgalert+='</div>';
319 return sgalert;
320 };
321
322 sgBackup.scrollToElement = function(id){
323 if(jQuery(id).position()){
324 if(jQuery(id).position().top < jQuery(window).scrollTop()){
325 //scroll up
326 jQuery('html,body').animate({scrollTop:jQuery(id).position().top}, 1000);
327 }
328 else if(jQuery(id).position().top + jQuery(id).height() > jQuery(window).scrollTop() + (window.innerHeight || document.documentElement.clientHeight)){
329 //scroll down
330 jQuery('html,body').animate({scrollTop:jQuery(id).position().top - (window.innerHeight || document.documentElement.clientHeight) + jQuery(id).height() + 15}, 1000);
331 }
332 }
333 };
334
335 sgBackup.showAjaxSpinner = function(appendToElement){
336 if(typeof appendToElement == 'undefined'){
337 appendToElement = '#sg-wrapper';
338 }
339 jQuery('<div class="sg-spinner"></div>').appendTo(appendToElement);
340 };
341
342 sgBackup.hideAjaxSpinner = function(){
343 jQuery('.sg-spinner').remove();
344 };
345
346 sgBackup.showReviewModal = function(){
347 if(typeof sgShowReview != 'undefined') {
348 jQuery('#sg-review').trigger("click");
349 }
350 };
351
352 sgBackup.initTablePagination = function(){
353 jQuery.fn.sgTablePagination = function(opts){
354 var jQuerythis = this,
355 defaults = {
356 perPage: 7,
357 showPrevNext: false,
358 hidePageNumbers: false,
359 pagerSelector: 'pagination'
360 },
361 settings = jQuery.extend(defaults, opts);
362
363 var listElement = jQuerythis.children('tbody');
364 var perPage = settings.perPage;
365 var children = listElement.children();
366 var pager = jQuery('.pager');
367
368 if (typeof settings.childSelector!="undefined") {
369 children = listElement.find(settings.childSelector);
370 }
371
372 if (typeof settings.pagerSelector!="undefined") {
373 pager = jQuery(settings.pagerSelector);
374 }
375
376 var numItems = children.size();
377 var numPages = Math.ceil(numItems/perPage);
378
379 pager.data("curr",0);
380
381 if (settings.showPrevNext){
382 jQuery('<li><a href="#" class="prev_link">«</a></li>').appendTo(pager);
383 }
384
385 var curr = 0;
386 while(numPages > curr && (settings.hidePageNumbers==false)){
387 jQuery('<li><a href="#" class="page_link">'+(curr+1)+'</a></li>').appendTo(pager);
388 curr++;
389 }
390
391 if(curr<=1){
392 jQuery(settings.pagerSelector).parent('div').hide();
393 jQuery('.page_link').hide();
394 }
395
396 if (settings.showPrevNext){
397 jQuery('<li><a href="#" class="next_link">»</a></li>').appendTo(pager);
398 }
399
400 pager.find('.page_link:first').addClass('active');
401 pager.find('.prev_link').hide();
402 if (numPages<=1) {
403 pager.find('.next_link').hide();
404 }
405 pager.children().eq(1).addClass("active");
406
407 children.hide();
408 children.slice(0, perPage).show();
409
410 pager.find('li .page_link').click(function(){
411 var clickedPage = jQuery(this).html().valueOf()-1;
412 goTo(clickedPage,perPage);
413 return false;
414 });
415 pager.find('li .prev_link').click(function(){
416 previous();
417 return false;
418 });
419 pager.find('li .next_link').click(function(){
420 next();
421 return false;
422 });
423
424 function previous(){
425 var goToPage = parseInt(pager.data("curr")) - 1;
426 goTo(goToPage);
427 }
428
429 function next(){
430 goToPage = parseInt(pager.data("curr")) + 1;
431 goTo(goToPage);
432 }
433
434 function goTo(page){
435 var startAt = page * perPage,
436 endOn = startAt + perPage;
437
438 children.css('display','none').slice(startAt, endOn).show();
439
440 if (page>=1) {
441 pager.find('.prev_link').show();
442 }
443 else {
444 pager.find('.prev_link').hide();
445 }
446
447 if (page<(numPages-1)) {
448 pager.find('.next_link').show();
449 }
450 else {
451 pager.find('.next_link').hide();
452 }
453
454 pager.data("curr",page);
455 pager.children().removeClass("active");
456 pager.children().eq(page+1).addClass("active");
457
458 }
459 };
460 jQuery('table.paginated').sgTablePagination({pagerSelector:'.pagination',showPrevNext:true,hidePageNumbers:false,perPage:7});
461 };
462
463 sgBackup.logout = function()
464 {
465 var ajaxHandler = new sgRequestHandler('logout', {token: BG_BACKUP_STRINGS.nonce});
466 ajaxHandler.callback = function(response){
467 location.reload();
468 };
469 ajaxHandler.run();
470 }
471