File: D:/HostingSpaces/PvdBoogaard/indoorski.nl/backup/oude-site/cms/javascript/admin.backups.js
/**
* System Backups Javascript File
*
* @author Jordie Bodlay
*/
// backup functions
var backups = {
// database backup functions
database: {
backupFileName: '',
createBackup: function () {
// start the database backup by retrieving stats
$.iModal({
type: 'ajax',
url: 'remote.php?section=maintenance&action=dbstart',
title: iwp.lang.get('dbCreateDbBackup'),
width: 500,
buttons: '<input type="button" style="font-weight: bold" id="startDBBackup" value="' + iwp.lang.get('StartBackup') + '" class="Button" />'
});
},
updateProgress: function (percent) {
// update the percentage number
$('#backupPercent').html(percent);
},
finishedBackup: function () {
// reset the cursor
$('body').css('cursor', 'default');
// remove the status information
$('#createBackupStatus').hide();
// set the path to the file to download
$('#backupFileLink').attr('href', backups.database.backupFileName);
// show the finish button
$('#createBackupFinished').show();
// show the finish button
$('#startDBBackup').hide().after('<input type="button" style="font-weight: bold" id="finishDBBackup" value="' + iwp.lang.get('FinishBackup') + '" class="Button" />');
$('#finishDBBackup').bind('click', function() {
window.location.reload();
});
},
setFileName: function (fileName) {
// set the filename that the current backup was saved into
backups.database.backupFileName = fileName;
}
},
// config backup functions
config: {
backupFileName: '',
createBackup: function () {
// start the database backup by retrieving stats
$.iModal({
type: 'ajax',
url: 'remote.php?section=maintenance&action=configstart',
title: iwp.lang.get('dbCreateConfigBackup'),
width: 500,
buttons: '<input type="button" style="font-weight: bold" id="startConfigBackup" value="' + iwp.lang.get('StartBackup') + '" class="Button" />'
});
},
finishedBackup: function () {
// reset the cursor
$('body').css('cursor', 'default');
// remove the status information
$('#createBackupStatus').hide();
// set the path to the file to download
$('#backupFileLink').attr('href', backups.config.backupFileName);
// show the finish button
$('#createBackupFinished').show();
// show the finish button
$('#startConfigBackup').hide().after('<input type="button" style="font-weight: bold" id="finishConfigBackup" value="' + iwp.lang.get('FinishBackup') + '" class="Button" />');
$('#finishConfigBackup').bind('click', function() {
window.location.reload();
});
},
setFileName: function (fileName) {
// set the filename that the current backup was saved into
backups.config.backupFileName = fileName;
}
}
};
jQuery(function($){
// bind click events for the buttons
$('#dbCreateDbBackup').bind('click', function () {
backups.database.createBackup();
});
$('#dbCreateConfigBackup').bind('click', function () {
backups.config.createBackup();
});
// bind the click for the 'delete selected' button which deletes multiple backup files
$('#deleteSelected').bind('click', function () {
if(!$('.backupCheckbox:checked').exists()) {
alert(iwp.lang.get('SelectaBackupFileToDelete'));
return;
}
if(confirm(iwp.lang.get('ConfirmDeleteBackups').replace(/\\r\\n/g, "\r\n"))) {
$('#deleteBackupsForm').submit();
}
});
// add a confirmation to the delete links for each row
$('.deleteLink').live('click', function () {
if(confirm(iwp.lang.get('ConfirmDeleteBackup').replace(/\\r\\n/g, "\r\n"))) {
return true;
}
return false;
});
// if the master checkbox is clicked, we want all the other checkboxes to gain the same checked-state
$('#masterCheckbox').bind('click', function () {
if($('#masterCheckbox:checked').exists()) {
$('.backupCheckbox').attr('checked', 'checked');
} else {
$('.backupCheckbox').removeAttr('checked');
}
});
$('#startDBBackup').live('click', function () {
// set the cursor to wait
$('body').css('cursor', 'wait');
// show the progress bar
$('#createBackupStatus').show();
$('#summary').hide();
$('<iframe></iframe>').attr('id', 'progressiframe').attr('src', 'remote.php?section=maintenance&action=createdbbackup').appendTo('body').hide();
});
$('#startConfigBackup').live('click', function () {
// set the cursor to wait
$('body').css('cursor', 'wait');
// show the progress bar
$('#createBackupStatus').show();
$('#summary').hide();
$.getJSON('remote.php?section=maintenance&action=createconfigbackup', function(json) {
if(json.success){
backups.config.setFileName(json.filename);
backups.config.finishedBackup();
}else{
$('#MainMessage').errorMessage(json.message);
}
});
});
});