| @@ -1,14 +1,14 @@ | ||
| 1 | 1 | |
| 2 | 2 | /** |
| 3 | 3 | * Backup |
| 4 | 4 | */ |
| 5 | -var backupDownloadRunning = false; | |
| 6 | -var backupError = false; | |
| 7 | -var backupContinueRetries = 0; | |
| 8 | -var backupContinueRetriesUnique = []; | |
| 5 | +let backupDownloadRunning = false; | |
| 6 | +let backupError = false; | |
| 7 | +let backupContinueRetries = 0; | |
| 8 | +let backupContinueRetriesUnique = []; | |
| 9 | 9 | |
| 10 | -jQuery(document).ready(function () { | |
| 10 | +jQuery(function () { | |
| 11 | 11 | jQuery('#backup_btnSubmit').on('click', function () { |
| 12 | 12 | backup(); |
| 13 | 13 | }); |
| 14 | 14 | jQuery('#managesite-backup-status-close').on('click', function () { |
| @@ -16,28 +16,28 @@ | ||
| 16 | 16 | mainwpPopup('#managesite-backup-status-box').close(true); |
| 17 | 17 | }); |
| 18 | 18 | |
| 19 | 19 | }); |
| 20 | -backup = function () { | |
| 20 | +let backup = function () { | |
| 21 | 21 | backupError = false; |
| 22 | 22 | backupContinueRetries = 0; |
| 23 | 23 | |
| 24 | 24 | jQuery('#backup_loading').show(); |
| 25 | - var remote_destinations = jQuery('#backup_location_remote').hasClass('mainwp_action_down') ? jQuery.map(jQuery('#backup_destination_list').find('input[name="remote_destinations[]"]'), function (el) { | |
| 25 | + let remote_destinations = jQuery('#backup_location_remote').hasClass('mainwp_action_down') ? jQuery.map(jQuery('#backup_destination_list').find('input[name="remote_destinations[]"]'), function (el) { | |
| 26 | 26 | return { id: jQuery(el).val(), title: jQuery(el).attr('title'), type: jQuery(el).attr('destination_type') }; |
| 27 | 27 | }) : []; |
| 28 | 28 | |
| 29 | - var type = jQuery('#mainwp-backup-type').val(); | |
| 30 | - var size = jQuery('#backup_site_' + type + '_size').val(); | |
| 29 | + let type = jQuery('#mainwp-backup-type').val(); | |
| 30 | + let size = jQuery('#backup_site_' + type + '_size').val(); | |
| 31 | 31 | if (type == 'full') { |
| 32 | 32 | size = size * 1024 * 1024 / 2.4; //Guessing how large the zip will be |
| 33 | 33 | } |
| 34 | - var fileName = jQuery('#backup_filename').val(); | |
| 35 | - var fileNameUID = mainwp_uid(); | |
| 36 | - var loadFilesBeforeZip = jQuery('[name="mainwp_options_loadFilesBeforeZip"]:checked').val(); | |
| 34 | + let fileName = jQuery('#backup_filename').val(); | |
| 35 | + let fileNameUID = mainwp_uid(); | |
| 36 | + let loadFilesBeforeZip = jQuery('[name="mainwp_options_loadFilesBeforeZip"]:checked').val(); | |
| 37 | 37 | |
| 38 | - var backupPid = Math.round(new Date().getTime() / 1000); | |
| 39 | - var data = mainwp_secure_data({ | |
| 38 | + let backupPid = Math.round(new Date().getTime() / 1000); | |
| 39 | + let data = mainwp_secure_data({ | |
| 40 | 40 | action: 'mainwp_backup', |
| 41 | 41 | site_id: jQuery('#backup_site_id').val(), |
| 42 | 42 | pid: backupPid, |
| 43 | 43 | type: type, |
| @@ -55,9 +55,9 @@ | ||
| 55 | 55 | loadFilesBeforeZip: loadFilesBeforeZip, |
| 56 | 56 | subfolder: jQuery('#backup_subfolder').val() |
| 57 | 57 | }, true); |
| 58 | 58 | |
| 59 | - mainwpPopup('#managesite-backup-status-box').getContentEl().html(dateToHMS(new Date()) + ' ' + __('Creating the backup file on the child site, this might take a while depending on the size. Please be patient.') + ' <div id="managesite-createbackup-status-progress" class="ui green progress"><div class="bar"><div class="progress"></div></div></div>'); | |
| 59 | + mainwpPopup('#managesite-backup-status-box').getContentEl().html(dateToHMS(new Date()) + ' ' + MainWP.I18n.t('Creating the backup file on the child site, this might take a while depending on the size. Please be patient.') + ' <div id="managesite-createbackup-status-progress" class="ui green progress"><div class="bar"><div class="progress"></div></div></div>'); | |
| 60 | 60 | jQuery('#managesite-createbackup-status-progress').progress({ value: 0, total: size }); |
| 61 | 61 | |
| 62 | 62 | mainwpPopup('#managesite-backup-status-box').init({ |
| 63 | 63 | callback: function () { |
| @@ -65,13 +65,13 @@ | ||
| 65 | 65 | location.reload(); |
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | }); |
| 69 | - var backsprocessContentEl = mainwpPopup('#managesite-backup-status-box').getContentEl(); | |
| 69 | + let backsprocessContentEl = mainwpPopup('#managesite-backup-status-box').getContentEl(); | |
| 70 | 70 | |
| 71 | - var fnc = function (pSiteId, pType, pFileName, pFileNameUID) { | |
| 71 | + let fnc = function (pSiteId, pType, pFileName, pFileNameUID) { | |
| 72 | 72 | return function (pFunction) { |
| 73 | - var data2 = mainwp_secure_data({ | |
| 73 | + let data2 = mainwp_secure_data({ | |
| 74 | 74 | action: 'mainwp_createbackup_getfilesize', |
| 75 | 75 | siteId: pSiteId, |
| 76 | 76 | type: pType, |
| 77 | 77 | fileName: pFileName, |
| @@ -91,9 +91,9 @@ | ||
| 91 | 91 | return; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | if (backupCreateRunning) { |
| 95 | - var progressBar = jQuery('#managesite-createbackup-status-progress'); | |
| 95 | + let progressBar = jQuery('#managesite-createbackup-status-progress'); | |
| 96 | 96 | if (progressBar.progress('get value') < progressBar.progress('get total')) { |
| 97 | 97 | progressBar.progress('set progress', response.size); |
| 98 | 98 | } |
| 99 | 99 | |
| @@ -132,12 +132,12 @@ | ||
| 132 | 132 | backup_retry_fail(pSiteId, pData, pRemoteDestinations, pBackupPid, pType, pSubfolder, pFilename, response.error ? response.error : ''); |
| 133 | 133 | } else { |
| 134 | 134 | backupCreateRunning = false; |
| 135 | 135 | |
| 136 | - var progressBar = jQuery('#managesite-createbackup-status-progress'); | |
| 136 | + let progressBar = jQuery('#managesite-createbackup-status-progress'); | |
| 137 | 137 | progressBar.progress('set progress', parseFloat(progressBar.progress('get total'))); |
| 138 | 138 | |
| 139 | - appendToDiv(backsprocessContentEl, __('Backup file on child site created successfully!')); | |
| 139 | + appendToDiv(backsprocessContentEl, MainWP.I18n.t('Backup file on child site created successfully!')); | |
| 140 | 140 | |
| 141 | 141 | backup_download_file(pSiteId, pType, response.result.url, response.result.local, response.result.regexfile, response.result.size, response.result.subfolder, pRemoteDestinations); |
| 142 | 142 | } |
| 143 | 143 | } |
| @@ -150,12 +150,12 @@ | ||
| 150 | 150 | dataType: 'json' |
| 151 | 151 | }); |
| 152 | 152 | }; |
| 153 | 153 | |
| 154 | -backup_retry_fail = function (siteId, pData, remoteDestinations, pid, type, subfolder, filename, responseError) { | |
| 155 | - var backsprocessContentEl = mainwpPopup('#managesite-backup-status-box').getContentEl(); | |
| 154 | +let backup_retry_fail = function (siteId, pData, remoteDestinations, pid, type, subfolder, filename, responseError) { | |
| 155 | + let backsprocessContentEl = mainwpPopup('#managesite-backup-status-box').getContentEl(); | |
| 156 | 156 | //we've got the pid file!!!! |
| 157 | - var data = mainwp_secure_data({ | |
| 157 | + let data = mainwp_secure_data({ | |
| 158 | 158 | action: 'mainwp_backup_checkpid', |
| 159 | 159 | site_id: siteId, |
| 160 | 160 | pid: pid, |
| 161 | 161 | type: type, |
| @@ -170,33 +170,26 @@ | ||
| 170 | 170 | success: function (response) { |
| 171 | 171 | if (response.status == 'done') { |
| 172 | 172 | backupCreateRunning = false; |
| 173 | 173 | |
| 174 | - var progressBar = jQuery('#managesite-createbackup-status-progress'); | |
| 174 | + let progressBar = jQuery('#managesite-createbackup-status-progress'); | |
| 175 | 175 | progressBar.progress('set progress', parseFloat(progressBar.progress('get total'))); |
| 176 | 176 | |
| 177 | 177 | //download!!! |
| 178 | - appendToDiv(backsprocessContentEl, __('Backup file on child site created successfully!')); | |
| 178 | + appendToDiv(backsprocessContentEl, MainWP.I18n.t('Backup file on child site created successfully!')); | |
| 179 | 179 | |
| 180 | 180 | backup_download_file(siteId, type, response.result.file, response.result.local, response.result.regexfile, response.result.size, response.result.subfolder, remoteDestinations); |
| 181 | - } else if (response.status == 'busy') { | |
| 182 | - //Try again in 5seconds | |
| 183 | - setTimeout(function () { | |
| 184 | - backup_retry_fail(siteId, pData, remoteDestinations, pid, type, subfolder, filename, responseError); | |
| 185 | - }, 10000); | |
| 186 | 181 | } else if (response.status == 'stalled') { |
| 187 | 182 | backupContinueRetries++; |
| 188 | 183 | |
| 189 | - if (backupContinueRetries > 10) { | |
| 184 | + if (backupContinueRetries > 15) { | |
| 190 | 185 | if (responseError != undefined) { |
| 191 | 186 | appendToDiv(backsprocessContentEl, ' <span class="mainwp-red">ERROR: ' + getErrorMessage(responseError) + '</span>'); |
| 192 | 187 | } else { |
| 193 | - appendToDiv(backsprocessContentEl, ' <span class="mainwp-red">ERROR: Backup timed out! <a href="https://mainwp.com/help/docs/mainwp-introduction/resolving-system-requirement-issues/">Please check this help document for more information and possible fixes</a></span>'); | |
| 188 | + appendToDiv(backsprocessContentEl, ' <span class="mainwp-red">ERROR: Backup timed out! (stalled) - <a href="https://mainwp.com/help/docs/mainwp-introduction/resolving-system-requirement-issues/">Please check this help document for more information and possible fixes</a></span>'); // NOSONAR - noopener - open safe. | |
| 194 | 189 | } |
| 195 | 190 | } else { |
| 196 | 191 | appendToDiv(backsprocessContentEl, ' Backup stalled, trying to resume from last file...'); |
| 197 | - //retrying file: response.result.file ! | |
| 198 | - | |
| 199 | 192 | pData['filename'] = response.result.file; |
| 200 | 193 | pData['append'] = 1; |
| 201 | 194 | pData = mainwp_secure_data(pData, true); //Rescure |
| 202 | 195 | |
| @@ -210,12 +203,12 @@ | ||
| 210 | 203 | backup_retry_fail(pSiteId, pData, pRemoteDestinations, pBackupPid, pType, pSubfolder, pFilename, response.error ? response.error : ''); |
| 211 | 204 | } else { |
| 212 | 205 | backupCreateRunning = false; |
| 213 | 206 | |
| 214 | - var progressBar = jQuery('#managesite-createbackup-status-progress'); | |
| 207 | + let progressBar = jQuery('#managesite-createbackup-status-progress'); | |
| 215 | 208 | progressBar.progress('set progress', parseFloat(progressBar.progress('get total'))); |
| 216 | 209 | |
| 217 | - appendToDiv(backsprocessContentEl, __('Backupfile on child site created successfully.')); | |
| 210 | + appendToDiv(backsprocessContentEl, MainWP.I18n.t('Backupfile on child site created successfully.')); | |
| 218 | 211 | |
| 219 | 212 | backup_download_file(pSiteId, pType, response.result.url, response.result.local, response.result.regexfile, response.result.size, response.result.subfolder, pRemoteDestinations); |
| 220 | 213 | } |
| 221 | 214 | } |
| @@ -233,11 +226,12 @@ | ||
| 233 | 226 | |
| 234 | 227 | if (responseError != undefined) { |
| 235 | 228 | appendToDiv(backsprocessContentEl, ' <span class="mainwp-red">ERROR: ' + getErrorMessage(responseError) + '</span>'); |
| 236 | 229 | } else { |
| 237 | - appendToDiv(backsprocessContentEl, ' <span class="mainwp-red">ERROR: Backup timed out! <a href="https://mainwp.com/help/docs/mainwp-introduction/resolving-system-requirement-issues/">Please check this help document for more information and possible fixes</a></span>'); | |
| 230 | + appendToDiv(backsprocessContentEl, ' <span class="mainwp-red">ERROR: Backup timed out! (invalid) - <a href="https://mainwp.com/help/docs/mainwp-introduction/resolving-system-requirement-issues/">Please check this help document for more information and possible fixes</a></span>'); // NOSONAR - noopener - open safe. | |
| 238 | 231 | } |
| 239 | 232 | } else { |
| 233 | + // busy or other. | |
| 240 | 234 | //Try again in 5seconds |
| 241 | 235 | setTimeout(function () { |
| 242 | 236 | backup_retry_fail(siteId, pData, remoteDestinations, pid, type, subfolder, filename, responseError); |
| 243 | 237 | }, 10000); |
| @@ -253,15 +247,15 @@ | ||
| 253 | 247 | }); |
| 254 | 248 | }; |
| 255 | 249 | |
| 256 | 250 | backup_download_file = function (pSiteId, type, url, file, regexfile, size, subfolder, remote_destinations) { |
| 257 | - var backsprocessContentEl = mainwpPopup('#managesite-backup-status-box').getContentEl(); | |
| 258 | - appendToDiv(backsprocessContentEl, __('Downloading the file.') + ' <div id="managesite-backup-status-progress" class="ui green progress"><div class="bar"><div class="progress"></div></div></div>'); | |
| 251 | + let backsprocessContentEl = mainwpPopup('#managesite-backup-status-box').getContentEl(); | |
| 252 | + appendToDiv(backsprocessContentEl, MainWP.I18n.t('Downloading the file.') + ' <div id="managesite-backup-status-progress" class="ui green progress"><div class="bar"><div class="progress"></div></div></div>'); | |
| 259 | 253 | jQuery('#managesite-backup-status-progress').progress({ value: 0, total: size }); |
| 260 | 254 | |
| 261 | - var fnc = function () { | |
| 255 | + let fnc = function (file) { | |
| 262 | 256 | return function (pFunction) { |
| 263 | - var data = mainwp_secure_data({ | |
| 257 | + let data = mainwp_secure_data({ | |
| 264 | 258 | action: 'mainwp_backup_getfilesize', |
| 265 | 259 | local: file |
| 266 | 260 | }); |
| 267 | 261 | jQuery.ajax({ |
| @@ -277,9 +271,9 @@ | ||
| 277 | 271 | return; |
| 278 | 272 | } |
| 279 | 273 | |
| 280 | 274 | if (backupDownloadRunning) { |
| 281 | - var progressBar = jQuery('#managesite-backup-status-progress'); | |
| 275 | + let progressBar = jQuery('#managesite-backup-status-progress'); | |
| 282 | 276 | if (progressBar.progress('get value') < progressBar.progress('get total')) { |
| 283 | 277 | progressBar.progress('set progress', response.result); |
| 284 | 278 | } |
| 285 | 279 | |
| @@ -306,9 +300,9 @@ | ||
| 306 | 300 | setTimeout(function () { |
| 307 | 301 | fnc(fnc); |
| 308 | 302 | }, 1000); |
| 309 | 303 | |
| 310 | - var data = mainwp_secure_data({ | |
| 304 | + let data = mainwp_secure_data({ | |
| 311 | 305 | action: 'mainwp_backup_download_file', |
| 312 | 306 | site_id: pSiteId, |
| 313 | 307 | type: type, |
| 314 | 308 | url: url, |
| @@ -325,9 +319,9 @@ | ||
| 325 | 319 | backupDownloadRunning = false; |
| 326 | 320 | |
| 327 | 321 | if (response.error) { |
| 328 | 322 | appendToDiv(backsprocessContentEl, '<span class="mainwp-red">ERROR: ' + getErrorMessage(response.error) + '</span>'); |
| 329 | - appendToDiv(backsprocessContentEl, '<span class="mainwp-red">' + __('Backup failed!') + '</span>'); | |
| 323 | + appendToDiv(backsprocessContentEl, '<span class="mainwp-red">' + MainWP.I18n.t('Backup failed!') + '</span>'); | |
| 330 | 324 | |
| 331 | 325 | jQuery('#managesite-backup-status-close').prop('value', 'Close'); |
| 332 | 326 | return; |
| 333 | 327 | } |
| @@ -332,11 +326,11 @@ | ||
| 332 | 326 | return; |
| 333 | 327 | } |
| 334 | 328 | |
| 335 | 329 | jQuery('#managesite-backup-status-progress').progress('set progress', pSize); |
| 336 | - appendToDiv(backsprocessContentEl, __('Download from child site completed.')); | |
| 330 | + appendToDiv(backsprocessContentEl, MainWP.I18n.t('Download from child site completed.')); | |
| 337 | 331 | |
| 338 | - var newData = mainwp_secure_data({ | |
| 332 | + let newData = mainwp_secure_data({ | |
| 339 | 333 | action: 'mainwp_backup_delete_file', |
| 340 | 334 | site_id: pSiteId, |
| 341 | 335 | file: pUrl |
| 342 | 336 | }); |
| @@ -355,22 +349,22 @@ | ||
| 355 | 349 | dataType: 'json' |
| 356 | 350 | }); |
| 357 | 351 | }; |
| 358 | 352 | |
| 359 | -var backupUploadRunning = []; | |
| 353 | +let backupUploadRunning = []; | |
| 360 | 354 | backup_upload_file = function (pSiteId, pFile, pRegexFile, pSubfolder, pRemoteDestinations, pType, pSize) { |
| 361 | - var backsprocessContentEl = mainwpPopup('#managesite-backup-status-box').getContentEl(); | |
| 355 | + let backsprocessContentEl = mainwpPopup('#managesite-backup-status-box').getContentEl(); | |
| 362 | 356 | if (pRemoteDestinations.length > 0) { |
| 363 | - var remote_destination = pRemoteDestinations[0]; | |
| 357 | + let remote_destination = pRemoteDestinations[0]; | |
| 364 | 358 | //upload.. |
| 365 | - var unique = Date.now(); | |
| 366 | - appendToDiv(backsprocessContentEl, __('Uploading to remote destination: %1 (%2)', remote_destination.title, remote_destination.type) + '<div id="managesite-upload-status-progress-' + unique + '" class="ui green progress"><div class="bar"><div class="progress"></div></div></div>'); | |
| 359 | + let unique = Date.now(); | |
| 360 | + appendToDiv(backsprocessContentEl, MainWP.I18n.t('Uploading to remote destination: %1 (%2)', remote_destination.title, remote_destination.type) + '<div id="managesite-upload-status-progress-' + unique + '" class="ui green progress"><div class="bar"><div class="progress"></div></div></div>'); | |
| 367 | 361 | |
| 368 | 362 | jQuery('#managesite-upload-status-progress-' + unique).progress({ value: 0, total: pSize }); |
| 369 | 363 | |
| 370 | - var fnc = function (pUnique) { | |
| 364 | + let fnc = function (pUnique) { | |
| 371 | 365 | return function (pFunction) { |
| 372 | - var data2 = mainwp_secure_data({ | |
| 366 | + let data2 = mainwp_secure_data({ | |
| 373 | 367 | action: 'mainwp_backup_upload_getprogress', |
| 374 | 368 | unique: pUnique |
| 375 | 369 | }, false); |
| 376 | 370 | |
| @@ -387,10 +381,10 @@ | ||
| 387 | 381 | return; |
| 388 | 382 | } |
| 389 | 383 | |
| 390 | 384 | if (backupUploadRunning[pUnique]) { |
| 391 | - var progressBar = jQuery('#managesite-upload-status-progress-' + pUnique); | |
| 392 | - if ((progressBar.length > 0) && (progressBar.progress('get value') < progressBar.progress('get total')) && (progressBar.progress('get value') < parseInt(response.result))) { | |
| 385 | + let progressBar = jQuery('#managesite-upload-status-progress-' + pUnique); | |
| 386 | + if ((progressBar.length > 0) && (progressBar.progress('get value') < progressBar.progress('get total')) && (progressBar.progress('get value') < Number.parseInt(response.result))) { | |
| 393 | 387 | progressBar.progress('set progress', response.result); |
| 394 | 388 | } |
| 395 | 389 | |
| 396 | 390 | setTimeout(function () { |
| @@ -418,9 +412,9 @@ | ||
| 418 | 412 | }, 1000); |
| 419 | 413 | |
| 420 | 414 | backupUploadRunning[unique] = true; |
| 421 | 415 | |
| 422 | - var data = mainwp_secure_data({ | |
| 416 | + let data = mainwp_secure_data({ | |
| 423 | 417 | action: 'mainwp_backup_upload_file', |
| 424 | 418 | file: pFile, |
| 425 | 419 | siteId: pSiteId, |
| 426 | 420 | regexfile: pRegexFile, |
| @@ -441,17 +435,17 @@ | ||
| 441 | 435 | backup_upload_file_retry_fail(pData, pSiteId, pFile, pRegexFile, pSubfolder, pNewRemoteDestinations, pType, pSize, pUnique, pRemoteDestId, response && response.error ? response.error : ''); |
| 442 | 436 | } else { |
| 443 | 437 | backupUploadRunning[pUnique] = false; |
| 444 | 438 | |
| 445 | - var progressBar = jQuery('#managesite-upload-status-progress-' + pUnique); | |
| 439 | + let progressBar = jQuery('#managesite-upload-status-progress-' + pUnique); | |
| 446 | 440 | progressBar.progress('set progress', pSize); |
| 447 | 441 | |
| 448 | - var obj = response.result; | |
| 442 | + let obj = response.result; | |
| 449 | 443 | if (obj.error) { |
| 450 | 444 | backupError = true; |
| 451 | - appendToDiv(backsprocessContentEl, '<span class="mainwp-red">' + __('Upload to %1 (%2) failed:', obj.title, obj.type) + ' ' + obj.error + '</span>'); | |
| 445 | + appendToDiv(backsprocessContentEl, '<span class="mainwp-red">' + MainWP.I18n.t('Upload to %1 (%2) failed:', obj.title, obj.type) + ' ' + obj.error + '</span>'); | |
| 452 | 446 | } else { |
| 453 | - appendToDiv(backsprocessContentEl, __('Upload to %1 (%2) successful!', obj.title, obj.type)); | |
| 447 | + appendToDiv(backsprocessContentEl, MainWP.I18n.t('Upload to %1 (%2) successful!', obj.title, obj.type)); | |
| 454 | 448 | } |
| 455 | 449 | |
| 456 | 450 | backup_upload_file(pSiteId, pFile, pRegexFile, pSubfolder, pNewRemoteDestinations, pType, pSize); |
| 457 | 451 | } |
| @@ -464,9 +458,9 @@ | ||
| 464 | 458 | }(pSiteId, pRemoteDestinations, pFile, pRegexFile, pSubfolder, pType, pSize, data, unique, remote_destination.id), |
| 465 | 459 | dataType: 'json' |
| 466 | 460 | }); |
| 467 | 461 | } else { |
| 468 | - appendToDiv(backsprocessContentEl, __('Backup completed!')); | |
| 462 | + appendToDiv(backsprocessContentEl, MainWP.I18n.t('Backup completed!')); | |
| 469 | 463 | jQuery('#managesite-backup-status-close').prop('value', 'Close'); |
| 470 | 464 | if (!backupError) { |
| 471 | 465 | setTimeout(function () { |
| 472 | 466 | mainwpPopup('#managesite-backup-status-box').close(true); |
| @@ -476,11 +470,11 @@ | ||
| 476 | 470 | } |
| 477 | 471 | }; |
| 478 | 472 | |
| 479 | 473 | backup_upload_file_retry_fail = function (pData, pSiteId, pFile, pRegexFile, pSubfolder, pNewRemoteDestinations, pType, pSize, pUnique, pRemoteDestId, responseError) { |
| 480 | - var backsprocessContentEl = mainwpPopup('#managesite-backup-status-box').getContentEl(); | |
| 474 | + let backsprocessContentEl = mainwpPopup('#managesite-backup-status-box').getContentEl(); | |
| 481 | 475 | //we've got the pid file!!!! |
| 482 | - var data = mainwp_secure_data({ | |
| 476 | + let data = mainwp_secure_data({ | |
| 483 | 477 | action: 'mainwp_backup_upload_checkstatus', |
| 484 | 478 | unique: pUnique, |
| 485 | 479 | remote_destination: pRemoteDestId |
| 486 | 480 | }); |
| @@ -492,19 +486,14 @@ | ||
| 492 | 486 | success: function (response) { |
| 493 | 487 | if (response.status == 'done') { |
| 494 | 488 | backupUploadRunning[pUnique] = false; |
| 495 | 489 | |
| 496 | - var progressBar = jQuery('#managesite-upload-status-progress-' + pUnique); | |
| 490 | + let progressBar = jQuery('#managesite-upload-status-progress-' + pUnique); | |
| 497 | 491 | progressBar.progress('set progress', pSize); |
| 498 | 492 | |
| 499 | - appendToDiv(backsprocessContentEl, __('Upload to %1 (%2) successful!', response.info.title, response.info.type)); | |
| 493 | + appendToDiv(backsprocessContentEl, MainWP.I18n.t('Upload to %1 (%2) successful!', response.info.title, response.info.type)); | |
| 500 | 494 | |
| 501 | 495 | backup_upload_file(pSiteId, pFile, pRegexFile, pSubfolder, pNewRemoteDestinations, pType, pSize); |
| 502 | - } else if (response.status == 'busy') { | |
| 503 | - //Try again in 10seconds | |
| 504 | - setTimeout(function () { | |
| 505 | - backup_upload_file_retry_fail(pData, pSiteId, pFile, pRegexFile, pSubfolder, pNewRemoteDestinations, pType, pSize, pUnique, pRemoteDestId, responseError); | |
| 506 | - }, 10000); | |
| 507 | 496 | } else if (response.status == 'stalled') { |
| 508 | 497 | if (backupContinueRetriesUnique[pUnique] == undefined) { |
| 509 | 498 | backupContinueRetriesUnique[pUnique] = 1; |
| 510 | 499 | } else { |
| @@ -513,9 +502,9 @@ | ||
| 513 | 502 | |
| 514 | 503 | if (backupContinueRetriesUnique[pUnique] > 10) { |
| 515 | 504 | if (responseError != undefined) { |
| 516 | 505 | backupError = true; |
| 517 | - appendToDiv(backsprocessContentEl, '<span class="mainwp-red">' + __('Upload to %1 (%2) failed:', response.info.title, response.info.type) + ' ' + responseError + '</span>'); | |
| 506 | + appendToDiv(backsprocessContentEl, '<span class="mainwp-red">' + MainWP.I18n.t('Upload to %1 (%2) failed:', response.info.title, response.info.type) + ' ' + responseError + '</span>'); | |
| 518 | 507 | } else { |
| 519 | 508 | appendToDiv(backsprocessContentEl, ' <span class="mainwp-red">ERROR: Upload timed out! <a href="http://docs.mainwp.com/backup-failed-php-ini-settings/">Please check this help document for more information and possible fixes</a></span>'); |
| 520 | 509 | } |
| 521 | 510 | |
| @@ -535,17 +524,17 @@ | ||
| 535 | 524 | backup_upload_file_retry_fail(pData, pSiteId, pFile, pRegexFile, pSubfolder, pNewRemoteDestinations, pType, pSize, pUnique, pRemoteDestId, response.error ? response.error : ''); |
| 536 | 525 | } else { |
| 537 | 526 | backupUploadRunning[pUnique] = false; |
| 538 | 527 | |
| 539 | - var progressBar = jQuery('#managesite-upload-status-progress-' + pUnique); | |
| 528 | + let progressBar = jQuery('#managesite-upload-status-progress-' + pUnique); | |
| 540 | 529 | progressBar.progress('set progress', pSize); |
| 541 | 530 | |
| 542 | - var obj = response.result; | |
| 531 | + let obj = response.result; | |
| 543 | 532 | if (obj.error) { |
| 544 | 533 | backupError = true; |
| 545 | - appendToDiv(backsprocessContentEl, '<span class="mainwp-red">' + __('Upload to %1 (%2) failed:', obj.title, obj.type) + ' ' + obj.error + '</span>'); | |
| 534 | + appendToDiv(backsprocessContentEl, '<span class="mainwp-red">' + MainWP.I18n.t('Upload to %1 (%2) failed:', obj.title, obj.type) + ' ' + obj.error + '</span>'); | |
| 546 | 535 | } else { |
| 547 | - appendToDiv(backsprocessContentEl, __('Upload to %1 (%2) successful!', obj.title, obj.type)); | |
| 536 | + appendToDiv(backsprocessContentEl, MainWP.I18n.t('Upload to %1 (%2) successful!', obj.title, obj.type)); | |
| 548 | 537 | } |
| 549 | 538 | |
| 550 | 539 | backup_upload_file(pSiteId, pFile, pRegexFile, pSubfolder, pNewRemoteDestinations, pType, pSize); |
| 551 | 540 | } |
| @@ -559,8 +548,9 @@ | ||
| 559 | 548 | dataType: 'json' |
| 560 | 549 | }); |
| 561 | 550 | } |
| 562 | 551 | } else { |
| 552 | + // busy or other. | |
| 563 | 553 | //Try again in 5seconds |
| 564 | 554 | setTimeout(function () { |
| 565 | 555 | backup_upload_file_retry_fail(pData, pSiteId, pFile, pRegexFile, pSubfolder, pNewRemoteDestinations, pType, pSize, pUnique, pRemoteDestId, responseError); |
| 566 | 556 | }, 10000); |
| @@ -579,9 +569,9 @@ | ||
| 579 | 569 | |
| 580 | 570 | /** |
| 581 | 571 | * Manage backups page |
| 582 | 572 | */ |
| 583 | -jQuery(document).ready(function () { | |
| 573 | +jQuery(function () { | |
| 584 | 574 | jQuery(document).on('click', '.backup_destination_exclude', function () { |
| 585 | 575 | jQuery(this).parent().parent().animate({ height: 0 }, { |
| 586 | 576 | duration: 'slow', complete: function () { |
| 587 | 577 | jQuery(this).remove(); |
| @@ -605,36 +595,36 @@ | ||
| 605 | 595 | managebackups_init(); |
| 606 | 596 | |
| 607 | 597 | }); |
| 608 | 598 | managebackups_exclude_folder = function (pElement) { |
| 609 | - var folder = pElement.parent().attr('rel') + "\n"; | |
| 610 | - if (jQuery('#excluded_folders_list').val().indexOf(folder) !== -1) | |
| 599 | + let folder = pElement.parent().attr('rel') + "\n"; | |
| 600 | + if (jQuery('#excluded_folders_list').val().includes(folder)) | |
| 611 | 601 | return; |
| 612 | 602 | |
| 613 | 603 | jQuery('#excluded_folders_list').val(jQuery('#excluded_folders_list').val() + folder); |
| 614 | 604 | }; |
| 615 | 605 | |
| 616 | -var manageBackupsError = false; | |
| 617 | -var manageBackupsTaskRemoteDestinations; | |
| 618 | -var manageBackupsTaskId; | |
| 619 | -var manageBackupsTaskType; | |
| 620 | -var manageBackupsTaskError; | |
| 606 | +let manageBackupsError = false; | |
| 607 | +let manageBackupsTaskRemoteDestinations; | |
| 608 | +let manageBackupsTaskId; | |
| 609 | +let manageBackupsTaskType; | |
| 610 | +let manageBackupsTaskError; | |
| 621 | 611 | managebackups_run_now = function (el) { |
| 622 | 612 | el = jQuery(el); |
| 623 | 613 | el.hide(); |
| 624 | 614 | el.parent().find('.backup_run_loading').show(); |
| 625 | - mainwpPopup('#managebackups-task-status-box').getContentEl().html(dateToHMS(new Date()) + ' ' + __('Starting the backup task...')); | |
| 626 | - jQuery('#managebackups-task-status-close').prop('value', __('Cancel')); | |
| 615 | + mainwpPopup('#managebackups-task-status-box').getContentEl().html(dateToHMS(new Date()) + ' ' + MainWP.I18n.t('Starting the backup task...')); | |
| 616 | + jQuery('#managebackups-task-status-close').prop('value', MainWP.I18n.t('Cancel')); | |
| 627 | 617 | mainwpPopup('#managebackups-task-status-box').init({ |
| 628 | - title: __('Running task'), callback: function () { | |
| 618 | + title: MainWP.I18n.t('Running task'), callback: function () { | |
| 629 | 619 | location.reload(); |
| 630 | 620 | } |
| 631 | 621 | }); |
| 632 | 622 | |
| 633 | - var taskId = el.attr('task_id'); | |
| 634 | - var taskType = el.attr('task_type'); | |
| 623 | + let taskId = el.attr('task_id'); | |
| 624 | + let taskType = el.attr('task_type'); | |
| 635 | 625 | //Fetch the sites to backup |
| 636 | - var data = mainwp_secure_data({ | |
| 626 | + let data = mainwp_secure_data({ | |
| 637 | 627 | action: 'mainwp_backuptask_get_sites', |
| 638 | 628 | task_id: taskId |
| 639 | 629 | }); |
| 640 | 630 | |
| @@ -652,13 +642,13 @@ | ||
| 652 | 642 | } |
| 653 | 643 | }(taskId, taskType), 'json'); |
| 654 | 644 | }; |
| 655 | 645 | managebackups_run_next = function () { |
| 656 | - var backtaskContentEl = mainwpPopup('#managebackups-task-status-box').getContentEl(); | |
| 646 | + let backtaskContentEl = mainwpPopup('#managebackups-task-status-box').getContentEl(); | |
| 657 | 647 | if (manageBackupTaskSites.length == 0) { |
| 658 | - appendToDiv(backtaskContentEl, __('Backup task completed') + (manageBackupsTaskError ? ' <span class="mainwp-red">' + __('with errors') + '</span>' : '') + '.'); | |
| 648 | + appendToDiv(backtaskContentEl, MainWP.I18n.t('Backup task completed') + (manageBackupsTaskError ? ' <span class="mainwp-red">' + MainWP.I18n.t('with errors') + '</span>' : '') + '.'); | |
| 659 | 649 | |
| 660 | - jQuery('#managebackups-task-status-close').prop('value', __('Close')); | |
| 650 | + jQuery('#managebackups-task-status-close').prop('value', MainWP.I18n.t('Close')); | |
| 661 | 651 | if (!manageBackupsError) { |
| 662 | 652 | setTimeout(function () { |
| 663 | 653 | mainwpPopup('#managebackups-task-status-box').close(true); |
| 664 | 654 | }, 3000); |
| @@ -665,16 +655,16 @@ | ||
| 665 | 655 | } |
| 666 | 656 | return; |
| 667 | 657 | } |
| 668 | 658 | |
| 669 | - var siteId = manageBackupTaskSites[0]['id']; | |
| 670 | - var siteName = manageBackupTaskSites[0]['name']; | |
| 671 | - var size = manageBackupTaskSites[0][manageBackupsTaskType + 'size']; | |
| 672 | - var fileNameUID = mainwp_uid(); | |
| 673 | - appendToDiv(backtaskContentEl, '[' + siteName + '] ' + __('Creating backup file.') + '<div id="managebackups-task-status-create-progress" siteId="' + siteId + '" class="ui green progress"><div class="bar"><div class="progress"></div></div></div>'); | |
| 659 | + let siteId = manageBackupTaskSites[0]['id']; | |
| 660 | + let siteName = manageBackupTaskSites[0]['name']; | |
| 661 | + let size = manageBackupTaskSites[0][manageBackupsTaskType + 'size']; | |
| 662 | + let fileNameUID = mainwp_uid(); | |
| 663 | + appendToDiv(backtaskContentEl, '[' + siteName + '] ' + MainWP.I18n.t('Creating backup file.') + '<div id="managebackups-task-status-create-progress" siteId="' + siteId + '" class="ui green progress"><div class="bar"><div class="progress"></div></div></div>'); | |
| 674 | 664 | |
| 675 | 665 | manageBackupTaskSites.shift(); |
| 676 | - var data = mainwp_secure_data({ | |
| 666 | + let data = mainwp_secure_data({ | |
| 677 | 667 | action: 'mainwp_backuptask_run_site', |
| 678 | 668 | task_id: manageBackupsTaskId, |
| 679 | 669 | site_id: siteId, |
| 680 | 670 | fileNameUID: fileNameUID |
| @@ -680,10 +670,10 @@ | ||
| 680 | 670 | fileNameUID: fileNameUID |
| 681 | 671 | }); |
| 682 | 672 | |
| 683 | 673 | jQuery('#managebackups-task-status-create-progress[siteId="' + siteId + '"]').progress({ value: 0, total: size }); |
| 684 | - var interVal = setInterval(function () { | |
| 685 | - var data = mainwp_secure_data({ | |
| 674 | + let interVal = setInterval(function () { | |
| 675 | + let data = mainwp_secure_data({ | |
| 686 | 676 | action: 'mainwp_createbackup_getfilesize', |
| 687 | 677 | type: manageBackupsTaskType, |
| 688 | 678 | siteId: siteId, |
| 689 | 679 | fileName: '', |
| @@ -694,9 +684,9 @@ | ||
| 694 | 684 | if (response.error) |
| 695 | 685 | return; |
| 696 | 686 | |
| 697 | 687 | if (backupCreateRunning) { |
| 698 | - var progressBar = jQuery('#managebackups-task-status-create-progress[siteId="' + pSiteId + '"]'); | |
| 688 | + let progressBar = jQuery('#managebackups-task-status-create-progress[siteId="' + pSiteId + '"]'); | |
| 699 | 689 | if (progressBar.progress('get value') < progressBar.progress('get total')) { |
| 700 | 690 | progressBar.progress('set progress', response.size); |
| 701 | 691 | } |
| 702 | 692 | } |
| @@ -714,9 +704,9 @@ | ||
| 714 | 704 | return function (response) { |
| 715 | 705 | backupCreateRunning = false; |
| 716 | 706 | clearInterval(pInterVal); |
| 717 | 707 | |
| 718 | - var progressBar = jQuery('#managebackups-task-status-create-progress[siteId="' + pSiteId + '"]'); | |
| 708 | + let progressBar = jQuery('#managebackups-task-status-create-progress[siteId="' + pSiteId + '"]'); | |
| 719 | 709 | progressBar.progress('set progress', parseFloat(progressBar.progress('get total'))); |
| 720 | 710 | |
| 721 | 711 | if (response.error) { |
| 722 | 712 | appendToDiv(backtaskContentEl, '[' + pSiteName + '] <span class="mainwp-red">Error: ' + getErrorMessage(response.error) + '</span>'); |
| @@ -722,9 +712,9 @@ | ||
| 722 | 712 | appendToDiv(backtaskContentEl, '[' + pSiteName + '] <span class="mainwp-red">Error: ' + getErrorMessage(response.error) + '</span>'); |
| 723 | 713 | manageBackupsTaskError = true; |
| 724 | 714 | managebackups_run_next(); |
| 725 | 715 | } else { |
| 726 | - appendToDiv(backtaskContentEl, '[' + pSiteName + '] ' + __('Backup file created successfully.')); | |
| 716 | + appendToDiv(backtaskContentEl, '[' + pSiteName + '] ' + MainWP.I18n.t('Backup file created successfully.')); | |
| 727 | 717 | |
| 728 | 718 | managebackups_backup_download_file(pSiteId, pSiteName, response.result.type, response.result.url, response.result.local, response.result.regexfile, response.result.size, response.result.subfolder, pRemoteDestinations); |
| 729 | 719 | } |
| 730 | 720 | } |
| @@ -732,20 +722,20 @@ | ||
| 732 | 722 | error: function (pInterVal, pSiteName) { |
| 733 | 723 | return function () { |
| 734 | 724 | backupCreateRunning = false; |
| 735 | 725 | clearInterval(pInterVal); |
| 736 | - appendToDiv(backtaskContentEl, '[' + pSiteName + '] ' + '<span class="mainwp-red">ERROR: Backup timed out - <a href="https://mainwp.com/help/docs/mainwp-introduction/resolving-system-requirement-issues/">Please check this help document for more information and possible fixes</a></span>'); | |
| 726 | + appendToDiv(backtaskContentEl, '[' + pSiteName + '] ' + '<span class="mainwp-red">ERROR: Backup timed out (request) - <a href="https://mainwp.com/help/docs/mainwp-introduction/resolving-system-requirement-issues/">Please check this help document for more information and possible fixes</a></span>'); // NOSONAR - noopener - open safe. | |
| 737 | 727 | } |
| 738 | 728 | }(interVal, siteName), dataType: 'json' |
| 739 | 729 | }); |
| 740 | 730 | }; |
| 741 | 731 | |
| 742 | -managebackups_backup_download_file = function (pSiteId, pSiteName, type, url, file, regexfile, size, subfolder, remote_destinations) { | |
| 743 | - var backtaskContentEl = mainwpPopup('#managebackups-task-status-box').getContentEl(); | |
| 732 | +let managebackups_backup_download_file = function (pSiteId, pSiteName, type, url, file, regexfile, size, subfolder, remote_destinations) { | |
| 733 | + let backtaskContentEl = mainwpPopup('#managebackups-task-status-box').getContentEl(); | |
| 744 | 734 | appendToDiv(backtaskContentEl, '[' + pSiteName + '] Downloading the file. <div id="managebackups-task-status-progress" siteId="' + pSiteId + '" class="ui green progress"><div class="bar"><div class="progress"></div></div></div>'); |
| 745 | 735 | jQuery('#managebackups-task-status-progress[siteId="' + pSiteId + '"]').progress({ value: 0, total: size }); |
| 746 | - var interVal = setInterval(function () { | |
| 747 | - var data = mainwp_secure_data({ | |
| 736 | + let interVal = setInterval(function () { | |
| 737 | + let data = mainwp_secure_data({ | |
| 748 | 738 | action: 'mainwp_backup_getfilesize', |
| 749 | 739 | local: file |
| 750 | 740 | }); |
| 751 | 741 | jQuery.post(ajaxurl, data, function (pSiteId) { |
| @@ -753,9 +743,9 @@ | ||
| 753 | 743 | if (response.error) |
| 754 | 744 | return; |
| 755 | 745 | |
| 756 | 746 | if (backupDownloadRunning) { |
| 757 | - var progressBar = jQuery('#managebackups-task-status-progress[siteId="' + pSiteId + '"]'); | |
| 747 | + let progressBar = jQuery('#managebackups-task-status-progress[siteId="' + pSiteId + '"]'); | |
| 758 | 748 | if (progressBar.progress('get value') < progressBar.progress('get total')) { |
| 759 | 749 | progressBar.progress('set progress', response.result); |
| 760 | 750 | } |
| 761 | 751 | } |
| @@ -762,9 +752,9 @@ | ||
| 762 | 752 | } |
| 763 | 753 | }(pSiteId), 'json'); |
| 764 | 754 | }, 500); |
| 765 | 755 | |
| 766 | - var data = mainwp_secure_data({ | |
| 756 | + let data = mainwp_secure_data({ | |
| 767 | 757 | action: 'mainwp_backup_download_file', |
| 768 | 758 | site_id: pSiteId, |
| 769 | 759 | type: type, |
| 770 | 760 | url: url, |
| @@ -777,9 +767,9 @@ | ||
| 777 | 767 | clearInterval(pInterVal); |
| 778 | 768 | |
| 779 | 769 | if (response.error) { |
| 780 | 770 | appendToDiv(backtaskContentEl, '[' + pSiteName + '] <span class="mainwp-red">ERROR: ' + getErrorMessage(response.error) + '</span>'); |
| 781 | - appendToDiv(backtaskContentEl, '[' + pSiteName + '] <span class="mainwp-red">' + __('Backup failed!') + '</span>'); | |
| 771 | + appendToDiv(backtaskContentEl, '[' + pSiteName + '] <span class="mainwp-red">' + MainWP.I18n.t('Backup failed!') + '</span>'); | |
| 782 | 772 | |
| 783 | 773 | manageBackupsError = true; |
| 784 | 774 | managebackups_run_next(); |
| 785 | 775 | return; |
| @@ -785,12 +775,12 @@ | ||
| 785 | 775 | return; |
| 786 | 776 | } |
| 787 | 777 | |
| 788 | 778 | jQuery('#managebackups-task-status-progress[siteId="' + pSiteId + '"]').progress('set progress', pSize); |
| 789 | - appendToDiv(backtaskContentEl, '[' + pSiteName + '] ' + __('Download from child site completed.')); | |
| 779 | + appendToDiv(backtaskContentEl, '[' + pSiteName + '] ' + MainWP.I18n.t('Download from child site completed.')); | |
| 790 | 780 | |
| 791 | 781 | |
| 792 | - var newData = mainwp_secure_data({ | |
| 782 | + let newData = mainwp_secure_data({ | |
| 793 | 783 | action: 'mainwp_backup_delete_file', |
| 794 | 784 | site_id: pSiteId, |
| 795 | 785 | file: pUrl |
| 796 | 786 | }); |
| @@ -801,20 +791,20 @@ | ||
| 801 | 791 | }(file, regexfile, subfolder, remote_destinations, size, type, interVal, pSiteName, pSiteId, url), 'json'); |
| 802 | 792 | }; |
| 803 | 793 | |
| 804 | 794 | managebackups_backup_upload_file = function (pSiteId, pSiteName, pFile, pRegexFile, pSubfolder, pRemoteDestinations, pType, pSize) { |
| 805 | - var backtaskContentEl = mainwpPopup('#managebackups-task-status-box').getContentEl(); | |
| 795 | + let backtaskContentEl = mainwpPopup('#managebackups-task-status-box').getContentEl(); | |
| 806 | 796 | if (pRemoteDestinations.length > 0) { |
| 807 | - var remote_destination = pRemoteDestinations[0]; | |
| 797 | + let remote_destination = pRemoteDestinations[0]; | |
| 808 | 798 | //upload.. |
| 809 | - var unique = Date.now(); | |
| 810 | - appendToDiv(backtaskContentEl, '[' + pSiteName + '] ' + __('Uploading to selected remote destination: %1 (%2)', remote_destination.title, remote_destination.type) + '<div id="managesite-upload-status-progress-' + unique + '" class="ui green progress"><div class="bar"><div class="progress"></div></div></div>'); | |
| 799 | + let unique = Date.now(); | |
| 800 | + appendToDiv(backtaskContentEl, '[' + pSiteName + '] ' + MainWP.I18n.t('Uploading to selected remote destination: %1 (%2)', remote_destination.title, remote_destination.type) + '<div id="managesite-upload-status-progress-' + unique + '" class="ui green progress"><div class="bar"><div class="progress"></div></div></div>'); | |
| 811 | 801 | |
| 812 | 802 | jQuery('#managesite-upload-status-progress-' + unique).progress({ value: 0, total: pSize }); |
| 813 | 803 | |
| 814 | - var fnc = function (pUnique) { | |
| 804 | + let fnc = function (pUnique) { | |
| 815 | 805 | return function (pFunction) { |
| 816 | - var data2 = mainwp_secure_data({ | |
| 806 | + let data2 = mainwp_secure_data({ | |
| 817 | 807 | action: 'mainwp_backup_upload_getprogress', |
| 818 | 808 | unique: pUnique |
| 819 | 809 | }, false); |
| 820 | 810 | |
| @@ -831,10 +821,10 @@ | ||
| 831 | 821 | return; |
| 832 | 822 | } |
| 833 | 823 | |
| 834 | 824 | if (backupUploadRunning[pUnique]) { |
| 835 | - var progressBar = jQuery('#managesite-upload-status-progress-' + pUnique); | |
| 836 | - if ((progressBar.length > 0) && (progressBar.progress('get value') < progressBar.progress('get total')) && (progressBar.progress('get value') < parseInt(response.result))) { | |
| 825 | + let progressBar = jQuery('#managesite-upload-status-progress-' + pUnique); | |
| 826 | + if ((progressBar.length > 0) && (progressBar.progress('get value') < progressBar.progress('get total')) && (progressBar.progress('get value') < Number.parseInt(response.result))) { | |
| 837 | 827 | progressBar.progress('set progress', response.result); |
| 838 | 828 | } |
| 839 | 829 | |
| 840 | 830 | setTimeout(function () { |
| @@ -862,9 +852,9 @@ | ||
| 862 | 852 | }, 1000); |
| 863 | 853 | |
| 864 | 854 | backupUploadRunning[unique] = true; |
| 865 | 855 | |
| 866 | - var data = mainwp_secure_data({ | |
| 856 | + let data = mainwp_secure_data({ | |
| 867 | 857 | action: 'mainwp_backup_upload_file', |
| 868 | 858 | file: pFile, |
| 869 | 859 | siteId: pSiteId, |
| 870 | 860 | regexfile: pRegexFile, |
| @@ -885,17 +875,17 @@ | ||
| 885 | 875 | managebackups_backup_upload_file_retry_fail(pData, pSiteId, pSiteName, pFile, pRegexFile, pSubfolder, pNewRemoteDestinations, pType, pSize, pUnique, pRemoteDestId, response.error ? response.error : ''); |
| 886 | 876 | } else { |
| 887 | 877 | backupUploadRunning[pUnique] = false; |
| 888 | 878 | |
| 889 | - var progressBar = jQuery('#managesite-upload-status-progress-' + pUnique); | |
| 879 | + let progressBar = jQuery('#managesite-upload-status-progress-' + pUnique); | |
| 890 | 880 | progressBar.progress('set progress', pSize); |
| 891 | 881 | |
| 892 | - var obj = response.result; | |
| 882 | + let obj = response.result; | |
| 893 | 883 | if (obj.error) { |
| 894 | 884 | manageBackupsError = true; |
| 895 | - appendToDiv(backtaskContentEl, '<span class="mainwp-red">[' + pSiteName + '] ' + __('Upload to %1 (%2) failed:', obj.title, obj.type) + ' ' + obj.error + '</span>'); | |
| 885 | + appendToDiv(backtaskContentEl, '<span class="mainwp-red">[' + pSiteName + '] ' + MainWP.I18n.t('Upload to %1 (%2) failed:', obj.title, obj.type) + ' ' + obj.error + '</span>'); | |
| 896 | 886 | } else { |
| 897 | - appendToDiv(backtaskContentEl, '[' + pSiteName + '] ' + __('Upload to %1 (%2) successful', obj.title, obj.type)); | |
| 887 | + appendToDiv(backtaskContentEl, '[' + pSiteName + '] ' + MainWP.I18n.t('Upload to %1 (%2) successful', obj.title, obj.type)); | |
| 898 | 888 | } |
| 899 | 889 | |
| 900 | 890 | managebackups_backup_upload_file(pSiteId, pSiteName, pFile, pRegexFile, pSubfolder, pNewRemoteDestinations, pType, pSize); |
| 901 | 891 | } |
| @@ -908,17 +898,17 @@ | ||
| 908 | 898 | }(pRemoteDestinations, pFile, pRegexFile, pSubfolder, pType, pSiteName, pSiteId, pSize, data, unique, remote_destination.id), |
| 909 | 899 | dataType: 'json' |
| 910 | 900 | }); |
| 911 | 901 | } else { |
| 912 | - appendToDiv(backtaskContentEl, '[' + pSiteName + '] ' + __('Backup completed.')); | |
| 902 | + appendToDiv(backtaskContentEl, '[' + pSiteName + '] ' + MainWP.I18n.t('Backup completed.')); | |
| 913 | 903 | managebackups_run_next(); |
| 914 | 904 | } |
| 915 | 905 | }; |
| 916 | 906 | |
| 917 | 907 | managebackups_backup_upload_file_retry_fail = function (pData, pSiteId, pSiteName, pFile, pRegexFile, pSubfolder, pNewRemoteDestinations, pType, pSize, pUnique, pRemoteDestId, responseError) { |
| 918 | - var backtaskContentEl = mainwpPopup('#managebackups-task-status-box').getContentEl(); | |
| 908 | + let backtaskContentEl = mainwpPopup('#managebackups-task-status-box').getContentEl(); | |
| 919 | 909 | //we've got the pid file!!!! |
| 920 | - var data = mainwp_secure_data({ | |
| 910 | + let data = mainwp_secure_data({ | |
| 921 | 911 | action: 'mainwp_backup_upload_checkstatus', |
| 922 | 912 | unique: pUnique, |
| 923 | 913 | remote_destination: pRemoteDestId |
| 924 | 914 | }); |
| @@ -930,12 +920,12 @@ | ||
| 930 | 920 | success: function (response) { |
| 931 | 921 | if (response.status == 'done') { |
| 932 | 922 | backupUploadRunning[pUnique] = false; |
| 933 | 923 | |
| 934 | - var progressBar = jQuery('#managesite-upload-status-progress-' + pUnique); | |
| 924 | + let progressBar = jQuery('#managesite-upload-status-progress-' + pUnique); | |
| 935 | 925 | progressBar.progress('set progress', pSize); |
| 936 | 926 | |
| 937 | - appendToDiv(backtaskContentEl, '[' + pSiteName + '] ' + __('Upload to %1 (%2) successful', response.info.title, response.info.type)); | |
| 927 | + appendToDiv(backtaskContentEl, '[' + pSiteName + '] ' + MainWP.I18n.t('Upload to %1 (%2) successful', response.info.title, response.info.type)); | |
| 938 | 928 | |
| 939 | 929 | managebackups_backup_upload_file(pSiteId, pSiteName, pFile, pRegexFile, pSubfolder, pNewRemoteDestinations, pType, pSize); |
| 940 | 930 | } else if (response.status == 'busy') { |
| 941 | 931 | //Try again in 10seconds |
| @@ -951,9 +941,9 @@ | ||
| 951 | 941 | |
| 952 | 942 | if (backupContinueRetriesUnique[pUnique] > 10) { |
| 953 | 943 | if (responseError != undefined) { |
| 954 | 944 | manageBackupsError = true; |
| 955 | - appendToDiv(backtaskContentEl, '<span class="mainwp-red">[' + pSiteName + '] ' + __('Upload to %1 (%2) failed:', response.info.title, response.info.type) + ' ' + responseError + '</span>'); | |
| 945 | + appendToDiv(backtaskContentEl, '<span class="mainwp-red">[' + pSiteName + '] ' + MainWP.I18n.t('Upload to %1 (%2) failed:', response.info.title, response.info.type) + ' ' + responseError + '</span>'); | |
| 956 | 946 | } else { |
| 957 | 947 | appendToDiv(backtaskContentEl, ' <span class="mainwp-red">[' + pSiteName + '] ERROR: Upload timed out - <a href="http://docs.mainwp.com/backup-failed-php-ini-settings/">Please check this help document for more information and possible fixes</a></span>'); |
| 958 | 948 | } |
| 959 | 949 | |
| @@ -973,17 +963,17 @@ | ||
| 973 | 963 | managebackups_backup_upload_file_retry_fail(pData, pSiteId, pSiteName, pFile, pRegexFile, pSubfolder, pNewRemoteDestinations, pType, pSize, pUnique, pRemoteDestId, response.error ? response.error : ''); |
| 974 | 964 | } else { |
| 975 | 965 | backupUploadRunning[pUnique] = false; |
| 976 | 966 | |
| 977 | - var progressBar = jQuery('#managesite-upload-status-progress-' + pUnique); | |
| 967 | + let progressBar = jQuery('#managesite-upload-status-progress-' + pUnique); | |
| 978 | 968 | progressBar.progress('set progress', pSize); |
| 979 | 969 | |
| 980 | - var obj = response.result; | |
| 970 | + let obj = response.result; | |
| 981 | 971 | if (obj.error) { |
| 982 | 972 | manageBackupsError = true; |
| 983 | - appendToDiv(backtaskContentEl, '<span class="mainwp-red">[' + pSiteName + '] ' + __('Upload to %1 (%2) failed:', obj.title, obj.type) + ' ' + obj.error + '</span>'); | |
| 973 | + appendToDiv(backtaskContentEl, '<span class="mainwp-red">[' + pSiteName + '] ' + MainWP.I18n.t('Upload to %1 (%2) failed:', obj.title, obj.type) + ' ' + obj.error + '</span>'); | |
| 984 | 974 | } else { |
| 985 | - appendToDiv(backtaskContentEl, '[' + pSiteName + '] ' + __('Upload to %1 (%2) successful', obj.title, obj.type)); | |
| 975 | + appendToDiv(backtaskContentEl, '[' + pSiteName + '] ' + MainWP.I18n.t('Upload to %1 (%2) successful', obj.title, obj.type)); | |
| 986 | 976 | } |
| 987 | 977 | |
| 988 | 978 | managebackups_backup_upload_file(pSiteId, pSiteName, pFile, pRegexFile, pSubfolder, pNewRemoteDestinations, pType, pSize); |
| 989 | 979 | } |
| @@ -1023,28 +1013,27 @@ | ||
| 1023 | 1013 | |
| 1024 | 1014 | mainwp_managebackups_update = function () { |
| 1025 | 1015 | managebackups_init(); |
| 1026 | 1016 | |
| 1027 | - var errors = []; | |
| 1017 | + let errors = []; | |
| 1028 | 1018 | if (jQuery('#mainwp_managebackups_add_name').val() == '') { |
| 1029 | - errors.push(__('Please enter a valid name for your backup task')); | |
| 1019 | + errors.push(MainWP.I18n.t('Please enter a valid name for your backup task')); | |
| 1030 | 1020 | } |
| 1031 | - | |
| 1032 | - if (jQuery('#select_by').val() == 'site') { | |
| 1033 | - var selected_sites = []; | |
| 1021 | + let selected_groups = []; | |
| 1022 | + let selected_sites = []; | |
| 1023 | + if (jQuery('input[name="select_by"]').val() == 'site') { | |
| 1034 | 1024 | jQuery("input[name='selected_sites[]']:checked").each(function () { |
| 1035 | 1025 | selected_sites.push(jQuery(this).val()); |
| 1036 | 1026 | }); |
| 1037 | 1027 | if (selected_sites.length == 0) { |
| 1038 | - errors.push(__('Please select websites or groups to add a backup task.')); | |
| 1028 | + errors.push(MainWP.I18n.t('Please select websites or groups to add a backup task.')); | |
| 1039 | 1029 | } |
| 1040 | 1030 | } else { |
| 1041 | - var selected_groups = []; | |
| 1042 | 1031 | jQuery("input[name='selected_groups[]']:checked").each(function () { |
| 1043 | 1032 | selected_groups.push(jQuery(this).val()); |
| 1044 | 1033 | }); |
| 1045 | 1034 | if (selected_groups.length == 0) { |
| 1046 | - errors.push(__('Please select websites or groups to add a backup task.')); | |
| 1035 | + errors.push(MainWP.I18n.t('Please select websites or groups to add a backup task.')); | |
| 1047 | 1036 | } |
| 1048 | 1037 | } |
| 1049 | 1038 | |
| 1050 | 1039 | if (errors.length > 0) { |
| @@ -1049,16 +1038,16 @@ | ||
| 1049 | 1038 | |
| 1050 | 1039 | if (errors.length > 0) { |
| 1051 | 1040 | feedback('mainwp-message-zone', errors.join('<br />'), 'red'); |
| 1052 | 1041 | } else { |
| 1053 | - feedback('mainwp-message-zone', __('Adding the task...'), 'green'); | |
| 1042 | + feedback('mainwp-message-zone', MainWP.I18n.t('Adding the task...'), 'green'); | |
| 1054 | 1043 | |
| 1055 | 1044 | jQuery('#mainwp_managebackups_update').attr('disabled', 'true'); //disable button to add.. |
| 1056 | 1045 | |
| 1057 | - //var loadFilesBeforeZip = jQuery( '[name="mainwp_options_loadFilesBeforeZip"]:checked' ).val(); | |
| 1058 | - var name = jQuery('#mainwp_managebackups_add_name').val(); | |
| 1046 | + //let loadFilesBeforeZip = jQuery( '[name="mainwp_options_loadFilesBeforeZip"]:checked' ).val(); | |
| 1047 | + let name = jQuery('#mainwp_managebackups_add_name').val(); | |
| 1059 | 1048 | name = name.replace(/"/g, '"'); |
| 1060 | - var data = mainwp_secure_data({ | |
| 1049 | + let data = mainwp_secure_data({ | |
| 1061 | 1050 | action: 'mainwp_updatebackup', |
| 1062 | 1051 | id: jQuery('#mainwp_managebackups_edit_id').val(), |
| 1063 | 1052 | name: name, |
| 1064 | 1053 | schedule: jQuery('#mainwp-backup-task-schedule').val(), |
| @@ -1093,45 +1082,43 @@ | ||
| 1093 | 1082 | }; |
| 1094 | 1083 | mainwp_managebackups_add = function () { |
| 1095 | 1084 | managebackups_init(); |
| 1096 | 1085 | |
| 1097 | - var errors = []; | |
| 1086 | + let errors = []; | |
| 1098 | 1087 | if (jQuery('#mainwp_managebackups_add_name').val() == '') { |
| 1099 | - errors.push(__('Please enter a valid name for your backup task')); | |
| 1088 | + errors.push(MainWP.I18n.t('Please enter a valid name for your backup task')); | |
| 1100 | 1089 | } |
| 1101 | - | |
| 1102 | - if (jQuery('#select_by').val() == 'site') { | |
| 1103 | - var selected_sites = []; | |
| 1090 | + let selected_sites = []; | |
| 1091 | + let selected_groups = []; | |
| 1092 | + if (jQuery('input[name="select_by"]').val() == 'site') { | |
| 1104 | 1093 | jQuery("input[name='selected_sites[]']:checked").each(function () { |
| 1105 | 1094 | selected_sites.push(jQuery(this).val()); |
| 1106 | 1095 | }); |
| 1107 | 1096 | if (selected_sites.length == 0) { |
| 1108 | - errors.push(__('Please select websites or groups.')); | |
| 1097 | + errors.push(MainWP.I18n.t('Please select websites or groups.')); | |
| 1109 | 1098 | } |
| 1110 | 1099 | } else { |
| 1111 | - var selected_groups = []; | |
| 1112 | 1100 | jQuery("input[name='selected_groups[]']:checked").each(function () { |
| 1113 | 1101 | selected_groups.push(jQuery(this).val()); |
| 1114 | 1102 | }); |
| 1115 | 1103 | if (selected_groups.length == 0) { |
| 1116 | - errors.push(__('Please select websites or groups.')); | |
| 1104 | + errors.push(MainWP.I18n.t('Please select websites or groups.')); | |
| 1117 | 1105 | } |
| 1118 | 1106 | } |
| 1119 | 1107 | |
| 1120 | - console.log(errors); | |
| 1121 | 1108 | |
| 1122 | 1109 | if (errors.length > 0) { |
| 1123 | 1110 | feedback('mainwp-message-zone', errors.join('<br />'), 'red'); |
| 1124 | 1111 | } else { |
| 1125 | - feedback('mainwp-message-zone', __('Adding the task...'), 'green'); | |
| 1112 | + feedback('mainwp-message-zone', MainWP.I18n.t('Adding the task...'), 'green'); | |
| 1126 | 1113 | |
| 1127 | 1114 | jQuery('#mainwp_managebackups_add').attr('disabled', 'true'); //disable button to add.. |
| 1128 | 1115 | |
| 1129 | 1116 | jQuery('#mainwp_managesites_add').attr('disabled', 'true'); //Disable add button |
| 1130 | - var loadFilesBeforeZip = jQuery('[name="mainwp_options_loadFilesBeforeZip"]:checked').val(); | |
| 1131 | - var name = jQuery('#mainwp_managebackups_add_name').val(); | |
| 1117 | + let loadFilesBeforeZip = jQuery('[name="mainwp_options_loadFilesBeforeZip"]:checked').val(); | |
| 1118 | + let name = jQuery('#mainwp_managebackups_add_name').val(); | |
| 1132 | 1119 | name = name.replace(/"/g, '"'); |
| 1133 | - var data = mainwp_secure_data({ | |
| 1120 | + let data = mainwp_secure_data({ | |
| 1134 | 1121 | action: 'mainwp_addbackup', |
| 1135 | 1122 | name: name, |
| 1136 | 1123 | schedule: jQuery('#mainwp-backup-task-schedule').val(), |
| 1137 | 1124 | type: jQuery('#mainwp-backup-type').val(), |
| @@ -1163,15 +1150,15 @@ | ||
| 1163 | 1150 | }, 'json'); |
| 1164 | 1151 | } |
| 1165 | 1152 | }; |
| 1166 | 1153 | managebackups_remove = function (element) { |
| 1167 | - var id = jQuery(element).attr('task_id'); | |
| 1154 | + let id = jQuery(element).attr('task_id'); | |
| 1168 | 1155 | managebackups_init(); |
| 1169 | 1156 | |
| 1170 | - var msg = __('Are you sure you want to delete this backup task?'); | |
| 1157 | + let msg = MainWP.I18n.t('Are you sure you want to delete this backup task?'); | |
| 1171 | 1158 | mainwp_confirm(msg, function () { |
| 1172 | - jQuery('#task-status-' + id).html(__('Removing the task...')); | |
| 1173 | - var data = mainwp_secure_data({ | |
| 1159 | + jQuery('#task-status-' + id).html(MainWP.I18n.t('Removing the task...')); | |
| 1160 | + let data = mainwp_secure_data({ | |
| 1174 | 1161 | action: 'mainwp_removebackup', |
| 1175 | 1162 | id: id |
| 1176 | 1163 | }); |
| 1177 | 1164 | jQuery.post(ajaxurl, data, function (pElement) { |
| @@ -1176,16 +1163,16 @@ | ||
| 1176 | 1163 | }); |
| 1177 | 1164 | jQuery.post(ajaxurl, data, function (pElement) { |
| 1178 | 1165 | return function (response) { |
| 1179 | 1166 | managebackups_init(); |
| 1180 | - var result = ''; | |
| 1181 | - var error = ''; | |
| 1167 | + let result = ''; | |
| 1168 | + let error = ''; | |
| 1182 | 1169 | if (response.error != undefined) { |
| 1183 | 1170 | error = response.error; |
| 1184 | 1171 | } else if (response.result == 'SUCCESS') { |
| 1185 | - result = __('The task has been removed.'); | |
| 1172 | + result = MainWP.I18n.t('The task has been removed.'); | |
| 1186 | 1173 | } else { |
| 1187 | - error = __('An undefined error occured.'); | |
| 1174 | + error = MainWP.I18n.t('An undefined error occurred.'); | |
| 1188 | 1175 | } |
| 1189 | 1176 | |
| 1190 | 1177 | if (error != '') { |
| 1191 | 1178 | setHtml('#mainwp_managebackups', error); |
| @@ -1202,13 +1189,13 @@ | ||
| 1202 | 1189 | }); |
| 1203 | 1190 | return false; |
| 1204 | 1191 | }; |
| 1205 | 1192 | managebackups_resume = function (element) { |
| 1206 | - var id = jQuery(element).attr('task_id'); | |
| 1193 | + let id = jQuery(element).attr('task_id'); | |
| 1207 | 1194 | managebackups_init(); |
| 1208 | 1195 | |
| 1209 | - jQuery('#task-status-' + id).html(__('Resuming the task...')); | |
| 1210 | - var data = mainwp_secure_data({ | |
| 1196 | + jQuery('#task-status-' + id).html(MainWP.I18n.t('Resuming the task...')); | |
| 1197 | + let data = mainwp_secure_data({ | |
| 1211 | 1198 | action: 'mainwp_resumebackup', |
| 1212 | 1199 | id: id |
| 1213 | 1200 | }); |
| 1214 | 1201 | jQuery.post(ajaxurl, data, function (pElement, pId) { |
| @@ -1213,16 +1200,16 @@ | ||
| 1213 | 1200 | }); |
| 1214 | 1201 | jQuery.post(ajaxurl, data, function (pElement, pId) { |
| 1215 | 1202 | return function (response) { |
| 1216 | 1203 | managebackups_init(); |
| 1217 | - var result = ''; | |
| 1218 | - var error = ''; | |
| 1204 | + let result = ''; | |
| 1205 | + let error = ''; | |
| 1219 | 1206 | if (response.error != undefined) { |
| 1220 | 1207 | error = response.error; |
| 1221 | 1208 | } else if (response.result == 'SUCCESS') { |
| 1222 | - result = __('The task has been resumed.'); | |
| 1209 | + result = MainWP.I18n.t('The task has been resumed.'); | |
| 1223 | 1210 | } else { |
| 1224 | - error = __('An undefined error occured.'); | |
| 1211 | + error = MainWP.I18n.t('An undefined error occurred.'); | |
| 1225 | 1212 | } |
| 1226 | 1213 | |
| 1227 | 1214 | if (error != '') { |
| 1228 | 1215 | setHtml('#mainwp_managebackups', error); |
| @@ -1232,9 +1219,9 @@ | ||
| 1232 | 1219 | } |
| 1233 | 1220 | jQuery('#task-status-' + id).html(''); |
| 1234 | 1221 | |
| 1235 | 1222 | if (error == '') { |
| 1236 | - jQuery(pElement).after('<a href="#" task_id="' + pId + '" onClick="return managebackups_pause(this)">' + __('Pause') + '</a>'); | |
| 1223 | + jQuery(pElement).after('<a href="#" task_id="' + pId + '" onClick="return managebackups_pause(this)">' + MainWP.I18n.t('Pause') + '</a>'); | |
| 1237 | 1224 | jQuery(pElement).remove(); |
| 1238 | 1225 | } |
| 1239 | 1226 | } |
| 1240 | 1227 | }(element, id), 'json'); |
| @@ -1241,13 +1228,13 @@ | ||
| 1241 | 1228 | |
| 1242 | 1229 | return false; |
| 1243 | 1230 | }; |
| 1244 | 1231 | managebackups_pause = function (element) { |
| 1245 | - var id = jQuery(element).attr('task_id'); | |
| 1232 | + let id = jQuery(element).attr('task_id'); | |
| 1246 | 1233 | managebackups_init(); |
| 1247 | 1234 | |
| 1248 | - jQuery('#task-status-' + id).html(__('Pausing the task...')); | |
| 1249 | - var data = mainwp_secure_data({ | |
| 1235 | + jQuery('#task-status-' + id).html(MainWP.I18n.t('Pausing the task...')); | |
| 1236 | + let data = mainwp_secure_data({ | |
| 1250 | 1237 | action: 'mainwp_pausebackup', |
| 1251 | 1238 | id: id |
| 1252 | 1239 | }); |
| 1253 | 1240 | jQuery.post(ajaxurl, data, function (pElement, pId) { |
| @@ -1252,16 +1239,16 @@ | ||
| 1252 | 1239 | }); |
| 1253 | 1240 | jQuery.post(ajaxurl, data, function (pElement, pId) { |
| 1254 | 1241 | return function (response) { |
| 1255 | 1242 | managebackups_init(); |
| 1256 | - var result = ''; | |
| 1257 | - var error = ''; | |
| 1243 | + let result = ''; | |
| 1244 | + let error = ''; | |
| 1258 | 1245 | if (response.error != undefined) { |
| 1259 | 1246 | error = response.error; |
| 1260 | 1247 | } else if (response.result == 'SUCCESS') { |
| 1261 | - result = __('The task has been paused.'); | |
| 1248 | + result = MainWP.I18n.t('The task has been paused.'); | |
| 1262 | 1249 | } else { |
| 1263 | - error = __('An undefined error occured.'); | |
| 1250 | + error = MainWP.I18n.t('An undefined error occurred.'); | |
| 1264 | 1251 | } |
| 1265 | 1252 | |
| 1266 | 1253 | if (error != '') { |
| 1267 | 1254 | setHtml('#mainwp_managebackups', error); |
| @@ -1270,9 +1257,9 @@ | ||
| 1270 | 1257 | setHtml('#mainwp_managebackups_add_message', result); |
| 1271 | 1258 | } |
| 1272 | 1259 | jQuery('#task-status-' + id).html(''); |
| 1273 | 1260 | if (error == '') { |
| 1274 | - jQuery(pElement).after('<a href="#" task_id="' + pId + '" onClick="return managebackups_resume(this)">' + __('Resume') + '</a>'); | |
| 1261 | + jQuery(pElement).after('<a href="#" task_id="' + pId + '" onClick="return managebackups_resume(this)">' + MainWP.I18n.t('Resume') + '</a>'); | |
| 1275 | 1262 | jQuery(pElement).remove(); |
| 1276 | 1263 | } |
| 1277 | 1264 | } |
| 1278 | 1265 | }(element, id), 'json'); |
| @@ -1283,18 +1270,17 @@ | ||
| 1283 | 1270 | |
| 1284 | 1271 | jQuery(document).on('click', '#updatesoverview-backup-ignore', function () { |
| 1285 | 1272 | if (updatesoverviewContinueAfterBackup != undefined) { |
| 1286 | 1273 | mainwpPopup('#updatesoverview-backup-box').close(); |
| 1287 | - console.log(updatesoverviewContinueAfterBackup); | |
| 1288 | 1274 | updatesoverviewContinueAfterBackup(); |
| 1289 | 1275 | updatesoverviewContinueAfterBackup = undefined; |
| 1290 | 1276 | } |
| 1291 | 1277 | }); |
| 1292 | 1278 | |
| 1293 | -var updatesoverviewShowBusyFunction; | |
| 1294 | -var updatesoverviewShowBusyTimeout; | |
| 1295 | -mainwp_updatesoverview_checkBackups = function (sitesToUpdate, siteNamesx) { | |
| 1296 | - if (mainwpParams['disable_checkBackupBeforeUpgrade'] == true) { | |
| 1279 | +let updatesoverviewShowBusyFunction; | |
| 1280 | +let updatesoverviewShowBusyTimeout; | |
| 1281 | +mainwp_updatesoverview_checkBackups = function (sitesToUpdate, siteNames) { | |
| 1282 | + if (mainwpParams['disable_checkBackupBeforeUpgrade']) { | |
| 1297 | 1283 | if (updatesoverviewContinueAfterBackup != undefined) { |
| 1298 | 1284 | updatesoverviewContinueAfterBackup(); |
| 1299 | 1285 | } |
| 1300 | 1286 | return false; |
| @@ -1301,15 +1287,15 @@ | ||
| 1301 | 1287 | } |
| 1302 | 1288 | |
| 1303 | 1289 | updatesoverviewShowBusyFunction = function () { |
| 1304 | 1290 | |
| 1305 | - var output = __('Checking if a backup is required for the selected updates...'); | |
| 1291 | + let output = MainWP.I18n.t('Checking if a backup is required for the selected updates...'); | |
| 1306 | 1292 | mainwpPopup('#updatesoverview-backup-box').getContentEl().html(output); |
| 1307 | 1293 | jQuery('#updatesoverview-backup-all').hide(); |
| 1308 | 1294 | jQuery('#updatesoverview-backup-ignore').hide(); |
| 1309 | 1295 | |
| 1310 | 1296 | mainwpPopup('#updatesoverview-backup-box').init({ |
| 1311 | - title: __("Checking backup settings..."), callback: function () { | |
| 1297 | + title: MainWP.I18n.t("Checking backup settings..."), callback: function () { | |
| 1312 | 1298 | window.location.href = location.href |
| 1313 | 1299 | } |
| 1314 | 1300 | }); |
| 1315 | 1301 | }; |
| @@ -1316,9 +1302,9 @@ | ||
| 1316 | 1302 | |
| 1317 | 1303 | updatesoverviewShowBusyTimeout = setTimeout(updatesoverviewShowBusyFunction, 300); |
| 1318 | 1304 | |
| 1319 | 1305 | //Step 2: Check if backups are ok. |
| 1320 | - var data = mainwp_secure_data({ | |
| 1306 | + let data = mainwp_secure_data({ | |
| 1321 | 1307 | action: 'mainwp_checkbackups', |
| 1322 | 1308 | sites: sitesToUpdate |
| 1323 | 1309 | }); |
| 1324 | 1310 | |
| @@ -1331,14 +1317,14 @@ | ||
| 1331 | 1317 | clearTimeout(updatesoverviewShowBusyTimeout); |
| 1332 | 1318 | |
| 1333 | 1319 | mainwpPopup('#updatesoverview-backup-box').close(); |
| 1334 | 1320 | |
| 1335 | - var siteFeedback = undefined; | |
| 1321 | + let siteFeedback = undefined; | |
| 1336 | 1322 | |
| 1337 | 1323 | if (response['result'] && response['result']['sites'] != undefined) { |
| 1338 | 1324 | siteFeedback = []; |
| 1339 | - for (var currSiteId in response['result']['sites']) { | |
| 1340 | - if (response['result']['sites'][currSiteId] == false) { | |
| 1325 | + for (let currSiteId in response['result']['sites']) { | |
| 1326 | + if (!response['result']['sites'][currSiteId]) { | |
| 1341 | 1327 | siteFeedback.push(currSiteId); |
| 1342 | 1328 | } |
| 1343 | 1329 | } |
| 1344 | 1330 | if (siteFeedback.length == 0) |
| @@ -1345,9 +1331,9 @@ | ||
| 1345 | 1331 | siteFeedback = undefined; |
| 1346 | 1332 | } |
| 1347 | 1333 | |
| 1348 | 1334 | if (siteFeedback != undefined) { |
| 1349 | - var backupPrimary = ''; | |
| 1335 | + let backupPrimary = ''; | |
| 1350 | 1336 | if (response['result']['primary_backup'] && response['result']['primary_backup'] != undefined) |
| 1351 | 1337 | backupPrimary = response['result']['primary_backup']; |
| 1352 | 1338 | |
| 1353 | 1339 | if (backupPrimary == '') { |
| @@ -1353,22 +1339,22 @@ | ||
| 1353 | 1339 | if (backupPrimary == '') { |
| 1354 | 1340 | jQuery('#updatesoverview-backup-all').show(); |
| 1355 | 1341 | jQuery('#updatesoverview-backup-ignore').show(); |
| 1356 | 1342 | } else { |
| 1357 | - var backupLink = mainwp_get_primaryBackup_link(backupPrimary); | |
| 1343 | + let backupLink = mainwp_get_primaryBackup_link(backupPrimary); | |
| 1358 | 1344 | jQuery('#updatesoverview-backup-now').attr('href', backupLink).show(); |
| 1359 | - jQuery('#updatesoverview-backup-ignore').val(__('Proceed with Updates')).show(); | |
| 1345 | + jQuery('#updatesoverview-backup-ignore').val(MainWP.I18n.t('Proceed with Updates')).show(); | |
| 1360 | 1346 | } |
| 1361 | 1347 | |
| 1362 | - var output = '<span class="mainwp-red">' + __('A full backup has not been taken in the last days for the following sites:') + '</span><br /><br />'; | |
| 1348 | + let output = '<span class="mainwp-red">' + MainWP.I18n.t('A full backup has not been taken in the last days for the following sites:') + '</span><br /><br />'; | |
| 1363 | 1349 | |
| 1364 | 1350 | if (backupPrimary == '') { // default backup feature |
| 1365 | - for (var j = 0; j < siteFeedback.length; j++) { | |
| 1366 | - output += '<span class="updatesoverview-backup-site" siteid="' + siteFeedback[j] + '">' + decodeURIComponent(pSiteNames[siteFeedback[j]]) + '</span><br />'; | |
| 1351 | + for (let id of siteFeedback) { | |
| 1352 | + output += '<span class="updatesoverview-backup-site" siteid="' + id + '">' + decodeURIComponent(pSiteNames[id]) + '</span><br />'; | |
| 1367 | 1353 | } |
| 1368 | 1354 | } else { |
| 1369 | - for (var j = 0; j < siteFeedback.length; j++) { | |
| 1370 | - output += '<span>' + decodeURIComponent(pSiteNames[siteFeedback[j]]) + '</span><br />'; | |
| 1355 | + for (let id of siteFeedback) { | |
| 1356 | + output += '<span>' + decodeURIComponent(pSiteNames[id]) + '</span><br />'; | |
| 1371 | 1357 | } |
| 1372 | 1358 | } |
| 1373 | 1359 | |
| 1374 | 1360 | mainwpPopup('#updatesoverview-backup-box').getContentEl().html(output); |
| @@ -1373,9 +1359,9 @@ | ||
| 1373 | 1359 | |
| 1374 | 1360 | mainwpPopup('#updatesoverview-backup-box').getContentEl().html(output); |
| 1375 | 1361 | |
| 1376 | 1362 | mainwpPopup('#updatesoverview-backup-box').init({ |
| 1377 | - title: __("Full backup required!"), callback: function () { | |
| 1363 | + title: MainWP.I18n.t("Full backup required!"), callback: function () { | |
| 1378 | 1364 | if (updatesoverviewContinueAfterBackup != undefined) { |
| 1379 | 1365 | updatesoverviewContinueAfterBackup = undefined; |
| 1380 | 1366 | } |
| 1381 | 1367 | window.location.href = location.href |
| @@ -1414,58 +1400,58 @@ | ||
| 1414 | 1400 | }); |
| 1415 | 1401 | jQuery(document).on('click', '#updatesoverview-backup-all', function () { |
| 1416 | 1402 | |
| 1417 | 1403 | // change action buttons |
| 1418 | - mainwpPopup('#updatesoverview-backup-box').setActionButtons('<input id="updatesoverview-backupnow-close" type="button" name="Ignore" value="' + __('Cancel') + '" class="button"/>'); | |
| 1404 | + mainwpPopup('#updatesoverview-backup-box').setActionButtons('<input id="updatesoverview-backupnow-close" type="button" name="Ignore" value="' + MainWP.I18n.t('Cancel') + '" class="button"/>'); | |
| 1419 | 1405 | mainwpPopup('#updatesoverview-backup-box').init({ |
| 1420 | - title: __("Full backup"), callback: function () { | |
| 1406 | + title: MainWP.I18n.t("Full backup"), callback: function () { | |
| 1421 | 1407 | updatesoverviewContinueAfterBackup = undefined; |
| 1422 | 1408 | window.location.href = location.href |
| 1423 | 1409 | } |
| 1424 | 1410 | }); |
| 1425 | 1411 | |
| 1426 | - var sitesToBackup = jQuery('.updatesoverview-backup-site'); | |
| 1412 | + let sitesToBackup = jQuery('.updatesoverview-backup-site'); | |
| 1427 | 1413 | updatesoverviewBackupSites = []; |
| 1428 | - for (var i = 0; i < sitesToBackup.length; i++) { | |
| 1429 | - var currentSite = []; | |
| 1430 | - currentSite['id'] = jQuery(sitesToBackup[i]).attr('siteid'); | |
| 1431 | - currentSite['name'] = jQuery(sitesToBackup[i]).text(); | |
| 1414 | + for (let id of sitesToBackup) { | |
| 1415 | + let currentSite = []; | |
| 1416 | + currentSite['id'] = jQuery(id).attr('siteid'); | |
| 1417 | + currentSite['name'] = jQuery(id).text(); | |
| 1432 | 1418 | updatesoverviewBackupSites.push(currentSite); |
| 1433 | 1419 | } |
| 1434 | 1420 | updatesoverview_backup_run(); |
| 1435 | 1421 | }); |
| 1436 | 1422 | |
| 1437 | -var updatesoverviewBackupSites; | |
| 1438 | -var updatesoverviewBackupError; | |
| 1439 | -var updatesoverviewBackupDownloadRunning; | |
| 1423 | +let updatesoverviewBackupSites; | |
| 1424 | +let updatesoverviewBackupError; | |
| 1425 | +let updatesoverviewBackupDownloadRunning; | |
| 1440 | 1426 | |
| 1441 | 1427 | updatesoverview_backup_run = function () { |
| 1442 | - mainwpPopup('#updatesoverview-backup-box').getContentEl().html(dateToHMS(new Date()) + ' ' + __('Starting required backup(s)...')); | |
| 1443 | - jQuery('#updatesoverview-backupnow-close').prop('value', __('Cancel')); | |
| 1428 | + mainwpPopup('#updatesoverview-backup-box').getContentEl().html(dateToHMS(new Date()) + ' ' + MainWP.I18n.t('Starting required backup(s)...')); | |
| 1429 | + jQuery('#updatesoverview-backupnow-close').prop('value', MainWP.I18n.t('Cancel')); | |
| 1444 | 1430 | jQuery('#updatesoverview-backupnow-close').prop('cancel', '1'); |
| 1445 | 1431 | updatesoverview_backup_run_next(); |
| 1446 | 1432 | }; |
| 1447 | 1433 | |
| 1448 | 1434 | updatesoverview_backup_run_next = function () { |
| 1449 | - var backupContentEl = mainwpPopup('#updatesoverview-backup-box').getContentEl(); | |
| 1435 | + let backupContentEl = mainwpPopup('#updatesoverview-backup-box').getContentEl(); | |
| 1450 | 1436 | if (updatesoverviewBackupSites.length == 0) { |
| 1451 | - appendToDiv(backupContentEl, __('Required backup(s) completed') + (updatesoverviewBackupError ? ' <span class="mainwp-red">' + __('with errors') + '</span>' : '') + '.'); | |
| 1437 | + appendToDiv(backupContentEl, MainWP.I18n.t('Required backup(s) completed') + (updatesoverviewBackupError ? ' <span class="mainwp-red">' + MainWP.I18n.t('with errors') + '</span>' : '') + '.'); | |
| 1452 | 1438 | |
| 1453 | 1439 | jQuery('#updatesoverview-backupnow-close').prop('cancel', '0'); |
| 1454 | 1440 | if (updatesoverviewBackupError) { |
| 1455 | - jQuery('#updatesoverview-backupnow-close').prop('value', __('Continue update anyway')); | |
| 1441 | + jQuery('#updatesoverview-backupnow-close').prop('value', MainWP.I18n.t('Continue update anyway')); | |
| 1456 | 1442 | } else { |
| 1457 | - jQuery('#updatesoverview-backupnow-close').prop('value', __('Continue update')); | |
| 1443 | + jQuery('#updatesoverview-backupnow-close').prop('value', MainWP.I18n.t('Continue update')); | |
| 1458 | 1444 | } |
| 1459 | 1445 | return; |
| 1460 | 1446 | } |
| 1461 | 1447 | |
| 1462 | - var siteName = updatesoverviewBackupSites[0]['name']; | |
| 1463 | - appendToDiv(backupContentEl, '[' + siteName + '] ' + __('Creating backup file...')); | |
| 1448 | + let siteName = updatesoverviewBackupSites[0]['name']; | |
| 1449 | + appendToDiv(backupContentEl, '[' + siteName + '] ' + MainWP.I18n.t('Creating backup file...')); | |
| 1464 | 1450 | |
| 1465 | - var siteId = updatesoverviewBackupSites[0]['id']; | |
| 1451 | + let siteId = updatesoverviewBackupSites[0]['id']; | |
| 1466 | 1452 | updatesoverviewBackupSites.shift(); |
| 1467 | - var data = mainwp_secure_data({ | |
| 1453 | + let data = mainwp_secure_data({ | |
| 1468 | 1454 | action: 'mainwp_backup_run_site', |
| 1469 | 1455 | site_id: siteId |
| 1470 | 1456 | }); |
| 1471 | 1457 | |
| @@ -1475,9 +1461,9 @@ | ||
| 1475 | 1461 | appendToDiv(backupContentEl, '[' + pSiteName + '] <span class="mainwp-red">ERROR: ' + getErrorMessage(response.error) + '</span>'); |
| 1476 | 1462 | updatesoverviewBackupError = true; |
| 1477 | 1463 | updatesoverview_backup_run_next(); |
| 1478 | 1464 | } else { |
| 1479 | - appendToDiv(backupContentEl, '[' + pSiteName + '] ' + __('Backup file created successfully!')); | |
| 1465 | + appendToDiv(backupContentEl, '[' + pSiteName + '] ' + MainWP.I18n.t('Backup file created successfully!')); | |
| 1480 | 1466 | |
| 1481 | 1467 | updatesoverview_backupnow_download_file(pSiteId, pSiteName, response.result.type, response.result.url, response.result.local, response.result.regexfile, response.result.size, response.result.subfolder); |
| 1482 | 1468 | } |
| 1483 | 1469 | |
| @@ -1484,13 +1470,13 @@ | ||
| 1484 | 1470 | } |
| 1485 | 1471 | }(siteId, siteName), 'json'); |
| 1486 | 1472 | }; |
| 1487 | 1473 | updatesoverview_backupnow_download_file = function (pSiteId, pSiteName, type, url, file, regexfile, size, subfolder) { |
| 1488 | - var backupContentEl = mainwpPopup('#updatesoverview-backup-box').getContentEl(); | |
| 1474 | + let backupContentEl = mainwpPopup('#updatesoverview-backup-box').getContentEl(); | |
| 1489 | 1475 | appendToDiv(backupContentEl, '[' + pSiteName + '] Downloading the file... <div id="updatesoverview-backupnow-status-progress" siteId="' + pSiteId + '" class="ui green progress"><div class="bar"><div class="progress"></div></div>'); |
| 1490 | 1476 | jQuery('#updatesoverview-backupnow-status-progress[siteId="' + pSiteId + '"]').progress({ value: 0, total: size }); |
| 1491 | - var interVal = setInterval(function () { | |
| 1492 | - var data = mainwp_secure_data({ | |
| 1477 | + let interVal = setInterval(function () { | |
| 1478 | + let data = mainwp_secure_data({ | |
| 1493 | 1479 | action: 'mainwp_backup_getfilesize', |
| 1494 | 1480 | local: file |
| 1495 | 1481 | }); |
| 1496 | 1482 | jQuery.post(ajaxurl, data, function (pSiteId) { |
| @@ -1498,9 +1484,9 @@ | ||
| 1498 | 1484 | if (response.error) |
| 1499 | 1485 | return; |
| 1500 | 1486 | |
| 1501 | 1487 | if (updatesoverviewBackupDownloadRunning) { |
| 1502 | - var progressBar = jQuery('#updatesoverview-backupnow-status-progress[siteId="' + pSiteId + '"]'); | |
| 1488 | + let progressBar = jQuery('#updatesoverview-backupnow-status-progress[siteId="' + pSiteId + '"]'); | |
| 1503 | 1489 | if (progressBar.progress('get value') < progressBar.progress('get total')) { |
| 1504 | 1490 | progressBar.progress('set progress', response.result); |
| 1505 | 1491 | } |
| 1506 | 1492 | } |
| @@ -1507,9 +1493,9 @@ | ||
| 1507 | 1493 | } |
| 1508 | 1494 | }(pSiteId), 'json'); |
| 1509 | 1495 | }, 500); |
| 1510 | 1496 | |
| 1511 | - var data = mainwp_secure_data({ | |
| 1497 | + let data = mainwp_secure_data({ | |
| 1512 | 1498 | action: 'mainwp_backup_download_file', |
| 1513 | 1499 | site_id: pSiteId, |
| 1514 | 1500 | type: type, |
| 1515 | 1501 | url: url, |
| @@ -1522,9 +1508,9 @@ | ||
| 1522 | 1508 | clearInterval(pInterVal); |
| 1523 | 1509 | |
| 1524 | 1510 | if (response.error) { |
| 1525 | 1511 | appendToDiv(backupContentEl, '[' + pSiteName + '] <span class="mainwp-red">ERROR: ' + getErrorMessage(response.error) + '</span>'); |
| 1526 | - appendToDiv(backupContentEl, '[' + pSiteName + '] <span class="mainwp-red">' + __('Backup failed!') + '</span>'); | |
| 1512 | + appendToDiv(backupContentEl, '[' + pSiteName + '] <span class="mainwp-red">' + MainWP.I18n.t('Backup failed!') + '</span>'); | |
| 1527 | 1513 | |
| 1528 | 1514 | updatesoverviewBackupError = true; |
| 1529 | 1515 | updatesoverview_backup_run_next(); |
| 1530 | 1516 | return; |
| @@ -1530,12 +1516,12 @@ | ||
| 1530 | 1516 | return; |
| 1531 | 1517 | } |
| 1532 | 1518 | |
| 1533 | 1519 | jQuery('#updatesoverview-backupnow-status-progress[siteId="' + pSiteId + '"]').progress('set progress', pSize); |
| 1534 | - appendToDiv(backupContentEl, '[' + pSiteName + '] ' + __('Download from the child site completed.')); | |
| 1535 | - appendToDiv(backupContentEl, '[' + pSiteName + '] ' + __('Backup completed.')); | |
| 1520 | + appendToDiv(backupContentEl, '[' + pSiteName + '] ' + MainWP.I18n.t('Download from the child site completed.')); | |
| 1521 | + appendToDiv(backupContentEl, '[' + pSiteName + '] ' + MainWP.I18n.t('Backup completed.')); | |
| 1536 | 1522 | |
| 1537 | - var newData = mainwp_secure_data({ | |
| 1523 | + let newData = mainwp_secure_data({ | |
| 1538 | 1524 | action: 'mainwp_backup_delete_file', |
| 1539 | 1525 | site_id: pSiteId, |
| 1540 | 1526 | file: pUrl |
| 1541 | 1527 | }); |