Files

353 lines
12 KiB
JavaScript
Executable File

/* Global Variables to keep Remote/Local locations - Start */
var dynamicRemoteArray = new Array();
var dynamicRemoteType = new Array();
var dynamicRemoteSize = new Array();
var dynamicRemoteDate = new Array();
var dynamicRemoteOrgSize = new Array();
var dynamicRemoteOrgiDate = new Array();
var dynamicRemoteRequestInfo = new Array();
var DeleteItemType = '';
var dynamicLocalRestoreArray = new Array();
var dynamicLocalRestoreType = new Array();
var dynamicLocalRestoreSize = new Array();
var dynamicLocalRestoreDate = new Array();
var dynamicLocalRestoreRequestInfo = new Array();
var ajaxRequestRemoteFiles = '';
var dynamicArray = new Array();
var dynamicType = new Array();
var dynamicRequestInfo = new Array();
var backupModeSet = null;
var localFileDirSize = new Array();
var loadFileSize = new Array(); // array of items to fetch the file/folder size
var dynamicTrashArray = new Array();
var dynamicTrashType = new Array();
var dynamicTrashSize = new Array();
var dynamicTrashDate = new Array();
var dynamicTrashStatus = new Array();
//Folders List For Backup/Restore Location
var dynamicLocalDirList = new Array();
var dynamicRemoteDirList = new Array();
var TrashPutbackHappen = 0;
var del_cookie = '';
var clickedDirPath = '/';
var clickedNewDirPath = new Array();
/* Job List Array Variables */
var jobListArray = new Array();
var jobListTypeArray = new Array();
var jobListSizeArray = new Array();
var jobListLMTimeArray = new Array();
var jobListfileInfoArray = new Array();
var currentBackupJob='Backup_Default Backup Set';
var currentLocalBackupJob='';
var currentRestoreJob='';
var currentLocalRestoreJob='';
var currentBackupLocation='';
var currentRestoreLocation='';
var activeJobsTimeoutVar='';
var selectedRestoreListPathDetail = '';
/* Backup Page Array Variables */
var backupSetArray = new Array();
var backupSetTypeArray = new Array();
var defaultBackupSetArray = new Array();
var defaultBackupSetTypeArray = new Array();
var defaultBackupSetFileInfo = new Array();
var defaultBackupSetSizeArray = new Array();
var defaultBackupSetModTimeInfo = new Array();
var manualBackupRunning=false;
var newBackupSetArray = new Array();
var newBackupSetTypeArray = new Array();
var backupListCount=0;
var backupCheckedCount=0;
/* Local backup page Array Variables */
var localBackupSetArray = new Array();
var localBackupSetTypeArray = new Array();
var defaultLocalBackupSetArray = new Array();
var defaultLocalBackupSetTypeArray = new Array();
var manualLocalBackupRunning=false;
/* Restore Page Array Variables */
var restoreSetArray = new Array();
var defaultRestoreSetArray = new Array();
var defaultRestoreSetTypeArray = new Array();
var defaultRestoreSetFileInfo = new Array();
var manualRestoreRunning=false;
/* Local Restore Page Array Variables */
var localRestoreSetArray = new Array();
var defaultLocalRestoreSetArray = new Array();
var defaultLocalRestoreSetTypeArray = new Array();
var manualLocalRestoreRunning=false;
var newRestoreSetArray = new Array();
var restoreListCount=0;
var restoreCheckedCount=0;
var startImmediateRunning=false;
var jobCancelling=false;
var watchTrashRestoreStatus = 0;
/* Preferences Page Full Exclude Array Variables */
var excludedFullPathArray = new Array();
var excludedFullPathTypeArray = new Array();
//Temp Arrays
var tempExcludedFullPathArray = new Array();
var tempExcludedFullPathTypeArray = new Array();
var tempExcludedFullPathMissingArray = new Array();
//Multiple share items Array
var shareItemArray = new Array();
var sharePathArray = new Array();
var shareTypeArray = new Array();
//Timeout Variables for Manual Backup/Restore Task status
var backupTimeoutVar = '';
var restoreTimeoutVar = '';
var logsTimeoutVar='';
var preferenceTimeoutVar='';
var preferenceChanged =0;
var sizeWatcherTimeoutVar='';
var msgTimeoutVar='';
var periodicTimeoutVar='';
var scheduleWatcherTimeoutVar='';
var renameAjaxStatus = 0;
var currentAjaxRequest = '';
var currentLocalAjaxRequest ='';
var reIndexTimeoutVar = '';
var reIndexStarted = false;
var dbUsedSize = new Array();
var searchAjaxRequest1 = '';
var searchAjaxRequest2 = '';
var trashAjaxCall = '';
var trashAjaxCall2 = '';
var searchStarted = false;
var trashListStarted = false;
var loadSearchTimout='';
var loadTrashTimout='';
var cancelledSearch=false;
var cancelledTrashList=false;
var searchKeyword;
var loadPage;
var searchItemArray = new Array();
var searchItemTempArray = new Array();
var searchItemTypeArray = new Array();
var startRemoteSearchValues ='';
var fileSizeFromSearch = new Array();
var previousProgressData = new Array();
var showHiddenClicked = false;
var sh='';
var checkingSelectedItems=false;
timeForArchiveWatcher = 200;
test = 0;
var progressJobBackupCount = 0;
var progressJobRestoreCount = 0;
var archiveAjax;
var archiveAjaxStatus;
var archiveTimeoutVar='';
var activeJobsTimeoutVar='';
var checkArchiveRunningAjax=false;
var removeScheduler=false;
var removeBackupAndRestoreList=false;
var refreshFolder = false;
var activeJobsetArray = [];
var rm_backup_perc = 0;
var rm_restore_perc = 0;
var prevAlertMsg = '';
var ajaxRequestJobs;
var restore_radioBtn_chk = "Online Account";
var dedupDeviceOptionListHTML = '';
var previousSelectedDedupBucket = '';
/* Global Variables to keep Remote/Local locations - End */
/* Constant Variables for Success - Start*/
var errorNewDirEmpty = "File/Folder name cannot be blank.";
var errorNewDirName = "File/Folder name entered is invalid.";
var errorNewDirExists = "Folder name already exists";
/* Constant Variables for Success - End*/
/* check box condition*/
var SemChkSelect=jQuery('.excludefiles .file_check label'),
MainChkSelect=jQuery('.header_part .file_check label');
MainChkSelect.die('click').live('click',function(){
if ($('.newBkpSet').is(':visible') == false) {
if ($('#cancelBackup').is(':visible') || $('#cancellingBackup').is(':visible')) {
if ($('#select_job').val() == 0) {
jQuery('.common_msg').hide();
showErrorMessages('.head_search .error_msg','Backup is in progress. Please try again later');
return false;
}
}
else if ($('#cancelRestore').is(':visible') || $('#cancellingRestore').is(':visible')) {
if(!$('.msg_option').is(':visible')){
if ($('#select_restore_job').val() == 0) {
jQuery('.common_msg').hide();
showErrorMessages('.head_search .error_msg','Restore is in progress. Please try again later');
return false;
}
}
}
}
//Restrict to add/remove items to/from Backup/Restore set if Manual Backup/Restore is running
var restricted = restrictAddRemoveItems();
if(restricted==false){ return false; }
$(this).toggleClass('label_checked');
var exclude_length=$(this).closest('.exclude').index(),RemoveBtnSpan='.backupset_chk_delete span',
chkbox='chkbox'+exclude_length,
chkboxClass='.'+chkbox,
chkboxExcludeFiles='.'+chkbox+' .excludefiles';
if($(this).hasClass('label_checked')){
if(($(this).closest('.exclude').attr('class') == 'exclude')){
$(this).closest('.exclude').addClass(chkbox);
}
var a=$(this).closest(chkboxClass).find('.header_part label').attr('class');
$(this).closest('.exclude').addClass(chkbox);
$(this).removeClass('mainCheck label_semi_checked');
$(chkboxExcludeFiles).find('.file_check label').removeClass('label_semi_checked');
$(chkboxExcludeFiles).find('.file_check label').addClass('label_checked');
$(chkboxExcludeFiles).find('.file_check input[type=checkbox]').prop('checked', true);
$(chkboxExcludeFiles).find('tr').addClass('chk');
$(chkboxExcludeFiles).find('.deny').removeClass('label_checked');
$(chkboxExcludeFiles).find('.deny').closest('tr').removeClass('chk');
$(chkboxClass).find(RemoveBtnSpan).show();
}else{
if(($(this).closest('.exclude').attr('class') == 'exclude')){
$(this).closest('.exclude').addClass(chkbox);
}
$(this).closest('.exclude').find('.header_part .file_check label').removeClass('label_checked label_semi_checked');
$(this).closest('.exclude').find('.excludefiles .file_check label').removeClass('label_checked');
$(this).closest('.exclude').find('.excludefiles .file_check input[type=checkbox]').removeAttr('checked');
$(this).closest('.exclude').find('.excludefiles').find('tr').removeClass('chk');
$(chkboxClass).find(RemoveBtnSpan).hide();
$(this).closest('.exclude').removeClass(chkbox);
}
});
SemChkSelect.die('click').live('click',function(){
var current_directory = jQuery('#fullPathBreadCrumb a:last').attr('alt');
//alert(current_directory);
if ($('.newBkpSet').is(':visible') == false) {
if ($('#cancelBackup').is(':visible') || $('#cancellingBackup').is(':visible')) {
if ($('#select_job').val() == 0) {
var errorClass = '.head_search .error_msg';
if(jQuery('.serverDts ').css('right')=='0px'){
errorClass = '#searchError';
}
jQuery('.common_msg').hide();
showErrorMessages(errorClass,'Backup is in progress. Please try again later');
return false;
}
}
else if ($('#cancelRestore').is(':visible') || $('#cancellingRestore').is(':visible')) {
if(($("#rgt").css("right") == "0px")){ }
else if(!$('.msg_option').is(':visible')){
if ($('#select_restore_job').val() == 0) {
var errorClass = '.head_search .error_msg';
if(jQuery('.serverDts ').css('right')=='0px'){
errorClass = '#searchError';
}
jQuery('.common_msg').hide();
showErrorMessages(errorClass,'Restore is in progress. Please try again later');
return false;
}
}
}
}
//Restrict to add/remove items to/from Backup/Restore set if Manual Backup/Restore is running
var restricted = restrictAddRemoveItems();
if(restricted==false){ return false; }
$(this).toggleClass('label_checked');
var exclude_length=$(this).closest('.exclude').index(),
HeaderLabel='.excludeheader.header_part label',
ExcludeChkd='.excludefiles input:checked',
chkbox='chkbox'+exclude_length,
RemoveBtnSpan='.backupset_chk_delete span',
chkboxClass='.'+chkbox,ChkBoxlen,ChkBoxTotallen;
if($(this).hasClass('label_semi_checked')){
$(this).removeClass('label_semi_checked');
}
if($(this).hasClass('label_checked')){
$(this).closest('tr').addClass('chk');
$(this).closest('.file_check').find('input[type=checkbox]').prop('checked', true);
$(this).closest('.exclude').addClass(chkbox);
$(chkboxClass).find(RemoveBtnSpan).show();
ChkBoxlen=$(this).closest('.exclude'+chkboxClass).find(ExcludeChkd).length;
ChkBoxTotallen=$(this).closest('.exclude'+chkboxClass).find('.excludefiles input[type=checkbox]').length;
if((ChkBoxlen > 0)){
$(this).closest(chkboxClass).find(HeaderLabel).removeAttr('class').addClass('label_semi_checked');
}
// need to comment this when it is first level and rootlevel lisiting is off.
//if((current_directory != "/") && (ChkBoxlen == ChkBoxTotallen)){
if(ChkBoxlen == ChkBoxTotallen){
$(this).closest('.exclude'+chkboxClass).find(HeaderLabel).removeAttr('class').addClass('label_checked');
}
}else{
$(this).closest('tr').removeClass('chk');
$(this).siblings('input').removeAttr('checked');
ChkBoxlen=$(this).closest('.exclude'+chkboxClass).find(ExcludeChkd).length;
if( ChkBoxlen === 0){
$(chkboxClass).find(RemoveBtnSpan).hide();
$(this).closest('.exclude'+chkboxClass).find(HeaderLabel).removeAttr('class').addClass('mainCheck ');
$(this).closest('.exclude').removeClass(chkbox);
}
if( ChkBoxlen > 0){
$(chkboxClass).find(RemoveBtnSpan).show();
$(this).closest(chkboxClass).find(HeaderLabel).removeAttr('class').addClass('label_semi_checked');
}
}
});
/* Function to partially search element in array */
function array_search(arr, letter) {
var matches = arr.filter(function(str) {
return isInString = (str.indexOf(letter) == 0);
});
return matches;
}
/* Function to partially search element in array with backslash */
function array_search_display(arr, letter) {
var matches = arr.filter(function(str) {
return isInString = (str+'/'.indexOf(letter) == 0);
});
return matches;
}
/* Function to partially search element in array reverse order */
function array_search_reverse(arr, letter) {
var matches = arr.filter(function(str) {
return isInString = (letter.indexOf(str+'/') == 0);
});
return matches;
}
/* Function to partially search element in array reverse order */
function array_search_reverse_display(arr, letter) {
var matches = arr.filter(function(str) {
return isInString = (letter+'/'.indexOf(str) == 0);
});
return matches;
}