/* Backup Page Array Variables */
backupSetArray = [];
backupSetTypeArray = [];
newBackupSetArray = [];
delFlag = 0;
delAjax = 0;
delCancel = 0;
fileScannedStatus = 0;
//calling job termination function for cancelling archive cleanup...
$(document).on('click', '#Stop',function(){
clearTimeout(archiveTimeoutVar);
archiveAjax.abort();
archiveTimeoutVar='';
$("#actiontype").val("stop");
var url="action.php?action=stopSearch&type=archive";
$.post(url,function(data){
$(secPosCont).append($('.archive_folder_cleanup_popup').hide());
$("#Stop").hide();
$("#Cleanup").show();
$(".cleanup-value").show();
$(".cleanup-file-scan").css("display", "none");
if($("#periodice_clean").is(':checked')){
$(".select-container select").removeAttr("disabled");
}
$(".archive_cleanup_popup").show();
$("#archiveerror").addClass("welcome_message");
$("#archiveerror").removeClass("error_msg");
showErrorMessages('#archiveerror.welcome_message','Archive cleanup operation has been cancelled successfully.');
$("#errorbtn").click(function()
{
$(".cleanup_operation_cleanup_popup").hide();
});
});
});
//function for deleting files...
var archiveDelete = function() {
$("#ajaxLoaderDeleteConfirm1").show();
$(secPosCont).append($('.archive_folder_cleanup_popup,.delete_files_cleanup_popup').show());
$(popcont).addClass('popLeft');
$('.sec_pos_container').addClass('set_relative');
$("#yes").unbind().click(function(){
$("#deleteCancel").show();
$("#deleteCancel").removeAttr('disabled');
$("#ajaxLoaderDeleteConfirm1").hide();
$(".delete_files_cleanup_popup").hide();
var delcontent=$("#archiveDeletedData").html();
$("#deleteValues").html(delcontent);
$(secPosCont).append($('.archive_folder_cleanup_popup').hide());
$(secPosCont).append($('#archiveCleanUp').show());
var url="action.php?action=deleteArchive&type=archive";
archDeleteStatus();
delAjax = $.post(url,function(data){
var dataArray = jQuery.parseJSON(data);
if(dataArray[0]==true){
$("#deleteCancel").hide(); /* hiding cancel butto here after loading delete status */
$.popContainerHide();
showErrorMessages('.welcome_message',DELETE_OPERATION_COMPLETED);
if($("#Deleting").is(':visible')){
$(secPosCont).append($('#archiveCleanUp,.nofiles_cleanup_popup').show());
}
/*clearing restore js arrays */
if(dataArray[1]==1){
restoreSetArray =[];
newRestoreSetArray = [];
dynamicRemoteArray = [];
dynamicRemoteRequestInfo = [];
}
$("#archiveWindow").val("0");
//can call recalc method here to refresh storage.
$( ".storage_calculate" ).trigger( "click" );
}
else{
$("#archiveWindow").val("0");
$("#deleteCancel").hide(); /* hiding cancel butto here after loading delete status */
/* Displaying delete error here.*/
$.popContainerHide();
if(dataArray[0] == 'AR_DEL_LOG_DIR')
showErrorMessages('.error_msg','Unable to continue the operation. Try again later.');
else if(dataArray[0] == 'AR_DEL_LOG')
showErrorMessages('.error_msg','Unable to continue the operation. Try again later.');
else if(dataArray[0] == 'AR_PID')
showErrorMessages('.error_msg','Operation could not be completed. Try again later.');
/*clearing restore js arrays */
if(dataArray[1]==1){
restoreSetArray =[];
newRestoreSetArray = [];
dynamicRemoteArray = [];
dynamicRemoteRequestInfo = [];
}
}
})
.fail(function() {
$("#archiveWindow").val("0");
$("#deleteCancel").hide();
$.popContainerHide();
showErrorMessages('.error_msg','Unable to continue the operation. Try again later.1');
});
});
$("#No").click(function(){
$("#ajaxLoaderDeleteConfirm1").hide();
$(".delete_files_cleanup_popup").hide();
});
/* Delete cancel call start */
$("#deleteCancel").unbind().click(function(){
delAjax.abort();
$("#deleteSuccess").hide();
var delurl="action.php?action=deleteCancel";
$.post(delurl,function(data){
//delCancel = 0;
});
$.popContainerHide();
showErrorMessages('.welcome_message','Delete Operation has been cancelled successfully.');
});
};
var currentperiodicPerc = ""; var currentperiodicDays = ""; var currentperiodicStatus = "0";
var currentSelectedJobval = "";
$(function()
{
if($("#periodice_clean").is(':checked')){
$(".select-container select").removeAttr("disabled");
}
//calling cleanup pop here... popup_close_btn hide_popup
$(document).on('click', '.archive_menu',function()
{
$("#archiveWindow").val("1");
/* checking manual backup is running here */
if(progressJobBackupCount > 0) {
if(manualBackupRunning == true || (manualLocalBackupRunning == false && progressJobBackupCount >= 1)) {
jQuery('.common_msg').hide();
showErrorMessages('.error_msg', 'Unable to start Archive Cleanup. Backup is in Progress.');
return;
}
}
clearTimeout(backupTimeoutVar);
/* manual backup check ends here */
var editDetails = false;
currentSelectedJobval = $("#select_job").val();
currentperiodicPerc = ""; currentperiodicDays = ""; currentperiodicStatus = "0";
var tempjob = IDrive.Jobs[currentSelectedJobval];
$("#periodic_perc option[value='5']").attr("selected","selected");
$("#periodic_days option[value='5']").attr("selected","selected");
$(".select-container select").attr("disabled", "disabled");
$('#periodice_clean').removeAttr('checked');
if(IDrive.Jobs[currentSelectedJobval].periodic !== undefined)
{
currentperiodicPerc = IDrive.Jobs[currentSelectedJobval].periodic.perc;
currentperiodicDays = IDrive.Jobs[currentSelectedJobval].periodic.days;
currentperiodicStatus = IDrive.Jobs[currentSelectedJobval].periodic.status;
$("#periodic_perc option[value='" + currentperiodicPerc + "']").attr("selected","selected");
$("#periodic_days option[value='" + currentperiodicDays + "']").attr("selected","selected");
if(currentperiodicStatus == "1"){
$('#periodice_clean').prop('checked', true);
$(".select-container select").removeAttr("disabled");
}
else{
$(".select-container select").attr("disabled", "disabled");
$('#periodice_clean').removeAttr('checked');
}
}
$(".file-scan-wrap").hide();
$(".welcome_message").hide();
if(actionRequired==2){editJob('backup');}
$(".error_msg").hide();
$(".cleanup-value").show();
$("#Cleanup").show();
jQuery('#archiveCleanupJobName').html('[ '+currentSelectedJobval.replace('Backup_','')+' ]');
$.popContainer();
// Added by sajana for clearing old data...
$("#output").html("");
$("#delete").hide();
$("#Stop").hide();
// -----sajana code ends here----
$(secPosCont).append($('.archive_cleanup_popup').show());
$(popcont).addClass('popLeft');
$('.sec_pos_container').addClass('set_relative');
});
$(document).on('click','.know-more-click',function(){$('.cleanup-know-more').show();});
$(document).on('click','.know_more_close_btn',function(){ $('.cleanup-know-more').hide(); });
$(document).on('mouseenter','#archiveQuestion',function(){ $('.question-popup').show(); });
$(document).on('mouseleave','#archiveQuestion',function(){ $('.question-popup').hide(); });
//checking any periodic cleanup settings has been changed.
$(document).on('change','#periodic_days',function(){
var selectedPeriodicDays = $("#periodic_days").val();
if(selectedPeriodicDays != currentperiodicDays){
showErrorMessages('#archiveerror.welcome_message','Periodic Cleanup settings has been changed.');
startTimeoutForAutoPost('periodic'); //Auto POST
}
});
$(document).on('change','#periodic_perc',function(){
var selectedPeriodicPerc = $("#periodic_perc").val();
if(selectedPeriodicPerc != currentperiodicPerc){
showErrorMessages('#archiveerror.welcome_message','Periodic Cleanup settings has been changed.');
startTimeoutForAutoPost('periodic'); //Auto POST
}
});
//--------------------
$(document).on('click','#resultPopupClose',function(){
var url1="action.php?action=removeArchivePid"; // calling stop archive while closing the archive popup.
$.post(url1,function(data){});
});
//-------------
/* checking closing button of popup window.*/
$(document).on('click','#archiveMainpopup',function(){
if ($('#archiveDeletedData').is(":visible") ) {
var url1="action.php?action=removeArchivePid"; // calling stop archive while closing the archive popup.
$.post(url1,function(data){});
}
$("#archiveWindow").val("0");
$(".cleanup-know-more").hide();
$("#actiontype").val("stop");
$(".welcome_message").hide();
if(archiveTimeoutVar!=''){
archiveAjax.abort();
archiveTimeoutVar='';
var url2="action.php?action=stopSearch&type=archive"; // calling stop archive while closing the archive popup.
$.post(url2,function(data){});
}
postPeriodicCleanup(); //Auto POST
});
/* Delete popup close checks here */
$(document).on('click','#deleteBoxClose',function(){
delAjax.abort();
$("#deleteSuccess").hide();
$("#archiveWindow").val("0");
/* calling stop delete while closing delete popup .*/
if($('#Deleting').css('display') == 'block'){
var url2="action.php?action=deleteCancel";
$.post(url2,function(data){});
}
showErrorMessages('.welcome_message','Delete Operation has been cancelled successfully.');
});
});
$(document).on('click','.period-chkbox',function(){
var CheckBoxLength = $('.period-chkbox').prop('checked');
if(CheckBoxLength)
{
if(backupSetArray.length !==0){ //checking backup set is empty..
$(".select-container select").removeAttr("disabled");
archiveErrors('AR_PERIODIC_ENA');
}
else{
archiveErrors('AR_FILE_MISS');
$(".select-container select").attr("disabled", "disabled");
$('.period-chkbox').prop('checked',false);
}
}
else
{
$(".select-container select").attr("disabled", "disabled");
archiveErrors('AR_PERIODIC_DIS');
}
startTimeoutForAutoPost('periodic'); //Auto POST
});
function postPeriodicCleanup(){
var periodic_days ="";
var periodic_perc = "";
var backupsetName = $("#select_job").val();
var url = "periodicCleanup.php";
periodic_days = $("#periodic_days").val();
periodic_perc = $("#periodic_perc").val();
var periodic_cleanStatus = "0";
if($("#periodice_clean").is(':checked')){
var periodic_cleanStatus = "1";
}
if(currentperiodicStatus == "0" && currentperiodicStatus == periodic_cleanStatus){
}
else if(currentperiodicPerc != periodic_perc || currentperiodicDays != periodic_days || currentperiodicStatus != periodic_cleanStatus )
{
$.post(url,{periodic_days:periodic_days,periodic_perc:periodic_perc,periodic_cleanStatus:periodic_cleanStatus,backupsetName:backupsetName},function(data){});
var tt=IDrive.Jobs[currentSelectedJobval];
var abc =tt.periodic;
if(typeof IDrive.Jobs[currentSelectedJobval].periodic === "undefined"){
IDrive.Jobs[currentSelectedJobval].periodic = new Array();
}
IDrive.Jobs[currentSelectedJobval].periodic.days = periodic_days;
IDrive.Jobs[currentSelectedJobval].periodic.perc = periodic_perc;
IDrive.Jobs[currentSelectedJobval].periodic.status = periodic_cleanStatus;
}
}
function watcherForArchive(){
if(archiveTimeoutVar!='' && jQuery('.archive_cleanup_popup').is(':visible')){
//AJAX call to get Archive Status
archiveAjax = $.ajax({
url: "action.php?action=archiveStatus",
success: function(data){
archiveData=$.parseJSON(data);
if(isNaN(archiveData.total_count) === false && archiveData.total_count != 0){
$("#total_files").html(archiveData.total_count);
if(archiveData.files_scanned != null) {
$("#file_scanned").html(archiveData.files_scanned);
fileScannedStatus = archiveData.operation_status;
}
}
if(archiveData.operation_status == 'completed'){
fileScannedStatus = archiveData.operation_status;
archiveAjaxStatus = archiveData.Error;
setTimeout(verifyScan,500);
clearTimeout(archiveTimeoutVar);
archiveTimeoutVar='';
}
else {
archiveTimeoutVar = setTimeout(watcherForArchive,timeForArchiveWatcher);
}
}
});
}
}
/*-------- error handling function for archive operation------*/
function archiveErrors(err){
$("#archiveerror").removeClass("welcome_message");
$("#archiveerror").addClass("error_msg");
if(err=='AR_RESULT_ERR'){
showErrorMessages('#archiveerror.error_msg','Count file does not exist.');
}
else if(err=='AR_NO_ITEM'){
$(".cleanup_operation_cleanup_popup").hide();
showErrorMessages('#archiveerror.error_msg','There are no items to delete.');
}
else if(err=='AR_FILE_MISS'){
$(".cleanup_operation_cleanup_popup").hide();
showErrorMessages('#archiveerror.error_msg','Backup set is empty. Please try again.');
}
else if(err=='AR_START_ERR'){
showErrorMessages('#archiveerror.error_msg','Unable to start the operation. Please try again later.');
}
else if(err=='ERR_STR_VAL'){
showErrorMessages('#archiveerror.error_msg','Operation could not be completed. Operation cancelled by user.');
}
else if(err=='AR_PERC_ERR'){
$("#archiveerror").hide();
jQuery('.cleanup_operation_cleanup_popup').hide();
jQuery('#page_loader').show();
$("#ajaxLoaderForPercError").show();
var urlperc = "action.php?action=archivePerc";
$.post(urlperc,{},function(data){
archivepercData=$.parseJSON(data);
var manualPerc = archivepercData.manualPerc;
var totalFilesConsider = archivepercData.total_count;
var filesConsiderDelete = archivepercData.total_del_count;
$("#errormsg").html("
Cleanup Now operation has been aborted because the number of files considered for cleanup is more than "+manualPerc+" % of the total number of files in your backup set.
Total files in your backup set : "+totalFilesConsider+" Total files listed for deletion : "+filesConsiderDelete+"
");
});
jQuery(secPosCont).append(jQuery('.cleanup_operation_cleanup_popup').show());
jQuery('#page_loader').hide();
}
else if(err=='AR_DIR'){
showErrorMessages('#archiveerror.error_msg','Operation could not be completed. Archive Directory cannot be created.');
}
else if(err=='JOB_DIR' || err == 'AR_DIR'){
showErrorMessages('#archiveerror.error_msg','Operation could not be completed. Please try again later.');
}
else if(err=='JOB_RUN'){
showErrorMessages('#archiveerror.error_msg','Unable to start Archive Cleanup. Backup is in progress.');
}
else if(err == 'AR_PERIODIC_ENA'){
var backupsetnameSelected = $("#select_job").val();
var periodicBackup = backupsetnameSelected.replace("Backup_","");
$("#archiveerror").removeClass("error_msg");
$("#archiveerror").addClass("welcome_message");
showErrorMessages('#archiveerror.welcome_message','Periodic cleanup has been enabled for '+periodicBackup+'');
}
else if(err == 'AR_PERIODIC_DIS'){
var backupsetnameSelected = $("#select_job").val();
var periodicBackup = backupsetnameSelected.replace("Backup_","");
$("#archiveerror").removeClass("error_msg");
$("#archiveerror").addClass("welcome_message");
showErrorMessages('#archiveerror.welcome_message','Periodic cleanup has been disabled for '+periodicBackup+'');
} else if(err!=''){
showErrorMessages('#archiveerror.error_msg',err);
}
}
$(document).on("click",'#Cleanup',function(){
if(backupSetArray.length==0){
archiveErrors('AR_FILE_MISS'); //checking backup set is empty..
return;
}
var current_selJob = $("#select_job").val();
var archive = $("#arch_perc").val();
$("#total_files").html('0');
$("#file_scanned").html('');
$("#actiontype").val("");
$("#Cleanup").hide();
$("#Stop").show();
var url2 = "startarchive.php";
$.post(url2,{current_selJob:current_selJob,archive:archive},function(pidstatus){
if(pidstatus !="yes"){
$("#Cleanup").show();
$("#Stop").hide();
archiveErrors(pidstatus);
return;
}
$("#archiveerror").addClass("welcome_message");
$("#archiveerror").removeClass("error_msg");
showErrorMessages('#archiveerror.welcome_message','Archive cleanup operation has been started successfully.');
$(".file-scan-wrap").show();
$("#total_files").show();
$("#file_scanned").show();
$(".cleanup-value").hide();
if ($("#output").children().length == 0){
$(".cleanup-file-scan").css("display", "block");
}
else{
$(".cleanup-file-scan").hide();
}
archiveTimeoutVar = setTimeout(watcherForArchive,10); // calling watcher function for archive cleanup status...
});
});
function verifyScan(){
var data = archiveAjaxStatus;
if(fileScannedStatus == 'completed'){
if((data =='AR_DATA_READY') && ($("#actiontype").val()!="stop"))
{
// calling archive display file in onscroll event.
var url3 = "action.php?action=displayArchiveResult";
jQuery('.archive_folder_cleanup_popup').hide();
$.post(url3,{},function(result){
var arresult = jQuery.parseJSON(result);
var dataStatus = arresult.data_status;
$(".files-folders").find('#archiveDeletedData').html('');
$(".files-folders").find('#archiveDeletedData').html(arresult.result);
jQuery('.archive_folder_cleanup_popup').show();
$(".files-folders").find('#archiveDeletedData').show()
jQuery('#ajaxLoaderDeleteConfirm_loader').hide();
jQuery('#page_loader').hide();
var loadOnScroll = function() {
if(dataStatus == "1"){
if(($(this).scrollTop() + $(this).innerHeight() >= this.scrollHeight)) {
$("#forDeletion").unbind();
jQuery('.archiveLazyLoader').show();
$.post(url3,{},function(resultpart){
var arresultPart = jQuery.parseJSON(resultpart);
$(".files-folders").find('p').append(arresultPart.result);
jQuery('.archiveLazyLoader').hide();
dataStatus = arresultPart.data_status;
$("#forDeletion").on("scroll",loadOnScroll);
});
}
}
};
$("#forDeletion").on("scroll",loadOnScroll);
});
$(".archive_cleanup_popup").hide();
$(secPosCont).append($('.archive_folder_cleanup_popup').show());
$("#delete").show().unbind().bind('click', archiveDelete);
$(popcont).addClass('popLeft');
$('.sec_pos_container').addClass('set_relative');
$(".cleanup-file-scan").css("display", "none");
}
else if($("#actiontype").val()!="stop" && data!='')
{
clearTimeout(archiveTimeoutVar);
if($("#periodice_clean").is(':checked')){
$(".select-container select").removeAttr("disabled");
}
$(".cleanup-value").show();
$(".archive_cleanup_popup").show();
$("#Cleanup").show();
$("#Stop").hide();
$(".cleanup-file-scan").css("display", "none");
archiveErrors(data);
$("#errorbtn").click(function()
{
$("#ajaxLoaderForPercError").hide();
$(".cleanup_operation_cleanup_popup").hide();
});
}
}
}
//------------------Archive cleanup ends here------------------------------------------------
/* Document Ready - End */
/* Load local system Files/Folders - Start */
jQuery(document).on('click', '.backup_page a.getDirList,.localbackup_page a.getDirList', function() {
var bcParent = jQuery(this).parent().attr('id');
var placeID = jQuery(this).closest('div').parent().attr('id');
if(bcParent=='fullPathBreadCrumb' || placeID == 'loadFullPath'){
loadLocalFiles(jQuery(this),'loadFullPath','fullPathBreadCrumb','backupFilePath');
} else {
loadLocalFiles(jQuery(this),'newBackupSet','bkpBreadCrumb','selectedFiles_tab');
}
});
jQuery(document).on('click', '.backup_page a.getBackupDirList', function() {
loadRemoteFiles(jQuery(this).attr('alt'),'loadBackupLocation','backupLocationBreadCrumb','');
});
/* Load local system Files/Folders - End */
/* Remove selected Backup Set files - Start */
jQuery(document).on('click', '#removebBackupsetFiles span', function() {
//Checking whether Job Selected to Edit or not
if(actionRequired ==1){
actionRequired =2;
startTimeoutForAutoPost('backup'); //Auto POST
}
var current_directory = jQuery('#fullPathBreadCrumb a:last').attr('alt');
jQuery('#backupsetFiles tr.chk').each(function(){
var curr_val = jQuery(this).find('input').val();
if(jQuery('.body_wrap').hasClass('backup_page')){
var index = backupSetArray.indexOf(curr_val);
if(index>=0){
backupSetArray.splice(index, 1);
backupSetTypeArray.splice(index, 1);
defaultBackupSetArray.splice(index, 1);
defaultBackupSetTypeArray.splice(index, 1);
}
} else {
var index = localBackupSetArray.indexOf(curr_val);
if(index>=0){
localBackupSetArray.splice(index, 1);
localBackupSetTypeArray.splice(index, 1);
defaultLocalBackupSetArray.splice(index, 1);
defaultLocalBackupSetTypeArray.splice(index, 1);
}
}
if(index>=0){
jQuery(this).remove();
var id_of_element = '';
if(typeof dynamicArray[current_directory]!='undefined' && dynamicArray[current_directory]!==null){
id_of_element = dynamicArray[current_directory].indexOf(curr_val);
}
if(sh=='Hide')
{
var hiddenCount = countHiddenFilesAboveSelectedFile(current_directory, curr_val);
id_of_element = id_of_element - hiddenCount;
}
if(curr_val==clickedDirPath){
jQuery("#loadFullPath tr").removeAttr('class').find('input:checkbox').removeAttr('checked').next().removeAttr('class');
} else if(clickedDirPath.indexOf(curr_val+'/')==0){
jQuery("#loadFullPath tr").removeAttr('class').find('input:checkbox').removeAttr('checked').next().removeAttr('class');
} else if(id_of_element>=0) {
jQuery("#loadFullPath tr").eq(id_of_element).removeAttr('class').find('input:checkbox').removeAttr('checked').next().removeAttr('class');
}
}
});
jQuery('#maincheckBackup').next().attr('class','maincheck'); //Uncheck the Main Checkbox
jQuery(this).hide();
checkRemainingBackupsetFiles('loadFullPath');
checkForSemicheckedItem('loadFullPath');
markMaincheckAfterRemove('loadFullPath');
getItemSize();
});
/* Remove selected Backup Set files - End */
/* Remove selected New Backup Set files - Start */
jQuery(document).on('click', '#removeSelectedFiles span', function() {
jQuery('#selectedBackupsetFiles tr.chk').each(function(){
var curr_val = jQuery(this).find('input').val();
var index = newBackupSetArray.indexOf(curr_val);
newBackupSetArray.splice(index, 1);
jQuery(this).remove();
var removedItem = jQuery('#newBackupSet input[value="'+curr_val+'"]');
var curID = removedItem.attr('id');
if(typeof curID == 'undefined'){
var currPath = jQuery('#bkpBreadCrumb a:last').attr('alt');
if(currPath == curr_val){
jQuery('#newBackupSet').find('input').removeAttr('checked').siblings('label').removeAttr('class');
jQuery('.bckheader').find('label').removeAttr('class');
}
} else {
removedItem.removeAttr('checked').siblings('label').removeAttr('class').closest('tr').removeAttr('class');
}
});
jQuery('#maincheckSelected').next().attr('class','maincheck'); //Uncheck the Main Checkbox
jQuery('#selectFiles .header_part .file_check label').removeAttr('class'); //Uncheck the Main Checkbox
jQuery(this).hide();
checkRemainingBackupsetFiles('selectedBackupsetFiles');
markMaincheckAfterRemove('newBackupSet');
});
/* Remove selected New Backup Set files - End */
/* Function to Load local system Files/Folders - Start */
function loadLocalFiles(obj,toPlace,breadcrum,maincheck) {
abortAjax(currentAjaxRequest);
var getDir = obj;
if(typeof getDir!='string'){
getDir = obj.attr('alt');
}
if(typeof isRefresh != "undefined" && isRefresh == true) {
getDir = '/';
}
clickedDirPath = getDir; //For the purpose while unchecking the child
var url = "fullPathSelection.php?fullPath="+rawurlencode(getDir);
var dirListVal = dynamicArray[getDir];
var dirListType = dynamicType[getDir];
jQuery('#maincheck,#selectFiles #maincheck').siblings('label').css('visibility','visible');
var forLoader = (toPlace=='loadFullPath')?'.breadcrum_menu':"#"+toPlace;
jQuery('#' + toPlace + '>.excludefiles').unbind('scroll');
var backup_list_template = function (dirURL, dirList, dirType, hasData, page_no) {
if (dirURL != '/') {
if(hasData==true) {
var dirHTML = '';
for(var j=0; j';
dirHTML += '