PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 1.4.7
JetBackup – Backup, Restore & Migrate v1.4.7
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 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 sgdiscount.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
557 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 ajaxHandler.type = 'GET';
194 ajaxHandler.dataType = 'html';
195 ajaxHandler.callback = function(data, error) {
196 sgBackup.hideAjaxSpinner();
197 if (typeof sgBackup.enableUi == 'function') {
198 sgBackup.enableUi();
199 }
200 if (error===false) {
201 jQuery('#sg-modal').append(data);
202 }
203 modal.on('hide.bs.modal', function() {
204 if(SG_CURRENT_ACTIVE_AJAX != '') {
205 if (!confirm(BG_MAIN_STRINGS.confirmCancel)) {
206 return false;
207 }
208 SG_CURRENT_ACTIVE_AJAX.abort();
209 SG_CURRENT_ACTIVE_AJAX = '';
210 }
211 });
212 modal.one('hidden.bs.modal', function() {
213 modal.html('');
214 }).modal('show');
215 sgBackup.didOpenModal(modalName, param);
216 };
217
218 if (modalName == 'ftp-settings' || modalName == 'amazon-settings') {
219 var storage = 'FTP';
220 if (modalName == 'amazon-settings') {
221 storage = 'AMAZON';
222 }
223 error = false;
224 var isFeatureAvailable = new sgRequestHandler('isFeatureAvailable', {sgFeature: storage});
225 isFeatureAvailable.callback = function(response) {
226 if (typeof response.error !== 'undefined') {
227 var alert = sgBackup.alertGenerator(response.error, 'alert-warning');
228 jQuery('.sg-cloud-container legend').after(alert);
229 that.bootstrapSwitch('state', false);
230 sgBackup.hideAjaxSpinner();
231 }
232 else {
233 ajaxHandler.run();
234 }
235 }
236
237 isFeatureAvailable.run();
238 }
239 else {
240 ajaxHandler.run();
241 }
242 });
243 };
244
245 sgBackup.toggleSftpSettings = function() {
246 jQuery('#ftpPort').val('22');
247 jQuery('#sg-sftp-key-file-block').show();
248 jQuery('#sg-browse-key-file-block').hide();
249
250 if (jQuery('#sg-connect-with-key-file').is(':checked') && connectioType=='sftp') {
251 jQuery('#sg-browse-key-file-block').show();
252 }
253 }
254
255 sgBackup.toggleFtpSettings = function() {
256 jQuery('#ftpPort').val('21');
257 jQuery('#sg-sftp-key-file-block').hide();
258 }
259
260 // Show/hide some fields that are needed/not needed for ftp/sftp
261 sgBackup.toggleNeededFtpFields = function(connectioType) {
262 if(connectioType == 'sftp') {
263 sgBackup.toggleSftpSettings();
264
265 }
266 else if(connectioType == 'ftp') {
267 sgBackup.toggleFtpSettings();
268 }
269 }
270
271 sgBackup.didOpenModal = function(modalName, param){
272 if(modalName == 'manual-backup' || modalName == 'manual-restore'){
273 sgBackup.initManulBackupRadioInputs();
274 sgBackup.initManualBackupTooltips();
275 jQuery('#fileSystemTreeContainer').jstree({ 'core' : {
276
277 'data' : {
278 'url' : function (node) {
279 return getAjaxUrl();
280 },
281 'data' : function (node) {
282 var path = node.id;
283 return { action:"backup_guard_getBackupContent", path:path, backupName:param, token: BG_BACKUP_STRINGS.nonce };
284 }
285 }
286 },
287 "plugins" : ["wholerow", "checkbox", "types"],
288 "checkbox" : {
289 "keep_selected_style" : false
290 },
291 "types": {
292 "file": {
293 "icon": "bg-file-icon"
294 },
295 "folder": {
296 "icon": "bg-folder-icon"
297 },
298 "default":{
299 "icon": "bg-no-icon"
300 }
301 }
302 });
303 }
304 else if(modalName == 'import'){
305 sgBackup.initImportTooltips();
306 jQuery('#modal-import-2').hide();
307 jQuery('#modal-import-3').hide();
308 jQuery('#switch-modal-import-pages-back').hide();
309 jQuery('#uploadSgbpFile').hide();
310 if(jQuery('#modal-import-1').length == 0) {
311 sgBackup.toggleDownloadFromPCPage();
312 }
313 sgBackup.initFileUpload();
314 }
315 else if(modalName == 'ftp-settings'){
316 connectioType = jQuery('#sg-connection-method').val();
317 sgBackup.toggleNeededFtpFields(connectioType);
318
319 jQuery('#sg-connection-method').on('change', function(){
320 connectioType = jQuery(this).val();
321 sgBackup.toggleNeededFtpFields(connectioType);
322 });
323
324 jQuery('#sg-connect-with-key-file').on('click', function(){
325 if(jQuery(this).is(':checked')) {
326 jQuery('#sg-browse-key-file-block').show();
327 }
328 else {
329 jQuery('#sg-browse-key-file-block').hide();
330 }
331 })
332
333 sgBackup.initSFTPKeyFileSelection();
334
335 jQuery('#sg-modal').on('hidden.bs.modal', function () {
336 if(sgBackup.isFtpConnected != true) {
337 jQuery('input[data-storage=FTP]').bootstrapSwitch('state', false);
338 }
339 })
340 }
341 else if(modalName == 'amazon-settings') {
342 jQuery('#sg-modal').on('hidden.bs.modal', function () {
343 if(sgBackup.isAmazonConnected != true) {
344 jQuery('input[data-storage=AMAZON]').bootstrapSwitch('state', false);
345 }
346 });
347 jQuery("#bucketType").on("change", function(){
348 jQuery("#bucketType option").each(function()
349 {
350 var name = jQuery(this).val();
351 jQuery(".form-group-"+name).css("display","none");
352 // Add $(this).val() to your list
353 });
354 var selected = jQuery("#bucketType").val();
355 jQuery(".form-group-"+selected).css("display","block");
356 })
357 }
358 else if(modalName == 'manual-review'){
359 var action = 'setReviewPopupState';
360 jQuery('#sgLeaveReview').click(function(){
361 var reviewUrl = jQuery(this).attr('data-review-url');
362 //Never show again
363 var reviewState = 2;
364 var ajaxHandler = new sgRequestHandler(action, {reviewState: reviewState, token: BG_BACKUP_STRINGS.nonce});
365 ajaxHandler.run();
366 window.open(reviewUrl);
367 });
368
369 jQuery('#sgDontAskAgain').click(function(){
370 //Never show again
371 var reviewState = 2;
372 var ajaxHandler = new sgRequestHandler(action, {reviewState: reviewState, token: BG_BACKUP_STRINGS.nonce});
373 ajaxHandler.run();
374 });
375
376 jQuery('#sgAskLater').click(function(){
377 var reviewState = 0;
378 var ajaxHandler = new sgRequestHandler(action, {reviewState: reviewState, token: BG_BACKUP_STRINGS.nonce});
379 ajaxHandler.run();
380 });
381 }
382 else if(modalName == 'create-schedule') {
383 sgBackup.initScheduleCreation();
384 }
385 };
386
387 sgBackup.isAnyOpenModal = function(){
388 return jQuery('#sg-modal').length;
389 };
390
391 sgBackup.alertGenerator = function(content, alertClass){
392 var sgalert = '';
393 sgalert+='<div class="alert alert-dismissible '+alertClass+'">';
394 sgalert+='<button type="button" class="close" data-dismiss="alert">×</button>';
395 if(jQuery.isArray(content)){
396 jQuery.each(content, function(index, value) {
397 sgalert+=value+'<br/>';
398 });
399 }
400 else if(content != ''){
401 sgalert+=content.replace('[','').replace(']','').replace('"','');
402 }
403 sgalert+='</div>';
404 return sgalert;
405 };
406
407 sgBackup.scrollToElement = function(id){
408 if(jQuery(id).position()){
409 if(jQuery(id).position().top < jQuery(window).scrollTop()){
410 //scroll up
411 jQuery('html,body').animate({scrollTop:jQuery(id).position().top}, 1000);
412 }
413 else if(jQuery(id).position().top + jQuery(id).height() > jQuery(window).scrollTop() + (window.innerHeight || document.documentElement.clientHeight)){
414 //scroll down
415 jQuery('html,body').animate({scrollTop:jQuery(id).position().top - (window.innerHeight || document.documentElement.clientHeight) + jQuery(id).height() + 15}, 1000);
416 }
417 }
418 };
419
420 sgBackup.showAjaxSpinner = function(appendToElement){
421 if(typeof appendToElement == 'undefined'){
422 appendToElement = '#sg-wrapper';
423 }
424 jQuery('<div class="sg-spinner"></div>').appendTo(appendToElement);
425 };
426
427 sgBackup.hideAjaxSpinner = function(){
428 jQuery('.sg-spinner').remove();
429 };
430
431 sgBackup.showReviewModal = function(){
432 if(typeof sgShowReview != 'undefined') {
433 jQuery('#sg-review').trigger("click");
434 }
435 };
436
437 sgBackup.initTablePagination = function(pageName){
438 var callBack = pageName+'';
439 jQuery.fn.sgTablePagination = function(opts){
440 var jQuerythis = this,
441 defaults = {
442 perPage: 7,
443 showPrevNext: false,
444 hidePageNumbers: false,
445 pagerSelector: '.'+pageName+' .pagination'
446 },
447 settings = jQuery.extend(defaults, opts);
448
449 var listElement = jQuerythis.children('tbody');
450 var perPage = settings.perPage;
451 var children = listElement.children();
452 var pager = jQuery('.'+pageName+'.pager');
453
454 if (typeof settings.childSelector!="undefined") {
455 children = listElement.find(settings.childSelector);
456 }
457
458 if (typeof settings.pagerSelector!="undefined") {
459 pager = jQuery(settings.pagerSelector);
460 }
461
462 var numItems = children.length;
463 var numPages = Math.ceil(numItems/perPage);
464
465 pager.data("curr",0);
466
467 if (settings.showPrevNext){
468 jQuery('<li><a href="#" class="prev_link">«</a></li>').appendTo(pager);
469 }
470
471 var curr = 0;
472 while(numPages > curr && (settings.hidePageNumbers==false)){
473 jQuery('<li><a href="#" class="page_link">'+(curr+1)+'</a></li>').appendTo(pager);
474 curr++;
475 }
476
477 if(curr<=1){
478 jQuery(settings.pagerSelector).parent('div').hide();
479 jQuery('.'+pageName+'.page_link').hide();
480 }
481
482 if (settings.showPrevNext){
483 jQuery('<li><a href="#" class="next_link">»</a></li>').appendTo(pager);
484 }
485
486 pager.find('.page_link:first').addClass('active');
487 pager.find('.prev_link').hide();
488 if (numPages<=1) {
489 pager.find('.next_link').hide();
490 }
491 pager.children().eq(1).addClass("active");
492
493 children.hide();
494 children.slice(0, perPage).show();
495
496 pager.find('li .page_link').click(function(){
497 var clickedPage = jQuery(this).html().valueOf()-1;
498 goTo(clickedPage,perPage);
499 return false;
500 });
501 pager.find('li .prev_link').click(function(){
502 previous();
503 return false;
504 });
505 pager.find('li .next_link').click(function(){
506 next();
507 return false;
508 });
509
510 function previous(){
511 var goToPage = parseInt(pager.data("curr")) - 1;
512 goTo(goToPage);
513 }
514
515 function next(){
516 goToPage = parseInt(pager.data("curr")) + 1;
517 goTo(goToPage);
518 }
519
520 function goTo(page){
521 var startAt = page * perPage,
522 endOn = startAt + perPage;
523
524 children.css('display','none').slice(startAt, endOn).show();
525
526 if (page>=1) {
527 pager.find('.prev_link').show();
528 }
529 else {
530 pager.find('.prev_link').hide();
531 }
532
533 if (page<(numPages-1)) {
534 pager.find('.next_link').show();
535 }
536 else {
537 pager.find('.next_link').hide();
538 }
539
540 pager.data("curr",page);
541 pager.children().removeClass("active");
542 pager.children().eq(page+1).addClass("active");
543
544 }
545 };
546 jQuery('table.paginated.'+pageName).sgTablePagination({pagerSelector:'.'+pageName+' .pagination',showPrevNext:true,hidePageNumbers:false,perPage:7});
547 };
548
549 sgBackup.logout = function()
550 {
551 var ajaxHandler = new sgRequestHandler('logout', {token: BG_BACKUP_STRINGS.nonce});
552 ajaxHandler.callback = function(response){
553 location.reload();
554 };
555 ajaxHandler.run();
556 };
557