/* 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 += ''; dirHTML += ''; dirHTML += ''; dirHTML += ''; dirHTML += dirName.replace(/[\s]/g,' '); dirHTML += ''; dirHTML += ' -- '+IDrive.LocalDirList[getDir][dirName1].datetime+' '; dirHTML += ''; } else { dirHTML += ''; dirHTML += ' '; dirHTML += ''; dirHTML += dirName.replace(/[\s]/g,' '); dirHTML += ''; dirHTML += ' '+IDrive.LocalDirList[getDir][dirName1].size+' '+IDrive.LocalDirList[getDir][dirName1].datetime+' '; dirHTML += ''; } } if (dirHTML != '') { jQuery('#'+toPlace).show().siblings('.nfiles').hide(); if (page_no > 1) { jQuery('#'+toPlace).find('tbody').append(dirHTML); } else { jQuery('#'+toPlace).find('tbody').html(dirHTML); } } } else { jQuery('.ajax_loader').hide(); if(page_no <=1) { jQuery('#'+toPlace).hide().siblings('.nfiles').show(); jQuery('#'+toPlace).find('tbody').html(''); jQuery('#maincheck,#selectFiles #maincheck').siblings('label').css('visibility','hidden'); } } } localFileBreadcrumb(getDir,toPlace,breadcrum,maincheck); //Call breadCrumb function markSelectedItems(getDir,toPlace,breadcrum,maincheck); //Call function to "Mark" the selected Items if(toPlace=='newBackupSet'){ jQuery('#'+toPlace).find('td').removeClass('file_menu_list'); } } // AJAX Call for new if(typeof dirListVal == "undefined" || dirListVal === "" || ((typeof dynamicRequestInfo[getDir] != "undefined") && !dynamicRequestInfo[getDir]['success'])) { var request = function(page_no) { jQuery(forLoader).siblings('.ajax_loader').show(); currentAjaxRequest = jQuery.ajax({ url: (url + "&page_no=" + page_no), success: function(locationData){ if(locationData.indexOf('')>0){ window.location.href='../index.php'; } jQuery(forLoader).siblings('.ajax_loader').hide(); if(locationData.trim()==''){ return true; } locationDataRes=$.parseJSON(locationData); //Keeping file/folder list to avoid AJAX call var dirURL = decodeURIComponent(locationDataRes[2]['url']); var dirList = locationDataRes[2]['dir']; var dirType = locationDataRes[2]['type']; if (page_no == 1) { dynamicArray[dirURL]=dirList; dynamicType[dirURL] =dirType; if(typeof(IDrive.LocalDirList) == 'undefined') { IDrive.LocalDirList = []; } IDrive.LocalDirList[dirURL] = locationDataRes[2]['dir_list']; if(locationDataRes[0]==true){ jQuery('#'+toPlace).show().siblings('.nfiles').hide(); } jQuery('#'+toPlace).find('tbody').html(locationDataRes[1]); } else { var tempDirList = dirList; var tempDirType = dirType; var tempDataRes = locationDataRes[2]['dir_list']; tempDirList = dynamicArray[dirURL].concat(tempDirList); tempDirType = dynamicType[dirURL].concat(tempDirType); tempDataRes = $.extend(IDrive.LocalDirList[dirURL], tempDataRes); dynamicArray[dirURL] = tempDirList; dynamicType[dirURL] = tempDirType; dynamicRequestInfo[dirURL] = {'page_no': page_no, 'success': false}; IDrive.LocalDirList[dirURL] = tempDataRes; } backup_list_template(dirURL, dirList, dirType, locationDataRes[0], page_no); if ((dirList !== null) && ((dirList.length * page_no) >= (998 * page_no))) { dynamicRequestInfo[dirURL] = {'page_no': page_no, 'success': false}; jQuery('#' + toPlace + '>.excludefiles').unbind('scroll').scroll(function() { var scrollHeight = jQuery('#' + toPlace + '>.excludefiles')[0].scrollHeight; var scrollTop = jQuery('#' + toPlace + '>.excludefiles').scrollTop(); var outerHeight = jQuery('#' + toPlace + '>.excludefiles').outerHeight(); if ((scrollHeight - scrollTop) == outerHeight) { request(++page_no); $(this).unbind('scroll'); } }); } else { dynamicRequestInfo[dirURL] = {'page_no': page_no, 'success': true}; } },//need to add error handling to remove loader atleast. error: function (request, status, error) { jQuery(forLoader).siblings('.ajax_loader').hide(); } }); } if ((typeof dynamicRequestInfo[getDir] != "undefined") && !dynamicRequestInfo[getDir]['success']) { backup_list_template(getDir, dirListVal, dirListType, true, 1); jQuery('#' + toPlace + '>.excludefiles').unbind('scroll').scroll(function() { var scrollHeight = jQuery('#' + toPlace + '>.excludefiles')[0].scrollHeight; var scrollTop = jQuery('#' + toPlace + '>.excludefiles').scrollTop(); var outerHeight = jQuery('#' + toPlace + '>.excludefiles').outerHeight(); if ((scrollHeight - scrollTop) == outerHeight) { request(++dynamicRequestInfo[getDir]['page_no']); $(this).unbind('scroll'); } }); } else { request(1); } } else if(dirListVal === null || dirListVal == ""){ jQuery('#'+toPlace).hide().siblings('.nfiles').show(); jQuery('#maincheck,#selectFiles #maincheck').siblings('label').css('visibility','hidden'); jQuery('#'+toPlace).find('tbody').html(''); jQuery(forLoader).siblings('.ajax_loader').hide(); localFileBreadcrumb(getDir,toPlace,breadcrum,maincheck); //Call breadCrumb function } else { //Loading files/folders from array intead of making AJAX call again jQuery('#'+toPlace).show().siblings('.nfiles').hide(); jQuery(forLoader).siblings('.ajax_loader').show(); var dirHTML = ''; /* Condition added for synology market place */ if(getDir=='/'){ for(var j=0; j0))){ var tr_style='style="display: none;"'; continue } else{ var tr_style=''; } var splitDir = dirFullPath.split("/"); var dir = splitDir.pop(); dirName1 = dirName.replace('"','"'); dirFullPath = htmlEntities(dirFullPath); dirName = htmlEntities(dirName); dir = htmlEntities(dir); drivePath = htmlEntities(drivePath); if(machine=='QNAP' || machine==ASUSTOR){ var drivePath = splitDir[1]+"/"+splitDir[2]; } else { var drivePath = splitDir[1]; } var title ; if(machine=='twotier' || rootLevelEnabled==true){ title = dir; } else if(machine==ASUSTOR){ title = IDrive.LocalDirList[getDir][dirName1].filename; } else { title = dir+' @ '+drivePath; } var dirDisplayName = dir; if(machine==ASUSTOR){ var dirDisplayName = IDrive.LocalDirList[getDir][dirName1].filename; } if(dirType=='folder'){ dirHTML += ''; dirHTML += ''; dirHTML += ''; dirHTML += ''; dirHTML += ''; dirHTML += dirDisplayName.replace(/[\s]/g,' '); dirHTML += ''; if(typeof(IDrive.LocalDirList) == 'undefined') { IDrive.LocalDirList = []; } dirHTML += ' -- '+IDrive.LocalDirList[getDir][dirName1].datetime+' '; dirHTML += ''; dirHTML += ''; } else { dirHTML += ''; dirHTML += ''; dirHTML += ''; dirHTML += dirDisplayName.replace(/[\s]/g,' '); dirHTML += ''; dirHTML += ' '+IDrive.LocalDirList[getDir][dirName1].size+' '+IDrive.LocalDirList[getDir][dirName1].datetime+' '; dirHTML += ''; dirHTML += ''; } } } else { for(var j=0; j'; dirHTML += ''; dirHTML += ''; dirHTML += ''; dirHTML += ''; dirHTML += dirName.replace(/[\s]/g,' '); dirHTML += ''; dirHTML += ' -- '+IDrive.LocalDirList[getDir][dirName1].datetime+' '; dirHTML += ''; } else { dirHTML += ''; dirHTML += ''; dirHTML += ''; dirHTML += dirName.replace(/[\s]/g,' '); dirHTML += ''; dirHTML += ' '+IDrive.LocalDirList[getDir][dirName1].size+' '+IDrive.LocalDirList[getDir][dirName1].datetime+' '; dirHTML += ''; } } } jQuery(forLoader).siblings('.ajax_loader').hide(); if(dirHTML!=''){ jQuery('#'+toPlace).find('tbody').html(dirHTML); } else { jQuery('#'+toPlace).hide().siblings('.nfiles').show(); jQuery('#maincheck,#selectFiles #maincheck').siblings('label').css('visibility','hidden'); } localFileBreadcrumb(getDir,toPlace,breadcrum,maincheck); //Call breadCrumb function markSelectedItems(getDir,toPlace,breadcrum,maincheck); //Call function to "Mark" the selected Items if(toPlace=='newBackupSet'){ jQuery('#'+toPlace).find('td').removeClass('file_menu_list'); } } } //Function to update BreadCrumb & keep the child file/folders as Selected if parent got selected function localFileBreadcrumb(getDir,toPlace,breadcrum,maincheck){ var splitDir = getDir.split('/'); var breadCrumb = 'Home'; var currDir = ""; splitDir = splitDir.filter(function(val) { if(!(val === "" || typeof val == "undefined" || val === null)){ currDir += "/"+htmlEntities(val); var title = currDir; if(machine=='twotier'){ title = currDir.substring(sharedFolderPathLength); } breadCrumb += ''+val+''; } }); jQuery('#'+breadcrum).html(breadCrumb); responsiveBreadcrumb('#'+breadcrum,'getDirList'); } //Function to "Mark" the selected Items function markSelectedItems(getDir,toPlace,breadcrum,maincheck){ if(rootLevelEnabled==false && getDir == "/"){ getDir = rootLevelVal; } var split_path = getDir.split('/'); var split_path_count = split_path.length; var selected_path = ''; var selected_path_found = 0; var current_directory = jQuery('#fullPathBreadCrumb a:last').attr('alt'); //Backup Set if(toPlace=='loadFullPath'){ if(jQuery('.body_wrap').hasClass('backup_page')){ //Backup Set var tempBackupSetArray = backupSetArray.slice(); } else { //Local Backup Set var tempBackupSetArray = localBackupSetArray.slice(); } //Avoiding the missing items of backup set if(defaultBackupSetFileInfo.length>0){ var test = defaultBackupSetFileInfo.filter(function(val) { var index = tempBackupSetArray.indexOf(val); if(index>=0){ tempBackupSetArray.splice(index, 1); } }); } //Backup Set: For child under the selected parent for(var i=1; i=0){ if(dynamicArray.indexOf(clickedDirPath) != "" && dynamicArray[clickedDirPath] != null) { var id_of_element = dynamicArray[clickedDirPath].indexOf(val); if(id_of_element>=0){ if(sh=='Hide') { var hiddenCount = countHiddenFilesAboveSelectedFile(clickedDirPath, val); id_of_element = id_of_element - hiddenCount; } var selected_dir_id = jQuery('#loadFullPath input[type="checkbox"]').eq(id_of_element); selected_dir_id.attr('checked',true).next().addClass('label_checked').closest('tr').addClass('chk'); if(selected_dir_id.attr('checked')=='checked'){ jQuery('.backupFilePath #maincheck').next().addClass('label_semi_checked'); } } } } } }); } //Mark "Partial check" if its child has been selected var curPathDirList = dynamicArray[clickedDirPath]; if(curPathDirList != null){ if(curPathDirList.length>0){ for(var i=0; i0){ selected_dir = getDir; var check_parent = array_search(curPathDirList1,selected_dir); if(check_parent.length>0){ var val = check_parent[0].slice(0,-1); if(dynamicArray.indexOf(clickedDirPath) != "" && dynamicArray[clickedDirPath] != null) { var id_of_element = dynamicArray[clickedDirPath].indexOf(val); var selected_dir_id = jQuery('#loadFullPath input[type="checkbox"]').eq(id_of_element); if(selected_dir_id.attr('checked')!='checked'){ selected_dir_id.next().addClass('label_semi_checked'); jQuery('.backupFilePath #maincheck').next().addClass('label_semi_checked'); } } } } } } else { //New Backup Set: For child under the selected parent for(var i=1; i=0){ if(sh=='Hide') { var hiddenCount = countHiddenFilesAboveSelectedFile(clickedDirPath, val); id_of_element = id_of_element - hiddenCount; } var selected_dir_id = jQuery('#newBackupSet input[type="checkbox"]').eq(id_of_element); selected_dir_id.attr('checked',true).next().addClass('label_checked').closest('tr').addClass('chk'); jQuery('#selectFiles #maincheck').next().addClass('label_semi_checked'); } } } }); } //Mark "Partial check" if its child has been selected var curPathDirList = dynamicArray[clickedDirPath]; if(curPathDirList != null){ if(curPathDirList.length>0){ for(var i=0; i')>0){ window.location.href='../index.php'; } dataArray=$.parseJSON(data); if(dataArray[0]=='running'){ showStartBackupButton(); return false; } else { reIndexStarted=false; } } }); } $("#backupsetFiles").find('tr:hidden input:checkbox').addClass("excludeForBackup"); var fieldsCount = jQuery("form[name*='startBackupForm'] input[type='checkbox']:not(.excludeForBackup)").attr('checked',true).length; if(fieldsCount == 0){ showErrorMessages('.head_search .error_msg',"Please select folder(s)/file(s) to backup"); showStartBackupButton(); return false; } if(machine=='twotier') { manualBackupAJAX(); } else { if(checkArchiveRunningAjax==true){ showStartBackupButton(); return false; } checkArchiveRunningAjax=true; //showErrorMessages('.head_search .alert','Verifying the archive cleanup process'); // check archive job is running var urlCheck = "action.php?action=checkJobRunning&job=archive"; $.get(urlCheck,function(jobdata){ jQuery('.head_search .alert').hide(); checkArchiveRunningAjax=false; var jobresult = $.parseJSON(jobdata); var jobStatus = jobresult.jobstatus; if(jobStatus !== true){ manualBackupAJAX(); } else{ showErrorMessages('.head_search .error_msg',"Unable to start backup. Archive is in progress."); showStartBackupButton(); return; } }); } //Edit BackupSetFile if(actionRequired==2){ editJob('backup'); } return false; } function manualBackupAJAX(){ if(jQuery("#backupLocation").val()==''){ showErrorMessages('.head_search .error_msg','Please select the Backup Location'); showStartBackupButton(); return false; } else { var currentBackupLocation = jQuery("#backupLocation").val(); } jQuery("#startManualTaskButton").val('Yes'); jQuery("#cancelManualTaskButton").val(''); $("#backupsetFiles").find('tr:hidden input:checkbox').addClass("excludeForBackup"); var fieldsCount = jQuery("form[name*='startBackupForm'] input[type='checkbox']:not(.excludeForBackup)").attr('checked',true).length; var values = jQuery("form#startBackupForm").serialize(); if(fieldsCount > 0){ //showStopBackupButton(); //jQuery("div.loading_icon").show(); var type = 'backup'; if(jQuery('.body_wrap').hasClass('backup_page')){ manualBackupRunning=true; //Clearing Default Set Array defaultBackupSetArray = []; defaultBackupSetTypeArray = []; defaultBackupSetFileInfo = []; jQuery("form[name*='startBackupForm'] input[type='checkbox']:checked").each(function(){ var dirName = jQuery(this).val(); var dirType = jQuery(this).siblings('input[type="hidden"]').val(); defaultBackupSetArray.push(dirName); defaultBackupSetTypeArray.push(dirType); }); } else { manualLocalBackupRunning=true; type = 'localBackup'; var currentBackupLocation = jQuery("#selectBackupLocation").val(); //Clearing Default Set Array defaultLocalBackupSetArray = []; defaultLocalBackupSetTypeArray = []; defaultBackupSetFileInfo = []; jQuery("form[name*='startBackupForm'] input[type='checkbox']:checked").each(function(){ var dirName = jQuery(this).val(); var dirType = jQuery(this).siblings('input[type="hidden"]').val(); defaultLocalBackupSetArray.push(dirName); defaultLocalBackupSetTypeArray.push(dirType); }); } //AJAX call to start Backup $.ajax({ url: "createManualJob.php", type: "POST", data: values, success: function(validatedData){ if(validatedData.indexOf('')>0){ window.location.href='../index.php'; } if(validatedData!=''){ validatedRes=$.parseJSON(validatedData); if(validatedRes[0]==true){ // calling activejob watcher after successfull job start clearTimeout(activeJobsTimeoutVar); activeJobsTimeoutVar = setTimeout(watcherForActiveJobs, PROGRESS_WATCHER_ENABLE_TIME); backupTimeoutVar = setTimeout(function(){watchBackupStatus(type)},timeForWatcher); showErrorMessages('.head_search .welcome_message','Backup has been started successfully.'); if(deDupDeviceID) bkpLocation = deDupDeviceID.substr(4).slice(0, -4); else bkpLocation = currentBackupLocation; deleteRemoteDirList(bkpLocation,type); //Delete the element from RemoteDirList array after Backup } else { showStartBackupButton(); clearTimeout(backupTimeoutVar); if(type == 'backup') manualBackupRunning=false; else manualLocalBackupRunning=false; if(validatedRes[1] == 1) showErrorMessages('.head_search .error_msg',"Backup job for the selected set is already in progress from scheduled jobs."); else showErrorMessages('.head_search .error_msg',"Backup Job has failed to start."); } } } }); } else { showStartBackupButton(); showErrorMessages('.head_search .error_msg',"Please select folder(s)/file(s) to backup"); } } /* Start Manual Backup - End*/ function showStartBackupButton() { jQuery("#startBackup").show(); jQuery("#cancelBackup,#cancellingBackup,.alert,.cancel_loading_icon").hide(); } function showStopBackupButton(){ jQuery("#startBackup").hide(); jQuery("#cancelBackup").show(); } /* Cancel Manual Backup Immediately - Start*/ function cancelManualBackup(){ jQuery("#cancelManualTaskButton").val('Yes'); jQuery("#startManualTaskButton").val(''); var values = jQuery("form#startBackupForm").serialize(); manualBackupRunning=false; if(values != ''){ jQuery('.common_msg').hide(); showErrorMessages('.head_search .alert',"Cancelling backup operation...Please wait"); if(jQuery('.body_wrap').hasClass('backup_page')){ //Clearing Default Set Array defaultBackupSetArray = []; defaultBackupSetTypeArray = []; } else { //Clearing Default Set Array defaultLocalBackupSetArray = []; defaultLocalBackupSetTypeArray = []; $('.backupset_table').find('input[type="checkbox"]').attr('checked', false); } defaultBackupSetFileInfo = []; //AJAX call to start Backup $.ajax({ url: "createManualJob.php", type: "POST", data: values, success: function(validatedData){ if(validatedData.indexOf('')>0){ window.location.href='../index.php'; } jQuery("#cancelBackup").hide(); jQuery("#cancellingBackup,.cancel_loading_icon").show(); //jQuery("div.loading_icon").hide(); } }); } return false; } /* Cancel Manual Backup Immediately - End*/ /* Backup Set - Start */ jQuery(document).on('click', '.backupFilePath td.file_check, .backupFilePath .header_part .file_check', function(e) { //Checking whether clicked on Checkbox or TD var clickedLabel = e.target.nodeName; if(clickedLabel != 'LABEL'){ return false; } //Checking whether Job Selected to Edit or not if(actionRequired ==1){ actionRequired =2; startTimeoutForAutoPost('backup'); //Auto POST } if(jQuery(this).find('label').hasClass('label_checked')){ if(jQuery(this).find('label').html()=="All"){ backupSetFiles("All"); } else { backupSetFiles(jQuery(this)); } } else { if(jQuery(this).find('label').html()=="All"){ removeBackupSetFiles("All","loadFullPath"); } else { removeBackupSetFiles(jQuery(this),"loadFullPath"); } } markMaincheckAfterRemove('startBackupForm'); //Added to check/uncheck the main check of backup set while add/remove item getItemSize(); }); /* Function to add selected elements into Backup Set */ function backupSetFiles(args) { var html = '', selected=''; if(jQuery('.body_wrap').hasClass('backup_page')){ var checkArray1 = backupSetArray; var checkArray2 = backupSetTypeArray; var checkArray3 = defaultBackupSetArray; var checkArray4 = defaultBackupSetTypeArray; } else { var checkArray1 = localBackupSetArray; var checkArray2 = localBackupSetTypeArray; var checkArray3 = defaultLocalBackupSetArray; var checkArray4 = defaultLocalBackupSetTypeArray; } /* Show files/folders under Backup Set. Hide "No items" - Start */ if(checkArray1.indexOf(selected)==-1){ jQuery('#removebBackupsetFiles span').hide(); jQuery('#maincheckBackup').siblings('label').removeAttr('class').parent().parent().show(); jQuery('#noBackupsetFiles').hide().siblings('form').find('.excludefiles').show(); } /* Show files/folders under Backup Set. Hide "No items" - End */ if(args!="All"){ var fileCheckLabel = jQuery('.backupFilePath .header_part .file_check label'); if(fileCheckLabel.hasClass('label_checked')){ args = "All"; } } /* if(rootLevelEnabled==false && clickedDirPath =='/'){ clickedDirPath = rootLevelVal; } */ /* Add selected files/folders under Backup Set - Start */ if(args=="All" && clickedDirPath =='/'){ jQuery('#loadFullPath input').each(function(){ selected = jQuery(this).val(); toParse = selected.replace('/',''); var parsedID = toParse.replace(/[\/]/g,'_'); parsedID = base64_encode(parsedID,1); parsedID = parsedID.replace(/[=]/gi, ''); var imgSrc = jQuery(this).parent().next().find('img').attr('src'); var imgSubstr = imgSrc.substring(23); var itemType = imgSubstr.replace('.png',''); if(checkArray1.indexOf(selected)==-1){ //To skip if the file/folder is hidden if(sh=='Hide' && selected.indexOf('/.')>=1){ return; } var displaySelected = selected; if(machine=='twotier'){ displaySelected = selected.substring(sharedFolderPathLength); } html += '\ \ '+htmlEntities(displaySelected).replace(/[\s]/g,' ');+'\ '; var selected_dir = selected+"/"; if(checkArray1.length>0){ var check_parent = array_search(checkArray1,selected_dir); if(check_parent.length>0){ removeSubDirecories(check_parent,'backupsetFiles'); } } checkArray1.push(selected); checkArray2.push(itemType); if(jQuery('#select_job').val()=='0' || machine=='twotier'){ if((jQuery('.body_wrap').hasClass('backup_page') && manualBackupRunning==false) || (jQuery('.body_wrap').hasClass('localbackup_page') && manualLocalBackupRunning==false)){ checkArray3.push(selected); checkArray4.push(itemType); } } } }); jQuery('#backupsetFiles').append(html); } else { var breadCrumbCall=false; if(args=='All'){ breadCrumbCall=true; args = clickedDirPath.replace(/\/$/, ''); } if(typeof args!='string'){ selected = args.find('input').val(); toParse = selected.replace('/',''); var parsedID = toParse.replace(/[\/]/g,'_'); parsedID = base64_encode(parsedID,1); parsedID = parsedID.replace(/[=]/gi, ''); var imgSrc = args.next().find('img').attr('src'); var imgSubstr = imgSrc.substring(23); var itemSize = args.siblings(".file_size").attr('value'); var itemLModf = args.siblings(".file_date").attr('value'); var itemType = imgSubstr.replace('.png',''); var selected_dir = selected+"/"; } else { selected = args; if(breadCrumbCall==true || jQuery('.serverDts ').css('right')=='0px'){ var selected_dir = selected + "/"; var checkParent = ''; if($("#addToBackupSet").is(":visible") && jQuery('.serverDts ').css('right') == '0px') { checkParent = array_search_reverse_display(checkArray1, selected_dir); } else { checkParent = array_search_reverse(checkArray1, selected); } if(checkParent.length > 0) { return false; } } toParse = selected.replace('/',''); var parsedID = toParse.replace(/[\/]/g,'_'); parsedID = base64_encode(parsedID,1); parsedID = parsedID.replace(/[=]/gi, ''); if(breadCrumbCall==false){ var searchItemIndex = searchItemArray.indexOf(selected); var itemType = searchItemTypeArray[searchItemIndex]; var imgSrc = "include/images/idq_ico_"+itemType+".png"; } else { var itemType = 'folder'; var imgSrc = "include/images/idq_ico_"+itemType+".png"; } } if(checkArray1.indexOf(selected)==-1){ var displaySelected = selected; if(machine=='twotier'){ displaySelected = selected.substring(sharedFolderPathLength); } html = '\ \ '+htmlEntities(displaySelected).replace(/[\s]/g,' ');+'\ '; jQuery('#backupsetFiles').append(html); if(checkArray1.length>0){ //Checking parent with Child item var check_parent = array_search(checkArray1,selected+'/'); if(check_parent.length>0){ removeSubDirecories(check_parent,'backupsetFiles'); } //Checking Child with parent item var check_child = array_search_reverse_display(checkArray1,selected); if(check_child.length>0){ removeSubDirecories(check_child,'backupsetFiles'); } } checkArray1.push(selected); checkArray2.push(itemType); if(jQuery('#select_job').val()=='0' || machine=='twotier'){ if((jQuery('.body_wrap').hasClass('backup_page') && manualBackupRunning==false) || (jQuery('.body_wrap').hasClass('localbackup_page') && manualLocalBackupRunning==false)){ checkArray3.push(selected); checkArray4.push(itemType); } } } } /* Add selected files/folders under Backup Set - End */ } /* Function to remove selected elements from Backup Set */ function removeBackupSetFiles(args,DivId){ if(DivId=='loadFullPath'){ //Backup Set var parentDiv = 'backupsetFiles'; var breadCrumbID = 'fullPathBreadCrumb'; if(jQuery('.body_wrap').hasClass('backup_page')){ var backupArray1 = backupSetArray; var backupArray2 = backupSetTypeArray; var backupArray3 = defaultBackupSetArray; var backupArray4 = defaultBackupSetTypeArray; } else { var backupArray1 = localBackupSetArray; var backupArray2 = localBackupSetTypeArray; var backupArray3 = defaultLocalBackupSetArray; var backupArray4 = defaultLocalBackupSetTypeArray; } } else { //New Backup Set var parentDiv = 'selectedBackupsetFiles'; var breadCrumbID = 'bkpBreadCrumb'; var backupArray1 = newBackupSetArray; var backupArray2 = newBackupSetTypeArray; } if(args=="All" && clickedDirPath =='/'){ jQuery('#'+parentDiv+' tr').remove(); backupArray1=[]; backupArray2=[]; if(DivId=='loadFullPath' && (jQuery('#select_job').val()=='0' || machine=='twotier')){ if((jQuery('.body_wrap').hasClass('backup_page') && manualBackupRunning==false) || (jQuery('.body_wrap').hasClass('localbackup_page') && manualLocalBackupRunning==false)){ backupArray3=[]; backupArray4=[]; defaultBackupSetFileInfo = []; } } } else { var checkedElement = jQuery('#'+DivId+' tr.chk input:checked'); if(args=="All"){ selected = clickedDirPath; }else{ selected = args.find('input').val(); } var index = backupArray1.indexOf(selected); if(index>=0){ toParse = selected.replace('/',''); var parsedID = toParse.replace(/[\/]/g,'_'); parsedID = base64_encode(parsedID,1); parsedID = parsedID.replace(/[=]/gi, ''); jQuery('#'+parentDiv+' tr#'+parsedID).remove(); backupArray1.splice(index, 1); backupArray2.splice(index, 1); if(DivId=='loadFullPath' && (jQuery('#select_job').val()=='0' || machine=='twotier')){ if((jQuery('.body_wrap').hasClass('backup_page') && manualBackupRunning==false) || (jQuery('.body_wrap').hasClass('localbackup_page') && manualLocalBackupRunning==false)){ backupArray3.splice(index, 1); backupArray4.splice(index, 1); } } } else { if(args=="All"){ var allClickedDirPath = clickedDirPath.split('/'); allClickedDirPath.pop(); var parentPath = allClickedDirPath.join("/"); } else{ var parentPath = clickedDirPath; } var index = backupArray1.indexOf(parentPath); if(index>=0 && args!="All"){ toParse = backupArray1[index].replace('/',''); var parsedID = toParse.replace(/[\/]/g,'_'); parsedID = base64_encode(parsedID,1); parsedID = parsedID.replace(/[=]/gi, ''); jQuery('#'+parentDiv+' tr#'+parsedID).remove(); backupArray1.splice(index, 1); backupArray2.splice(index, 1); if(DivId=='loadFullPath' && (jQuery('#select_job').val()=='0' || machine=='twotier')){ if((jQuery('.body_wrap').hasClass('backup_page') && manualBackupRunning==false) || (jQuery('.body_wrap').hasClass('localbackup_page') && manualLocalBackupRunning==false)){ backupArray3.splice(index, 1); backupArray4.splice(index, 1); } } addSelectedItemExceptUnchecked(parentDiv,checkedElement,parentPath); // Call function to add other items } else { var clickedDirPathSplit = parentPath.split('/'); if(args!="All") clickedDirPathSplit.pop(); var clickedDirPathSplitCount = clickedDirPathSplit.length; var pathAppend = ''; var pathSearch = new Array(); for(var i=1; i=0; j--){ var index = backupArray1.indexOf(pathSearch[j]); addSelectedItemExceptUnchecked(parentDiv,'',pathSearch[j]); //Call function to add other items if(index>=0){ toParse = pathSearch[j].replace('/',''); var parsedID = toParse.replace(/[\/]/g,'_'); parsedID = base64_encode(parsedID,1); parsedID = parsedID.replace(/[=]/gi, ''); jQuery('#'+parentDiv+' tr#'+parsedID).remove(); backupArray1.splice(index, 1); backupArray2.splice(index, 1); if(DivId=='loadFullPath' && (jQuery('#select_job').val()=='0' || machine=='twotier')){ if((jQuery('.body_wrap').hasClass('backup_page') && manualBackupRunning==false) || (jQuery('.body_wrap').hasClass('localbackup_page') && manualLocalBackupRunning==false)){ backupArray3.splice(index, 1); backupArray4.splice(index, 1); } } break; } } } //End } } checkRemainingBackupsetFiles(DivId); markMaincheckAfterRemove('loadFullPath'); } /* Function to remove already selected sub-directories while selecting its parent */ function removeSubDirecories(args,parentDiv){ arr_length = args.length; if(parentDiv == 'selectedBackupsetFiles'){ //New Backup Set var backupArray1 = newBackupSetArray; var backupArray2 = newBackupSetTypeArray; } else { if(jQuery('.body_wrap').hasClass('backup_page')){ //Backup Set var backupArray1 = backupSetArray; var backupArray2 = backupSetTypeArray; var backupArray3 = defaultBackupSetArray; var backupArray4 = defaultBackupSetTypeArray; } else { //Local Backup Set var backupArray1 = localBackupSetArray; var backupArray2 = localBackupSetTypeArray; var backupArray3 = defaultLocalBackupSetArray; var backupArray4 = defaultLocalBackupSetTypeArray; } } for(var i=0;i\ \ '+htmlEntities(displaySelected).replace(/[\s]/g,' ');+'\ '; var selected_dir = selected+"/"; backupArray1.push(selected); backupArray2.push(itemType); if(backupsetDivID=='backupsetFiles'){ backupArray3.push(selected); backupArray4.push(itemType); } } }); jQuery('#'+backupsetDivID).append(html); } else { var dirListVal = dynamicArray[currDirPath]; var dirTypeVal = dynamicType[currDirPath]; var dirHTML = ''; for(var j=0; j< dirListVal.length; j++){ var dirFullPath = dirListVal[j]; var itemType = dirTypeVal[j]; var splitPath = dirFullPath.split('/'); var dirName = splitPath[splitPath.length-1]; selected = dirFullPath; toParse = selected.replace('/',''); var parsedID = toParse.replace(/[\/]/g,'_'); parsedID = base64_encode(parsedID,1); parsedID = parsedID.replace(/[=]/gi, ''); var isInString = clickedDirPath.indexOf(selected+'/'); if(backupArray1.indexOf(selected)==-1 && isInString==-1 && clickedDirPath!=selected){ var displaySelected = selected; if(machine=='twotier'){ displaySelected = selected.substring(sharedFolderPathLength); } dirHTML += '\ \ '+htmlEntities(displaySelected).replace(/[\s]/g,' ');+'\ '; var selected_dir = selected+"/"; backupArray1.push(selected); backupArray2.push(itemType); if(backupsetDivID=='backupsetFiles'){ backupArray3.push(selected); backupArray4.push(itemType); } } } } jQuery('#'+backupsetDivID).append(dirHTML); } /* Backup Set - End */ /* New Backup Set - Start */ jQuery(document).on('click', '.newBackupSetClass #newBackupSet td.file_check, .newBackupSetClass #selectFiles .header_part .file_check', function(e) { //Checking whether clicked on Checkbox or TD var clickedLabel = e.target.nodeName; if(clickedLabel != 'LABEL'){ return false; } if(jQuery(this).find('label').hasClass('label_checked')){ if(jQuery(this).find('label').html()=="All"){ newBackupSetFiles("All"); } else { newBackupSetFiles(jQuery(this)); } } else { if(jQuery(this).find('label').html()=="All"){ removeBackupSetFiles("All","newBackupSet"); } else { removeBackupSetFiles(jQuery(this),"newBackupSet"); } } }); /* Function to add selected elements into New Backup Set */ function newBackupSetFiles(args){ var html = '', selected=''; /* Show files/folders under Backup Set. Hide "No items" - Start */ if(newBackupSetArray.indexOf(selected)==-1){ jQuery('#selectedFiles .main_chk_table').show(); jQuery('.selected_bdr .nfiles').hide(); } /* Show files/folders under Backup Set. Hide "No items" - End */ if(args!="All"){ var fileCheckLabel = jQuery('.selectedFiles_tab .header_part .file_check label'); if(fileCheckLabel.hasClass('label_checked')){ args = "All"; } } /* Add selected files/folders under Backup Set - Start */ if(args=="All" && clickedDirPath =='/'){ jQuery('#newBackupSet input').each(function(){ selected = jQuery(this).val(); toParse = selected.replace('/',''); var parsedID = toParse.replace(/[\/]/g,'_'); parsedID = base64_encode(parsedID,1); parsedID = parsedID.replace(/[=]/gi, ''); var itemSize = jQuery(this).parent('td').siblings(".file_size").html(); var itemLModf = jQuery(this).parent('td').siblings(".file_date").html(); var imgSrc = jQuery(this).parent().next().find('img').attr('src'); var imgSubstr = imgSrc.substring(23); var itemType = imgSubstr.replace('.png',''); if(newBackupSetArray.indexOf(selected)==-1){ //To skip if the file/folder is hidden if(sh=='Hide' && selected.indexOf('/.')>=1){ return; } var displaySelected = selected; html += '\ \ '+htmlEntities(displaySelected).replace(/[\s]/g,' ');+'\ '; if(newBackupSetArray.length>0){ var check_parent = array_search(newBackupSetArray,selected); if(check_parent.length>0){ removeSubDirecories(check_parent,'selectedBackupsetFiles'); } } newBackupSetArray.push(selected); } }); jQuery('#selectedBackupsetFiles').append(html); } else { var breadCrumbCall=false; if(args=='All'){ breadCrumbCall=true; args = clickedDirPath.replace(/\/$/, ''); } if(typeof args!='string'){ selected = args.find('input').val(); toParse = selected.replace('/',''); var parsedID = toParse.replace(/[\/]/g,'_'); parsedID = base64_encode(parsedID,1); parsedID = parsedID.replace(/[=]/gi, ''); var imgSrc = args.next().find('img').attr('src'); var itemSize = args.siblings(".file_size").attr('value'); var itemLModf = args.siblings(".file_date").attr('value'); var imgSubstr = imgSrc.substring(23); var itemType = imgSubstr.replace('.png',''); var selected_dir = selected+"/"; } else { selected = args; if(breadCrumbCall==true){ var checkParent = array_search_reverse(newBackupSetArray, selected); if(checkParent.length>0){ return false; } } toParse = selected.replace('/',''); var parsedID = toParse.replace(/[\/]/g,'_'); parsedID = base64_encode(parsedID,1); parsedID = parsedID.replace(/[=]/gi, ''); var itemType = 'folder'; var imgSrc = "include/images/idq_ico_"+itemType+".png"; } if(newBackupSetArray.indexOf(selected)==-1){ var displaySelected = selected; html = '\ \ '+htmlEntities(displaySelected).replace(/[\s]/g,' ');+'\ '; jQuery('#selectedBackupsetFiles').append(html); if(newBackupSetArray.length>0){ //Checking parent with Child item var check_parent = array_search(newBackupSetArray,selected+'/'); if(check_parent.length>0){ removeSubDirecories(check_parent,'selectedBackupsetFiles'); } //Checking Child with parent item var check_child = array_search_reverse(newBackupSetArray,selected); if(check_parent.length>0){ removeSubDirecories(check_child,'selectedBackupsetFiles'); } } newBackupSetArray.push(selected); } } /* Add selected files/folders under Backup Set - End */ } /* New Backup Set - End */ //Function frequently check the ManualTask status until complete function watchBackupStatus(type) { // AJAX call to get Backup Status $.ajax({ url: "watchManualTaskStatus.php?type=" + type, success: function(data) { if(data.indexOf('') > 0) { window.location.href = '../index.php'; } // manualBackupRunning = true; if(data == 'running') { jQuery("#startBackup, #cancellingBackup, .cancel_loading_icon").hide(); jQuery("#cancelBackup").show(); backupTimeoutVar = setTimeout(function(){watchBackupStatus(type)}, timeForWatcher); } else if(data == 'cancelling') { jQuery("#startBackup, #cancelBackup").hide(); jQuery("#cancellingBackup, .cancel_loading_icon").show(); backupTimeoutVar = setTimeout(function(){watchBackupStatus(type)}, timeForWatcher); } else if(data == 'completed') { jQuery("#startBackup").show(); jQuery("#cancelBackup, #cancellingBackup, .alert, .cancel_loading_icon").hide(); if(machine == 'twotier' && type == "backup") { manualBackupRunning = false; } else { containerPage = ''; if(type == "backup") { containerPage = '.backup_page '; } else { containerPage = '.localbackup_page '; } jQuery(containerPage + "#backupsetFiles").html(''); jQuery(containerPage + "#noBackupsetFiles").show().siblings('form').find('div.excludefiles').hide(); jQuery(containerPage + "#backupset_list tr.header_part, #backupset_list td.scheduleChangeBtn").hide(); jQuery(containerPage + ".archive_menu, .sizeLoadingIcon").hide(); jQuery(containerPage + ".backupFilePath label").removeAttr('class').siblings('input').removeAttr('checked'); jQuery(containerPage + "select.backupsetInput option").removeAttr('selected'); jQuery(containerPage + "#oldJobName").val('0'); jQuery(containerPage + "#backupSetSizeHTML").html('0.00 B'); jQuery(containerPage + "#backupSetSize").val(0); //Senthil: Added this condition for the issue after cancelling backup with full items if(type == "backup" && ((typeof manualBackupRunning != "undefined" && manualBackupRunning == true) || (defaultBackupSetArray.length ==0))){ //if(type == "backup" && typeof manualBackupRunning != "undefined" && manualBackupRunning == true){ // if(type == "backup") { backupSetArray = []; backupSetTypeArray = []; // Clearing Default Set Array defaultBackupSetArray = []; defaultBackupSetTypeArray = []; defaultBackupSetFileInfo = []; manualBackupRunning = false; } else if(typeof manualLocalBackupRunning != "undefined" && manualLocalBackupRunning == true) { // } else { localBackupSetArray = []; localBackupSetTypeArray = []; // Clearing Local Default Set Array defaultLocalBackupSetArray = []; defaultLocalBackupSetTypeArray = []; manualLocalBackupRunning = false; } clearTimeout(backupTimeoutVar); //Stop watcher backupTimeoutVar = ''; actionRequired = 1; currentBackupJob = 0; jQuery(containerPage + "#cancelManualTaskButton").val('Yes'); jQuery(containerPage + "#startManualTaskButton").val(''); } } else { backupTimeoutVar = setTimeout(function(){watchBackupStatus(type)}, timeForWatcher); } } }); } //Function to delete the element from RemoteDirList array after Backup function deleteRemoteDirList(currentBackupLocation,type){ if(currentBackupLocation!=''){ if(type=='backup'){ for (var key in dynamicRemoteArray){ if(key.indexOf(currentBackupLocation) == 0){ delete dynamicRemoteArray[key]; delete dynamicRemoteType[key]; delete dynamicRemoteSize[key]; delete dynamicRemoteDate[key]; delete dynamicRemoteRequestInfo[key]; } } } else if(type=='localBackup'){ for (var key in dynamicLocalRestoreArray){ if(key.indexOf(currentBackupLocation) == 0){ delete dynamicLocalRestoreArray[key]; delete dynamicLocalRestoreType[key]; delete dynamicLocalRestoreSize[key]; delete dynamicLocalRestoreDate[key]; delete dynamicLocalRestoreRequestInfo[key]; } } } } } //Function to schedule Backup for Two tier function scheduleBackup(){ $("#backupsetFiles").find('tr:hidden input:checkbox').addClass("excludeForBackup"); var fieldsCount = jQuery("form[name*='startBackupForm'] input[type='checkbox']:not(.excludeForBackup)").attr('checked',true).length; if(fieldsCount == 0){ showErrorMessages('.head_search .error_msg',"Please select folder(s)/file(s) to schedule backup"); return false; } var job = jQuery('#select_job').val(); jQuery('#oldJobName').val(job); editJob('backup'); jQuery('#nav_scheduler').trigger('click'); return false; } function getItemSize(item, itemType){ jQuery('.sizeLoadingIcon').show(); if (item === undefined) { if (loadFileSize['-1'] !== undefined) { loadFileSize = []; loadFileSize['-1'] = '-1'; } else { loadFileSize = []; } var backupSet = []; var backupSetType = []; if(jQuery('.body_wrap').hasClass('backup_page')){ var jobName = jQuery('#oldJobName').val(); if(jobName==0 || (machine=='twotier')){ backupSet = defaultBackupSetArray.slice(); backupSetType = defaultBackupSetTypeArray.slice(); } else { backupSet = backupSetArray.slice(); backupSetType = backupSetTypeArray.slice(); } } else { backupSet = defaultLocalBackupSetArray.slice(); backupSetType = defaultLocalBackupSetTypeArray.slice(); } jQuery("#backupSetSize").val(0); jQuery.each(backupSet,function(index, item) { if($('.cont_heading[title="' + item.replace(/"/g,"\\\"") + '"]').length > 0) { // If item is not visible, item is hidden if($('.cont_heading[title="' + item.replace(/"/g,"\\\"") + '"]').is(':visible')) { getItemSize(item, backupSetType[index]); } } else { // Couldn't find the DOM element, so consider this also for size calculation getItemSize(item, backupSetType[index]); } }); jQuery('.sizeLoadingIcon').hide(); return; } var dirListVal = localFileDirSize[item]; if ((dirListVal === undefined) && (itemType !== 'file')) { if ($.inArray(item, loadFileSize) === -1) { if($('.cont_heading[title="' + item.replace(/"/g,"\\\"") + '"]').length > 0) { // If item is not visible, item is hidden if($('.cont_heading[title="' + item.replace(/"/g,"\\\"") + '"]').is(':visible')) { loadFileSize.push(item); } } else { loadFileSize.push(item); } } } var jobName = jQuery('#oldJobName').val(); if (dirListVal != -1) { if (dirListVal === undefined) { //if(itemType!='' && itemType=='file'){ if(itemType!=''){ var pathSplit = item.split('/'); var fileName = pathSplit.pop(); itemNew = pathSplit.join("/"); var dirVal = dynamicArray[itemNew]; if(dirVal != "" && typeof dirVal != "undefined" && dirVal.length>0){ var fileSize = IDrive.LocalDirList[itemNew][fileName].size; fileSize = getMachineSize(fileSize); localFileDirSize[item] = fileSize; updateCalculatedSize(fileSize); return false; } else if(typeof fileSizeFromSearch[item] != 'undefined'){ var fileSize = fileSizeFromSearch[item]; fileSize = getMachineSize(fileSize); updateCalculatedSize(fileSize); } } else if (loadFileSize['-1'] !== undefined) { return; } localFileDirSize[item] = '-1'; jQuery('.sizeLoadingIcon').show(); var load = function(requestItem, action) { if(!hasUserLoggedIn()) { return false; } action = action || 'getSize'; var values = "item="+encodeURIComponent(requestItem); loadFileSize['-1'] = '-1'; //AJAX call to get size $.ajax({ url : ("action.php?action=" + action), type: "POST", data: values, success: function(result) { if(result.indexOf('')>0) { window.location.href='../index.php'; } var dataRes = $.parseJSON(result); if (dataRes['retry']) { var selectedFileSet = []; if(jQuery('.body_wrap').hasClass('backup_page')){ if(jobName==0 || (machine=='twotier')){ selectedFileSet = defaultBackupSetArray.slice(); } else { selectedFileSet = backupSetArray.slice(); } } else { selectedFileSet = defaultLocalBackupSetArray.slice(); } var showLoadingIcon = false; $.each(selectedFileSet.reverse(), function(index, file) { if ($.inArray(file, loadFileSize) !== -1) { showLoadingIcon = true; return false; } else if (requestItem == file) { showLoadingIcon = true; return false; } }); if (showLoadingIcon) { jQuery('.sizeLoadingIcon').show(); } else { jQuery('.sizeLoadingIcon').hide(); } setTimeout(function() { load(requestItem, 'getSizeResult'); }, 3000); return; } delete loadFileSize['-1']; jQuery.each(dataRes, function(index,value) { localFileDirSize[value['name']] = value['size']; if(jQuery('.body_wrap').hasClass('backup_page')){ if(jobName==0 || (machine=='twotier')){ selectedFileSet = defaultBackupSetArray.slice(); } else { selectedFileSet = backupSetArray.slice(); } if ($.inArray(value['name'], selectedFileSet) !== -1) { updateCalculatedSize(value['size']); } } else { if ($.inArray(value['name'], defaultLocalBackupSetArray) !== -1) { updateCalculatedSize(value['size']); } } var qItem = loadFileSize.shift(); if (qItem !== undefined) { load(qItem); } else { jQuery('.sizeLoadingIcon').hide(); } }); } }); } load(loadFileSize.shift()); } else { jQuery('.sizeLoadingIcon').hide(); updateCalculatedSize(localFileDirSize[item]); } } else if(typeof fileSizeFromSearch[item] != 'undefined'){ var fileSize = fileSizeFromSearch[item]; fileSize = getMachineSize(fileSize); updateCalculatedSize(fileSize); } else { jQuery('.sizeLoadingIcon').hide();} } sizeOf = function (bytes) { if (bytes === 0) { return "0.00 B"; } //bytes = bytes*1024; var e = Math.floor(Math.log(bytes) / Math.log(1024)); return (bytes/Math.pow(1024, e)).toFixed(2)+' '+' KMGTP'.charAt(e)+'B'; } function updateCalculatedSize(dirSize){ var currSize = jQuery("#backupSetSize").val(); currSize = isNaN(currSize)?0:currSize; currSize = (currSize<0)?0:currSize; dirSize = isNaN(dirSize)?0:dirSize; var total = parseFloat(currSize)+parseFloat(dirSize); total = (total<0)?currSize:total; total = isNaN(total)?0:total; jQuery("#backupSetSize").val(total); var humanReadable = sizeOf(total); jQuery("#backupSetSizeHTML").html(humanReadable); } function getMachineSize(fileSize){ if(typeof fileSize === "undefined"){ return 0; } var getNumber = ''; if(fileSize.indexOf('TB')>0){ getNumber = fileSize.replace(' TB'); var total = parseFloat(getNumber)*(1024*1024*1024*1024); } else if(fileSize.indexOf('GB')>0){ getNumber = fileSize.replace(' GB'); var total = parseFloat(getNumber)*(1024*1024*1024); } else if(fileSize.indexOf('MB')>0){ getNumber = fileSize.replace(' MB'); var total = parseFloat(getNumber)*(1024*1024); } else if(fileSize.indexOf('KB')>0){ getNumber = fileSize.replace(' KB'); var total = parseFloat(getNumber)*1024; } else if(fileSize.indexOf('B')>0){ getNumber = fileSize.replace(' B'); var total = parseFloat(getNumber); } else if(fileSize.indexOf('bytes')>0){ getNumber = fileSize.replace(' bytes'); var total = parseFloat(getNumber); } return total; } function archDeleteStatus(){ if(!$("#Deleting").is(':visible')){ clearTimeout(activeDeleteStatusVar); activeDeleteStatusVar = ''; return false; } var url="action.php?action=deletedArchiveStatus"; $.post(url,function(data){ var dataArray = jQuery.parseJSON(data); if(dataArray['response']){ $("#Deleting").html(dataArray['response']); } }); activeDeleteStatusVar = setTimeout(archDeleteStatus, PROGRESS_WATCHER_ENABLE_TIME); }