PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 1.5.3
JetBackup – Backup, Restore & Migrate v1.5.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 / main.js
backup / public / js Last commit date
Chart.bundle.min.js 5 years ago bootstrap-switch.min.js 5 years ago bootstrap.min.js 5 years ago deactivationSurvey.js 5 years ago jquery-ui.js 5 years ago jquery.fileupload.js 5 years ago jquery.iframe-transport.js 5 years ago jquery.rateyo.js 5 years ago jquery.validate.min.js 5 years ago jstree.checkbox.js 5 years ago jstree.min.js 5 years ago jstree.types.js 5 years ago jstree.wholerow.js 5 years ago less.min.js 5 years ago main.js 5 years ago popup.js 5 years ago sgNoticeDismiss.js 5 years ago sgbackup.js 5 years ago sgcloud.js 5 years ago sglicense.js 5 years ago sglogin.js 5 years ago sgrequesthandler.js 5 years ago sgrequesthandler.wordpress.js 5 years ago sgschedule.js 5 years ago sgsettings.js 5 years ago
main.js
564 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).on('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 sgBackup.downloadButton();
75 sgBackup.navMenu();
76 sgBackup.sendUsageDataStatus();
77 };
78
79 sgBackup.sendUsageDataStatus = function ()
80 {
81 var checkbox = jQuery('.backup-send-usage-data-status');
82
83 if (!checkbox.length) {
84 return false;
85 }
86
87 checkbox.bind('switchChange.bootstrapSwitch', function () {
88 var currentStatus = jQuery(this).is(':checked');
89 var action = 'send_usage_status';
90 jQuery(this).prop('disabled', true);
91 var ajaxHandler = new sgRequestHandler(action, {currentStatus: currentStatus, token: BG_BACKUP_STRINGS.nonce});
92 ajaxHandler.callback = function(data, error) {
93 jQuery(this).prop('disabled', false);
94 }
95
96 ajaxHandler.run();
97 });
98 };
99
100 sgBackup.navMenu = function ()
101 {
102 var navMenu = jQuery('.sg-backup-sidebar-nav a');
103
104 if (!navMenu.length) {
105 return false;
106 }
107
108 navMenu.unbind('click').bind('click', function (event) {
109 event.preventDefault();
110 sgBackup.init();
111
112 var currentUrl = jQuery(this).attr('href');
113 var openContent = jQuery(this).data('open-content');
114
115 if (typeof openContent != 'undefined' && openContent == 0) {
116 window.open(currentUrl);
117 return true;
118 }
119 jQuery('.sg-backup-page-content').addClass('sg-visibility-hidden');
120 jQuery('.sg-backup-sidebar-nav li').removeClass('active');
121
122 var currentKey = jQuery(this).data('page-key');
123 var currentPageContent = jQuery('#sg-backup-page-content-'+currentKey);
124
125 if (!currentPageContent.length) {
126 return false;
127 }
128 jQuery(this).parent().addClass('active');
129 currentPageContent.removeClass('sg-visibility-hidden');
130 });
131 };
132
133 sgBackup.downloadButton = function()
134 {
135 var downloadButtons = jQuery('.sg-bg-download-button');
136
137 if (!downloadButtons.length) {
138 return false;
139 }
140 var isOPen = false;
141 jQuery(window).bind('click', function () {
142 if (isOPen) {
143 jQuery('.sg-backup-table .dropdown-menu').removeClass('sg-bg-show');
144 isOPen = false;
145 }
146 });
147
148 downloadButtons.bind('click', function () {
149 var currentButton = jQuery(this);
150
151 if (!currentButton.length) {
152 return false;
153 }
154 setTimeout(function () {
155 currentButton.next().addClass('sg-bg-show');
156 isOPen = true;
157 }, 0);
158 });
159 };
160
161 //SG Modal popup logic
162 sgBackup.initModals = function(){
163
164 jQuery('[data-toggle="modal"][href], [data-toggle="modal"][data-remote]').off('click').on('click', function(e) {
165 var param = '';
166 if (typeof jQuery(this).attr('data-sgbp-params') !== 'undefined'){
167 param = jQuery(this).attr('data-sgbp-params');
168 }
169
170 e.preventDefault();
171 var btn = jQuery(this),
172 url = btn.attr('data-remote'),
173 modalName = btn.attr('data-modal-name'),
174 backupType = btn.attr('sg-data-backup-type'),
175 modal = jQuery('#sg-modal');
176 if( modal.length == 0 ) {
177 modal = jQuery('' +
178 '<div class="modal fade" id="sg-modal" tabindex="-1" role="dialog" aria-hidden="true"></div>' +
179 '');
180 body.append(modal);
181 }
182 sgBackup.showAjaxSpinner('#sg-content-wrapper');
183 if (typeof sgBackup.disableUi == 'function') {
184 sgBackup.disableUi();
185 }
186
187 var ajaxHandler = new sgRequestHandler(url, {
188 param: param,
189 backupType: backupType,
190 token: BG_BACKUP_STRINGS.nonce
191 });
192
193 if (modalName == 'backup-guard-details') {
194 modal.modal({
195 backdrop: 'static',
196 keyboard: false
197 });
198 }
199
200 ajaxHandler.type = 'GET';
201 ajaxHandler.dataType = 'html';
202 ajaxHandler.callback = function(data, error) {
203 sgBackup.hideAjaxSpinner();
204 if (typeof sgBackup.enableUi == 'function') {
205 sgBackup.enableUi();
206 }
207 if (error===false) {
208 jQuery('#sg-modal').append(data);
209 }
210 modal.on('hide.bs.modal', function() {
211 if(SG_CURRENT_ACTIVE_AJAX != '') {
212 if (!confirm(BG_MAIN_STRINGS.confirmCancel)) {
213 return false;
214 }
215 SG_CURRENT_ACTIVE_AJAX.abort();
216 SG_CURRENT_ACTIVE_AJAX = '';
217 }
218 });
219 modal.one('hidden.bs.modal', function() {
220 modal.html('');
221 }).modal('show');
222 sgBackup.didOpenModal(modalName, param);
223 };
224
225 if (modalName == 'ftp-settings' || modalName == 'amazon-settings') {
226 var storage = 'FTP';
227 if (modalName == 'amazon-settings') {
228 storage = 'AMAZON';
229 }
230 error = false;
231 var isFeatureAvailable = new sgRequestHandler('isFeatureAvailable', {sgFeature: storage});
232 isFeatureAvailable.callback = function(response) {
233 if (typeof response.error !== 'undefined') {
234 var alert = sgBackup.alertGenerator(response.error, 'alert-warning');
235 jQuery('.sg-cloud-container legend').after(alert);
236 that.bootstrapSwitch('state', false);
237 sgBackup.hideAjaxSpinner();
238 }
239 else {
240 ajaxHandler.run();
241 }
242 }
243
244 isFeatureAvailable.run();
245 }
246 else {
247 ajaxHandler.run();
248 }
249 });
250 };
251
252 sgBackup.toggleSftpSettings = function() {
253 jQuery('#ftpPort').val('22');
254 jQuery('#sg-sftp-key-file-block').show();
255 jQuery('#sg-browse-key-file-block').hide();
256
257 if (jQuery('#sg-connect-with-key-file').is(':checked') && connectioType=='sftp') {
258 jQuery('#sg-browse-key-file-block').show();
259 }
260 }
261
262 sgBackup.toggleFtpSettings = function() {
263 jQuery('#ftpPort').val('21');
264 jQuery('#sg-sftp-key-file-block').hide();
265 }
266
267 // Show/hide some fields that are needed/not needed for ftp/sftp
268 sgBackup.toggleNeededFtpFields = function(connectioType) {
269 if(connectioType == 'sftp') {
270 sgBackup.toggleSftpSettings();
271
272 }
273 else if(connectioType == 'ftp') {
274 sgBackup.toggleFtpSettings();
275 }
276 }
277
278 sgBackup.didOpenModal = function(modalName, param){
279 if(modalName == 'manual-backup' || modalName == 'manual-restore'){
280 sgBackup.initManulBackupRadioInputs();
281 sgBackup.initManualBackupTooltips();
282 jQuery('#fileSystemTreeContainer').jstree({ 'core' : {
283
284 'data' : {
285 'url' : function (node) {
286 return getAjaxUrl();
287 },
288 'data' : function (node) {
289 var path = node.id;
290 return { action:"backup_guard_getBackupContent", path:path, backupName:param, token: BG_BACKUP_STRINGS.nonce };
291 }
292 }
293 },
294 "plugins" : ["wholerow", "checkbox", "types"],
295 "checkbox" : {
296 "keep_selected_style" : false
297 },
298 "types": {
299 "file": {
300 "icon": "bg-file-icon"
301 },
302 "folder": {
303 "icon": "bg-folder-icon"
304 },
305 "default":{
306 "icon": "bg-no-icon"
307 }
308 }
309 });
310 }
311 else if(modalName == 'import'){
312 sgBackup.initImportTooltips();
313 jQuery('#modal-import-2').hide();
314 jQuery('#modal-import-3').hide();
315 jQuery('#switch-modal-import-pages-back').hide();
316 jQuery('#uploadSgbpFile').hide();
317 if(jQuery('#modal-import-1').length == 0) {
318 sgBackup.toggleDownloadFromPCPage();
319 }
320 sgBackup.initFileUpload();
321 }
322 else if(modalName == 'ftp-settings'){
323 connectioType = jQuery('#sg-connection-method').val();
324 sgBackup.toggleNeededFtpFields(connectioType);
325
326 jQuery('#sg-connection-method').on('change', function(){
327 connectioType = jQuery(this).val();
328 sgBackup.toggleNeededFtpFields(connectioType);
329 });
330
331 jQuery('#sg-connect-with-key-file').on('click', function(){
332 if(jQuery(this).is(':checked')) {
333 jQuery('#sg-browse-key-file-block').show();
334 }
335 else {
336 jQuery('#sg-browse-key-file-block').hide();
337 }
338 })
339
340 sgBackup.initSFTPKeyFileSelection();
341
342 jQuery('#sg-modal').on('hidden.bs.modal', function () {
343 if(sgBackup.isFtpConnected != true) {
344 jQuery('input[data-storage=FTP]').bootstrapSwitch('state', false);
345 }
346 })
347 }
348 else if(modalName == 'amazon-settings') {
349 jQuery('#sg-modal').on('hidden.bs.modal', function () {
350 if(sgBackup.isAmazonConnected != true) {
351 jQuery('input[data-storage=AMAZON]').bootstrapSwitch('state', false);
352 }
353 });
354 jQuery("#bucketType").on("change", function(){
355 jQuery("#bucketType option").each(function()
356 {
357 var name = jQuery(this).val();
358 jQuery(".form-group-"+name).css("display","none");
359 // Add $(this).val() to your list
360 });
361 var selected = jQuery("#bucketType").val();
362 jQuery(".form-group-"+selected).css("display","block");
363 })
364 }
365 else if(modalName == 'manual-review'){
366 var action = 'setReviewPopupState';
367 jQuery('#sgLeaveReview').click(function(){
368 var reviewUrl = jQuery(this).attr('data-review-url');
369 //Never show again
370 var reviewState = 2;
371 var ajaxHandler = new sgRequestHandler(action, {reviewState: reviewState, token: BG_BACKUP_STRINGS.nonce});
372 ajaxHandler.run();
373 window.open(reviewUrl);
374 });
375
376 jQuery('#sgDontAskAgain').click(function(){
377 //Never show again
378 var reviewState = 2;
379 var ajaxHandler = new sgRequestHandler(action, {reviewState: reviewState, token: BG_BACKUP_STRINGS.nonce});
380 ajaxHandler.run();
381 });
382
383 jQuery('#sgAskLater').click(function(){
384 var reviewState = 0;
385 var ajaxHandler = new sgRequestHandler(action, {reviewState: reviewState, token: BG_BACKUP_STRINGS.nonce});
386 ajaxHandler.run();
387 });
388 }
389 else if(modalName == 'create-schedule') {
390 sgBackup.initScheduleCreation();
391 }
392 };
393
394 sgBackup.isAnyOpenModal = function(){
395 return jQuery('#sg-modal').length;
396 };
397
398 sgBackup.alertGenerator = function(content, alertClass){
399 var sgalert = '';
400 sgalert+='<div class="alert alert-dismissible '+alertClass+'">';
401 sgalert+='<button type="button" class="close" data-dismiss="alert">×</button>';
402 if(jQuery.isArray(content)){
403 jQuery.each(content, function(index, value) {
404 sgalert+=value+'<br/>';
405 });
406 }
407 else if(content != ''){
408 sgalert+=content.replace('[','').replace(']','').replace('"','');
409 }
410 sgalert+='</div>';
411 return sgalert;
412 };
413
414 sgBackup.scrollToElement = function(id){
415 if(jQuery(id).position()){
416 if(jQuery(id).position().top < jQuery(window).scrollTop()){
417 //scroll up
418 jQuery('html,body').animate({scrollTop:jQuery(id).position().top}, 1000);
419 }
420 else if(jQuery(id).position().top + jQuery(id).height() > jQuery(window).scrollTop() + (window.innerHeight || document.documentElement.clientHeight)){
421 //scroll down
422 jQuery('html,body').animate({scrollTop:jQuery(id).position().top - (window.innerHeight || document.documentElement.clientHeight) + jQuery(id).height() + 15}, 1000);
423 }
424 }
425 };
426
427 sgBackup.showAjaxSpinner = function(appendToElement){
428 if(typeof appendToElement == 'undefined'){
429 appendToElement = '#sg-wrapper';
430 }
431 jQuery('<div class="sg-spinner"></div>').appendTo(appendToElement);
432 };
433
434 sgBackup.hideAjaxSpinner = function(){
435 jQuery('.sg-spinner').remove();
436 };
437
438 sgBackup.showReviewModal = function(){
439 if(typeof sgShowReview != 'undefined') {
440 jQuery('#sg-review').trigger("click");
441 }
442 };
443
444 sgBackup.initTablePagination = function(pageName){
445 var callBack = pageName+'';
446 jQuery.fn.sgTablePagination = function(opts){
447 var jQuerythis = this,
448 defaults = {
449 perPage: 7,
450 showPrevNext: false,
451 hidePageNumbers: false,
452 pagerSelector: '.'+pageName+' .pagination'
453 },
454 settings = jQuery.extend(defaults, opts);
455
456 var listElement = jQuerythis.children('tbody');
457 var perPage = settings.perPage;
458 var children = listElement.children();
459 var pager = jQuery('.'+pageName+'.pager');
460
461 if (typeof settings.childSelector!="undefined") {
462 children = listElement.find(settings.childSelector);
463 }
464
465 if (typeof settings.pagerSelector!="undefined") {
466 pager = jQuery(settings.pagerSelector);
467 }
468
469 var numItems = children.length;
470 var numPages = Math.ceil(numItems/perPage);
471
472 pager.data("curr",0);
473
474 if (settings.showPrevNext){
475 jQuery('<li><a href="#" class="prev_link">«</a></li>').appendTo(pager);
476 }
477
478 var curr = 0;
479 while(numPages > curr && (settings.hidePageNumbers==false)){
480 jQuery('<li><a href="#" class="page_link">'+(curr+1)+'</a></li>').appendTo(pager);
481 curr++;
482 }
483
484 if(curr<=1){
485 jQuery(settings.pagerSelector).parent('div').hide();
486 jQuery('.'+pageName+'.page_link').hide();
487 }
488
489 if (settings.showPrevNext){
490 jQuery('<li><a href="#" class="next_link">»</a></li>').appendTo(pager);
491 }
492
493 pager.find('.page_link:first').addClass('active');
494 pager.find('.prev_link').hide();
495 if (numPages<=1) {
496 pager.find('.next_link').hide();
497 }
498 pager.children().eq(1).addClass("active");
499
500 children.hide();
501 children.slice(0, perPage).show();
502
503 pager.find('li .page_link').click(function(){
504 var clickedPage = jQuery(this).html().valueOf()-1;
505 goTo(clickedPage,perPage);
506 return false;
507 });
508 pager.find('li .prev_link').click(function(){
509 previous();
510 return false;
511 });
512 pager.find('li .next_link').click(function(){
513 next();
514 return false;
515 });
516
517 function previous(){
518 var goToPage = parseInt(pager.data("curr")) - 1;
519 goTo(goToPage);
520 }
521
522 function next(){
523 goToPage = parseInt(pager.data("curr")) + 1;
524 goTo(goToPage);
525 }
526
527 function goTo(page){
528 var startAt = page * perPage,
529 endOn = startAt + perPage;
530
531 children.css('display','none').slice(startAt, endOn).show();
532
533 if (page>=1) {
534 pager.find('.prev_link').show();
535 }
536 else {
537 pager.find('.prev_link').hide();
538 }
539
540 if (page<(numPages-1)) {
541 pager.find('.next_link').show();
542 }
543 else {
544 pager.find('.next_link').hide();
545 }
546
547 pager.data("curr",page);
548 pager.children().removeClass("active");
549 pager.children().eq(page+1).addClass("active");
550
551 }
552 };
553 jQuery('table.paginated.'+pageName).sgTablePagination({pagerSelector:'.'+pageName+' .pagination',showPrevNext:true,hidePageNumbers:false,perPage:7});
554 };
555
556 sgBackup.logout = function()
557 {
558 var ajaxHandler = new sgRequestHandler('logout', {token: BG_BACKUP_STRINGS.nonce});
559 ajaxHandler.callback = function(response){
560 location.reload();
561 };
562 ajaxHandler.run();
563 };
564