| 1 |
jQuery(document).ready(function($) { |
| 2 |
UpdraftCentral_Module_UpdraftPlus = new UpdraftCentral_UpdraftPlus_Module(); |
| 3 |
|
| 4 |
// To allow labelauty remote storage buttons to be used with keyboard |
| 5 |
jQuery(document).keyup(function(event) { |
| 6 |
if (event.keyCode === 32 || event.keyCode === 13) { |
| 7 |
if (jQuery(document.activeElement).is("input.labelauty + label")) { |
| 8 |
var for_box = jQuery(document.activeElement).attr("for"); |
| 9 |
if (for_box) { |
| 10 |
jQuery("#"+for_box).change(); |
| 11 |
} |
| 12 |
} |
| 13 |
} |
| 14 |
}); |
| 15 |
}); |
| 16 |
|
| 17 |
/** |
| 18 |
* UpdraftCentral UpdraftPlus Module |
| 19 |
* |
| 20 |
* @return {void} |
| 21 |
*/ |
| 22 |
function UpdraftCentral_UpdraftPlus_Module() { |
| 23 |
|
| 24 |
var $ = jQuery; |
| 25 |
|
| 26 |
var settings_css_sub_prefix = '.updraftcentral_row_extracontents .updraft_site_settings_output '; |
| 27 |
var settings_css_prefix = '#updraftcentral_dashboard_existingsites '+settings_css_sub_prefix; |
| 28 |
|
| 29 |
/** |
| 30 |
* Inserts bulk delete elements (input boxes, bulk delete button) along with the collapsable info |
| 31 |
* to an existing template pulled from the remote controlled website for the "Existing Backups" section. |
| 32 |
* |
| 33 |
* @param {Object} site_row - the jQuery object of the row that the existing backup data was pulled from |
| 34 |
* @return {void} |
| 35 |
*/ |
| 36 |
function insert_bulk_delete($site_row) { |
| 37 |
|
| 38 |
var $button = $site_row.find('.updraftcentral_row_extracontents button.updraft_download_button'); |
| 39 |
|
| 40 |
var keys = []; |
| 41 |
$button.wrapAll(function() { |
| 42 |
var key = $(this).closest('tr').data('key'); |
| 43 |
|
| 44 |
if (-1 === $.inArray(key, keys)) { |
| 45 |
keys.push(key); |
| 46 |
$(this).parent().prepend('<a class="show-backup-data" data-key="'+key+'"><span class="dashicons dashicons-arrow-right"></span> '+udclion.updraftplus.select_backup_data+'</a>'); |
| 47 |
} |
| 48 |
return '<span class="backup-data-'+key+' hide-backup-data"></span>'; |
| 49 |
}); |
| 50 |
|
| 51 |
UpdraftCentral.register_event_handler('click', 'a.show-backup-data', function() { |
| 52 |
var key = $(this).data('key'); |
| 53 |
|
| 54 |
$(this).find('span.dashicons').toggleClass('dashicons-arrow-right dashicons-arrow-down'); |
| 55 |
$(this).parent().find('.backup-label-container-'+key).toggleClass('hide-backup-data'); |
| 56 |
$(this).parent().find('.backup-data-'+key).toggleClass('hide-backup-data'); |
| 57 |
}); |
| 58 |
|
| 59 |
var $backup_date_label = $site_row.find('.updraftcentral_row_extracontents div.backup_date_label'); |
| 60 |
if (!$backup_date_label.length) { |
| 61 |
$site_row.find('.updraftcentral_row_extracontents td.updraft_existingbackup_date').each(function() { |
| 62 |
var backup_item = $(this); |
| 63 |
backup_item.wrapInner('<div class="backup_date_label"></div>'); |
| 64 |
}); |
| 65 |
|
| 66 |
$backup_date_label = $site_row.find('.updraftcentral_row_extracontents div.backup_date_label'); |
| 67 |
} |
| 68 |
|
| 69 |
if ($backup_date_label.length) { |
| 70 |
$backup_date_label.prepend('<div class="delete-backup-container"><input type="checkbox" class="delete_backup_item" name="delete_backup" value="1" /></div>'); |
| 71 |
|
| 72 |
var $backup_container = $site_row.find('.updraftcentral_row_extracontents div.updraft_existing_backups'); |
| 73 |
$backup_container.append('<button id="btn-backup-bulk-delete" class="btn btn-secondary">'+udclion.updraftplus.delete_selected+'</button>'); |
| 74 |
} |
| 75 |
|
| 76 |
// Adding new columns for backup label and storage |
| 77 |
insert_storage_column($site_row); |
| 78 |
insert_label_column($site_row); |
| 79 |
} |
| 80 |
|
| 81 |
/** |
| 82 |
* Inserts column to the existing backups table |
| 83 |
* |
| 84 |
* @param {Object} $site_row The jQuery object of the row that the existing backup data was pulled from |
| 85 |
* @param {String} column The desired column name |
| 86 |
* @param {Boolean} [add_class] Optional - A flag whether to add the 'updraft_existingbackup_data' class. |
| 87 |
* @return {Object} jQuery object representing the backups table |
| 88 |
*/ |
| 89 |
function insert_existingbackup_column($site_row, column, add_class) { |
| 90 |
var $table = $site_row.find('.updraftcentral_row_extracontents table.existing-backups-table'); |
| 91 |
var $header = $table.find('thead th.backup-date'); |
| 92 |
var $content = $table.find('tbody td.updraft_existingbackup_date'); |
| 93 |
if ('undefined' !== typeof add_class && add_class) $content.next('td').attr('class', 'updraft_existingbackup_data'); |
| 94 |
|
| 95 |
$('<th class="backup-'+column+'">'+udclion.updraftplus.backup+' '+column+'</th>').insertAfter($header); |
| 96 |
$('<td class="updraft_existingbackup_'+column+'"></td>').insertAfter($content); |
| 97 |
|
| 98 |
return $table; |
| 99 |
} |
| 100 |
|
| 101 |
/** |
| 102 |
* Inserts the storage column |
| 103 |
* |
| 104 |
* @param {Object} $site_row The jQuery object of the row that the existing backup data was pulled from |
| 105 |
* @return {void} |
| 106 |
*/ |
| 107 |
function insert_storage_column($site_row) { |
| 108 |
$table = insert_existingbackup_column($site_row, 'storage', true); |
| 109 |
$table.find('tr.updraft_existing_backups_row').each(function() { |
| 110 |
var $tr = $(this); |
| 111 |
$tr.find('.backup_date_label img.stored_icon').each(function() { |
| 112 |
$(this).appendTo($tr.find('td.updraft_existingbackup_storage')); |
| 113 |
}); |
| 114 |
}); |
| 115 |
} |
| 116 |
|
| 117 |
/** |
| 118 |
* Inserts the label column |
| 119 |
* |
| 120 |
* @param {Object} $site_row The jQuery object of the row that the existing backup data was pulled from |
| 121 |
* @return {void} |
| 122 |
*/ |
| 123 |
function insert_label_column($site_row) { |
| 124 |
var $table = $site_row.find('.updraftcentral_row_extracontents table.existing-backups-table'); |
| 125 |
$table.find('tr.updraft_existing_backups_row').each(function() { |
| 126 |
var $tr = $(this); |
| 127 |
var $show_backup_data = $tr.find('td.updraft_existingbackup_data a.show-backup-data'); |
| 128 |
var class_name = 'backup-label-container-'+$show_backup_data.data('key'); |
| 129 |
$('<div class="'+class_name+' hide-backup-data"></div>').insertAfter($show_backup_data); |
| 130 |
|
| 131 |
$tr.find('.backup_date_label br').wrap('<span></span>'); |
| 132 |
$tr.find('.backup_date_label .clear-right ~ span').appendTo($tr.find('div.'+class_name)); |
| 133 |
}); |
| 134 |
} |
| 135 |
|
| 136 |
// Backup now listeners |
| 137 |
|
| 138 |
/** |
| 139 |
* Listener function for handling "Backup Now" listeners |
| 140 |
* |
| 141 |
* @param {Object} site_listener_row - the jQuery object of the row of the listener |
| 142 |
* @param {Object} site_row - the jQuery object of the row that the backup is for |
| 143 |
* @param {number} site_id - the site ID of the site that the backup is for |
| 144 |
* |
| 145 |
* @return {void} |
| 146 |
*/ |
| 147 |
function listener_processor_updraftplus_backup(site_listener_row, site_row, site_id) { |
| 148 |
|
| 149 |
if ($(site_listener_row).find('.updraft_finished').length > 0) { |
| 150 |
if (UpdraftCentral.get_debug_level() > 1) { |
| 151 |
console.log("UDCentral: UpdraftPlus backup listener: job finished"); |
| 152 |
} |
| 153 |
// This means, "finished, and close it after a delay") |
| 154 |
return 0; |
| 155 |
} |
| 156 |
|
| 157 |
var job_id = $(site_listener_row).data('job_id'); |
| 158 |
return { call: 'updraftplus.backup_progress', data: { job_id: job_id } }; |
| 159 |
} |
| 160 |
|
| 161 |
/** |
| 162 |
* Listener function for handling "Backup Now" listener results |
| 163 |
* |
| 164 |
* @param {Object} site_listener_row - the jQuery object of the row of the listener |
| 165 |
* @param {Object} site_row - the jQuery object of the row that the backup is for |
| 166 |
* @param {number} site_id - the site ID of the site that the backup is for |
| 167 |
* @param {*} data - the data returned by the remote call to get the backup progress |
| 168 |
* |
| 169 |
* @return {void} |
| 170 |
*/ |
| 171 |
function result_listener_processor_updraftplus_backup_progress(site_listener_row, site_row, site_id, data) { |
| 172 |
var output = ''; |
| 173 |
if (data.hasOwnProperty('l')) { |
| 174 |
output += '<strong>'+udclion.updraftplus.lastlogline+':</strong> '+data.l+'<br>'; |
| 175 |
} |
| 176 |
if (data.hasOwnProperty('j')) { |
| 177 |
output += data.j; |
| 178 |
} |
| 179 |
$(site_listener_row).find('.backup_state:first').html(UpdraftCentral_Library.sanitize_html(output)); |
| 180 |
|
| 181 |
// here we get the attributes that come with the response and make our own progressbar using bootstrap's one. |
| 182 |
var info = (jQuery.type($(site_listener_row).find('.updraft_percentage').data('info')) === "undefined" ) ? udclion.updraftplus.missing_data_attributes : UpdraftCentral_Library.sanitize_html($(site_listener_row).find('.updraft_percentage').data('info')); |
| 183 |
var stage = (jQuery.type($(site_listener_row).find('.updraft_percentage').data('progress')) === "undefined" ) ? '0' : UpdraftCentral_Library.quote_attribute($(site_listener_row).find('.updraft_percentage').data('progress')); |
| 184 |
|
| 185 |
var html_to_show = "<div class='text-center' id='info"+site_id+"'>"+info+"</div>"; |
| 186 |
html_to_show +="<progress class='progress progress-updraftcentral' value='"+stage+"' max='100' ></progress>"; |
| 187 |
|
| 188 |
$(site_listener_row).find('.curstage').html(html_to_show); |
| 189 |
} |
| 190 |
UpdraftCentral.register_listener_processor('updraftplus_backup', listener_processor_updraftplus_backup); |
| 191 |
UpdraftCentral.register_listener_processor('updraftplus.backup_progress', result_listener_processor_updraftplus_backup_progress); |
| 192 |
|
| 193 |
/** |
| 194 |
* A listener function for feeding back on what downloads need monitoring |
| 195 |
* |
| 196 |
* @param {Object} site_listener_row - jQuery object of the listener row involved |
| 197 |
* @param {Object} site_row - jQuery object of the site row of the site involved |
| 198 |
* @param {number} site_id - the site ID (an integer) |
| 199 |
* |
| 200 |
* @return {void} |
| 201 |
*/ |
| 202 |
function listener_processor_updraftplus_download(site_listener_row, site_row, site_id) { |
| 203 |
|
| 204 |
var items = []; |
| 205 |
var all_finished = null; |
| 206 |
$(site_listener_row).find('.updraftplus_downloader').each(function(index, item) { |
| 207 |
if ($(item).data('updraft_finished')) { |
| 208 |
if (null === all_finished) { all_finished = true; } |
| 209 |
} else { |
| 210 |
all_finished = false; |
| 211 |
} |
| 212 |
var findex = $(item).data('findex'); |
| 213 |
var what = $(item).data('what'); |
| 214 |
var backup_timestamp = $(item).data('backup_timestamp'); |
| 215 |
// <base(arbitrary - put anything you want returned)>,<timestamp>,<type>(,<findex>) |
| 216 |
items.push(site_id+','+backup_timestamp+','+what+','+findex); |
| 217 |
}); |
| 218 |
|
| 219 |
if (all_finished) { |
| 220 |
console.log("UDCentral: UpdraftPlus download listener: job finished - will not poll any more"); |
| 221 |
// 1 means "don't poll this any more, but don't close it either" |
| 222 |
return 1; |
| 223 |
} |
| 224 |
|
| 225 |
return { call: 'updraftplus.get_download_status', data: items }; |
| 226 |
} |
| 227 |
|
| 228 |
/** |
| 229 |
* Update the listener(s) with the returned download info |
| 230 |
* |
| 231 |
* @param {Object} status - an object with various properties corresponding to the download state as returned by UD |
| 232 |
* |
| 233 |
* @return {number} - whether to not bother with polling again (advisory) |
| 234 |
*/ |
| 235 |
function updraft_downloader_status_update(status) { |
| 236 |
|
| 237 |
var site_id = status.base; |
| 238 |
var fullpath = status.f; |
| 239 |
var findex = status.findex; |
| 240 |
var message = status.m; |
| 241 |
var percent = status.hasOwnProperty('p') ? status.p : null; |
| 242 |
var size_downloaded = status.s; |
| 243 |
var total_size = status.t; |
| 244 |
var backup_timestamp = status.timestamp; |
| 245 |
var what = status.what; |
| 246 |
|
| 247 |
var stid = site_id+'_'+backup_timestamp+'_'+what+'_'+findex; |
| 248 |
var stid_selector = '#updraftcentral_notice_container .'+stid; |
| 249 |
|
| 250 |
var cancel_repeat = 0; |
| 251 |
|
| 252 |
if (status.hasOwnProperty('failed') && status.failed) { |
| 253 |
$(stid_selector).data('updraft_finished', true); |
| 254 |
} |
| 255 |
|
| 256 |
if (status.hasOwnProperty('e') && status.e) { |
| 257 |
$(stid_selector+' .raw').html('<strong>'+udclion.error+':</strong> '+status.e); |
| 258 |
console.log("UDCentral: UpdraftPlus: downloader ("+stid+"): an error was returned (follows)"); |
| 259 |
console.log(status); |
| 260 |
} else if (status.p !== null) { |
| 261 |
$(stid_selector+'_st .dlfileprogress').width(status.p+'%'); |
| 262 |
// Is a restart appropriate? |
| 263 |
// status.a, if set, indicates that a) the download is incomplete and b) the value is the number of seconds since the file was last modified... |
| 264 |
if (status.a != null && status.a > 0) { |
| 265 |
|
| 266 |
var time_now = (new Date).getTime(); |
| 267 |
|
| 268 |
var last_time_began = $(stid_selector).data('last_time_began'); |
| 269 |
// Remember that this is in milliseconds |
| 270 |
var since_last_restart = time_now - last_time_began; |
| 271 |
|
| 272 |
if (status.a > 90 && since_last_restart > 60000) { |
| 273 |
console.log("UDCentral: UpdraftPlus: "+stid+": restarting download: file_age="+status.a+", since_last_restart_ms="+since_last_restart); |
| 274 |
|
| 275 |
var downloader_params = { |
| 276 |
type: what, |
| 277 |
timestamp: backup_timestamp, |
| 278 |
findex: findex |
| 279 |
}; |
| 280 |
|
| 281 |
var $site_row = $('#updraftcentral_dashboard_existingsites .updraftcentral_site_row[data-site_id="'+site_id+'"'); |
| 282 |
|
| 283 |
// We set this, regardless of success/failure, because we don't want to send the same request multiple times, whether it succeeds or not, until an interval has passed |
| 284 |
$(stid_selector).data('last_time_began', (new Date).getTime()); |
| 285 |
|
| 286 |
// We don't do anything with a positive result, in terms of creating listeners, etc., because those already exist |
| 287 |
UpdraftCentral.send_site_rpc('updraftplus.downloader', downloader_params, $site_row, function(response, code, error_code) { |
| 288 |
if ('ok' != code) { |
| 289 |
$(stid_selector+' .raw').html(udclion.updraftplus.backup_start_failed); |
| 290 |
console.log("code="+code+", error_code="+error_code); |
| 291 |
console.log(response); |
| 292 |
} |
| 293 |
}); |
| 294 |
|
| 295 |
} |
| 296 |
} |
| 297 |
|
| 298 |
if (status.hasOwnProperty('m') && status.m != null) { |
| 299 |
|
| 300 |
if (status.p < 100) { |
| 301 |
$(stid_selector+' .raw').html(status.m); |
| 302 |
} else { |
| 303 |
|
| 304 |
msg = template_replace('updraftplus-downloaded', { |
| 305 |
file_ready: udclion.updraftplus.file_ready, |
| 306 |
download_to_computer: udclion.updraftplus.download_to_computer, |
| 307 |
and_then: udclion.updraftplus.and_then, |
| 308 |
you_should: udclion.updraftplus.you_should, |
| 309 |
backup_timestamp: backup_timestamp, |
| 310 |
site_id: site_id, |
| 311 |
what: what, |
| 312 |
findex: findex, |
| 313 |
delete_from_server: udclion.updraftplus.delete_from_server |
| 314 |
}); |
| 315 |
$(stid_selector).data('updraft_finished', true); |
| 316 |
$(stid_selector+' .raw').html(msg); |
| 317 |
} |
| 318 |
} |
| 319 |
|
| 320 |
// dlstatus_lastlog = response; |
| 321 |
} else if (status.m != null) { |
| 322 |
$(stid_selector+' .raw').html(status.m); |
| 323 |
} else { |
| 324 |
$(stid_selector+' .raw').html(udclion.updraftplus.backup_start_failed); |
| 325 |
cancel_repeat = 1; |
| 326 |
} |
| 327 |
return cancel_repeat; |
| 328 |
} |
| 329 |
|
| 330 |
/** |
| 331 |
* Process the results of the request for updates on the download status |
| 332 |
* |
| 333 |
* @param {Object} site_listener_row - jQuery object for the listener that made the request (not used) |
| 334 |
* @param {Object} site_row - jQuery object for the site that the request was to (not used) |
| 335 |
* @param {number} site_id - the site ID for the site that the request was to (not used) |
| 336 |
* @param {array} data - the returned download statuses (one array member for each downloader that information was requested on) |
| 337 |
* |
| 338 |
* @return {void} |
| 339 |
*/ |
| 340 |
function result_listener_processor_updraftplus_get_download_status(site_listener_row, site_row, site_id, data) { |
| 341 |
$.each(data, function(index, status) { |
| 342 |
// Though the site_id is returned by UpdraftCentral's listener handling, it also comes back in the result - so, we don't need to pass anything on |
| 343 |
if (status.hasOwnProperty('base')) { |
| 344 |
var cancel_repeat = updraft_downloader_status_update(status); |
| 345 |
} |
| 346 |
}); |
| 347 |
} |
| 348 |
UpdraftCentral.register_listener_processor('updraftplus_download', listener_processor_updraftplus_download); |
| 349 |
UpdraftCentral.register_listener_processor('updraftplus.get_download_status', result_listener_processor_updraftplus_get_download_status); |
| 350 |
|
| 351 |
/** |
| 352 |
* Opens the dialog box for starting a "Backup Now" backup, via fetching the dialog contents (so that we get the relevant options) from the remote site |
| 353 |
* |
| 354 |
* @param {boolean} backupnow_nodb - indicate whether to exclude the database from the backup |
| 355 |
* @param {boolean} backupnow_nofiles - indicate whether to exclude the files from the backup |
| 356 |
* @param {boolean} backupnow_nocloud - indicate whether to skip sending the backup to any configured remote destination |
| 357 |
* @param {string} [onlythesefileentities] - a comma-separated list of file entities to back up (only relevant if files are being backed up) |
| 358 |
* @param {String} [onlythesetableentities] a comma-separated list of table entities to back up (only relevant if databases are being backed up) |
| 359 |
* @param {*} [extradata] - arbitrary extra data to send with the backup request (though, of course, only relevant data will have any effect) |
| 360 |
* @param {string} [label] - a label to give to the backup |
| 361 |
* |
| 362 |
* @return {void} |
| 363 |
*/ |
| 364 |
this.backupnow_go = function(backupnow_nodb, backupnow_nofiles, backupnow_nocloud, onlythesefileentities, extradata, label, onlythesetableentities) { |
| 365 |
|
| 366 |
var listener_title; |
| 367 |
if (extradata && extradata.hasOwnProperty('_listener_title')) { |
| 368 |
listener_title = extradata._listener_title; |
| 369 |
delete extradata._listener_title; |
| 370 |
} |
| 371 |
|
| 372 |
var params = { |
| 373 |
backupnow_nodb: backupnow_nodb, |
| 374 |
backupnow_nofiles: backupnow_nofiles, |
| 375 |
backupnow_nocloud: backupnow_nocloud, |
| 376 |
backupnow_label: label, |
| 377 |
extradata: extradata |
| 378 |
}; |
| 379 |
|
| 380 |
if ('' != onlythesefileentities) { |
| 381 |
params.onlythisfileentity = onlythesefileentities; |
| 382 |
} |
| 383 |
|
| 384 |
if ('' != onlythesetableentities) { |
| 385 |
params.onlythesetableentities = onlythesetableentities; |
| 386 |
} |
| 387 |
|
| 388 |
UpdraftCentral.send_site_rpc('updraftplus.backupnow', params, UpdraftCentral.$site_row, function(response, code, error_code) { |
| 389 |
if ('ok' == code && false !== response && response.hasOwnProperty('data')) { |
| 390 |
if (response.data.hasOwnProperty('nonce')) { |
| 391 |
|
| 392 |
var listener_message = '<div class="backup_state">'+udclion.updraftplus.backupstarted +'</div>'; |
| 393 |
|
| 394 |
UpdraftCentral.create_dashboard_listener('updraftplus_backup', UpdraftCentral.$site_row, listener_message, { job_id: response.data.nonce }, listener_title); |
| 395 |
|
| 396 |
} else { |
| 397 |
UpdraftCentral.add_dashboard_notice('<h2>'+UpdraftCentral.$site_row.data('site_description')+'</h2>'+udclion.updraftplus.backup_start_failed, 'error'); |
| 398 |
} |
| 399 |
} |
| 400 |
}); |
| 401 |
|
| 402 |
} |
| 403 |
|
| 404 |
/** |
| 405 |
* Create a download listener |
| 406 |
* |
| 407 |
* @param {number} site_id - the ID of the site that the downloader is for |
| 408 |
* @param {number} backup_timestamp - the epoch time of the backup |
| 409 |
* @param {string} what - the entity name to download (e.g. "plugins") |
| 410 |
* @param {string} set_contents - comma-separated list of indexes corresponding to files to download |
| 411 |
* @param {string} pretty_date - the formatted date of the backup |
| 412 |
* @param {boolean} async - (unused; future possibility) whether to send the request asynchronously, or not |
| 413 |
* @param {Object} spinner_where - a jQuery object indicating where to place the spinner |
| 414 |
* |
| 415 |
* @return {void} |
| 416 |
*/ |
| 417 |
function updraft_downloader(site_id, backup_timestamp, what, set_contents, pretty_date, async, spinner_where) { |
| 418 |
|
| 419 |
if (typeof set_contents !== "string") set_contents = set_contents.toString(); |
| 420 |
async = async ? true : false; |
| 421 |
|
| 422 |
set_contents = set_contents.split(','); |
| 423 |
|
| 424 |
// If there's an existing listener downloading from this site, then add our widget to it instead of creating another. |
| 425 |
var $listener = $('#updraftcentral_notice_container .updraftcentral_listener_updraftplus_download[data-site_id="'+site_id+'"'); |
| 426 |
if ($listener.length == 0) { $listener = false; } |
| 427 |
|
| 428 |
for (var i=0; i<set_contents.length; i++) { |
| 429 |
|
| 430 |
// Create somewhere for the status to be found |
| 431 |
|
| 432 |
var findex = set_contents[i]; |
| 433 |
var stid = site_id+'_'+backup_timestamp+'_'+what+'_'+findex; |
| 434 |
var stid_selector = '.'+stid; |
| 435 |
|
| 436 |
if ($(stid_selector).length) { |
| 437 |
console.log("UDCentral: There already appears to be an active downloader for this entity (stid: "+stid+")"); |
| 438 |
return; |
| 439 |
} |
| 440 |
|
| 441 |
// Now send the actual request to kick it all off |
| 442 |
|
| 443 |
var downloader_params = { |
| 444 |
type: what, |
| 445 |
timestamp: backup_timestamp, |
| 446 |
findex: findex |
| 447 |
}; |
| 448 |
|
| 449 |
UpdraftCentral.send_site_rpc('updraftplus.downloader', downloader_params, UpdraftCentral.$site_row, function(response, code, error_code) { |
| 450 |
if ('ok' == code && false !== response && response.hasOwnProperty('data') && response.data.hasOwnProperty('result')) { |
| 451 |
|
| 452 |
var result = response.data.result; |
| 453 |
var request = response.data.request; |
| 454 |
|
| 455 |
var backup_timestamp = request.timestamp; |
| 456 |
var what = request.type; |
| 457 |
var findex = parseInt(request.findex); |
| 458 |
|
| 459 |
var stid = site_id+'_'+backup_timestamp+'_'+what+'_'+findex; |
| 460 |
var stid_selector = '.'+stid; |
| 461 |
|
| 462 |
var msg = '??'; |
| 463 |
|
| 464 |
var last_time_began = (new Date).getTime(); |
| 465 |
|
| 466 |
var show_index = findex+1; |
| 467 |
var itext = (findex == 0) ? '' : ' ('+show_index+')'; |
| 468 |
var prdate = (pretty_date) ? pretty_date : backup_timestamp; |
| 469 |
|
| 470 |
// This is the parent object, that contains the results. The updated results go into div.raw within this. |
| 471 |
widgets_html = template_replace('updraftplus-downloader', { |
| 472 |
stid: stid, |
| 473 |
download_verb: udclion.updraftplus.download_verb, |
| 474 |
what: what, |
| 475 |
itext: itext, |
| 476 |
pretty_date: prdate, |
| 477 |
begun_looking: udclion.updraftplus.begun_looking, |
| 478 |
site_id: site_id, |
| 479 |
backup_timestamp: backup_timestamp, |
| 480 |
findex: findex |
| 481 |
}); |
| 482 |
|
| 483 |
// deleted|downloaded|needs_download|download_failed |
| 484 |
if ('downloaded' == result) { |
| 485 |
msg = template_replace('updraftplus-downloaded', { |
| 486 |
file_ready: udclion.updraftplus.file_ready, |
| 487 |
download_to_computer: udclion.updraftplus.download_to_computer, |
| 488 |
and_then: udclion.updraftplus.and_then, |
| 489 |
you_should: udclion.updraftplus.you_should, |
| 490 |
backup_timestamp: backup_timestamp, |
| 491 |
site_id: site_id, |
| 492 |
what: what, |
| 493 |
findex: findex, |
| 494 |
delete_from_server: udclion.updraftplus.delete_from_server |
| 495 |
}); |
| 496 |
} else if ('needs_download' == result) { |
| 497 |
msg = udclion.updraftplus.needs_download; |
| 498 |
} else if ('download_failed' == result) { |
| 499 |
msg = udclion.updraftplus.download_failed; |
| 500 |
} |
| 501 |
|
| 502 |
if (false === $listener) { |
| 503 |
$listener = UpdraftCentral.create_dashboard_listener('updraftplus_download', UpdraftCentral.$site_row, widgets_html); |
| 504 |
} else { |
| 505 |
// Add a new widget into that listener |
| 506 |
$listener.append(widgets_html); |
| 507 |
} |
| 508 |
// If it was already marked as 'finished', then it won't be polled - we want it to start being polled again |
| 509 |
$listener.data('finished', false); |
| 510 |
$listener.find(stid_selector).data('last_time_began', last_time_began); |
| 511 |
$listener.find(stid_selector+' .raw').html(msg); |
| 512 |
|
| 513 |
|
| 514 |
} else { |
| 515 |
UpdraftCentral.add_dashboard_notice('<h2>'+UpdraftCentral.$site_row.data('site_description')+'</h2>'+udclion.updraftplus.download_start_failed, 'error'); |
| 516 |
} |
| 517 |
}); |
| 518 |
|
| 519 |
} |
| 520 |
} |
| 521 |
|
| 522 |
var updraftplus_morefiles_lastind = 0; |
| 523 |
var updraftplus_version = 0; |
| 524 |
|
| 525 |
/** |
| 526 |
* Get the "Settings" panel from the remote UpdraftPlus |
| 527 |
* |
| 528 |
* @param {Object} $site_row - jQuery object for the row of the site for which the information is being requested |
| 529 |
* |
| 530 |
* @return {void} |
| 531 |
*/ |
| 532 |
function updraft_get_existing_backup_settings($site_row) { |
| 533 |
|
| 534 |
$site_row.find('.updraftcentral_row_extracontents').css('opacity', '0.3'); |
| 535 |
|
| 536 |
UpdraftCentral.send_site_rpc('updraftplus.get_settings', { |
| 537 |
include_database_decrypter: 0, |
| 538 |
include_adverts: 0, |
| 539 |
include_save_button: 1 |
| 540 |
}, $site_row, function(response, code, error_code) { |
| 541 |
$site_row.find('.updraftcentral_row_extracontents').css('opacity', '1.0'); |
| 542 |
if ('ok' == code && response) { |
| 543 |
$site_row.find('.updraftcentral_row_extracontents').html('<div class="updraft_site_settings_output"><div class="dashicons dashicons-image-rotate updraftcentral_site_backup_settings"></div>'+UpdraftCentral_Library.sanitize_html(response.data.settings)+'</div>'); |
| 544 |
if (response.data.hasOwnProperty('remote_storage_templates') && response.data.hasOwnProperty('remote_storage_options')) { |
| 545 |
var html = ''; |
| 546 |
for (var method in response.data.remote_storage_templates) { |
| 547 |
if ('undefined' != typeof response.data.remote_storage_options[method]) { |
| 548 |
var template = Handlebars.compile(response.data.remote_storage_templates[method]); |
| 549 |
var first_instance = true; |
| 550 |
for (var instance_id in response.data.remote_storage_options[method]) { |
| 551 |
if ('default' === instance_id) continue; |
| 552 |
var context = response.data.remote_storage_options[method][instance_id]; |
| 553 |
context['first_instance'] = first_instance; |
| 554 |
if ('undefined' == typeof context['instance_enabled']) { |
| 555 |
context['instance_enabled'] = 1; |
| 556 |
} |
| 557 |
html += template(context); |
| 558 |
first_instance = false; |
| 559 |
} |
| 560 |
} else { |
| 561 |
html += response.data.remote_storage_templates[method]; |
| 562 |
} |
| 563 |
} |
| 564 |
$('#remote-storage-holder').append(html); |
| 565 |
} |
| 566 |
|
| 567 |
$('.updraftcentral_row_extracontents #remote-storage-holder').on('click', '.updraftplusmethod a.updraft_add_instance', function(e) { |
| 568 |
e.preventDefault(); |
| 569 |
|
| 570 |
var method = $(this).data('method'); |
| 571 |
add_new_instance(method); |
| 572 |
}); |
| 573 |
|
| 574 |
$('.updraftcentral_row_extracontents #remote-storage-holder').on('click', '.updraftplusmethod a.updraft_delete_instance', function(e) { |
| 575 |
e.preventDefault(); |
| 576 |
|
| 577 |
var method = $(this).data('method'); |
| 578 |
var instance_id = $(this).data('instance_id'); |
| 579 |
|
| 580 |
if (1 === $('.' + method + '_updraft_remote_storage_border').length) { |
| 581 |
add_new_instance(method); |
| 582 |
} |
| 583 |
|
| 584 |
$('.' + method + '-' + instance_id).hide('slow', function() { |
| 585 |
$(this).remove(); |
| 586 |
}); |
| 587 |
}); |
| 588 |
|
| 589 |
/** |
| 590 |
* This method will get the default options and compile a template with them |
| 591 |
* |
| 592 |
* @param {string} method - the remote storage name |
| 593 |
* @param {boolean} first_instance - indicates if this is the first instance of this type |
| 594 |
*/ |
| 595 |
function add_new_instance(method) { |
| 596 |
var template = Handlebars.compile(response.data.remote_storage_templates[method]); |
| 597 |
var context = response.data.remote_storage_options[method]['default']; |
| 598 |
context['instance_id'] = 's-' + generate_instance_id(32); |
| 599 |
context['instance_enabled'] = 1; |
| 600 |
var html = template(context); |
| 601 |
$(html).hide().insertAfter('.' + method + '_add_instance_container:first').show('slow'); |
| 602 |
} |
| 603 |
|
| 604 |
/** |
| 605 |
* This method will return a random instance id string |
| 606 |
* |
| 607 |
* @param {integer} length - the length of the string to be generated |
| 608 |
* |
| 609 |
* @return string - the instance id |
| 610 |
*/ |
| 611 |
function generate_instance_id(length) { |
| 612 |
var uuid = ''; |
| 613 |
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
| 614 |
|
| 615 |
for (var i = 0; i < length; i++) { |
| 616 |
uuid += characters.charAt(Math.floor(Math.random() * characters.length)); |
| 617 |
} |
| 618 |
|
| 619 |
return uuid; |
| 620 |
} |
| 621 |
|
| 622 |
$('.updraftcentral_row_extracontents #remote-storage-holder').on("change", "input[class='updraft_instance_toggle']", function () { |
| 623 |
if ($(this).is(':checked')) { |
| 624 |
$(this).siblings('label').html(udclion.updraftplus.instance_enabled); |
| 625 |
} else { |
| 626 |
$(this).siblings('label').html(udclion.updraftplus.instance_disabled); |
| 627 |
} |
| 628 |
}); |
| 629 |
|
| 630 |
/** |
| 631 |
* For some reason, the google caja sanitizer is removing the "aria-label" attribute or is currently |
| 632 |
* not supported. The "aria-label" is intended for accessibility and used by the labelauty to update the label |
| 633 |
* tag's attribute. Thus, we're rebuilding the aria-label attribute based from the value of the checkbox element |
| 634 |
* to restore the lost keyboard support (e.g. tab, etc.) |
| 635 |
*/ |
| 636 |
$site_row.find('.updraftcentral_row_extracontents #remote-storage-container > input[type="checkbox"]').each(function() { |
| 637 |
var input = jQuery(this); |
| 638 |
input.attr('aria-label', udclion.updraftplus.backup_using + ' ' + input.val() + '?'); |
| 639 |
}); |
| 640 |
|
| 641 |
|
| 642 |
// Set the initial state of the schedule selection text and widgetry |
| 643 |
updraft_check_same_times(); |
| 644 |
|
| 645 |
updraft_remote_storage_tabs_setup(); |
| 646 |
|
| 647 |
updraft_extra_dbs = 0; |
| 648 |
updraftplus_morefiles_lastind = 0; |
| 649 |
|
| 650 |
if (response.data.hasOwnProperty('meta')) { |
| 651 |
|
| 652 |
var meta = response.data.meta; |
| 653 |
|
| 654 |
if (meta.hasOwnProperty('retain_rules') && meta.retain_rules.hasOwnProperty('files')) { |
| 655 |
setup_retain_rules(meta.retain_rules.files, meta.retain_rules.db); |
| 656 |
} |
| 657 |
|
| 658 |
if (meta.hasOwnProperty('extra_dbs')) { |
| 659 |
$.each(meta.extra_dbs, function(i, db) { |
| 660 |
if (db.hasOwnProperty('host')) { |
| 661 |
extradbs_add(db.host, db.user, db.name, db.pass, db.prefix); |
| 662 |
} |
| 663 |
}); |
| 664 |
} |
| 665 |
} |
| 666 |
|
| 667 |
if (response.data.hasOwnProperty('updraftplus_version')) { |
| 668 |
updraftplus_version = response.data.updraftplus_version; |
| 669 |
} |
| 670 |
|
| 671 |
setup_file_entity_exclude_field('uploads'); |
| 672 |
setup_file_entity_exclude_field('others'); |
| 673 |
setup_file_entity_exclude_field('wpcore'); |
| 674 |
|
| 675 |
reportbox_index = $('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output #updraft_report_cell .updraft_reportbox').length + 2; |
| 676 |
|
| 677 |
$('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output #updraft_include_more_paths input.updraft_include_more_path').each(function(i, input) { |
| 678 |
var mp_index = $(input).data(mp_index); |
| 679 |
if (mp_index > updraftplus_morefiles_lastind) { updraftplus_morefiles_lastind = mp_index; } |
| 680 |
}); |
| 681 |
|
| 682 |
$('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output input[type="submit"]').removeClass().addClass('btn btn-primary-outline'); |
| 683 |
|
| 684 |
// Update the WebDAV URL setting as the user edits |
| 685 |
$('#updraftcentral_dashboard_existingsites .updraft_site_settings_output .updraft_webdav_settings').on("change keyup paste", function() { |
| 686 |
|
| 687 |
var updraft_webdav_settings = []; |
| 688 |
var instance_id = ""; |
| 689 |
$('.updraft_webdav_settings').each(function(index, item) { |
| 690 |
|
| 691 |
var id = $(item).attr('id'); |
| 692 |
|
| 693 |
// The first part of the "if" is to handle the old options format and can be removed in future |
| 694 |
if (id && 'updraft_webdav_settings_' == id.substring(0, 24)) { |
| 695 |
var which_one = id.substring(24); |
| 696 |
updraft_webdav_settings[which_one] = this.value; |
| 697 |
} else if (id && 'updraft_webdav_' == id.substring(0, 15)) { |
| 698 |
var which_one = id.substring(15); |
| 699 |
id_split = which_one.split('_'); |
| 700 |
which_one = id_split[0]; |
| 701 |
instance_id = id_split[1]; |
| 702 |
updraft_webdav_settings[which_one] = this.value; |
| 703 |
} |
| 704 |
|
| 705 |
}); |
| 706 |
|
| 707 |
var updraft_webdav_url = ""; |
| 708 |
var host = "@"; |
| 709 |
var slash = "/"; |
| 710 |
var colon = ":"; |
| 711 |
var colon_port = ":"; |
| 712 |
|
| 713 |
if (updraft_webdav_settings['host'].indexOf("@") >= 0 || "" === updraft_webdav_settings['host']) { |
| 714 |
host = ""; |
| 715 |
} |
| 716 |
|
| 717 |
if (updraft_webdav_settings['host'].indexOf("/") >= 0 ) { |
| 718 |
$('#updraft_webdav_host_error').show(); |
| 719 |
} else { |
| 720 |
$('#updraft_webdav_host_error').hide(); |
| 721 |
} |
| 722 |
|
| 723 |
if (updraft_webdav_settings['path'].indexOf("/") == 0 || "" === updraft_webdav_settings['path']) { |
| 724 |
slash = ""; |
| 725 |
} |
| 726 |
|
| 727 |
if ("" === updraft_webdav_settings['user'] || "" === updraft_webdav_settings['pass']) { |
| 728 |
colon = ""; |
| 729 |
} |
| 730 |
|
| 731 |
if ("" === updraft_webdav_settings['host'] || "" === updraft_webdav_settings['port']) { |
| 732 |
colon_port = ""; |
| 733 |
} |
| 734 |
|
| 735 |
updraft_webdav_url = updraft_webdav_settings['webdav'] + updraft_webdav_settings['user'] + colon + updraft_webdav_settings['pass'] + host + encodeURIComponent(updraft_webdav_settings['host']) + colon_port + updraft_webdav_settings['port'] + slash + updraft_webdav_settings['path']; |
| 736 |
|
| 737 |
// The first part of the "if" is to handle the old options format and can be removed in future |
| 738 |
if ("" == instance_id) { |
| 739 |
$('#updraftcentral_dashboard .updraft_site_settings_output #updraft_webdav_settings_url').val(updraft_webdav_url); |
| 740 |
} else { |
| 741 |
$('#updraftcentral_dashboard .updraft_site_settings_output #updraft_webdav_url_' + instance_id).val(updraft_webdav_url); |
| 742 |
} |
| 743 |
|
| 744 |
}); |
| 745 |
|
| 746 |
} |
| 747 |
}); |
| 748 |
} |
| 749 |
|
| 750 |
var updraft_extra_dbs = 0; |
| 751 |
/** |
| 752 |
* Add a box for configuring backing of an extra database |
| 753 |
* |
| 754 |
* @param {string} host - The hostname of the MySQL database to be backed up |
| 755 |
* @param {string} user - The MySQL username |
| 756 |
* @param {string} name - The name of the MySQL database |
| 757 |
* @param {string} pass - The MySQL password |
| 758 |
* @param {string} prefix - Only tables prefixed with this string will be backed up. Pass an empty string to back them all up. |
| 759 |
* |
| 760 |
* @return {void} |
| 761 |
*/ |
| 762 |
function extradbs_add(host, user, name, pass, prefix) { |
| 763 |
updraft_extra_dbs++; |
| 764 |
$(template_replace('updraftplus-settings-extra-db', { |
| 765 |
updraft_extra_dbs: updraft_extra_dbs, |
| 766 |
remove: udclion.updraftplus.remove, |
| 767 |
backup_external_database: udclion.updraftplus.backup_external_database, |
| 768 |
host: udclion.updraftplus.host, |
| 769 |
database: udclion.updraftplus.database, |
| 770 |
username: udclion.updraftplus.username, |
| 771 |
password: udclion.updraftplus.password, |
| 772 |
table_prefix: udclion.updraftplus.table_prefix, |
| 773 |
backup_tables_with_prefixes: udclion.updraftplus.backup_tables_with_prefixes, |
| 774 |
test_connection: udclion.updraftplus.test_connection |
| 775 |
}, { |
| 776 |
host_attr: host, |
| 777 |
user_attr: user, |
| 778 |
name_attr: name, |
| 779 |
pass_attr: pass, |
| 780 |
prefix_attr: prefix |
| 781 |
})).appendTo($('#updraft_backupextradbs')).fadeIn(); |
| 782 |
} |
| 783 |
|
| 784 |
/** |
| 785 |
* Registers listeners that occur on all tabs. |
| 786 |
* |
| 787 |
* @return {void} |
| 788 |
*/ |
| 789 |
function register_global_listeners() { |
| 790 |
UpdraftCentral.register_row_clicker('.row_backupnow, .updraftcentral_site_backup_now', function($site_row) { |
| 791 |
backup_now($site_row); |
| 792 |
}); |
| 793 |
|
| 794 |
UpdraftCentral.register_modal_listener('#backupnow_includefiles_showmoreoptions', function(e) { |
| 795 |
e.preventDefault(); |
| 796 |
$('#updraftcentral_modal #backupnow_includefiles_moreoptions').slideToggle(); |
| 797 |
}); |
| 798 |
|
| 799 |
UpdraftCentral.register_modal_listener('#backupnow_database_showmoreoptions', function(e) { |
| 800 |
e.preventDefault(); |
| 801 |
$('#updraftcentral_modal #backupnow_database_moreoptions').slideToggle(); |
| 802 |
}); |
| 803 |
} |
| 804 |
|
| 805 |
if ('notices' != UpdraftCentral.get_dashboard_mode()) { register_global_listeners(); } |
| 806 |
|
| 807 |
// Register the row clickers for all tabs |
| 808 |
$('#updraftcentral_dashboard_existingsites').on('updraftcentral_dashboard_mode_set', function(event, data) { |
| 809 |
|
| 810 |
// The 'upgrade' tab has no sites rows visible |
| 811 |
if (data && data.hasOwnProperty('new_mode') && 'notices' == data.new_mode) { return; } |
| 812 |
|
| 813 |
register_global_listeners(); |
| 814 |
|
| 815 |
}); |
| 816 |
|
| 817 |
// Register the row clickers for this tab |
| 818 |
$('#updraftcentral_dashboard_existingsites').on('updraftcentral_dashboard_mode_set_backups', function() { |
| 819 |
|
| 820 |
UpdraftCentral.register_row_clicker('.updraftcentral_row_extracontents .updraft_site_settings_output #updraft_backupextradb_another', function() { |
| 821 |
extradbs_add('', '', '', '', ''); |
| 822 |
}); |
| 823 |
|
| 824 |
UpdraftCentral.register_row_clicker('.updraftcentral_row_extracontents .updraft_site_settings_output #updraft_backupextradbs .updraft_backupextradbs_row_delete', function() { |
| 825 |
$(this).parents('.updraft_backupextradbs_row').fadeOut('medium', function() { |
| 826 |
$(this).remove(); |
| 827 |
}); |
| 828 |
}); |
| 829 |
|
| 830 |
UpdraftCentral.register_row_clicker('.updraftcentral_row_extracontents .updraft_site_settings_output #updraft_backupextradbs .updraft_backupextradbs_row_testconnection', function() { |
| 831 |
var $row = $(this).closest('.updraft_backupextradbs_row'); |
| 832 |
$row.find('.updraft_backupextradbs_testresultarea').html('<p><em>'+udclion.updraftplus.testing+'</em></p>'); |
| 833 |
|
| 834 |
var data = { |
| 835 |
row: $row.attr('id'), |
| 836 |
host: $row.find('.extradb_host').val(), |
| 837 |
user: $row.find('.extradb_user').val(), |
| 838 |
pass: $row.find('.extradb_pass').val(), |
| 839 |
name: $row.find('.extradb_name').val(), |
| 840 |
prefix: $row.find('.extradb_prefix').val() |
| 841 |
}; |
| 842 |
|
| 843 |
UpdraftCentral.send_site_rpc('updraftplus.extradb_testconnection', data, UpdraftCentral.$site_row, function(response, code, error_code) { |
| 844 |
if ('ok' == code && response) { |
| 845 |
$row.find('.updraft_backupextradbs_testresultarea').html(UpdraftCentral_Library.sanitize_html(response.data.m)); |
| 846 |
} |
| 847 |
}, $row); |
| 848 |
}); |
| 849 |
|
| 850 |
UpdraftCentral.register_row_clicker('.updraftcentral_row_extracontents .updraft_site_settings_output .updraftplusmethod button.updraft-test-button', function() { |
| 851 |
|
| 852 |
var $method_button = $(this); |
| 853 |
var method = $method_button.data('method'); |
| 854 |
|
| 855 |
updraft_remote_storage_test($method_button, function(response, code, error_code, data) { |
| 856 |
|
| 857 |
if ('sftp' != method) { return false; } |
| 858 |
|
| 859 |
if ('undefined' !== typeof data && data.hasOwnProperty('scp') && data.scp) { |
| 860 |
UpdraftCentral_Library.dialog.alert('<h2>'+sprintf(udclion.updraftplus.settings_test_result, 'SCP')+'</h2> '+response.data.output); |
| 861 |
} else { |
| 862 |
UpdraftCentral_Library.dialog.alert('<h2>'+sprintf(udclion.updraftplus.settings_test_result, 'SFTP')+'</h2> '+response.data.output); |
| 863 |
} |
| 864 |
|
| 865 |
return true; |
| 866 |
|
| 867 |
}); |
| 868 |
}); |
| 869 |
|
| 870 |
UpdraftCentral.register_row_clicker('.updraftcentral_row_extracontents .updraft_site_settings_output #updraftplus-settings-save', function($site_row, site_id) { |
| 871 |
|
| 872 |
// Gather data |
| 873 |
var form_data = $(settings_css_prefix+' input, '+settings_css_prefix+' textarea, '+settings_css_prefix+' select').serialize(); |
| 874 |
|
| 875 |
// include unchecked checkboxes. user filter to only include unchecked boxes. |
| 876 |
$.each($(settings_css_prefix+' input[type=checkbox]') |
| 877 |
.filter(function(idx) { |
| 878 |
return $(this).prop('checked') == false |
| 879 |
}), |
| 880 |
function(idx, el) { |
| 881 |
// attach matched element names to the form_data with chosen value. |
| 882 |
var empty_val = '0'; |
| 883 |
form_data += '&' + $(el).attr('name') + '=' + empty_val; |
| 884 |
} |
| 885 |
); |
| 886 |
|
| 887 |
spin_this = $(this).closest('td'); |
| 888 |
|
| 889 |
form_data += '&updraftplus_version=' + updraftplus_version; |
| 890 |
|
| 891 |
UpdraftCentral.send_site_rpc('updraftplus.save_settings', form_data, $site_row, function(response, code, error_code) { |
| 892 |
|
| 893 |
if ('ok' === code) { |
| 894 |
|
| 895 |
// If backup dir is not writable, change the text, and grey out the 'Backup Now' button |
| 896 |
var backup_dir_writable = response.data.backup_dir.writable; |
| 897 |
var backup_dir_message = response.data.backup_dir.message; |
| 898 |
var backup_button_title = response.data.backup_dir.button_title; |
| 899 |
|
| 900 |
if (backup_dir_writable == false) { |
| 901 |
// $('#updraft-backupnow-button').attr('disabled', 'disabled'); |
| 902 |
// $('#updraft-backupnow-button').attr('title', backup_button_title); |
| 903 |
$(settings_css_prefix+'#updraft_writable_mess').html(backup_dir_message); |
| 904 |
$(settings_css_prefix+'.backupdirrow').show(); |
| 905 |
} else { |
| 906 |
// $('#updraft-backupnow-button').removeAttr('disabled'); |
| 907 |
// $('#updraft-backupnow-button').removeAttr('title'); |
| 908 |
$(settings_css_prefix+'.backupdirrow').hide(); |
| 909 |
} |
| 910 |
|
| 911 |
var site_url = $site_row.data('site_url'); |
| 912 |
|
| 913 |
// Get rid of any existing results-of-saving-settings boxes |
| 914 |
$('#updraftcentral_notice_container .updraftplus_saved_settings').closest('.updraftcentral_notice').remove(); |
| 915 |
|
| 916 |
var $new_notice = add_dashboard_notice('<h2>'+udclion.updraftplus.settings_saved+' - '+site_url+'</h2><div class="updraftplus_saved_settings" data-site_id="'+site_id+'">'+response.data.messages+'</div>', 'notice', false); |
| 917 |
|
| 918 |
$('html, body').animate({ |
| 919 |
scrollTop: $new_notice.offset().top |
| 920 |
}, 1000); |
| 921 |
} |
| 922 |
|
| 923 |
}, spin_this); |
| 924 |
|
| 925 |
}); |
| 926 |
|
| 927 |
UpdraftCentral.register_row_clicker(settings_css_sub_prefix+'.backupdirrow a.updraft_backup_dir_reset', function() { |
| 928 |
$(settings_css_prefix+'#updraft_dir').val('updraft'); |
| 929 |
}); |
| 930 |
|
| 931 |
UpdraftCentral.register_row_clicker('.updraftcentral_row_extracontents .updraft_site_settings_output .enableexpertmode', function() { |
| 932 |
$('.updraftcentral_row_extracontents .updraft_site_settings_output .expertmode').fadeIn(); |
| 933 |
$('.updraftcentral_row_extracontents .updraft_site_settings_output .enableexpertmode').off('click'); |
| 934 |
}); |
| 935 |
|
| 936 |
UpdraftCentral.register_row_clicker(settings_css_sub_prefix+' a.updraft_authlink', function($site_row) { |
| 937 |
var href = $(this).attr('href'); |
| 938 |
if ('undefined' === typeof href) { return; } |
| 939 |
var spinner_where = $(this).closest('td'); |
| 940 |
UpdraftCentral_Library.open_browser_at($site_row, { module: 'direct_url', url: href }, spinner_where); |
| 941 |
}); |
| 942 |
|
| 943 |
UpdraftCentral.register_row_clicker('.updraftcentral_row_extracontents .updraft_site_settings_output .updraft_include_entity', function() { |
| 944 |
var has_exclude_field = $(this).data('toggle_exclude_field'); |
| 945 |
if (has_exclude_field) { |
| 946 |
setup_file_entity_exclude_field(has_exclude_field, false); |
| 947 |
} |
| 948 |
}, false, 'change'); |
| 949 |
|
| 950 |
UpdraftCentral.register_row_clicker('.updraft_existing_backups_output .updraft_existingbackup_date', function($site_row) { |
| 951 |
var data = $(this).data('rawbackup'); |
| 952 |
if (data != null && data != '') { |
| 953 |
UpdraftCentral.open_modal(udclion.updraftplus.raw, data, true, false); |
| 954 |
} |
| 955 |
}, false, 'dblclick'); |
| 956 |
|
| 957 |
UpdraftCentral.register_row_clicker('.updraft_existing_backups_output .choose-components-button', function($site_row) { |
| 958 |
var this_button = this; |
| 959 |
var entities = $(this_button).data('entities'); |
| 960 |
var spinner_where = $(this_button).closest('td'); |
| 961 |
if (entities) { |
| 962 |
|
| 963 |
// Alert the user of possible consequences of restoring + other relevant info, before proceeding. |
| 964 |
UpdraftCentral_Library.dialog.confirm('<h2>'+udclion.updraftplus.restore_backup+'</h2>'+udclion.updraftplus.pre_restore_message, function(go_ahead) { |
| 965 |
if (!go_ahead) { return; } |
| 966 |
UpdraftCentral_Library.open_browser_at($site_row, { module: 'updraftplus', action: 'initiate_restore', data: { |
| 967 |
entities: entities, |
| 968 |
backup_timestamp: $(this_button).data('backup_timestamp'), |
| 969 |
showdata: $(this_button).data('showdata') |
| 970 |
} }, spinner_where); |
| 971 |
}); |
| 972 |
|
| 973 |
} |
| 974 |
}); |
| 975 |
|
| 976 |
UpdraftCentral.register_row_clicker('.updraft_existing_backups_output .updraft_download_button', function($site_row) { |
| 977 |
|
| 978 |
var site_id = $site_row.data('site_id'); |
| 979 |
var backup_timestamp = $(this).data('backup_timestamp'); |
| 980 |
var what = $(this).data('what'); |
| 981 |
var set_contents = $(this).data('set_contents'); |
| 982 |
var pretty_date = $(this).data('prettydate'); |
| 983 |
var async = true; |
| 984 |
|
| 985 |
var spinner_where = $(this).closest('td'); |
| 986 |
|
| 987 |
updraft_downloader(site_id, backup_timestamp, what, set_contents, pretty_date, async, spinner_where); |
| 988 |
|
| 989 |
}); |
| 990 |
|
| 991 |
UpdraftCentral.register_row_clicker('.updraft_existing_backups_output .updraft-delete-link', function($site_row) { |
| 992 |
var hasremote = $(this).data('hasremote').toString(); |
| 993 |
hasremote = (hasremote === '0') ? false : true; |
| 994 |
var nonce = $(this).data('nonce').toString(); |
| 995 |
var key = $(this).data('key').toString(); |
| 996 |
if (nonce) { |
| 997 |
updraft_delete(key, nonce, hasremote); |
| 998 |
} else { |
| 999 |
console.log("UDCentral: UpdraftPlus: A delete link was clicked, but the backup ID could not be found"); |
| 1000 |
} |
| 1001 |
}); |
| 1002 |
|
| 1003 |
UpdraftCentral.register_event_handler('click', '.delete-backup-container input.delete_backup_item', function($site_row) { |
| 1004 |
var checked = $('.delete-backup-container input.delete_backup_item:checked').length; |
| 1005 |
|
| 1006 |
if (0 < checked) { |
| 1007 |
$('button#btn-backup-bulk-delete').removeClass('btn-secondary').addClass('btn-primary'); |
| 1008 |
} else { |
| 1009 |
$('button#btn-backup-bulk-delete').removeClass('btn-primary').addClass('btn-secondary'); |
| 1010 |
} |
| 1011 |
}); |
| 1012 |
|
| 1013 |
UpdraftCentral.register_row_clicker('.updraft_existing_backups_output button#btn-backup-bulk-delete', function($site_row) { |
| 1014 |
var keys = [], |
| 1015 |
hasremote = false, |
| 1016 |
nonce; |
| 1017 |
|
| 1018 |
$('.delete-backup-container input.delete_backup_item').each(function() { |
| 1019 |
if ($(this).is(':checked')) { |
| 1020 |
var delete_link = $(this).closest('tr.updraft_existing_backups_row').find('a.updraft-delete-link'); |
| 1021 |
var key = delete_link.data('key'); |
| 1022 |
|
| 1023 |
if ('undefined' !== typeof key && key) { |
| 1024 |
keys.push(key.toString()); |
| 1025 |
nonce = delete_link.data('nonce'); |
| 1026 |
|
| 1027 |
if (!hasremote) { |
| 1028 |
hasremote = ('undefined' === typeof delete_link.data('hasremote') || delete_link.data('hasremote') === '0') ? false : true; |
| 1029 |
} |
| 1030 |
} |
| 1031 |
} |
| 1032 |
}); |
| 1033 |
|
| 1034 |
if (keys.length) { |
| 1035 |
updraft_delete(keys.join(), nonce, hasremote); |
| 1036 |
} else { |
| 1037 |
console.log("UDCentral: UpdraftPlus: The bulk delete button was clicked, but none of the backup IDs could be found"); |
| 1038 |
} |
| 1039 |
}); |
| 1040 |
|
| 1041 |
UpdraftCentral.register_row_clicker('.updraft_existing_backups_output a.updraft_diskspaceused_update', function($site_row) { |
| 1042 |
var spin_this = this.closest('ul'); |
| 1043 |
UpdraftCentral.send_site_rpc('updraftplus.get_fragment', { fragment: 'disk_usage', data: 'updraft' } , $site_row, function(response, code, error_code) { |
| 1044 |
if ('ok' == code && response) { |
| 1045 |
$site_row.find('.updraft_diskspaceused').html(UpdraftCentral_Library.sanitize_html(response.data.output)); |
| 1046 |
} |
| 1047 |
}, spin_this); |
| 1048 |
}); |
| 1049 |
|
| 1050 |
UpdraftCentral.register_row_clicker('.updraft_existing_backups_output a.updraft_rescan_local', function($site_row) { |
| 1051 |
var spin_this = this.closest('ul'); |
| 1052 |
$site_row.find('.updraft_existing_backups').html('<div class="rescanning">'+udclion.updraftplus.rescanning+'</div>'); |
| 1053 |
UpdraftCentral.send_site_rpc('updraftplus.rescan', 'rescan' , $site_row, function(response, code, error_code) { |
| 1054 |
if ('ok' == code && response) { |
| 1055 |
$site_row.find('.updraft_existing_backups').html(response.data.t); |
| 1056 |
$site_row.find('.updraft_existing_backups_output h2').html(response.data.n); |
| 1057 |
|
| 1058 |
insert_bulk_delete($site_row); |
| 1059 |
} |
| 1060 |
}, spin_this); |
| 1061 |
}); |
| 1062 |
|
| 1063 |
UpdraftCentral.register_row_clicker('.updraft_existing_backups_output a.updraft_rescan_remote', function($site_row) { |
| 1064 |
var spin_this = this.closest('ul'); |
| 1065 |
$site_row.find('.updraft_existing_backups').html('<div class="rescanning">'+udclion.updraftplus.rescanningremote+'</div>'); |
| 1066 |
UpdraftCentral.send_site_rpc('updraftplus.rescan', 'remotescan' , $site_row, function(response, code, error_code) { |
| 1067 |
if ('ok' == code && response) { |
| 1068 |
$site_row.find('.updraft_existing_backups').html(response.data.t); |
| 1069 |
$site_row.find('.updraft_existing_backups_output h2').html(response.data.n); |
| 1070 |
|
| 1071 |
insert_bulk_delete($site_row); |
| 1072 |
} |
| 1073 |
}, spin_this, 90); |
| 1074 |
}); |
| 1075 |
|
| 1076 |
UpdraftCentral.register_row_clicker('.updraftcentral_site_backups_manage', function($site_row) { |
| 1077 |
updraft_get_existing_backups_panel($site_row); |
| 1078 |
}, true); |
| 1079 |
|
| 1080 |
UpdraftCentral.register_row_clicker('.updraftcentral_site_backup_settings', function($site_row) { |
| 1081 |
updraft_get_existing_backup_settings($site_row); |
| 1082 |
}, true); |
| 1083 |
|
| 1084 |
UpdraftCentral.register_row_clicker('.updraft_site_settings_output select.updraft_interval, .updraft_site_settings_output select.updraft_interval_database', function() { |
| 1085 |
updraft_check_same_times(); |
| 1086 |
}, false, 'change'); |
| 1087 |
|
| 1088 |
// Remote method authentication click |
| 1089 |
UpdraftCentral.register_row_clicker('.updraft_authlink', function($site_row) { |
| 1090 |
var spin_this = this.closest('ul'); |
| 1091 |
var data = { |
| 1092 |
remote_method: $(this).data('remote_method'), |
| 1093 |
instance_id: $(this).data('instance_id') |
| 1094 |
} |
| 1095 |
|
| 1096 |
UpdraftCentral.send_site_rpc('updraftplus.auth_remote_method', data, $site_row, function(response, code, error_code) { |
| 1097 |
if ('ok' == code && false !== response) { |
| 1098 |
var resp = response.data; |
| 1099 |
if ('error' == resp.result) { |
| 1100 |
UpdraftCentral_Library.dialog.alert('<h2>'+udclion.error+'</h2>'+resp.message); |
| 1101 |
} else if ('success' == resp.result) { |
| 1102 |
updraft_get_existing_backup_settings($site_row); |
| 1103 |
} |
| 1104 |
} |
| 1105 |
}, spin_this); |
| 1106 |
|
| 1107 |
}, true); |
| 1108 |
|
| 1109 |
// Remote method deauthentication click |
| 1110 |
UpdraftCentral.register_row_clicker('.updraft_deauthlink', function($site_row) { |
| 1111 |
var spin_this = this.closest('ul'); |
| 1112 |
var data = { |
| 1113 |
remote_method: $(this).data('remote_method'), |
| 1114 |
instance_id: $(this).data('instance_id') |
| 1115 |
} |
| 1116 |
|
| 1117 |
UpdraftCentral.send_site_rpc('updraftplus.deauth_remote_method', data, $site_row, function(response, code, error_code) { |
| 1118 |
if ('ok' == code && false !== response) { |
| 1119 |
var resp = response.data; |
| 1120 |
if ('error' == resp.result) { |
| 1121 |
UpdraftCentral_Library.dialog.alert('<h2>'+udclion.error+'</h2>'+resp.message); |
| 1122 |
} else if ('success' == resp.result) { |
| 1123 |
updraft_get_existing_backup_settings($site_row); |
| 1124 |
} |
| 1125 |
} |
| 1126 |
}, spin_this); |
| 1127 |
|
| 1128 |
}, true); |
| 1129 |
|
| 1130 |
UpdraftCentral.register_row_clicker('.updraft_site_settings_output #updraft_retain_db_addnew', function() { |
| 1131 |
add_rule('db', 12, 604800, 1, 604800); |
| 1132 |
}); |
| 1133 |
|
| 1134 |
UpdraftCentral.register_row_clicker('.updraft_site_settings_output #updraft_retain_files_addnew', function() { |
| 1135 |
add_rule('files', 12, 604800, 1, 604800); |
| 1136 |
}); |
| 1137 |
|
| 1138 |
UpdraftCentral.register_row_clicker('.updraft_site_settings_output .updraft_retain_rules_delete, .updraft_site_settings_output .updraft_retain_rules_delete', function() { |
| 1139 |
$(this).parent('.updraft_retain_rules').slideUp(function() { |
| 1140 |
$(this).remove(); |
| 1141 |
}); |
| 1142 |
}); |
| 1143 |
|
| 1144 |
UpdraftCentral.register_row_clicker('.updraftcentral_row_extracontents .updraft_site_settings_output #updraft_report_cell .updraft_reportbox .updraft_reportbox_delete', function() { |
| 1145 |
$(this).closest('.updraft_reportbox').fadeOut('medium', function() { |
| 1146 |
$(this).remove(); |
| 1147 |
}); |
| 1148 |
}); |
| 1149 |
|
| 1150 |
UpdraftCentral.register_row_clicker('.updraftcentral_row_extracontents .updraft_site_settings_output #updraft_report_cell .updraft_report_another', function() { |
| 1151 |
|
| 1152 |
$('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output #updraft_report_cell .updraft_report_another_p').before(template_replace('updraftplus-settings-report-email', { |
| 1153 |
index: reportbox_index, |
| 1154 |
send_only_on_warnings: udclion.updraftplus.send_only_on_warnings, |
| 1155 |
whole_backup: udclion.updraftplus.whole_backup, |
| 1156 |
email_size_limits: udclion.updraftplus.email_size_limits |
| 1157 |
})); |
| 1158 |
$('#updraft_reportbox_'+reportbox_index).fadeIn(); |
| 1159 |
reportbox_index++; |
| 1160 |
|
| 1161 |
}); |
| 1162 |
|
| 1163 |
UpdraftCentral.register_row_clicker('.updraftcentral_row_extracontents .updraft_site_settings_output #updraft_include_more', function() { |
| 1164 |
if ($('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output #updraft_include_more').is(':checked')) { |
| 1165 |
$('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output #updraft_include_more_options').slideDown(); |
| 1166 |
} else { |
| 1167 |
$('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output #updraft_include_more_options').slideUp(); |
| 1168 |
} |
| 1169 |
}, false, 'change'); |
| 1170 |
|
| 1171 |
UpdraftCentral.register_row_clicker('.updraftcentral_row_extracontents .updraft_site_settings_output #updraft_include_more_paths_another', function() { |
| 1172 |
updraftplus_morefiles_lastind++; |
| 1173 |
$(template_replace('updraftplus-settings-more-paths', { |
| 1174 |
index: updraftplus_morefiles_lastind, |
| 1175 |
enter_the_directory: udclion.updraftplus.enter_the_directory, |
| 1176 |
remove: udclion.updraftplus.remove |
| 1177 |
})).appendTo($('.updraftcentral_row_extracontents .updraft_site_settings_output #updraft_include_more_paths')).slideDown(); |
| 1178 |
}); |
| 1179 |
|
| 1180 |
UpdraftCentral.register_row_clicker('.updraftcentral_row_extracontents .updraft_site_settings_output #updraft_include_more_options .updraftplus-morefiles-row-delete', function() { |
| 1181 |
var prow = $(this).closest('.updraftplus-morefiles-row'); |
| 1182 |
$(prow).slideUp('medium', function() { |
| 1183 |
$(this).remove(); |
| 1184 |
}); |
| 1185 |
}); |
| 1186 |
|
| 1187 |
UpdraftCentral.register_row_clicker('.updraftcentral_row_extracontents .updraft_site_settings_output .updraft_servicecheckbox', function() { |
| 1188 |
var sclass = $(this).attr('id'); |
| 1189 |
if ('updraft_servicecheckbox_' == sclass.substring(0,24)) { |
| 1190 |
var serv = sclass.substring(24); |
| 1191 |
if (null != serv && '' != serv) { |
| 1192 |
if ($(this).is(':checked')) { |
| 1193 |
remote_storage_tabs_any_checked++; |
| 1194 |
$('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output .remote-tab-'+serv).fadeIn(); |
| 1195 |
updraft_remote_storage_tab_activation(serv); |
| 1196 |
} else { |
| 1197 |
remote_storage_tabs_any_checked--; |
| 1198 |
$('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output .remote-tab-'+serv).hide(); |
| 1199 |
// Check if this was the active tab, if yes, switch to another |
| 1200 |
if ($('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output .remote-tab-'+serv).data('active') == true) { |
| 1201 |
updraft_remote_storage_tab_activation($('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output .remote-tab:visible').last().attr('name')); |
| 1202 |
} |
| 1203 |
} |
| 1204 |
} |
| 1205 |
} |
| 1206 |
|
| 1207 |
if (remote_storage_tabs_any_checked <= 0) { |
| 1208 |
$('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output .updraftplusmethod.none').fadeIn(); |
| 1209 |
} else { |
| 1210 |
$('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output .updraftplusmethod.none').hide(); |
| 1211 |
} |
| 1212 |
}, false, 'change'); |
| 1213 |
|
| 1214 |
// Changing tabs for the remote storage methods |
| 1215 |
UpdraftCentral.register_row_clicker('.updraftcentral_row_extracontents .updraft_site_settings_output .remote-tab', function() { |
| 1216 |
var the_method = $(this).attr('name'); |
| 1217 |
updraft_remote_storage_tab_activation(the_method); |
| 1218 |
}); |
| 1219 |
|
| 1220 |
// For the free version, where only one remote storage choice can be made at a time |
| 1221 |
UpdraftCentral.register_row_clicker('.updraftcentral_row_extracontents .updraft_site_settings_output .updraft_servicecheckbox:not(.multi)', function() { |
| 1222 |
var svalue = $(this).attr('value'); |
| 1223 |
|
| 1224 |
if ($(this).is(':not(:checked)')) { |
| 1225 |
$('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output .updraftplusmethod.'+svalue).hide(); |
| 1226 |
$('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output .updraftplusmethod.none').fadeIn(); |
| 1227 |
} else { |
| 1228 |
$('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output .updraft_servicecheckbox').not(this).prop('checked', false); |
| 1229 |
} |
| 1230 |
}, false, 'change'); |
| 1231 |
|
| 1232 |
// UpdraftVault settings handling |
| 1233 |
UpdraftCentral.register_row_clicker(settings_css_sub_prefix+'#updraftvault_settings_cell .updraftvault_backtostart', function() { |
| 1234 |
$(settings_css_prefix+'#updraftvault_settings_showoptions').slideUp(); |
| 1235 |
$(settings_css_prefix+'#updraftvault_settings_connect').slideUp(); |
| 1236 |
$(settings_css_prefix+'#updraftvault_settings_connected').slideUp(); |
| 1237 |
$(settings_css_prefix+'#updraftvault_settings_default').slideDown(); |
| 1238 |
}); |
| 1239 |
|
| 1240 |
// Prevent default event when pressing return in the form |
| 1241 |
UpdraftCentral.register_row_clicker(settings_css_sub_prefix+'#updraftvault_settings_connect input', function($site_row, site_id, event) { |
| 1242 |
if (event.which == 13) { |
| 1243 |
$(settings_css_prefix+'#updraftvault_connect_go').click(); |
| 1244 |
event.preventDefault(); |
| 1245 |
} |
| 1246 |
}, false, 'keypress'); |
| 1247 |
|
| 1248 |
UpdraftCentral.register_row_clicker(settings_css_sub_prefix+'#updraftvault_settings_cell #updraftvault_recountquota', function() { |
| 1249 |
$(settings_css_prefix+'#updraftvault_recountquota').html(udclion.updraftplus.counting); |
| 1250 |
UpdraftCentral.send_site_rpc('updraftplus.vault_recountquota', { instance_id: $('#updraftvault_settings_connect').data('instance_id') }, UpdraftCentral.$site_row, function(response, code, error_code) { |
| 1251 |
$(settings_css_prefix+'#updraftvault_recountquota').html(udclion.updraftplus.update_quota_count); |
| 1252 |
if ('ok' == code && response) { |
| 1253 |
if (response.hasOwnProperty('data') && response.data.hasOwnProperty('html')) { |
| 1254 |
$(settings_css_prefix+'#updraftvault_settings_connected').html(response.data.html); |
| 1255 |
if (response.data.hasOwnProperty('connected')) { |
| 1256 |
if (response.data.connected) { |
| 1257 |
$(settings_css_prefix+'#updraftvault_settings_default').hide(); |
| 1258 |
$(settings_css_prefix+'#updraftvault_settings_connected').show(); |
| 1259 |
} else { |
| 1260 |
$(settings_css_prefix+'#updraftvault_settings_connected').hide(); |
| 1261 |
$(settings_css_prefix+'#updraftvault_settings_default').show(); |
| 1262 |
} |
| 1263 |
} |
| 1264 |
} |
| 1265 |
} |
| 1266 |
}); |
| 1267 |
}); |
| 1268 |
|
| 1269 |
UpdraftCentral.register_row_clicker(settings_css_sub_prefix+'#updraftvault_settings_cell #updraftvault_disconnect', function() { |
| 1270 |
$(settings_css_prefix+'#updraftvault_disconnect').html(udclion.updraftplus.disconnecting); |
| 1271 |
UpdraftCentral.send_site_rpc('updraftplus.vault_disconnect', { instance_id: $('#updraftvault_settings_connect').data('instance_id') }, UpdraftCentral.$site_row, function(response, code, error_code) { |
| 1272 |
$(settings_css_prefix+'#updraftvault_disconnect').html(udclion.updraftplus.disconnect); |
| 1273 |
|
| 1274 |
if ('ok' == code && response.hasOwnProperty('data')) { |
| 1275 |
|
| 1276 |
$(settings_css_prefix+'#updraftvault_disconnect').html(udclion.updraftplus.disconnect); |
| 1277 |
|
| 1278 |
if (response.data.hasOwnProperty('html')) { |
| 1279 |
$(settings_css_prefix+'#updraftvault_settings_connected').html(response.data.html).slideUp(); |
| 1280 |
$(settings_css_prefix+'#updraftvault_settings_default').slideDown(); |
| 1281 |
} |
| 1282 |
} |
| 1283 |
}); |
| 1284 |
}); |
| 1285 |
|
| 1286 |
UpdraftCentral.register_row_clicker(settings_css_sub_prefix+'#updraftvault_connect', function() { |
| 1287 |
$(settings_css_prefix+'#updraftvault_settings_default').slideUp(); |
| 1288 |
$(settings_css_prefix+'#updraftvault_settings_connect').slideDown(); |
| 1289 |
}); |
| 1290 |
|
| 1291 |
UpdraftCentral.register_row_clicker(settings_css_sub_prefix+'#updraftvault_showoptions', function() { |
| 1292 |
$(settings_css_prefix+'#updraftvault_settings_default').slideUp(); |
| 1293 |
$(settings_css_prefix+'#updraftvault_settings_showoptions').slideDown(); |
| 1294 |
}); |
| 1295 |
|
| 1296 |
UpdraftCentral.register_row_clicker(settings_css_sub_prefix+'#updraft_s3_newapiuser', function($site_row) { |
| 1297 |
var spin_this = this.closest('td'); |
| 1298 |
UpdraftCentral.send_site_rpc('updraftplus.get_fragment', { fragment: 's3_new_api_user_form', data: null } , $site_row, function(response, code, error_code) { |
| 1299 |
if ('ok' == code && response) { |
| 1300 |
UpdraftCentral.open_modal(udclion.updraftplus.create_new_iam_user_and_bucket, response.data.output, function() { |
| 1301 |
|
| 1302 |
// $('#updraftcentral_modal #updraft-s3newapiuser-results').html('<p style="color:green">'+udclion.updraftplus.trying+'</p>'); |
| 1303 |
$('#updraftcentral_modal #updraft-s3newapiuser-results').empty(); |
| 1304 |
|
| 1305 |
var data = { |
| 1306 |
adminaccesskey: $('#updraftcentral_modal #updraft_s3newapiuser_adminaccesskey').val(), |
| 1307 |
adminsecret: $('#updraftcentral_modal #updraft_s3newapiuser_adminsecret').val(), |
| 1308 |
newuser: $('#updraftcentral_modal #updraft_s3newapiuser_newuser').val(), |
| 1309 |
bucket: $('#updraftcentral_modal #updraft_s3newapiuser_bucket').val(), |
| 1310 |
region: $('#updraftcentral_modal #updraft_s3newapiuser_region').val(), |
| 1311 |
useservercerts: $('#updraftcentral_modal #updraft_ssl_useservercerts').val(), |
| 1312 |
disableverify: $('#updraftcentral_modal #updraft_ssl_disableverify').val(), |
| 1313 |
nossl: $('#updraftcentral_modal #updraft_ssl_nossl').val(), |
| 1314 |
allowdelete: $('#updraftcentral_modal #updraft_s3newapiuser_allowdelete').is(':checked') ? 1 : 0, |
| 1315 |
allowdownload: $('#updraftcentral_modal #updraft_s3newapiuser_allowdownload').is(':checked') ? 1 : 0 |
| 1316 |
}; |
| 1317 |
|
| 1318 |
var spin_this = $('#updraftcentral_modal'); |
| 1319 |
|
| 1320 |
UpdraftCentral.send_site_rpc('updraftplus.s3_newuser', data , $site_row, function(response, code, error_code) { |
| 1321 |
|
| 1322 |
if ('ok' == code && response) { |
| 1323 |
if (response.data.e == 1) { |
| 1324 |
$('#updraftcentral_modal #updraft-s3newapiuser-results').html('<p style="color:red;">'+UpdraftCentral_Library.sanitize_html(response.data.m)+'</p>'); |
| 1325 |
} else if (response.data.e == 0) { |
| 1326 |
$('#updraftcentral_modal #updraft-s3newapiuser-results').html('<p style="color:green;">'+UpdraftCentral_Library.sanitize_html(response.data.m)+'</p>'); |
| 1327 |
$(settings_css_prefix+'#updraft_s3_apikey').val(response.data.k); |
| 1328 |
$(settings_css_prefix+'#updraft_s3_apisecret').val(response.data.s); |
| 1329 |
$(settings_css_prefix+'#updraft_s3_rrs').prop(':checked', response.data.r); |
| 1330 |
$(settings_css_prefix+'#updraft_s3_path').val(response.data.c); |
| 1331 |
|
| 1332 |
// Change link to open dialog to reflect that using IAM user |
| 1333 |
$(settings_css_prefix+'#updraft_s3_newapiuser').html(udclion.updraftplus.now_using_iam); |
| 1334 |
|
| 1335 |
UpdraftCentral.close_modal(); |
| 1336 |
} |
| 1337 |
} |
| 1338 |
|
| 1339 |
}, spin_this); |
| 1340 |
|
| 1341 |
}, udclion.updraftplus.create); |
| 1342 |
} |
| 1343 |
}, spin_this); |
| 1344 |
}); |
| 1345 |
|
| 1346 |
UpdraftCentral.register_row_clicker(settings_css_sub_prefix+'#updraft_cloudfiles_newapiuser', function($site_row) { |
| 1347 |
var spin_this = this.closest('td'); |
| 1348 |
|
| 1349 |
UpdraftCentral.send_site_rpc('updraftplus.get_fragment', { fragment: 'cloudfiles_new_api_user_form', data: null }, $site_row, function(response, code, error_code) { |
| 1350 |
if ('ok' == code) { |
| 1351 |
var html = UpdraftCentral.template_replace('updraftplus-cloudfiles_new_api_user', response.data.output); |
| 1352 |
|
| 1353 |
UpdraftCentral.open_modal(udclion.updraftplus.new_api_user, UpdraftCentral_Library.sanitize_html(html), function() { |
| 1354 |
var $form = $(this).closest('.modal-dialog').find('.form-table'), |
| 1355 |
new_user = { |
| 1356 |
'adminuser': $form.find('.adminuser').val(), |
| 1357 |
'adminapikey': $form.find('.adminapikey').val(), |
| 1358 |
'newuser': $form.find('.newuser').val(), |
| 1359 |
'container': $form.find('.container').val(), |
| 1360 |
'newemail': $form.find('.newemail').val(), |
| 1361 |
'location': $form.find('.location').val(), |
| 1362 |
'region': $form.find('.region').val() |
| 1363 |
}; |
| 1364 |
|
| 1365 |
var spin_this = $('.modal-dialog'); |
| 1366 |
|
| 1367 |
UpdraftCentral.send_site_rpc('updraftplus.cloudfiles_newuser', new_user, $site_row, function(response, code, error_code) { |
| 1368 |
if ('ok' == code) { |
| 1369 |
UpdraftCentral.close_modal(); |
| 1370 |
|
| 1371 |
var user = response.data.u; |
| 1372 |
var key = response.data.k; |
| 1373 |
var container = response.data.c; |
| 1374 |
|
| 1375 |
$site_row.find('#updraft_cloudfiles_user').val(user); |
| 1376 |
$site_row.find('#updraft_cloudfiles_apikey').val(key); |
| 1377 |
$site_row.find('#updraft_cloudfiles_path').val(container); |
| 1378 |
} else if (error_code === "error") { |
| 1379 |
UpdraftCentral_Library.dialog.alert('<h3>'+udclion.error+'</h3>' + response.m); |
| 1380 |
return true; |
| 1381 |
} |
| 1382 |
}, spin_this) |
| 1383 |
}, udclion.updraftplus.create); |
| 1384 |
} |
| 1385 |
}, spin_this) |
| 1386 |
}); |
| 1387 |
|
| 1388 |
UpdraftCentral.register_row_clicker(settings_css_sub_prefix+'#updraftvault_connect_go', function() { |
| 1389 |
$(settings_css_prefix+'#updraftvault_connect_go').html(udclion.updraftplus.connecting); |
| 1390 |
|
| 1391 |
var data = { |
| 1392 |
email: $(settings_css_prefix+'#updraftvault_email').val(), |
| 1393 |
pass: $(settings_css_prefix+'#updraftvault_pass').val(), |
| 1394 |
instance_id: $(settings_css_prefix+'#updraftvault_settings_connect').data('instance_id') |
| 1395 |
} |
| 1396 |
|
| 1397 |
UpdraftCentral.send_site_rpc('updraftplus.vault_connect', data, UpdraftCentral.$site_row, function(response, code, error_code) { |
| 1398 |
|
| 1399 |
$(settings_css_prefix+'#updraftvault_connect_go').html(udclion.updraftplus.connect); |
| 1400 |
|
| 1401 |
if ('ok' == code && response.hasOwnProperty('data')) { |
| 1402 |
if (response.data.hasOwnProperty('e')) { |
| 1403 |
UpdraftCentral_Library.dialog.alert('<h2>'+udclion.error+'</h2><p>'+response.data.e+'</p>'); |
| 1404 |
if (response.data.hasOwnProperty('code') && response.data.code == 'no_quota') { |
| 1405 |
$(settings_css_prefix+'#updraftvault_settings_connect').slideUp(); |
| 1406 |
$(settings_css_prefix+'#updraftvault_settings_default').slideDown(); |
| 1407 |
} |
| 1408 |
} else if (response.data.hasOwnProperty('connected') && response.data.connected && response.data.hasOwnProperty('html')) { |
| 1409 |
$(settings_css_prefix+'#updraftvault_settings_connect').slideUp(); |
| 1410 |
$(settings_css_prefix+'#updraftvault_settings_connected').html(response.data.html).slideDown(); |
| 1411 |
} else { |
| 1412 |
console.log(response); |
| 1413 |
UpdraftCentral_Library.dialog.alert('<h2>'+udclion.error+'</h2><p>'+udclion.js_exception_occurred+'</p>'); |
| 1414 |
} |
| 1415 |
} |
| 1416 |
|
| 1417 |
}); |
| 1418 |
}); |
| 1419 |
|
| 1420 |
}); |
| 1421 |
|
| 1422 |
/** |
| 1423 |
* Remote test call back |
| 1424 |
* |
| 1425 |
* @callable RemoteTestCallback |
| 1426 |
* @param {Object} response - the data returned by the RPC call |
| 1427 |
* @param {string} code - the code returned by the RPC call |
| 1428 |
* @param {string|null} error_code - the error code returned by the RPC call (if any) |
| 1429 |
* @param {Object} data - the data that was sent to the remote side (the settings to be tested) |
| 1430 |
*/ |
| 1431 |
|
| 1432 |
/** |
| 1433 |
* Do a remote storage test based on the indicated button having been pressed, and report the results in a dialog |
| 1434 |
* |
| 1435 |
* @param {Object} $method_button - jQuery object for the relevant button |
| 1436 |
* @param {RemoteTestCallback|false} [result_callback] - optional callable to be invoked with the result |
| 1437 |
* |
| 1438 |
* @return {void} |
| 1439 |
*/ |
| 1440 |
function updraft_remote_storage_test($method_button, result_callback) { |
| 1441 |
|
| 1442 |
var $site_row = $method_button.closest('.updraftcentral_site_row'); |
| 1443 |
|
| 1444 |
var method = $method_button.data('method'); |
| 1445 |
var method_label = $method_button.data('method_label'); |
| 1446 |
var instance_id = $method_button.data('instance_id'); |
| 1447 |
var settings_selector; |
| 1448 |
|
| 1449 |
if (instance_id) { |
| 1450 |
settings_selector = '.updraftplusmethod.'+method+'-'+instance_id; |
| 1451 |
} else { |
| 1452 |
settings_selector = '.updraftplusmethod.'+method; |
| 1453 |
} |
| 1454 |
|
| 1455 |
$method_button.html(sprintf(udclion.updraftplus.testing_settings, method_label)); |
| 1456 |
|
| 1457 |
var data = { |
| 1458 |
method: method |
| 1459 |
}; |
| 1460 |
|
| 1461 |
// Add the other items to the data object. The expert mode settings are for the generic SSL options. |
| 1462 |
$('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output '+settings_selector+' input[data-updraft_settings_test], #updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output .expertmode input[data-updraft_settings_test]').each(function(index, item) { |
| 1463 |
var item_key = $(item).data('updraft_settings_test'); |
| 1464 |
var input_type = $(item).attr('type'); |
| 1465 |
if (!item_key) { return; } |
| 1466 |
if (!input_type) { |
| 1467 |
console.log("UpdraftCentral: UpdraftPlus: settings test input item with no type found"); |
| 1468 |
console.log(item); |
| 1469 |
// A default |
| 1470 |
input_type = 'text'; |
| 1471 |
} |
| 1472 |
var value = null; |
| 1473 |
if ('checkbox' == input_type) { |
| 1474 |
value = $(item).is(':checked') ? 1 : 0; |
| 1475 |
} else if ('text' == input_type || 'password' == input_type) { |
| 1476 |
value = $(item).val(); |
| 1477 |
} else { |
| 1478 |
console.log("UpdraftCentral: UpdraftPlus: settings test input item with unrecognised type ("+input_type+") found"); |
| 1479 |
console.log(item); |
| 1480 |
} |
| 1481 |
data[item_key] = value; |
| 1482 |
}); |
| 1483 |
// Data from any text areas or select drop-downs |
| 1484 |
$('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output '+settings_selector+' textarea[data-updraft_settings_test], #updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output '+settings_selector+' select[data-updraft_settings_test]').each(function(index, item) { |
| 1485 |
var item_key = $(item).data('updraft_settings_test'); |
| 1486 |
data[item_key] = $(item).val(); |
| 1487 |
}); |
| 1488 |
|
| 1489 |
UpdraftCentral.send_site_rpc('updraftplus.test_storage_settings', data, $site_row, function(response, code, error_code) { |
| 1490 |
|
| 1491 |
if ('ok' == code && response) { |
| 1492 |
$method_button.html(sprintf(udclion.updraftplus.test_settings, method_label)); |
| 1493 |
if ('undefined' !== typeof result_callback && false != result_callback) { |
| 1494 |
result_callback = result_callback.call(this, response, code, error_code, data); |
| 1495 |
} |
| 1496 |
if ('undefined' !== typeof result_callback && false === result_callback) { |
| 1497 |
UpdraftCentral_Library.dialog.alert('<h2>'+sprintf(udclion.updraftplus.settings_test_result, method_label)+'</h2> '+response.data.output); |
| 1498 |
} |
| 1499 |
} |
| 1500 |
|
| 1501 |
}, $method_button.closest('td')); |
| 1502 |
|
| 1503 |
|
| 1504 |
} |
| 1505 |
|
| 1506 |
$('#updraftcentral_notice_container').on('click', '.updraftplus_saved_settings a.updraft_authlink', function(e) { |
| 1507 |
|
| 1508 |
var href = $(this).attr('href'); |
| 1509 |
if ('undefined' === typeof href) { return; } |
| 1510 |
var site_id = $(this).closest('.updraftplus_saved_settings').data('site_id'); |
| 1511 |
var $site_row = $('#updraftcentral_dashboard_existingsites .updraftcentral_site_row[data-site_id="'+site_id+'"'); |
| 1512 |
|
| 1513 |
if ($site_row.length < 1) { |
| 1514 |
console.log("UpdraftCentral: UpdraftPlus: site row not found for the link clicked (site_id="+site_id+")"); |
| 1515 |
return; |
| 1516 |
} |
| 1517 |
|
| 1518 |
e.preventDefault(); |
| 1519 |
|
| 1520 |
var spinner_where = $(this).closest('.updraftplus_saved_settings'); |
| 1521 |
|
| 1522 |
UpdraftCentral_Library.open_browser_at($site_row, { module: 'direct_url', url: href }, spinner_where); |
| 1523 |
|
| 1524 |
}); |
| 1525 |
|
| 1526 |
/** |
| 1527 |
* Get the "Existing Backups" panel from the remote UpdraftPlus |
| 1528 |
* |
| 1529 |
* @param {Object} $site_row - jQuery object for the row of the site for which the information is being requested |
| 1530 |
* |
| 1531 |
* @return {void} |
| 1532 |
*/ |
| 1533 |
function updraft_get_existing_backups_panel($site_row) { |
| 1534 |
|
| 1535 |
$site_row.find('.updraftcentral_row_extracontents').css('opacity', '0.3'); |
| 1536 |
|
| 1537 |
// This just causes an extra informational message to be shown, if set (telling the user to turn off 'Turbo' mode prior to downloading). It does not affect any functionality. |
| 1538 |
var is_opera = (navigator.userAgent.match(/Opera|OPR\//) ? 1 : 0); |
| 1539 |
UpdraftCentral.send_site_rpc('updraftplus.get_fragment', { |
| 1540 |
fragment: 'panel_download_and_restore', |
| 1541 |
data: { |
| 1542 |
include_opera_warning: is_opera, |
| 1543 |
include_uploader: 0, |
| 1544 |
will_immediately_calculate_disk_space: 0, |
| 1545 |
include_header: 1 |
| 1546 |
} |
| 1547 |
}, $site_row, function(response, code, error_code) { |
| 1548 |
$site_row.find('.updraftcentral_row_extracontents').css('opacity', '1.0'); |
| 1549 |
if ('ok' == code && response) { |
| 1550 |
$site_row.find('.updraftcentral_row_extracontents').html('<div class="updraft_existing_backups_output"><div class="dashicons dashicons-image-rotate updraftcentral_site_backups_manage" style="float:right;"></div>'+UpdraftCentral_Library.sanitize_html(response.data.output)+'</div>'); |
| 1551 |
insert_bulk_delete($site_row); |
| 1552 |
} |
| 1553 |
}); |
| 1554 |
} |
| 1555 |
|
| 1556 |
/** |
| 1557 |
* Start a "Backup Now" operation on the specified site |
| 1558 |
* |
| 1559 |
* @param {Object} $site_row - the jQuery object for the row of the site to start the backup on |
| 1560 |
* |
| 1561 |
* @return {void} |
| 1562 |
*/ |
| 1563 |
function backup_now($site_row) { |
| 1564 |
UpdraftCentral.send_site_rpc('updraftplus.get_fragment', 'backupnow_modal_contents', $site_row, function(response, code, error_code) { |
| 1565 |
if ('ok' == code && response) { |
| 1566 |
|
| 1567 |
var was_error = response.data.output.hasOwnProperty('error') && response.data.output.error; |
| 1568 |
|
| 1569 |
var action_button = (was_error) ? false : udclion.updraftplus.backupnow; |
| 1570 |
|
| 1571 |
UpdraftCentral.open_modal(udclion.updraftplus.backupnow, response.data.output.html, function() { |
| 1572 |
var backupnow_nodb = $('#updraftcentral_modal #backupnow_includedb').is(':checked') ? 0 : 1; |
| 1573 |
var backupnow_nofiles = $('#updraftcentral_modal #backupnow_includefiles').is(':checked') ? 0 : 1; |
| 1574 |
var backupnow_nocloud = $('#updraftcentral_modal #backupnow_includecloud').is(':checked') ? 0 : 1; |
| 1575 |
|
| 1576 |
var onlythesefileentities = ''; |
| 1577 |
$('#updraftcentral_modal #backupnow_includefiles_moreoptions input[type="checkbox"]').each(function(index) { |
| 1578 |
if (!$(this).is(':checked')) { return; } |
| 1579 |
var name = $(this).attr('name'); |
| 1580 |
if (name.substring(0, 16) != 'updraft_include_') { return; } |
| 1581 |
var entity = name.substring(16); |
| 1582 |
if (onlythesefileentities != '') { onlythesefileentities += ','; } |
| 1583 |
onlythesefileentities += entity; |
| 1584 |
}); |
| 1585 |
|
| 1586 |
var onlythesetableentities = ''; |
| 1587 |
var send_list = false; |
| 1588 |
$('#backupnow_database_moreoptions input[type="checkbox"]').each(function(index) { |
| 1589 |
if (!$(this).is(':checked')) { send_list = true; return; } |
| 1590 |
}); |
| 1591 |
|
| 1592 |
if (send_list) { |
| 1593 |
onlythesetableentities = jQuery("input[name^='updraft_include_tables_']").serializeArray(); |
| 1594 |
} else { |
| 1595 |
onlythesetableentities = true; |
| 1596 |
} |
| 1597 |
|
| 1598 |
if ('' == onlythesefileentities && 0 == backupnow_nofiles) { |
| 1599 |
UpdraftCentral_Library.dialog.alert(udclion.updraftplus.nofileschosen); |
| 1600 |
return; |
| 1601 |
} |
| 1602 |
|
| 1603 |
if ('' == onlythesetableentities && 0 == backupnow_nodb) { |
| 1604 |
UpdraftCentral_Library.dialog.alert(udclion.updraftplus.notableschosen); |
| 1605 |
return; |
| 1606 |
} |
| 1607 |
|
| 1608 |
if (!send_list) { |
| 1609 |
onlythesetableentities = null; |
| 1610 |
} |
| 1611 |
|
| 1612 |
if (backupnow_nodb && backupnow_nofiles) { |
| 1613 |
UpdraftCentral_Library.dialog.alert(udclion.updraftplus.excludedeverything); |
| 1614 |
return; |
| 1615 |
} |
| 1616 |
|
| 1617 |
UpdraftCentral.close_modal(); |
| 1618 |
|
| 1619 |
UpdraftCentral_Module_UpdraftPlus.backupnow_go(backupnow_nodb, backupnow_nofiles, backupnow_nocloud, onlythesefileentities, '', $('#updraftcentral_modal #backupnow_label').val(), onlythesetableentities); |
| 1620 |
}, action_button, function() { |
| 1621 |
$('#updraftcentral_modal #backupnow_includefiles_moreoptions').hide(); |
| 1622 |
// Remove the <a> link tab wrapping it, as that goes to the site's WP dashboard |
| 1623 |
$('#updraftcentral_modal #updraft_backupnow_gotosettings').contents().unwrap(); |
| 1624 |
}, true, 'backup-now'); |
| 1625 |
} |
| 1626 |
}); |
| 1627 |
} |
| 1628 |
|
| 1629 |
/** |
| 1630 |
* Open a modal showing the indicated log file for the indicated site |
| 1631 |
* |
| 1632 |
* @param {string} job_id - The UpdraftPlus job identifier string |
| 1633 |
* @param {Object} $site_row - The jQuery object for the site row that the request is for |
| 1634 |
* |
| 1635 |
* @return {void} |
| 1636 |
*/ |
| 1637 |
function updraft_popuplog(job_id, $site_row) { |
| 1638 |
UpdraftCentral.send_site_rpc('updraftplus.get_log', job_id, $site_row, function(response, code, error_code) { |
| 1639 |
if ('ok' == code && response) { |
| 1640 |
UpdraftCentral.open_modal(udclion.updraftplus.logfile, '<pre id="updraft_poppedlog">'+UpdraftCentral_Library.sanitize_html(response.data.log)+'</pre>', function() { |
| 1641 |
UpdraftCentral_Library.download_inner_html('log.'+job_id+'.txt', 'updraft_poppedlog'); |
| 1642 |
}, udclion.updraftplus.downloadlog, function() { |
| 1643 |
// Function that gets called after population of modal, before opening |
| 1644 |
}, null, true, 'modal-lg'); |
| 1645 |
} |
| 1646 |
}); |
| 1647 |
} |
| 1648 |
|
| 1649 |
/** |
| 1650 |
* Open the modal to confirm, and then carry out, deletion of the indicate backup |
| 1651 |
* |
| 1652 |
* @param {string} key - A comma-separated list of timestamps of the backups to delete |
| 1653 |
* @param {string} nonce - the UpdraftPlus job identifier string |
| 1654 |
* @param {boolean} showremote - whether or not to show the option to also remove the backup from remote storage (if any) |
| 1655 |
* |
| 1656 |
* @return {void} |
| 1657 |
*/ |
| 1658 |
function updraft_delete(key, nonce, showremote) { |
| 1659 |
var delete_question = udclion.updraftplus.delete_areyousure_singular; |
| 1660 |
if (key.indexOf(',') > -1) { |
| 1661 |
delete_question = udclion.updraftplus.delete_areyousure_plural; |
| 1662 |
} |
| 1663 |
|
| 1664 |
// title, body, action_button_callback, action_button_text, pre_open_callback, sanitize_body |
| 1665 |
UpdraftCentral.open_modal( |
| 1666 |
udclion.updraftplus.deletebackupset, |
| 1667 |
UpdraftCentral.template_replace('updraftplus-deletebackup', { |
| 1668 |
nonce: nonce, |
| 1669 |
timestamp: key, |
| 1670 |
delete_question: delete_question, |
| 1671 |
also_delete_from_remote: udclion.updraftplus.also_delete_from_remote, |
| 1672 |
deleting_please_allow_time: udclion.updraftplus.deleting_please_allow_time |
| 1673 |
}), |
| 1674 |
function() { |
| 1675 |
var nonce = $('#updraft_delete_modal_contents').data('nonce').toString(); |
| 1676 |
var timestamps = $('#updraft_delete_modal_contents').data('timestamp').toString(); |
| 1677 |
var delete_remote = 0; |
| 1678 |
if ($('#updraft_delete_modal_contents #updraft_delete_remote').is(':checked')) { |
| 1679 |
delete_remote = 1; |
| 1680 |
} |
| 1681 |
|
| 1682 |
$('#updraftcentral_modal #updraft-delete-waitwarning').slideDown(); |
| 1683 |
|
| 1684 |
var is_opera = (navigator.userAgent.match(/Opera|OPR\//) ? true : false); |
| 1685 |
|
| 1686 |
UpdraftCentral.send_site_rpc('updraftplus.deleteset', { |
| 1687 |
backup_nonce: nonce, |
| 1688 |
backup_timestamp: timestamps, |
| 1689 |
delete_remote: delete_remote, |
| 1690 |
get_history_opts: { |
| 1691 |
include_opera_warning: is_opera, |
| 1692 |
include_uploader: false, |
| 1693 |
will_immediately_calculate_disk_space: false, |
| 1694 |
include_header: true |
| 1695 |
} |
| 1696 |
}, UpdraftCentral.$site_row, function(response, code, error_code) { |
| 1697 |
|
| 1698 |
$('#updraftcentral_modal #updraft-delete-waitwarning').slideUp(); |
| 1699 |
if ('ok' == code && response) { |
| 1700 |
var resp = response.data; |
| 1701 |
if (resp.result != null) { |
| 1702 |
if (resp.result == 'error') { |
| 1703 |
UpdraftCentral_Library.dialog.alert('<h2>'+udclion.error+'</h2>'+resp.message); |
| 1704 |
} else if (resp.result == 'success') { |
| 1705 |
|
| 1706 |
if (resp.hasOwnProperty('history')) { |
| 1707 |
UpdraftCentral.$site_row.find('.updraftcentral_row_extracontents').html('<div class="updraft_existing_backups_output">'+UpdraftCentral_Library.sanitize_html(resp.history)+'</div>'); |
| 1708 |
insert_bulk_delete($site_row); |
| 1709 |
} else { |
| 1710 |
updraft_get_existing_backups_panel(UpdraftCentral.$site_row); |
| 1711 |
} |
| 1712 |
|
| 1713 |
UpdraftCentral.close_modal(); |
| 1714 |
|
| 1715 |
var message = resp.message; |
| 1716 |
if ('undefined' === typeof message) { |
| 1717 |
message = resp.local_message+' '+resp.backup_local; |
| 1718 |
message += ', '+resp.remote_message+' '+resp.backup_remote; |
| 1719 |
message += ', '+resp.set_message+' '+resp.backup_sets; |
| 1720 |
} |
| 1721 |
|
| 1722 |
UpdraftCentral_Library.dialog.alert('<h2>'+udclion.updraftplus.deleted+'</h2>'+message); |
| 1723 |
} |
| 1724 |
} |
| 1725 |
} |
| 1726 |
|
| 1727 |
}); |
| 1728 |
|
| 1729 |
}, |
| 1730 |
udclion.updraftplus.delete, |
| 1731 |
function() { |
| 1732 |
if (!showremote) { |
| 1733 |
$('#updraft-delete-remote-section').remove(); |
| 1734 |
} else { |
| 1735 |
$('#updraft-delete-remote-section, #updraft_delete_remote').removeAttr('disabled').show(); |
| 1736 |
} |
| 1737 |
|
| 1738 |
} |
| 1739 |
); |
| 1740 |
|
| 1741 |
} |
| 1742 |
|
| 1743 |
/** |
| 1744 |
* Send a command to abort an active backup job_id |
| 1745 |
* |
| 1746 |
* @param {string} job_id - the job identifier for the job to be aborted |
| 1747 |
* @param {Object} $site_row - the jQuery object for the row for the site to send the command to |
| 1748 |
* @param {Object} site_listener_row - the jQuery object for the listener row associated with the request |
| 1749 |
* |
| 1750 |
* @return {void} |
| 1751 |
*/ |
| 1752 |
function updraft_activejobs_delete(job_id, $site_row, site_listener_row) { |
| 1753 |
|
| 1754 |
UpdraftCentral.send_site_rpc('updraftplus.activejobs_delete', job_id, $site_row, function(response, code, error_code) { |
| 1755 |
if ('ok' == code && response) { |
| 1756 |
var msg = ''; |
| 1757 |
if (response.hasOwnProperty('data') && response.data.hasOwnProperty('c')) { |
| 1758 |
if ('deleted' == response.data.c) { |
| 1759 |
msg = udclion.updraftplus.delete_deleted; |
| 1760 |
} else if ('not_found' == response.data.c) { |
| 1761 |
msg = udclion.updraftplus.delete_not_found; |
| 1762 |
} else { |
| 1763 |
console.log("UDCentral: UpdraftPlus: abort job: unknown response"); |
| 1764 |
console.log(response.data); |
| 1765 |
msg = UpdraftCentral_Library.sanitize_html(response.data.m); |
| 1766 |
} |
| 1767 |
} else { |
| 1768 |
console.log("UDCentral: UpdraftPlus: abort job: unknown response"); |
| 1769 |
console.log(response.data); |
| 1770 |
msg = udclion.js_exception_occurred; |
| 1771 |
} |
| 1772 |
$(site_listener_row).find('.backup_state:first').html(msg); |
| 1773 |
} |
| 1774 |
}); |
| 1775 |
} |
| 1776 |
|
| 1777 |
$('#updraftcentral_notice_container').on('click', '.updraftcentral_listener .updraftplus_downloader_closebutton', function(e) { |
| 1778 |
e.preventDefault(); |
| 1779 |
var $listener = $(this).closest('.updraftcentral_listener'); |
| 1780 |
$(this).closest('.updraftplus_downloader').fadeOut().remove(); |
| 1781 |
var how_many_downloaders = $listener.find('.updraftplus_downloader').length; |
| 1782 |
if (how_many_downloaders < 1) { |
| 1783 |
console.log($listener); |
| 1784 |
$listener.clearQueue().slideUp('slow', function() { |
| 1785 |
$(this).remove(); |
| 1786 |
}); |
| 1787 |
} |
| 1788 |
}); |
| 1789 |
|
| 1790 |
$('#updraftcentral_notice_container').on('click', '.updraftcentral_listener .updraft_downloaded', function(e) { |
| 1791 |
var site_id = $(this).data('site_id'); |
| 1792 |
var $site_row = $('#updraftcentral_dashboard_existingsites .updraftcentral_site_row[data-site_id="'+site_id+'"'); |
| 1793 |
if ($site_row.length < 1) { return; } |
| 1794 |
var backup_timestamp = $(this).data('backup_timestamp'); |
| 1795 |
var what = $(this).data('what'); |
| 1796 |
var findex = $(this).data('findex'); |
| 1797 |
UpdraftCentral_Library.open_browser_at($site_row, { module: 'updraftplus', action: 'download_file', data: { |
| 1798 |
backup_timestamp: backup_timestamp, |
| 1799 |
what: what, |
| 1800 |
findex: findex |
| 1801 |
} }, null); |
| 1802 |
}); |
| 1803 |
|
| 1804 |
$('#updraftcentral_notice_container').on('click', '.updraftcentral_listener .updraft_delete_downloaded_backup', function(e) { |
| 1805 |
e.preventDefault(); |
| 1806 |
var delete_button = this; |
| 1807 |
var site_id = $(this).data('site_id'); |
| 1808 |
var $site_row = $('#updraftcentral_dashboard_existingsites .updraftcentral_site_row[data-site_id="'+site_id+'"'); |
| 1809 |
var findex = $(this).data('findex'); |
| 1810 |
var what = $(this).data('what'); |
| 1811 |
var backup_timestamp = $(this).data('backup_timestamp'); |
| 1812 |
UpdraftCentral.send_site_rpc('updraftplus.delete_downloaded', { |
| 1813 |
timestamp: backup_timestamp, |
| 1814 |
site_id: site_id, |
| 1815 |
type: what, |
| 1816 |
findex: findex |
| 1817 |
}, $site_row, function(response, code, error_code) { |
| 1818 |
if ('ok' == code && false !== response && response.hasOwnProperty('data')) { |
| 1819 |
$(delete_button).closest('.raw').html(udclion.updraftplus.entity_deleted); |
| 1820 |
} |
| 1821 |
}); |
| 1822 |
}); |
| 1823 |
|
| 1824 |
$('#updraftcentral_notice_container, #updraftcentral_dashboard_existingsites').on('click', '.updraftcentral_listener .updraft-log-link, .updraft_existing_backups_output .updraft-log-link', function(e) { |
| 1825 |
e.preventDefault(); |
| 1826 |
var job_id = $(this).data('jobid'); |
| 1827 |
if (job_id) { |
| 1828 |
var $site_listener = $(this).closest('.updraftcentral_listener, .updraftcentral_site_row'); |
| 1829 |
var site_id = $site_listener.data('site_id'); |
| 1830 |
var $site_row = $('#updraftcentral_dashboard_existingsites .updraftcentral_site_row[data-site_id="'+site_id+'"'); |
| 1831 |
updraft_popuplog(job_id, $site_row); |
| 1832 |
} else { |
| 1833 |
console.log(this); |
| 1834 |
console.log("UpdraftPlus: A log link was clicked, but the Job ID could not be found"); |
| 1835 |
} |
| 1836 |
}); |
| 1837 |
|
| 1838 |
$('#updraftcentral_notice_container').on('click', '.updraftcentral_listener .updraft_jobinfo_delete', function(e) { |
| 1839 |
e.preventDefault(); |
| 1840 |
var job_id = $(this).data('jobid'); |
| 1841 |
if (job_id) { |
| 1842 |
var $site_listener = $(this).closest('.updraftcentral_listener'); |
| 1843 |
var site_id = $site_listener.data('site_id'); |
| 1844 |
var $site_row = $('#updraftcentral_dashboard_existingsites .updraftcentral_site_row[data-site_id="'+site_id+'"'); |
| 1845 |
updraft_activejobs_delete(job_id, $site_row, $site_listener); |
| 1846 |
} else { |
| 1847 |
console.log("UpdraftPlus: A stop job link was clicked, but the Job ID could not be found"); |
| 1848 |
console.log(this); |
| 1849 |
} |
| 1850 |
}); |
| 1851 |
|
| 1852 |
/** |
| 1853 |
* Updates the various bits of widgetry and text associated with the scheduling settings. Suitable for calling when a chosen schedule value (daily/monthly/etc.) changes. |
| 1854 |
* |
| 1855 |
* @return {void} |
| 1856 |
*/ |
| 1857 |
function updraft_check_same_times() { |
| 1858 |
var dbmanual = 0; |
| 1859 |
var file_interval = $('#updraftcentral_dashboard_existingsites .updraft_site_settings_output .updraft_interval').val(); |
| 1860 |
if (file_interval == 'manual') { |
| 1861 |
$('#updraftcentral_dashboard_existingsites .updraft_site_settings_output .updraft_files_timings').hide(); |
| 1862 |
} else { |
| 1863 |
$('#updraftcentral_dashboard_existingsites .updraft_site_settings_output .updraft_files_timings').show(); |
| 1864 |
} |
| 1865 |
|
| 1866 |
if ('weekly' == file_interval || 'fortnightly' == file_interval || 'monthly' == file_interval) { |
| 1867 |
updraft_intervals_monthly_or_not('updraft_startday_files', file_interval); |
| 1868 |
$('#updraftcentral_dashboard_existingsites .updraft_site_settings_output #updraft_startday_files').show(); |
| 1869 |
} else { |
| 1870 |
$('#updraftcentral_dashboard_existingsites .updraft_monthly_extra_words_updraft_startday_files').remove(); |
| 1871 |
$('#updraftcentral_dashboard_existingsites .updraft_site_settings_output #updraft_startday_files').hide(); |
| 1872 |
} |
| 1873 |
|
| 1874 |
var db_interval = $('#updraftcentral_dashboard_existingsites .updraft_site_settings_output .updraft_interval_database').val(); |
| 1875 |
if (db_interval == 'manual') { |
| 1876 |
dbmanual = 1; |
| 1877 |
// $('#updraft_db_timings').css('opacity', '0.25'); |
| 1878 |
$('#updraftcentral_dashboard_existingsites .updraft_site_settings_output .updraft_db_timings').hide(); |
| 1879 |
} |
| 1880 |
|
| 1881 |
if ('weekly' == db_interval || 'fortnightly' == db_interval || 'monthly' == db_interval) { |
| 1882 |
updraft_intervals_monthly_or_not('updraft_startday_db', db_interval); |
| 1883 |
$('#updraftcentral_dashboard_existingsites .updraft_site_settings_output #updraft_startday_db').show(); |
| 1884 |
} else { |
| 1885 |
$('#updraftcentral_dashboard_existingsites .updraft_monthly_extra_words_updraft_startday_db').remove(); |
| 1886 |
$('#updraftcentral_dashboard_existingsites .updraft_site_settings_output #updraft_startday_db').hide(); |
| 1887 |
} |
| 1888 |
|
| 1889 |
if (db_interval == file_interval) { |
| 1890 |
// $('#updraft_db_timings').css('opacity','0.25'); |
| 1891 |
$('#updraftcentral_dashboard_existingsites .updraft_site_settings_output .updraft_db_timings').hide(); |
| 1892 |
// $('#updraft_same_schedules_message').show(); |
| 1893 |
if (0 == dbmanual) { |
| 1894 |
$('#updraftcentral_dashboard_existingsites .updraft_site_settings_output .updraft_same_schedules_message').show(); |
| 1895 |
} else { |
| 1896 |
$('#updraftcentral_dashboard_existingsites .updraft_site_settings_output .updraft_same_schedules_message').hide(); |
| 1897 |
} |
| 1898 |
} else { |
| 1899 |
$('#updraftcentral_dashboard_existingsites .updraft_site_settings_output .updraft_same_schedules_message').hide(); |
| 1900 |
if (0 == dbmanual) { |
| 1901 |
$('#updraftcentral_dashboard_existingsites .updraft_site_settings_output .updraft_db_timings').show(); |
| 1902 |
} |
| 1903 |
} |
| 1904 |
} |
| 1905 |
|
| 1906 |
var updraft_interval_week_val = false; |
| 1907 |
var updraft_interval_month_val = false; |
| 1908 |
|
| 1909 |
/** |
| 1910 |
* This function displays the month-day selector, and adjusts the wording, of the backup scheduling portion of the settings |
| 1911 |
* |
| 1912 |
* @param {string} selector_id - the CSS ID to use for finding the element to adjust (according to whether adjusting the files or DB schedule) |
| 1913 |
* @param {string} now_showing - the currently chosen interval |
| 1914 |
* |
| 1915 |
* @return {void} |
| 1916 |
*/ |
| 1917 |
function updraft_intervals_monthly_or_not(selector_id, now_showing) { |
| 1918 |
var selector = '#updraftcentral_dashboard_existingsites .updraft_site_settings_output #'+selector_id; |
| 1919 |
var current_length = $(selector+' option').length; |
| 1920 |
var is_monthly = ('monthly' == now_showing) ? true : false; |
| 1921 |
var existing_is_monthly = false; |
| 1922 |
if (current_length > 10) { existing_is_monthly = true; } |
| 1923 |
if (!is_monthly && !existing_is_monthly) { |
| 1924 |
return; |
| 1925 |
} |
| 1926 |
if (is_monthly && existing_is_monthly) { |
| 1927 |
if ('monthly' == now_showing) { |
| 1928 |
// existing_is_monthly does not mean the same as now_showing=='monthly'. existing_is_monthly refers to the drop-down, not whether the drop-down is being displayed. We may need to add these words back. |
| 1929 |
$('#updraftcentral_dashboard_existingsites .updraft_site_settings_output .updraft_monthly_extra_words_'+selector_id).remove(); |
| 1930 |
$(selector).before('<span class="updraft_monthly_extra_words_'+selector_id+'">'+udclion.updraftplus.day+' </span>').after('<span class="updraft_monthly_extra_words_'+selector_id+'"> '+udclion.updraftplus.in_the_month+' </span>'); |
| 1931 |
} |
| 1932 |
return; |
| 1933 |
} |
| 1934 |
$('#updraftcentral_dashboard_existingsites .updraft_site_settings_output .updraft_monthly_extra_words_'+selector_id).remove(); |
| 1935 |
if (is_monthly) { |
| 1936 |
// Save the old value |
| 1937 |
updraft_interval_week_val = $(selector+' option:selected').val(); |
| 1938 |
$(selector).html(udclion.updraftplus.mday_selector).before('<span class="updraft_monthly_extra_words_'+selector_id+'">'+udclion.updraftplus.day+' </span>').after('<span class="updraft_monthly_extra_words_'+selector_id+'"> '+udclion.updraftplus.in_the_month+' </span>'); |
| 1939 |
var select_mday = (updraft_interval_month_val === false) ? 1 : updraft_interval_month_val; |
| 1940 |
// Convert from day of the month (ordinal) to option index (starts at 0) |
| 1941 |
select_mday = select_mday - 1; |
| 1942 |
$(selector+" option:eq("+select_mday+")").prop('selected', true); |
| 1943 |
} else { |
| 1944 |
// Save the old value |
| 1945 |
updraft_interval_month_val = $(selector+' option:selected').val(); |
| 1946 |
$(selector).html(udclion.updraftplus.day_selector); |
| 1947 |
var select_day = (updraft_interval_week_val === false) ? 1 : updraft_interval_week_val; |
| 1948 |
$(selector+" option:eq("+select_day+")").prop('selected', true); |
| 1949 |
} |
| 1950 |
} |
| 1951 |
|
| 1952 |
var db_index; |
| 1953 |
var files_index; |
| 1954 |
/** |
| 1955 |
* Set up the HTML for the retain rules. This should be called after receiving the settings and rules from the remote end. |
| 1956 |
* |
| 1957 |
* @param {array} retain_rules_files - array of retain rules for the files backup |
| 1958 |
* @param {array} retain_rules_db - array of retain rules for the database backup |
| 1959 |
* |
| 1960 |
* @return {void} |
| 1961 |
*/ |
| 1962 |
function setup_retain_rules(retain_rules_files, retain_rules_db) { |
| 1963 |
// Code for handling the advanced retain rules |
| 1964 |
db_index = 0; |
| 1965 |
files_index = 0; |
| 1966 |
$.each(retain_rules_files, function(index, rule) { |
| 1967 |
add_rule('files', rule.after_howmany, rule.after_period, rule.every_howmany, rule.every_period); |
| 1968 |
}); |
| 1969 |
|
| 1970 |
$.each(retain_rules_db, function(index, rule) { |
| 1971 |
add_rule('db', rule.after_howmany, rule.after_period, rule.every_howmany, rule.every_period); |
| 1972 |
}); |
| 1973 |
} |
| 1974 |
|
| 1975 |
/** |
| 1976 |
* Adds a new advanced retain rule to the relevant section of the settings |
| 1977 |
* |
| 1978 |
* @param {string} type - either 'files' or 'db' |
| 1979 |
* @param {number} howmany_after - how many periods the rule applies after |
| 1980 |
* @param {number} period_after - the length (in seconds) of the period that the rule applies after |
| 1981 |
* @param {number} howmany_every - how many periods 1 backup is to be kept for |
| 1982 |
* @param {number} period_every - the length (in seconds) of the period that 1 backup is to be kept for |
| 1983 |
* |
| 1984 |
* @return {void} |
| 1985 |
*/ |
| 1986 |
function add_rule(type, howmany_after, period_after, howmany_every, period_every) { |
| 1987 |
var selector = 'updraft_retain_'+type+'_rules'; |
| 1988 |
var index; |
| 1989 |
if ('db' == type) { |
| 1990 |
db_index++; |
| 1991 |
index = db_index; |
| 1992 |
} else { |
| 1993 |
files_index++; |
| 1994 |
index = files_index; |
| 1995 |
} |
| 1996 |
$('#'+selector).append( |
| 1997 |
'<div style="float:left; clear:left;" class="updraft_retain_rules '+selector+'_entry">'+ |
| 1998 |
udclion.updraftplus.for_backups_older_than+' '+rule_period_selector(type, index, 'after', howmany_after, period_after)+' keep no more than 1 backup every '+rule_period_selector(type, index, 'every', howmany_every, period_every)+ |
| 1999 |
' <span title="'+udclion.updraftplus.delete+'" class="updraft_retain_rules_delete">X</span></div>' |
| 2000 |
) |
| 2001 |
} |
| 2002 |
|
| 2003 |
/** |
| 2004 |
* Returns the HTML for creating a dropdown <select> widget |
| 2005 |
* |
| 2006 |
* @param {string} type - either 'files' or 'db' |
| 2007 |
* @param {number} index - the rule number, used for constructing the name attribute |
| 2008 |
* @param {string} which - drop-down type - either 'every' or 'after' |
| 2009 |
* @param {number} howmany_value - the number of periods of time |
| 2010 |
* @param {number} period - the length (in seconds) of each period of time |
| 2011 |
* |
| 2012 |
* @return {void} |
| 2013 |
*/ |
| 2014 |
function rule_period_selector(type, index, which, howmany_value, period) { |
| 2015 |
var nameprefix = "updraft_retain_extrarules["+type+"]["+index+"]["+which+"-"; |
| 2016 |
var ret = '<input type="number" min="1" step="1" class="additional-rule-width" name="'+nameprefix+'howmany]" value="'+howmany_value+'"> \ |
| 2017 |
<select name="'+nameprefix+'period]">\ |
| 2018 |
<option value="3600"'; |
| 2019 |
if (period == 3600) { ret += ' selected="selected"'; } |
| 2020 |
ret += '>'+udclion.updraftplus.hours+'</option>\ |
| 2021 |
<option value="86400"'; |
| 2022 |
if (period == 86400) { ret += ' selected="selected"'; } |
| 2023 |
ret += '>'+udclion.updraftplus.days+'</option>\ |
| 2024 |
<option value="604800"'; |
| 2025 |
if (period == 604800) { ret += ' selected="selected"'; } |
| 2026 |
ret += '>'+udclion.updraftplus.weeks+'</option>\ |
| 2027 |
</select>'; |
| 2028 |
return ret; |
| 2029 |
} |
| 2030 |
|
| 2031 |
/** |
| 2032 |
* Set up the status of the 'exclude' field (relevant to backing up uploads, others, WordPress Core) |
| 2033 |
* |
| 2034 |
* @param {string} field - the entity type ('uploads', 'others', 'wpcore') |
| 2035 |
* @param {boolean} instant - whether to simply show/hide, or whether to apply an effect |
| 2036 |
* |
| 2037 |
* @return {void} |
| 2038 |
*/ |
| 2039 |
function setup_file_entity_exclude_field(field, instant) { |
| 2040 |
if ($('.updraftcentral_row_extracontents .updraft_site_settings_output #updraft_include_'+field).is(':checked')) { |
| 2041 |
if (instant) { |
| 2042 |
$('.updraftcentral_row_extracontents .updraft_site_settings_output #updraft_include_'+field+'_exclude').show(); |
| 2043 |
} else { |
| 2044 |
$('.updraftcentral_row_extracontents .updraft_site_settings_output #updraft_include_'+field+'_exclude').slideDown(); |
| 2045 |
} |
| 2046 |
} else { |
| 2047 |
if (instant) { |
| 2048 |
$('.updraftcentral_row_extracontents .updraft_site_settings_output #updraft_include_'+field+'_exclude').hide(); |
| 2049 |
} else { |
| 2050 |
$('.updraftcentral_row_extracontents .updraft_site_settings_output #updraft_include_'+field+'_exclude').slideUp(); |
| 2051 |
} |
| 2052 |
} |
| 2053 |
} |
| 2054 |
|
| 2055 |
var reportbox_index = 1; |
| 2056 |
|
| 2057 |
/** |
| 2058 |
* Activate the specified tab within the remote storage section |
| 2059 |
* |
| 2060 |
* @param {string} the_method - the remote storage method whose tab is to be activated. Corresponds to UD's internal method string identifiers (e.g. s3, dropbox, etc.) |
| 2061 |
* |
| 2062 |
* @return {void} |
| 2063 |
*/ |
| 2064 |
function updraft_remote_storage_tab_activation(the_method) { |
| 2065 |
var prefix = '#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output'; |
| 2066 |
$(prefix+' .updraftplusmethod').hide(); |
| 2067 |
$(prefix+' .remote-tab').data('active', false); |
| 2068 |
$(prefix+' .remote-tab').removeClass('nav-tab-active'); |
| 2069 |
$(prefix+' .updraftplusmethod.'+the_method).show(); |
| 2070 |
$(prefix+' .remote-tab-'+the_method).data('active', true); |
| 2071 |
$(prefix+' .remote-tab-'+the_method).addClass('nav-tab-active'); |
| 2072 |
} |
| 2073 |
|
| 2074 |
var remote_storage_tabs_any_checked = 0; |
| 2075 |
|
| 2076 |
/** |
| 2077 |
* Set the initial state of the remote storage options, depending on the currently selected option(s). Includes labelauty setup. |
| 2078 |
* |
| 2079 |
* @return {void} |
| 2080 |
*/ |
| 2081 |
function updraft_remote_storage_tabs_setup() { |
| 2082 |
|
| 2083 |
remote_storage_tabs_any_checked = 0; |
| 2084 |
var set = $('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output .updraft_servicecheckbox:checked'); |
| 2085 |
|
| 2086 |
$(set).each(function(ind, obj) { |
| 2087 |
var ser = $(obj).val(); |
| 2088 |
|
| 2089 |
if ($(obj).attr('id') != 'updraft_servicecheckbox_none') { |
| 2090 |
remote_storage_tabs_any_checked++; |
| 2091 |
} |
| 2092 |
|
| 2093 |
$('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output .remote-tab-'+ser).show(); |
| 2094 |
if (ind == $(set).length-1) { |
| 2095 |
updraft_remote_storage_tab_activation(ser); |
| 2096 |
} |
| 2097 |
}); |
| 2098 |
|
| 2099 |
if (remote_storage_tabs_any_checked > 0) { |
| 2100 |
$('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output .updraftplusmethod.none').hide(); |
| 2101 |
} else { |
| 2102 |
$('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output .updraftplusmethod:not(.none)').hide(); |
| 2103 |
$('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output .updraftplusmethod.none').show(); |
| 2104 |
} |
| 2105 |
|
| 2106 |
var servicecheckbox = $('#updraftcentral_dashboard_existingsites .updraftcentral_row_extracontents .updraft_site_settings_output .updraft_servicecheckbox'); |
| 2107 |
if (typeof servicecheckbox.labelauty === 'function') { servicecheckbox.labelauty(); } |
| 2108 |
|
| 2109 |
} |
| 2110 |
|
| 2111 |
} |
| 2112 |
|