872 lines
29 KiB
JavaScript
Executable File
872 lines
29 KiB
JavaScript
Executable File
/* Local Search - Start */
|
|
var searchAjaxCall='';
|
|
var searchResult=false;
|
|
|
|
$(document).on('keyup','.search_input',function(e){
|
|
if (e.keyCode == 13) {
|
|
var element = jQuery(this).siblings('input');
|
|
if (searchStarted == true) {
|
|
stopCurrentSearch();
|
|
}
|
|
((element.attr('id') == 'localSearch') ? startLocalSearch(): startRemoteSearch());
|
|
return false;
|
|
}
|
|
});
|
|
$(document).on('mousedown','#remoteSearch',function(){
|
|
if (searchStarted == true) {
|
|
stopCurrentSearch();
|
|
}
|
|
startRemoteSearch();
|
|
return false;
|
|
});
|
|
$(document).on('click','#remoteSearchTrash',function(){
|
|
$(".search_box_trash_btn").hide();
|
|
$(".search_box_trash_cancel_btn").show();
|
|
if (searchStarted == true) {
|
|
stopCurrentSearch();
|
|
}
|
|
startRemoteSearch("trash");
|
|
return false;
|
|
});
|
|
|
|
$(document).on('mousedown','#localSearch',function(){
|
|
if (searchStarted == true) {
|
|
stopCurrentSearch();
|
|
}
|
|
startLocalSearch();
|
|
return false;
|
|
});
|
|
|
|
//Function to Start Remote Search
|
|
function startRemoteSearch(trash){
|
|
searchKeyword = jQuery('input.search_input').val();
|
|
searchKeyword = searchKeyword.toLowerCase();
|
|
var searchPath = $('#location_selected').attr('title');
|
|
|
|
if(trash!="trash"){
|
|
if(jQuery('.body_wrap').hasClass('trash-wrap')){
|
|
trash="trash";
|
|
classVal = ".error_msg";
|
|
} else {
|
|
classVal = "#searchError";
|
|
}
|
|
} else {
|
|
classVal = ".error_msg";
|
|
}
|
|
if(typeof searchPath == 'undefined' || searchPath == '')
|
|
searchPath = '/';
|
|
if(searchKeyword!=''){
|
|
if(searchKeyword.indexOf('/')>=0 || searchKeyword.indexOf('\\')>=0){
|
|
showErrorMessages(classVal,'Invalid search string. String should not contain "/" and "\\"');
|
|
$(".search_box_trash_btn").show();
|
|
$(".search_box_trash_cancel_btn").hide();
|
|
return false;
|
|
}
|
|
searchKeyword = searchKeyword.replace(/^\/+|\/+$/g, '');
|
|
if(searchKeyword.trim()=='' || searchKeyword.trim()=='.' || searchKeyword.trim()=='..'){
|
|
showErrorMessages(classVal,'Please enter the valid search string');
|
|
$(".search_box_trash_btn").show();
|
|
$(".search_box_trash_cancel_btn").hide();
|
|
return false;
|
|
}
|
|
startRemoteSearchValues = "searchKeyword="+rawurlencode(searchKeyword)+"&searchPath="+rawurlencode(searchPath);
|
|
if(trash=="trash")
|
|
{
|
|
startRemoteSearchValues+="&trash=1";
|
|
window.trashSearch = 1;
|
|
}
|
|
else
|
|
{
|
|
window.trashSearch = 0;
|
|
jQuery('.search_box_btn').hide();
|
|
}
|
|
if(dedup==true){
|
|
if(trash=="trash")
|
|
var deviceID = selectedRestoreListPath;
|
|
else
|
|
var deviceID = jQuery('select.restoreDropdown-txtbox').val();
|
|
|
|
startRemoteSearchValues+="&deviceID="+encodeURIComponent(deviceID);
|
|
}
|
|
jQuery('#rgt .backupset_table').html('');
|
|
jQuery('#rgt .nfiles,.tab_loader,.disabled_search_btn').show();
|
|
jQuery('.search_box_btn,#searchError').hide();
|
|
searchStarted = true; //Flag to identify the Search process
|
|
loadPage =2;
|
|
searchResult=false;
|
|
|
|
if(searchStarted == true && trash=="trash"){
|
|
stopSearchExecution(trash);
|
|
}else{
|
|
if(jQuery('#rgt h4').html() == "Local Search")
|
|
startLocalRestoreSearch(0);
|
|
else
|
|
startRemoteSearchAjax();
|
|
}
|
|
} else {
|
|
showErrorMessages(classVal,'Please enter the search keyword');
|
|
$(".search_box_trash_btn").show();
|
|
$(".search_box_trash_cancel_btn").hide();
|
|
}
|
|
}
|
|
|
|
function startRemoteSearchAjax(){
|
|
searchAjaxCall = $.ajax({
|
|
url: "action.php?action=startRemoteSearch",
|
|
type: "POST",
|
|
data: startRemoteSearchValues,
|
|
success: function(responseData){
|
|
if(responseData.indexOf('<html>')>0){
|
|
window.location.href='../index.php';
|
|
}
|
|
}
|
|
});
|
|
if(cancelledSearch==false){
|
|
loadSearchTimout = setTimeout("getSearchResult('1','restore','0')",3000); //1000 = 1Sec
|
|
}
|
|
}
|
|
|
|
//Function to Start Local Search
|
|
function startLocalSearch(){
|
|
searchKeyword = jQuery('input.search_input').val();
|
|
var searchPath = $('#location_selected').attr('title');
|
|
|
|
if(searchKeyword!=''){
|
|
if(searchKeyword.indexOf('/')>=0 || searchKeyword.indexOf('\\')>=0){
|
|
showErrorMessages('#searchError','Invalid search string. String should not contain "/" and "\\"');
|
|
return false;
|
|
}
|
|
searchKeyword = searchKeyword.replace(/^\/+|\/+$/g, '');
|
|
if(searchKeyword.trim()=='' || searchKeyword.trim()=='.' || searchKeyword.trim()=='..'){
|
|
showErrorMessages('#searchError','Please enter the valid search string');
|
|
return false;
|
|
}
|
|
jQuery('#rgt .backupset_table').html('');
|
|
jQuery('#rgt .nfiles,.tab_loader,.disabled_search_btn').show();
|
|
jQuery('.search_box_btn,#searchError').hide();
|
|
var values = "searchKeyword="+rawurlencode(searchKeyword)+"&searchPath="+rawurlencode(searchPath);
|
|
searchStarted = true; //Flag to identify the Search process
|
|
loadPage =2;
|
|
searchResult=false;
|
|
//AJAX call to start Search
|
|
searchAjaxCall = $.ajax({
|
|
url: "action.php?action=startLocalSearch",
|
|
type: "POST",
|
|
data: values,
|
|
success: function(responseData){
|
|
if(responseData.indexOf('<html>')>0){
|
|
window.location.href='../index.php';
|
|
}
|
|
cmd = $.parseJSON(responseData);
|
|
if(cmd[0]==true){
|
|
if(cancelledSearch==false){
|
|
loadSearchTimout = setTimeout("getSearchResult('1','backup','0')",3000); //1000 = 1Sec
|
|
}
|
|
} else {
|
|
getSearchResult('1','backup','0');
|
|
}
|
|
}
|
|
});
|
|
|
|
} else {
|
|
showErrorMessages('#searchError','Please enter the search keyword');
|
|
}
|
|
}
|
|
|
|
//Function to get Search Result
|
|
function getSearchResult(page,type,count){
|
|
var html='';
|
|
var img,itemSize;
|
|
localDirMore =false;
|
|
abortAjax(searchAjaxCall); // Abort the Search request
|
|
//AJAX call to get Search Result
|
|
var dir_elements = 'dir_elements';
|
|
var dir_elements_type = '';
|
|
var trash_ = 0;
|
|
if(window.trashSearch && type != 'backup'){
|
|
dir_elements = 'chk_group';
|
|
dir_elements_type = 'itemType';
|
|
trash_ = 1;
|
|
if(!jQuery('.body_wrap').hasClass('trash-wrap')){
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if($('#startTrashRestoreForm input#mainchek').siblings('label').hasClass('label_checked') && trash_){
|
|
jQuery('input#mainchek').removeAttr('checked').siblings('label').removeClass('label_checked').addClass('label_semi_checked');
|
|
}
|
|
|
|
searchAjaxRequest2 = $.ajax({
|
|
url: "action.php?action=getSearchRes&page="+page+"&type="+type+"&count="+count+"&trash="+trash_,
|
|
success: function(locationData){
|
|
if(locationData.indexOf('<html>')>0){
|
|
window.location.href='../index.php';
|
|
}
|
|
if(locationData==''){
|
|
return true;
|
|
}
|
|
searchRes = $.parseJSON(locationData);
|
|
if(searchRes[0]==1 && searchRes[3]>0){
|
|
|
|
$.each(searchRes[2], function(i,res){
|
|
/*if(sh=="Hide"){
|
|
var mname=res.name;
|
|
var pos=mname.indexOf("/.");
|
|
if(pos>0 || pos==0){
|
|
var tr_style='style="display: none;"';
|
|
return;
|
|
} else {
|
|
var tr_style='';
|
|
}
|
|
}
|
|
else{
|
|
var tr_style='';
|
|
}*/
|
|
var tr_style='';
|
|
if(!res.type)
|
|
return true;
|
|
img = res.type=='F'?'file':'folder';
|
|
itemSize = res.type=='F'?res.size:'--';
|
|
html += '<tr '+tr_style+'>';
|
|
if(window.trashSearch){
|
|
html += '<td class="search-chk-box file_check">\
|
|
<input type="checkbox" id="'+dir_elements+'[]" name="'+dir_elements+'[]" value="'+htmlEntities(res.name)+'">';
|
|
html += '<input type="hidden" id="'+dir_elements_type+'[]" name="'+dir_elements_type+'[]" value="'+htmlEntities(img)+'">';
|
|
}else{
|
|
html += '<td class="search-chk-box file_check">\
|
|
<input type="checkbox" id="'+dir_elements+'['+i+']" name="'+dir_elements+'['+i+']" value="'+htmlEntities(res.name)+'">';
|
|
}
|
|
html += '<label>'+img+'</label></td>';
|
|
html += '<td class="cont_heading search-file-name" title="'+htmlEntities(res.name)+'"><img src="include/images/idq_ico_'+img+'.png" >\
|
|
<span>'+htmlEntities(res.name).replace(/\s/g,' ')+'</span></td>';
|
|
html += '<td class="search-file-size">'+itemSize+'</td>';
|
|
html += '<td class="search-file-date">'+res.date+'</td>';
|
|
|
|
if(jQuery('#rgt .excludefiles').attr('id')=="remoteDirSearchList" || trash_ == 1){
|
|
var tdClass = ' trash_list';
|
|
jQuery('#rgt .backupset_table').addClass('restr');
|
|
} else {
|
|
var tdClass = '';
|
|
}
|
|
html += '<td class="search-menu-icon drop_list'+tdClass+'"></td>';
|
|
html += '</tr>';
|
|
});
|
|
if(html!=''){
|
|
searchResult=true;
|
|
if(trash_)
|
|
jQuery('#rgt').show();
|
|
} //Flag to confirm the result
|
|
html += '<tr class="search_loading"><td colspan="4"> </td></tr>';
|
|
localDirMore =true;
|
|
jQuery('.tab_loader').hide();
|
|
jQuery('.backupset_table tr.search_loading').remove();
|
|
if(page==1 && count==0){
|
|
jQuery('#rgt .excludefiles').html('<table cellspacing="0" cellpadding="0" border="0" width="100%" class="folderBackupContent selectedFiles_tab backupset_table bc_table"><tbody></tbody></table>');
|
|
if(trash_){
|
|
jQuery('#rgt .nfiles').hide();
|
|
jQuery('#empty_trash,#deleteButton,#putbackButton').show();
|
|
$('.body_wrap .exclude,#empty_trash').show();
|
|
$('.empty_box').hide();
|
|
}
|
|
jQuery('#rgt .nfiles,.disabled_search_btn').hide();
|
|
jQuery('#rgt .menu,.search_box_btn,#rgt .header_part input').show();
|
|
jQuery('#rgt .header_part td:first').removeClass('file_check_disabled').addClass('file_check');
|
|
//searchStarted = false;
|
|
}
|
|
jQuery('#rgt .backupset_table').append(html);
|
|
|
|
if(jQuery('#rgt .excludefiles').attr('id')=="remoteDirSearchList"){
|
|
jQuery('#rgt .backupset_table').addClass('restr');
|
|
}
|
|
if(searchRes[1]<400){
|
|
jQuery('.backupset_table tr.search_loading').show();
|
|
loadSearchTimout = setTimeout("getSearchResult('"+page+"','"+type+"','"+searchRes[1]+"')",10000); //1000 = 1Sec
|
|
localDirMore =false;
|
|
}
|
|
}
|
|
else if((searchRes[0]==1)) {
|
|
localDirMore =false;
|
|
loadSearchTimout = setTimeout("getSearchResult('"+page+"','"+type+"','"+searchRes[1]+"')",5000); //1000 = 1Sec
|
|
}
|
|
else if(searchRes[0]==0) {
|
|
jQuery('#rgt .backupset_table tr.search_loading').remove();
|
|
if(page>=1 && !count>0)
|
|
jQuery('#empty_trash,#deleteButton,#putbackButton').hide();
|
|
if((page==1 && count==0) || searchResult==false){
|
|
var nofile = "<b>No items match your search.</b><br><br>Change search term and try again."
|
|
jQuery('.tab_loader').hide();
|
|
if(trash_){
|
|
$('.body_wrap .exclude,#empty_trash,#deleteButton,#putbackButton').hide();
|
|
$('.empty_box').show();
|
|
}
|
|
else
|
|
jQuery('#rgt .nfiles').show().html(nofile);
|
|
jQuery('#rgt .backupset_table').html('');
|
|
jQuery('#rgt .menu,.disabled_search_btn').hide();
|
|
jQuery('.search_box_btn').show();
|
|
}
|
|
searchStarted = false;
|
|
localDirMore =false;
|
|
}
|
|
|
|
if(window.trashSearch){
|
|
$(".search_box_trash_btn").show();
|
|
$(".search_box_trash_cancel_btn").hide();
|
|
jQuery('.tab_loader').hide();
|
|
}
|
|
// Added for Trash page reviste time process watcher
|
|
if(watchTrashRestoreStatus == 1)
|
|
watchRestoreStatus();
|
|
}
|
|
});
|
|
}
|
|
|
|
function ViewportDetect(el) {
|
|
if(typeof el!='undefined'){
|
|
var rect = el.getBoundingClientRect();
|
|
return rect.bottom > 0 && rect.top < (window.innerHeight || document.documentElement.clientHeight);
|
|
}
|
|
}
|
|
|
|
function onScrollForLocal(){
|
|
jQuery("#localDirSearchList").on("scroll", function() {
|
|
jQuery('tr.search_loading').show();
|
|
if(localDirMore==true){
|
|
localDirMore = false;
|
|
if(ViewportDetect(document.getElementsByClassName("search_loading")[0])){
|
|
getSearchResult(loadPage,'backup','0');
|
|
loadPage++;
|
|
} else {
|
|
localDirMore = true;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function onScrollForRemote(){
|
|
jQuery("#remoteDirSearchList,#loadTrashPath .excludefiles").on("scroll", function() {
|
|
jQuery('tr.search_loading').show();
|
|
if(localDirMore==true){
|
|
localDirMore = false;
|
|
if(typeof document.getElementsByClassName("search_loading")[0]!='undefined' && ViewportDetect(document.getElementsByClassName("search_loading")[0])){
|
|
if(jQuery('#rgt h4').html() == "Local Search")
|
|
startLocalRestoreSearch(loadPage);
|
|
else
|
|
getSearchResult(loadPage,'restore','0');
|
|
loadPage++;
|
|
} else {
|
|
localDirMore = true;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
//Function to add local folder/file to backup set
|
|
$(document).on('click', '#addToBackupSet', function() {
|
|
if(searchItemArray.length > 0) {
|
|
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;
|
|
}
|
|
}
|
|
searchItemTempArray = keepParentInsteadChild(searchItemTempArray);
|
|
var data = searchItemTempArray.filter(function(selectedItem) {
|
|
var isParent = checkParentOnBackupSet(selectedItem, 'backup');
|
|
if(isParent == true) {
|
|
backupSetFiles(selectedItem);
|
|
}
|
|
});
|
|
if($("#fullPathBreadCrumb a").length>1) {
|
|
$("#fullPathBreadCrumb a:last").trigger("click");
|
|
} else {
|
|
if(jQuery('.body_wrap').hasClass('backup_page')){
|
|
markSelectedJobItems('backup');
|
|
} else {
|
|
markSelectedJobItems('localBackup');
|
|
}
|
|
jQuery('#fullPathBreadCrumb a:last').trigger("click");
|
|
}
|
|
|
|
$(".closeWin").trigger("click");
|
|
getItemSize();
|
|
actionRequired=2;
|
|
} else {
|
|
showErrorMessages('#searchError',"Please select files/folders to add into backup set");
|
|
return false;
|
|
}
|
|
if(jQuery('#select_job').val()!=0){
|
|
startTimeoutForAutoPost('backup');
|
|
}
|
|
});
|
|
//Function to add local folder/file to backup set
|
|
$(document).on('click','#addToRestoreSet',function(){
|
|
if ($('#cancelRestore').is(':visible') || $('#cancellingRestore').is(':visible')) {
|
|
showErrorMessages("#searchError", "Restore is in progress. Please try later.");
|
|
return false;
|
|
}
|
|
|
|
if(searchItemArray.length>0){
|
|
searchItemTempArray = keepParentInsteadChild(searchItemTempArray);
|
|
var data = searchItemTempArray.filter(function(selectedItem){
|
|
var isParent = checkParentOnBackupSet(selectedItem,'restore');
|
|
if(isParent==true){
|
|
restoreSetFiles(selectedItem);
|
|
}
|
|
});
|
|
if($("#fullPathBreadCrumb a").length>1){
|
|
$("#fullPathBreadCrumb a:last").trigger("click");
|
|
} else {
|
|
|
|
var restoreDropdown = $('input[type=radio][name="restore_type_detail[]"]:checked').val();
|
|
if(restoreDropdown=='Online Account'){
|
|
markSelectedJobItems('restore');
|
|
}else{
|
|
markSelectedJobItems('localRestore');
|
|
}
|
|
$("#fullPathBreadCrumb a:last").trigger("click");
|
|
|
|
}
|
|
$(".closeWin").trigger("click");
|
|
actionRequired=2;
|
|
} else {
|
|
showErrorMessages('#searchError',"Please select files/folders to add into restore set");
|
|
return false;
|
|
}
|
|
if(jQuery('#select_restore_job').val()!=0){
|
|
startTimeoutForAutoPost('restore');
|
|
}
|
|
});
|
|
//Cancel the Search
|
|
$(document).on('click','.search_popup .popup_cancelBtn,.search_popup .popup_close_btn',function(){
|
|
if($(".head_search .page_title h4").text() == "Trash"){
|
|
cancelledSearch=true;
|
|
}
|
|
$.popContainerHide();
|
|
toResetForm();
|
|
jQuery('.search_popup .nfiles').show();
|
|
if(jQuery('.body_wrap').hasClass('backup_page') || jQuery('.body_wrap').hasClass('localbackup_page')){
|
|
jQuery('#localDirSearchList').html('');
|
|
jQuery('#rgt .menu').hide();
|
|
stopSearchExecution('backup');
|
|
} else {
|
|
jQuery('#remoteDirSearchList').html('');
|
|
jQuery('#rgt .menu').hide();
|
|
stopSearchExecution('restore');
|
|
}
|
|
});
|
|
//Stop the execution of Search
|
|
function stopSearchExecution(type){
|
|
if(searchStarted == true){
|
|
localDirMore = true;
|
|
abortAjax(searchAjaxCall); // Stop the "search command" AJAX request
|
|
abortAjax(searchAjaxRequest2); // Stop the "get search result" AJAX request
|
|
clearTimeout(loadSearchTimout); // Clear the "get search page result" timer
|
|
|
|
//Clear the selected search item array
|
|
searchItemArray = [];
|
|
searchItemTempArray = [];
|
|
searchItemTypeArray = [];
|
|
|
|
//jQuery('.tab_loader').hide();
|
|
var values = "&searchKeyword="+encodeURIComponent(searchKeyword);
|
|
//AJAX call to stop the execution of Search
|
|
$.ajax({
|
|
url: "action.php?action=stopSearch&type="+type+values,
|
|
success: function(locationData){
|
|
if(locationData.indexOf('<html>')>0){
|
|
window.location.href='../index.php';
|
|
}
|
|
//Success message
|
|
if(type == 'trash'){
|
|
startRemoteSearchAjax();
|
|
}
|
|
}
|
|
});
|
|
searchStarted = false; //Flag to identify the Search process
|
|
}
|
|
}
|
|
function checkParentOnBackupSet(selected,type){
|
|
if(type=='backup'){
|
|
if(jQuery('.body_wrap').hasClass('backup_page')){
|
|
var backupArray1 = backupSetArray;
|
|
} else {
|
|
var backupArray1 = localBackupSetArray;
|
|
}
|
|
var isParent1 = array_search_reverse(backupArray1, selected+'/'); // changed for bug id:Harish_2.03.27_3_2
|
|
} else {
|
|
if($('.radio-restore:checked').val() == "Online Account")
|
|
var backupArray1 = restoreSetArray;
|
|
else
|
|
var backupArray1 = localRestoreSetArray;
|
|
var isParent1 = array_search_display(backupArray1, selected+'/');
|
|
}
|
|
if(isParent1 == '') {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
/* Local Search - End */
|
|
|
|
$(document).on('click','#rgt td.file_check,#rgt .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"){
|
|
addSearchFiles("All");
|
|
} else {
|
|
addSearchFiles(jQuery(this));
|
|
}
|
|
|
|
} else {
|
|
if(jQuery(this).find('label').html()=="All"){
|
|
removeSearchFiles("All");
|
|
} else {
|
|
removeSearchFiles(jQuery(this));
|
|
}
|
|
|
|
}
|
|
return false;
|
|
});
|
|
|
|
/* Function to add selected elements to search array */
|
|
function addSearchFiles(args){
|
|
var html = '', selected='';
|
|
var chk_page;
|
|
/* Add selected files/folders under search array to add into Backup/Restore Set - Start */
|
|
if(args=="All"){
|
|
chk_page = $(".head_search .page_title h4").text();
|
|
jQuery('#rgt .backupset_table input').each(function(){
|
|
selected = jQuery(this).val();
|
|
// To escape from item type in trash list page
|
|
if(jQuery(this).attr('type') == 'hidden' && chk_page == 'Trash'){
|
|
return;
|
|
}
|
|
var imgSrc = jQuery(this).parent().next().find('img').attr('src');
|
|
var imgSubstr = imgSrc.substring(23);
|
|
var itemType = imgSubstr.replace('.png','');
|
|
|
|
if(searchItemArray.indexOf(selected)==-1){
|
|
searchItemArray.push(selected);
|
|
searchItemTempArray.push(selected);
|
|
searchItemTypeArray.push(itemType);
|
|
if(itemType=='file'){
|
|
var fileSize = jQuery(this).parent().siblings('.search-file-size').html();
|
|
fileSizeFromSearch[selected] = fileSize;
|
|
}
|
|
}
|
|
});
|
|
|
|
} else {
|
|
selected = args.find('input').val();
|
|
|
|
var imgSrc = args.next().find('img').attr('src');
|
|
var imgSubstr = imgSrc.substring(23);
|
|
var itemType = imgSubstr.replace('.png','');
|
|
|
|
if(searchItemArray.indexOf(selected)==-1){
|
|
searchItemArray.push(selected);
|
|
searchItemTempArray.push(selected);
|
|
searchItemTypeArray.push(itemType);
|
|
if(itemType=='file'){
|
|
var fileSize = args.siblings('.search-file-size').html();
|
|
fileSizeFromSearch[selected] = fileSize;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/* Function to remove selected elements from Backup Set */
|
|
function removeSearchFiles(args){
|
|
if(args=="All"){
|
|
searchItemArray = [];
|
|
searchItemTempArray = [];
|
|
searchItemTypeArray = [];
|
|
} else {
|
|
selected = args.find('input').val();
|
|
var index = searchItemArray.indexOf(selected);
|
|
if(index>=0){
|
|
searchItemArray.splice(index, 1);
|
|
searchItemTempArray.splice(index, 1);
|
|
searchItemTypeArray.splice(index, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
$(document).ready(function(){
|
|
var pHeight = $(window).innerHeight();
|
|
$(".serverDts").css("height", pHeight);
|
|
$(".serverDts .excludefiles").css("height", pHeight-190);
|
|
});
|
|
$(window).resize(function(){
|
|
var pHeight = $(window).height();
|
|
$(".serverDts").css("height", pHeight);
|
|
$(".serverDts .excludefiles").css("height", pHeight-190);
|
|
});
|
|
$(document).on("click", ".search_menu", function() {
|
|
if(reIndexStarted == true && $('.localRestore').length > 0 && $('.radio-restore:checked').val() != 'Online Account') {
|
|
showErrorMessages('.head_search .error_msg', 'Re-Indexing in progress, Please try later.');
|
|
return;
|
|
}
|
|
|
|
|
|
$('#location_selected').text('/').attr('title', '/');
|
|
var pHeight = $(window).innerHeight();
|
|
$(".serverDts").css("height", pHeight);
|
|
$(".serverDts .excludefiles").css("height", pHeight-190);
|
|
jQuery('#searchError,#rgt .menu,.disabled_search_btn').hide();
|
|
jQuery('.search_input').val('').focus();
|
|
//Clearing the array
|
|
searchItemArray = [];
|
|
searchItemTempArray = [];
|
|
searchItemTypeArray = [];
|
|
cancelledSearch=false;
|
|
loadPage=1;
|
|
jQuery('#rgt .nfiles').show().html('<b>No Results</b>');
|
|
jQuery('#rgt .menu,#rgt .header_part input').hide();
|
|
jQuery('#rgt .header_part td:first').removeClass('file_check').addClass('file_check_disabled');
|
|
if(jQuery('.body_wrap').hasClass('backup_page') || jQuery('.body_wrap').hasClass('localbackup_page')){
|
|
jQuery('#localDirSearchList').html('');
|
|
} else {
|
|
var restoreDropdown = $('input[type=radio][name="restore_type_detail[]"]:checked').val();
|
|
if(restoreDropdown=='Online Account'){
|
|
jQuery('#rgt h4').html('Search');
|
|
} else {
|
|
jQuery('#rgt h4').html('Local Search'); //Added for Express Restore
|
|
//$('#location_selected').text(restoreDropdown+'/').attr('title', restoreDropdown+'/');
|
|
$('#location_selected').text('/').attr('title', '/');
|
|
}
|
|
//jQuery('#rgt h4').html('Search');
|
|
jQuery('#remoteDirSearchList').html('');
|
|
}
|
|
|
|
$(".serverDts").animate({right:'0px'},{ duration: 500, queue: false });
|
|
$('.errorContent,.search_box_btn').css('display', 'block');
|
|
$('body,html').css('overflow','hidden');
|
|
jQuery('.searchSection .tab_loader').hide();
|
|
searchStarted = false;
|
|
});
|
|
|
|
$(document).on("click",".closeWin",function(){
|
|
$(".serverDts").animate({right:'-800px'},{ duration: 500, queue: false });
|
|
$('body,html').css('overflow','auto');
|
|
$("#rgt .empty_trash_menu, #rgt .search_menu").css('display','block');
|
|
stopCurrentSearch();
|
|
});
|
|
|
|
|
|
/* Function to add selected elements to search array */
|
|
function stopCurrentSearch(){
|
|
if($(".head_search .page_title h4").text() == "Trash"){
|
|
cancelledSearch=true;
|
|
}
|
|
jQuery('#rgt .nfiles').show();
|
|
jQuery('#rgt .menu,#rgt .header_part input').hide();
|
|
jQuery('#rgt .header_part td:first').removeClass('file_check').addClass('file_check_disabled');
|
|
jQuery('.currentLoad input#mainchek').removeAttr('checked').siblings('label').removeAttr('class');
|
|
if(jQuery('.body_wrap').hasClass('backup_page') || jQuery('.body_wrap').hasClass('localbackup_page')){
|
|
jQuery('#localDirSearchList').html('');
|
|
stopSearchExecution('backup');
|
|
} else {
|
|
jQuery('#remoteDirSearchList').html('');
|
|
stopSearchExecution('restore');
|
|
}
|
|
}
|
|
$(document).on('mouseup', function (e){
|
|
if(jQuery('.serverDts ').css('right')=='0px'){
|
|
var OutSideClick = $(".search_menu,.serverDts");
|
|
var OutSideClickRename = $(".file_menu_details, .file_menu_rename, .file_menu_share, .file_menu_version, .file_menu_search"); //search-menu-icon drop_list
|
|
var exclude_list_menu = $(".exclude_list");
|
|
var singleDelete = $(".file_menu_delete");
|
|
var multipleDelete = $(".menu_delete");
|
|
var cancelDelete = $("#cancelDelete");
|
|
var closeDelete = $(".popup_close_btn.hide_popup");
|
|
var popupWrapper = $(".popup_wrapper");
|
|
var content = $(".content");
|
|
var sec_pos_container = $(".sec_pos_container");
|
|
var popup_container = $(".popup_container,.popup_header,.popup_content,.popup_footer");
|
|
|
|
if(e.target.nodeName!='IMG'){
|
|
if (!OutSideClick.is(e.target) && !OutSideClickRename.is(e.target) && !exclude_list_menu.is(e.target) && !singleDelete.is(e.target) && !multipleDelete.is(e.target) && !cancelDelete.is(e.target) && !closeDelete.is(e.target) && !popupWrapper.is(e.target) && !content.is(e.target) && !sec_pos_container.is(e.target) && !popup_container.is(e.target) && OutSideClick.has(e.target).length === 0){
|
|
$(".closeWin").trigger("click");
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
$(document).on('mousedown','#localDirSearchList tr,#remoteDirSearchList tr', function(e) {
|
|
if( (e.which == 3) ) {
|
|
$(this).addClass('rgtclk chk');
|
|
$(this).find('label').addClass('label_checked');
|
|
$(this).find('input[type=checkbox]').attr('checked',true);
|
|
}
|
|
});
|
|
|
|
function keepParentInsteadChild(arr) {
|
|
arr.sort(function(a, b) {
|
|
return a.length - b.length; // ASC -> a - b; DESC -> b - a
|
|
});
|
|
|
|
var arrTemp = arr.slice(0);
|
|
var i = 0;
|
|
var spliceStat = false;
|
|
var matches = arrTemp.filter(function(str) {
|
|
if(spliceStat) {
|
|
i = 0;
|
|
spliceStat = false;
|
|
}
|
|
|
|
var j = i + 1;
|
|
if(arrTemp.length - 1 < j) {
|
|
return;
|
|
}
|
|
|
|
var matches1 = arrTemp.filter(function(str) {
|
|
if((typeof arrTemp[j] != "undefined") && (arrTemp[j].indexOf(arrTemp[i]) != -1)) {
|
|
isInString = (arrTemp[j].indexOf(arrTemp[i]+'/') == 0);
|
|
if(isInString === true) {
|
|
if(arrTemp.indexOf(arrTemp[j]) != "" && arrTemp.indexOf(arrTemp[j]) != null) {
|
|
var index = arrTemp.indexOf(arrTemp[j]);
|
|
arrTemp.splice(index, 1);
|
|
spliceStat = true;
|
|
}
|
|
}
|
|
|
|
if(arrTemp.length - 1 > j) {
|
|
j++;
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
});
|
|
|
|
i++;
|
|
});
|
|
|
|
return arrTemp;
|
|
}
|
|
|
|
function startLocalRestoreSearch(page){
|
|
var count = 0;
|
|
var html='';
|
|
var img,itemSize;
|
|
jQuery(".menu_share").hide();
|
|
searchKeyword = jQuery('input.search_input').val();
|
|
searchKeyword = searchKeyword.toLowerCase();
|
|
if(searchKeyword!=''){
|
|
if(searchKeyword.indexOf('/')>=0 || searchKeyword.indexOf('\\')>=0){
|
|
showErrorMessages('#searchError','Invalid search string. String should not contain "/" and "\\"');
|
|
return false;
|
|
}
|
|
searchKeyword = searchKeyword.replace(/^\/+|\/+$/g, '');
|
|
if(searchKeyword==''){
|
|
showErrorMessages('#searchError','Please enter the valid search keyword');
|
|
return false;
|
|
}
|
|
var search_path = encodeURIComponent($('#location_selected').attr('title'));
|
|
var values = "search_str=" + encodeURIComponent(searchKeyword) + "&page=" + page + "&search_path=" + search_path;
|
|
if(typeof availableLocalDevices != "undefined" && availableLocalDevices.length > 0 && $('.localRestore').length > 0) {
|
|
values += "&dedupBucket=" + $('#localBackupHost').find("option:selected").attr('idr-bkt');
|
|
values += "&deviceID=" + $('#localBackupHost option:selected').val();
|
|
}
|
|
if(page == 0)
|
|
{
|
|
jQuery('#rgt .backupset_table').html('');
|
|
jQuery('#rgt .nfiles,.tab_loader,.disabled_search_btn').show();
|
|
}
|
|
jQuery('.search_box_btn,#searchError').hide();
|
|
searchStarted = true; //Flag to identify the Search process
|
|
loadPage =2;
|
|
searchAjaxCall = $.ajax({
|
|
url: "action.php?action=getLocalRestoreSearchList",
|
|
type: "POST",
|
|
data: values,
|
|
success: function(locationData){
|
|
searchRes = $.parseJSON(locationData);
|
|
count = parseInt(searchRes['count']);
|
|
if(count > 0){
|
|
$.each(searchRes['data'], function(i,res){
|
|
if(sh=="Hide"){
|
|
var mname=res.name;
|
|
var pos=mname.indexOf("/.");
|
|
if(pos>0 || pos==0){
|
|
var tr_style='style="display: none;"';
|
|
} else {
|
|
var tr_style='';
|
|
}
|
|
}
|
|
else{
|
|
var tr_style='';
|
|
}
|
|
|
|
img = res.type=='F'?'file':'folder';
|
|
itemSize = res.type=='F'?res.size:'--';
|
|
html += '<tr '+tr_style+'>';
|
|
html += '<td class="search-chk-box file_check">\
|
|
<input type="checkbox" id="dir_elements['+i+']" name="dir_elements['+i+']" value="'+res.name+'"> <label>'+img+'</label></td>';
|
|
html += '<td class="cont_heading search-file-name" title="'+res.name+'"><img src="include/images/idq_ico_'+img+'.png" >\
|
|
<span>'+res.name.replace(/[\s]/g,' ')+'</span></td>';
|
|
html += '<td class="search-file-size">'+itemSize+'</td>';
|
|
html += '<td class="search-file-date">'+res.date+'</td>';
|
|
|
|
if(jQuery('#rgt .excludefiles').attr('id')=="remoteDirSearchList"){
|
|
var tdClass = ' drop_list';
|
|
jQuery('#rgt .backupset_table').addClass('restr');
|
|
} else {
|
|
var tdClass = '';
|
|
}
|
|
// html += '<td class="search-menu-icon drop_list'+tdClass+'"></td>';
|
|
html += '</tr>';
|
|
});
|
|
html += '<tr class="search_loading"><td colspan="4"> </td></tr>';
|
|
localDirMore =true;
|
|
jQuery('.tab_loader').hide();
|
|
jQuery('.backupset_table tr.search_loading').remove();
|
|
if(page==0 && count>0){
|
|
jQuery('#rgt .excludefiles').html('<table cellspacing="0" cellpadding="0" border="0" width="100%" class="folderBackupContent selectedFiles_tab backupset_table bc_table"><tbody></tbody></table>');
|
|
|
|
jQuery('#rgt .menu,.search_box_btn,#rgt .header_part input').show();
|
|
jQuery('#rgt .header_part td:first').removeClass('file_check_disabled').addClass('file_check');
|
|
searchStarted = false;
|
|
}
|
|
jQuery('#rgt .nfiles,.disabled_search_btn').hide();
|
|
jQuery('#rgt .backupset_table').append(html);
|
|
}
|
|
else if(page > 0 && count==0){
|
|
localDirMore =false;
|
|
jQuery('.tab_loader').hide();
|
|
jQuery('#rgt .nfiles,.disabled_search_btn').hide();
|
|
jQuery('#rgt .menu,.search_box_btn,#rgt .header_part input').show();
|
|
jQuery('#rgt .backupset_table tr.search_loading').remove();
|
|
searchStarted = false;
|
|
}
|
|
else {
|
|
if(page==0 && count==0){
|
|
var nofile = "<b>No items match your search.</b><br><br>Change search term and try again."
|
|
jQuery('.tab_loader').hide();
|
|
jQuery('#rgt .nfiles').show().html(nofile);
|
|
jQuery('#rgt .backupset_table').html('');
|
|
jQuery('#rgt .menu,.disabled_search_btn').hide();
|
|
jQuery('.search_box_btn').show();
|
|
searchStarted = false;
|
|
}
|
|
jQuery('.tab_loader').hide();
|
|
localDirMore =false;
|
|
jQuery('#rgt .backupset_table tr.search_loading').remove();
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
showErrorMessages('#searchError','Please enter the search keyword');
|
|
}
|
|
} |