1216 lines
44 KiB
JavaScript
Executable File
1216 lines
44 KiB
JavaScript
Executable File
var workingFolderType;
|
|
var workingFolderValue;
|
|
|
|
tempExcludedFullPathArray = [];
|
|
tempExcludedFullPathTypeArray = [];
|
|
/* Adding partial name - Start */
|
|
jQuery("div.wrapper section#content").die('click').on('click','#partial_name_submit',function (event) {
|
|
var fileName = jQuery('#fileName');
|
|
var fileNameVal = fileName.val();
|
|
|
|
var tempFileName = '';
|
|
var hasSlash = false;
|
|
|
|
jQuery.each(fileNameVal, function(index, value) {
|
|
if ('/' == value){
|
|
if(!hasSlash){
|
|
tempFileName += value;
|
|
hasSlash = true;
|
|
}
|
|
}
|
|
else{
|
|
tempFileName += value;
|
|
hasSlash = false;
|
|
}
|
|
});
|
|
fileNameVal = tempFileName;
|
|
|
|
if ('' == jQuery.trim(fileNameVal.replace(/\//g, ''))) {
|
|
showErrorMessages('.head_search .error_msg','Invalid partial name.');
|
|
}
|
|
else if ("/" == jQuery.trim(fileNameVal)) {
|
|
showErrorMessages('.head_search .error_msg','Invalid partial name.');
|
|
}
|
|
else if(fileNameVal.length>=1){
|
|
jQuery('#noPartialName').hide().siblings('.excludefiles').show();
|
|
jQuery('#maincheckPartial').parent().parent().show();
|
|
fileNameVal = htmlEntities(fileNameVal);
|
|
var checkDuplicate = jQuery('#selectedPartialName input[type="hidden"][value="'+fileNameVal+'"]').attr('name');
|
|
if(checkDuplicate==undefined){
|
|
var splitChar = fileNameVal.split('\\');
|
|
var charCount = (splitChar.length-1);
|
|
var partialNameField = '<tr>\
|
|
<td class="file_check"><input type="checkbox">\
|
|
<input type="hidden" name="selectedPartial[]" value="'+fileNameVal+'"><label >'+fileNameVal+'</label><input type="hidden" name="chk_length_partial[]" value="'+charCount+'" >\
|
|
</td>\
|
|
<td class="cont_heading" title="'+fileNameVal+'">\
|
|
<img src="include/images/idq_ico_partialName.png" ><span>'+fileNameVal.replace(/[\s]/g,' ')+'</span>\
|
|
</td>\
|
|
</tr>';
|
|
jQuery('#selectedPartialName').append(partialNameField);
|
|
fileName.val('');
|
|
} else {
|
|
showErrorMessages('.head_search .error_msg',PARTIAL_NAME_ALREADY_ADDED);
|
|
|
|
}
|
|
|
|
} else {
|
|
fileName.focus();
|
|
}
|
|
startTimeoutForAutoPost('preferences'); //Auto POST
|
|
});
|
|
/* Adding partial name - End */
|
|
/* Remove selected partial names - Start */
|
|
jQuery("div.wrapper section#content").die('click').on('click', '#removeSelectedPartialName span',function(){
|
|
jQuery('#selectedPartialName tr.chk').remove();
|
|
jQuery(this).hide();
|
|
jQuery('#maincheckPartial').next().attr('class','mainchek');
|
|
var remaining = jQuery('#selectedPartialName input').length;
|
|
if(remaining==0){
|
|
jQuery('#maincheckPartial').parent().parent().hide();
|
|
jQuery('#noPartialName').show().siblings('.excludefiles').hide();;
|
|
}
|
|
startTimeoutForAutoPost('preferences'); //Auto POST
|
|
});
|
|
/* Remove selected partial names - End */
|
|
|
|
/* Add selected full path - Start */
|
|
jQuery("div.wrapper section#content").die('click').on('click','input#add_full_path',function(event){
|
|
var checkedPath,imgType;
|
|
var html='';
|
|
//Assigning Temp array values
|
|
excludedFullPathArray = tempExcludedFullPathArray;
|
|
excludedFullPathTypeArray = tempExcludedFullPathTypeArray;
|
|
excludedFullPathMissingArray = tempExcludedFullPathMissingArray;
|
|
|
|
var pathCount = excludedFullPathArray.length; //Added on May17
|
|
var checkedCount = jQuery('table#excludeFilesPath input:checked').length;
|
|
|
|
if(pathCount > 0 || checkedCount>0){
|
|
|
|
var tempValue = excludedFullPathArray[0];
|
|
var tempType = excludedFullPathTypeArray[0];
|
|
|
|
var disable= "";
|
|
var disabled_row = "";
|
|
|
|
if(machine!='netgear' && machine!='twotier' && machine!='synology'){
|
|
if(workingFolderValue!='' && typeof workingFolderValue != "undefined"){
|
|
var workingFolderValueIndex = $.inArray(workingFolderValue, excludedFullPathArray);
|
|
|
|
if(workingFolderValueIndex == -1 )
|
|
{
|
|
excludedFullPathArray[0] = workingFolderValue;
|
|
excludedFullPathTypeArray[0] = workingFolderType;
|
|
|
|
excludedFullPathArray[pathCount] = tempValue;
|
|
excludedFullPathTypeArray[pathCount] = tempType;
|
|
|
|
pathCount++;
|
|
}
|
|
else if( workingFolderValueIndex > 0 )
|
|
{
|
|
excludedFullPathArray[0] = excludedFullPathArray[workingFolderValueIndex];
|
|
excludedFullPathTypeArray[0] = excludedFullPathTypeArray[workingFolderValueIndex];
|
|
|
|
excludedFullPathArray[workingFolderValueIndex] = tempValue;
|
|
excludedFullPathTypeArray[workingFolderValueIndex] = tempType;
|
|
}
|
|
}
|
|
disable = 'class ="deny" style="pointer-events:none;"';
|
|
disabled_row = "style='background-color:#dae4ea'";
|
|
}
|
|
|
|
for(var i=0; i < pathCount;i++){
|
|
var checkedPath = excludedFullPathArray[i];
|
|
var cssSpanClassName = '';
|
|
var cssClassName = '';
|
|
var fileMissingEle = '';
|
|
var displaySelected = checkedPath;
|
|
if(machine=='twotier'){
|
|
displaySelected = checkedPath.substring(sharedFolderPathLength);
|
|
}
|
|
imgType = excludedFullPathTypeArray[i];
|
|
if (jQuery.inArray(checkedPath, excludedFullPathMissingArray) != -1) {
|
|
cssSpanClassName = 'class="file_missing_filename"';
|
|
cssClassName = 'class="file_missing"';
|
|
fileMissingEle = '<span class="file_missing_text">';
|
|
fileMissingEle += (imgType + ' is missing');
|
|
fileMissingEle += '</span>';
|
|
}
|
|
var splitChar = checkedPath.split('\\');
|
|
var charCount = (splitChar.length-1);
|
|
html += '<tr '+disabled_row+' ' + cssClassName + '>';
|
|
html += '<td class="file_check"> <input type="checkbox"><input type="hidden" name="selectedFull[]" value="'+htmlEntities(checkedPath)+'"><input type="hidden" name="imgType[]" value="'+imgType+'"> <label ' + disable + '> files </label> <input type="hidden" name="chk_length_full[]" value="'+charCount+'" > </td>';
|
|
html += '<td class="cont_heading" title="'+htmlEntities(displaySelected)+'"><img src="include/images/idq_ico_'+imgType+'.png"><span ' + cssSpanClassName + ((fileMissingEle != '')? "style=\"max-width: 560px;\"" : '') + ' >'+htmlEntities(displaySelected).replace(/[\s]/g,' ')+'</span>' + fileMissingEle + '</td>';
|
|
html += '</tr>';
|
|
|
|
disable= "";
|
|
disabled_row = "";
|
|
}
|
|
jQuery('#excludeFullPath').html(html);
|
|
jQuery('#maincheckFull').parent().parent().show();
|
|
jQuery('#noFullPath').hide().siblings('.excludefiles').show();
|
|
$.popContainerHide();
|
|
} else {
|
|
event.preventDefault();
|
|
|
|
showErrorMessages('#excludeFullError',SELECT_FILE_FOLDER);
|
|
return false;
|
|
}
|
|
startTimeoutForAutoPost('preferences'); //Auto POST
|
|
});
|
|
/* Add selected full path - End */
|
|
|
|
/* Remove selected full paths - Start */
|
|
jQuery("div.wrapper section#content").die('click').on('click','#removeSelectedFullPath span',function(){
|
|
jQuery('#excludeFullPath tr.chk').remove();
|
|
jQuery('#maincheckFull').next().attr('class','mainchek');
|
|
jQuery(this).hide();
|
|
var remaining = jQuery('#excludeFullPath input').length;
|
|
if(remaining==0){
|
|
jQuery('#maincheckFull').parent().parent().hide();
|
|
jQuery('#noFullPath').show().siblings('.excludefiles').hide();
|
|
}
|
|
storeAddedFullPath();
|
|
startTimeoutForAutoPost('preferences'); //Auto POST
|
|
});
|
|
/* Remove selected full paths - End */
|
|
|
|
function hideShowNoFiles(){
|
|
var remainingFullPath = jQuery('#excludeFullPath input').length;
|
|
|
|
if(remainingFullPath==0){
|
|
jQuery('#maincheckFull').closest('tr').hide();
|
|
jQuery('#noFullPath').show().siblings('.excludefiles').hide();
|
|
} else {
|
|
jQuery('#maincheckFull').closest('tr').show();
|
|
jQuery('#noFullPath').hide().siblings('.excludefiles').show();
|
|
}
|
|
|
|
var remainingPartialName = jQuery('#selectedPartialName input').length;
|
|
if(remainingPartialName==0){
|
|
jQuery('#maincheckPartial').closest('tr').hide();
|
|
jQuery('#noPartialName').show().siblings('.excludefiles').hide();
|
|
} else {
|
|
jQuery('#maincheckPartial').closest('tr').show();
|
|
jQuery('#noPartialName').hide().siblings('.excludefiles').show();
|
|
}
|
|
}
|
|
|
|
/* Load Files/Folders - Start */
|
|
jQuery("div.wrapper section#content").die('click').on('click','.preferences a.getDirList',function(){
|
|
var getDir = jQuery(this).attr('alt');
|
|
currDirPath = getDir;
|
|
loadPathForExclude(getDir);
|
|
});
|
|
jQuery("div.wrapper section#content").die('click').on('click','#addFullExclude',function(){
|
|
jQuery('.common_msg').hide();
|
|
currDirPath = '/';
|
|
storeAddedFullPath();
|
|
loadPathForExclude('/');
|
|
});
|
|
jQuery("div.wrapper section#content").die('click').on('click','#cancel_full_path',function(){
|
|
excludedFullPathArray = [];
|
|
tempExcludedFullPathArray = [];
|
|
$.popContainerHide();
|
|
});
|
|
|
|
function loadPathForExclude(getDir, pagination, page_no){
|
|
|
|
pagination = pagination || false;
|
|
page_no = page_no || 1;
|
|
//sajana Added for Hiding Exclude Option
|
|
var exclude_option="no";
|
|
var url = "fullPathSelection.php?fullPath="+encodeURIComponent(getDir)+"&exclude_option="+exclude_option;
|
|
|
|
var dirListVal = dynamicArray[getDir];
|
|
var dirListType = dynamicType[getDir];
|
|
var toPlace = 'loadFullPath';
|
|
var breadcrum = 'fullPathBreadCrumb';
|
|
var maincheck ='excludeBackupFilePath';
|
|
jQuery('#maincheck').siblings('label').css('visibility','visible');
|
|
var container = '<div class="excludefiles" style="overflow: hidden;">';
|
|
container += '<table id="excludeFilesPath" width="100%" border="0" cellspacing="0" cellpadding="0" class="folderBackupContent backupset_table bc_table">';
|
|
container += '<tbody></tbody>';
|
|
container += '</table></div>';
|
|
if (!pagination)
|
|
jQuery('#loadFullPath').html(container);
|
|
jQuery('#' + toPlace + '>.excludefiles').unbind('scroll');
|
|
|
|
// AJAX Call for new
|
|
if((dirListVal === "" || typeof dirListVal == "undefined" || pagination)){
|
|
jQuery('#'+toPlace).siblings('.ajax_loader').show();
|
|
jQuery('#' + toPlace + '>.excludefiles').unbind('scroll');
|
|
var loadList = function() {
|
|
jQuery.ajax({
|
|
url: (url + '&page_no=' + page_no),
|
|
success: function(locationData){
|
|
if(locationData.indexOf('<html>')>0){
|
|
window.location.href='../index.php';
|
|
}
|
|
locationDataRes=$.parseJSON(locationData);
|
|
jQuery('#'+toPlace).siblings('.ajax_loader').hide();
|
|
if(locationDataRes[0]==true){
|
|
jQuery('#'+toPlace).show().prev('.nfiles').hide();
|
|
if ( !pagination ) {
|
|
jQuery('#'+toPlace).find('tbody').html(locationDataRes[1]);
|
|
}
|
|
else {
|
|
jQuery('#'+toPlace).find('tbody').append(locationDataRes[1]);
|
|
}
|
|
}
|
|
else if ( typeof locationDataRes['retry'] != 'undefined' ) {
|
|
jQuery('#'+toPlace).siblings('.ajax_loader').show();
|
|
if (locationDataRes['retry']) {
|
|
loadList();
|
|
}
|
|
else {
|
|
jQuery('#'+toPlace).siblings('.ajax_loader').hide();
|
|
}
|
|
}
|
|
else {
|
|
jQuery('#loadFullPath').hide().prev('.nfiles').show();
|
|
jQuery('#maincheck').siblings('label').css('visibility','hidden');
|
|
}
|
|
|
|
//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 (!pagination) {
|
|
dynamicArray[dirURL]=dirList;
|
|
dynamicType[dirURL] =dirType;
|
|
IDrive.LocalDirList[dirURL] = locationDataRes[2]['dir_list'];
|
|
}
|
|
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;
|
|
}
|
|
|
|
localExcludeFileBreadcrumb(getDir,toPlace,breadcrum,maincheck); //Call BreadCrumb
|
|
markSelectedExcludeItems(getDir,toPlace); //Call function to "Mark" the selected Items
|
|
jQuery('#'+toPlace+' .excludefiles').css('overflow','auto');
|
|
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) {
|
|
loadPathForExclude(getDir, true, (++dynamicRequestInfo[dirURL]['page_no']));
|
|
$(this).unbind('scroll');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
loadList();
|
|
} else if(dirListVal === null){
|
|
jQuery('#'+toPlace).hide().prev('.nfiles').show();
|
|
localExcludeFileBreadcrumb(getDir,toPlace,breadcrum,maincheck); //Call breadCrumb function
|
|
jQuery('#maincheck').siblings('label').css('visibility','hidden');
|
|
} else {
|
|
//Loading files/folders from array intead of making AJAX call again
|
|
var dirHTML = '';
|
|
jQuery('#'+toPlace).siblings('.ajax_loader').show();
|
|
/* Condition added for synology market place */
|
|
if(getDir=='/'){
|
|
for(var j=0; j<dirListVal.length; j++){
|
|
var dirFullPath = dirListVal[j];
|
|
var dirType = dirListType[j];
|
|
|
|
dirFullPath = dirFullPath.replace('\/\/','\/');
|
|
var dirName = dirFullPath;
|
|
|
|
if(sh=="Hide" && ((rootLevelEnabled==true && dirName.indexOf("/.")==0) || (rootLevelEnabled==false && dirName.indexOf("/.")>0))){
|
|
var tr_style='class="hideData"';
|
|
continue;
|
|
} else{
|
|
var tr_style='';
|
|
}
|
|
|
|
var splitDir = dirFullPath.split("/");
|
|
var dir = splitDir.pop();
|
|
if(machine=='QNAP'){
|
|
var drivePath = splitDir[1]+"/"+splitDir[2];
|
|
} else {
|
|
var drivePath = splitDir[1];
|
|
}
|
|
|
|
dirName1 = dirName.replace('"','"');
|
|
dirFullPath = htmlEntities(dirFullPath);
|
|
dirName = htmlEntities(dirName);
|
|
dir = htmlEntities(dir);
|
|
drivePath = htmlEntities(drivePath);
|
|
|
|
if(machine=='twotier'){
|
|
var title = dir;
|
|
} else {
|
|
var title = dir;
|
|
if(typeof rootLevelEnabled == "undefined" || rootLevelEnabled == false || rootLevelEnabled == "") {
|
|
title = title + ' @ ' + drivePath;
|
|
}
|
|
}
|
|
|
|
if(dirType=='folder'){
|
|
if(machine == ASUSTOR){
|
|
if(dirFullPath.indexOf('/home/'+dir.replace(/[\s]/g,' ')) != -1){
|
|
dir = "Home";
|
|
title = "Home";
|
|
}
|
|
}
|
|
dirHTML += '<tr '+tr_style+' class="row_list">';
|
|
dirHTML += '<td class="file_check"><input type="checkbox" name="chk_elements['+j+']" value="'+dirFullPath+'" id="chk_elements['+j+']"> <label> folder </label> </td>';
|
|
dirHTML += '<td class="cont_heading" title="'+title+'"><a class="getDirList" href="javascript:void(0);" alt="'+dirFullPath+'">';
|
|
dirHTML += '<img src="include/images/idq_ico_folder.png"></a>';
|
|
dirHTML += '<a class="getDirList" href="javascript:void(0);" alt="'+dirFullPath+'"><span>';
|
|
dirHTML += dir.replace(/[\s]/g,' ');
|
|
dirHTML += '</span></a></td>';
|
|
dirHTML += '<td class="file_size"> -- </td><td class="file_date"> '+IDrive.LocalDirList[getDir][dirName1].datetime+' </td>';
|
|
dirHTML += '</tr>';
|
|
} else {
|
|
dirHTML += '<tr '+tr_style+' class="row_list">';
|
|
dirHTML += '<td class="file_check"><input type="checkbox" name="chk_elements['+j+']" value="'+dirFullPath+'" id="chk_elements['+j+']"> <label> file </label> </td>';
|
|
dirHTML += '<td class="cont_heading" title="'+title+'"><img src="include/images/idq_ico_file.png"><span>';
|
|
dirHTML += dir.replace(/[\s]/g,' ');
|
|
dirHTML += '</span></td>';
|
|
dirHTML += '<td class="file_size"> '+IDrive.LocalDirList[getDir][dirName1].size+' </td><td class="file_date"> '+IDrive.LocalDirList[getDir][dirName1].datetime+' </td>';
|
|
dirHTML += '</tr>';
|
|
}
|
|
}
|
|
} else {
|
|
for(var j=0; j<dirListVal.length; j++){
|
|
var dirFullPath = dirListVal[j];
|
|
var dirType = dirListType[j];
|
|
var splitPath = dirFullPath.split('/');
|
|
|
|
var dirName = splitPath[splitPath.length-1];
|
|
|
|
if(sh=="Hide" && !dirName.indexOf(".")){
|
|
var tr_style='class="hideData"';
|
|
continue;
|
|
} else{
|
|
var tr_style='';
|
|
}
|
|
dirName1 = dirName.replace('"','"');
|
|
dirFullPath = htmlEntities(dirFullPath);
|
|
dirName = htmlEntities(dirName);
|
|
|
|
if(dirType=='folder'){
|
|
dirHTML += '<tr '+tr_style+'>';
|
|
dirHTML += '<td class="file_check"><input type="checkbox" name="chk_elements['+j+']" value="'+dirFullPath+'" id="chk_elements['+j+']"> <label>folder</label> </td>';
|
|
dirHTML += '<td class="cont_heading" width="40%" title="'+dirName+'" ><img src="include/images/idq_ico_folder.png"><span>';
|
|
dirHTML += '<a class="getDirList" href="javascript:void(0);" alt="'+dirFullPath+'">';
|
|
dirHTML += dirName.replace(/[\s]/g,' ');
|
|
dirHTML += '</a></span></td>';
|
|
dirHTML += '<td class="file_size" width="14%"> -- </td><td class="file_date" width="25%"> '+IDrive.LocalDirList[getDir][dirName1].datetime+' </td>';
|
|
dirHTML += '</tr>';
|
|
} else {
|
|
dirHTML += '<tr '+tr_style+'>';
|
|
dirHTML += '<td class="file_check"><input type="checkbox" name="chk_elements['+j+']" value="'+dirFullPath+'" id="chk_elements['+j+']"> <label>file</label> </td>';
|
|
dirHTML += '<td class="cont_heading" width="40%" title="'+dirName+'" ><img src="include/images/idq_ico_file.png"><span>';
|
|
dirHTML += dirName.replace(/[\s]/g,' ');
|
|
dirHTML += '</span></td>';
|
|
dirHTML += '<td class="file_size" width="14%">'+IDrive.LocalDirList[getDir][dirName1].size+'</td><td class="file_date" width="25%"> '+IDrive.LocalDirList[getDir][dirName1].datetime+' </td>';
|
|
dirHTML += '</tr>';
|
|
}
|
|
|
|
}
|
|
}
|
|
jQuery('#'+toPlace).siblings('.nfiles,.ajax_loader').hide();
|
|
jQuery('#'+toPlace).show().find('tbody').html(dirHTML);
|
|
localExcludeFileBreadcrumb(getDir,toPlace,breadcrum,maincheck); //Call breadCrumb function
|
|
markSelectedExcludeItems(getDir,toPlace); //Call function to "Mark" the selected Items
|
|
jQuery('#'+toPlace+' .excludefiles').css('overflow','auto');
|
|
if ((typeof dynamicRequestInfo[getDir] != "undefined") && !dynamicRequestInfo[getDir]['success']) {
|
|
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) {
|
|
loadPathForExclude(getDir, true, (++dynamicRequestInfo[getDir]['page_no']));
|
|
$(this).unbind('scroll');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
/* Load Files/Folders - End */
|
|
|
|
//Function to update BreadCrumb & keep the child file/folders as Selected if parent got selected
|
|
function localExcludeFileBreadcrumb(getDir,toPlace,breadcrum,maincheck){
|
|
|
|
var splitDir = getDir.split('/');
|
|
|
|
var breadCrumb = '<a href="javascript:void(0);" alt="/" title="/" class="getDirList">/</a>';
|
|
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 += '<a href="javascript:void(0);" alt="'+currDir+'" title="'+title+'" class="getDirList">'+val+'</a>';
|
|
}
|
|
});
|
|
|
|
jQuery('#'+breadcrum).html(breadCrumb);
|
|
if(maincheck !=''){
|
|
jQuery('.'+maincheck+' .header_part .file_check label').removeAttr('class');
|
|
}
|
|
responsiveBreadcrumb('#'+breadcrum,'getDirList');
|
|
}
|
|
|
|
//Function to "Mark" the selected Items
|
|
function markSelectedExcludeItems(getDir,toPlace){
|
|
|
|
var split_path = getDir.split('/');
|
|
var split_path_count = split_path.length;
|
|
var selected_path = '';
|
|
var selected_path_found = 0;
|
|
var current_directory = getDir;
|
|
jQuery('.excludeBackupFilePath #maincheck').siblings('label').removeAttr('class');
|
|
for(var i=1; i<split_path_count; i++){
|
|
selected_path += "/"+split_path[i];
|
|
if((sh=='Hide' && selected_path.indexOf('/.')!=-1))
|
|
continue;
|
|
|
|
if(tempExcludedFullPathArray.indexOf(selected_path)!=-1){ //alert("selected_path index "+selected_path);
|
|
jQuery('#'+toPlace).find('tr').addClass('chk').find('input').attr('checked',true).next('label').addClass('label_checked');
|
|
jQuery('.excludeBackupFilePath #maincheck').next().addClass('label_checked');
|
|
selected_path_found=1;
|
|
}
|
|
}
|
|
|
|
//Backup Set: For selected parent directory
|
|
if(selected_path_found ==0){
|
|
test = tempExcludedFullPathArray.filter(function(val) {
|
|
if(!(val === "" || typeof val == "undefined" || val === null)){
|
|
|
|
if((sh=='Hide' && val.indexOf('/.')!=-1))
|
|
return;
|
|
|
|
var checkId = tempExcludedFullPathArray.indexOf(val);
|
|
if(checkId >= 0)
|
|
{
|
|
if(dynamicArray.indexOf(current_directory) != "" && dynamicArray[current_directory] != null)
|
|
{
|
|
var id_of_element = dynamicArray[current_directory].indexOf(val);
|
|
if(id_of_element>=0){
|
|
|
|
if(sh=='Hide')
|
|
{
|
|
var hiddenCount = countHiddenFilesAboveSelectedFile(current_directory, 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('.excludeBackupFilePath #maincheck').next().addClass('label_semi_checked');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
//Mark "Partial check" if its child has been selected
|
|
var curPathDirList = dynamicArray[getDir];
|
|
if(curPathDirList != null){
|
|
if(curPathDirList.length>0){
|
|
for(var i=0; i<curPathDirList.length; i++){
|
|
var selected_dir = curPathDirList[i];
|
|
|
|
if((sh=='Hide' && selected_dir.indexOf('/.')!=-1))
|
|
continue;
|
|
|
|
var check_parent = array_search(tempExcludedFullPathArray,selected_dir+'/');
|
|
if(check_parent!=''){
|
|
|
|
var val = selected_dir;
|
|
|
|
if(dynamicArray.indexOf(current_directory) != "" && dynamicArray[current_directory] != null)
|
|
{
|
|
var id_of_element = dynamicArray[current_directory].indexOf(val);
|
|
|
|
if(sh=='Hide')
|
|
{
|
|
var hiddenCount = countHiddenFilesAboveSelectedFile(current_directory, val);
|
|
id_of_element = id_of_element - hiddenCount;
|
|
}
|
|
|
|
var selected_dir_id = jQuery('#loadFullPath input[type="checkbox"]').eq(id_of_element);
|
|
if(selected_dir_id.attr('checked')!='checked'){
|
|
parent_dris_with_slash = (check_parent + "/").split(',').join('/,');
|
|
// Avoid lower order directories with substring match
|
|
if(parent_dris_with_slash.indexOf(selected_dir + "/") != -1) {
|
|
selected_dir_id.next().addClass('label_semi_checked');
|
|
jQuery('.excludeBackupFilePath #maincheck').next().addClass('label_semi_checked');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
markMaincheckAfterRemove('loadFullPath');
|
|
}
|
|
|
|
/* Load Backup Locations - Start */
|
|
jQuery("div.wrapper section#content").die('click').on('click','.preferences a.getBackupDirList',function(){
|
|
jQuery('#loadBackupLocation').siblings('.ajax_loader').show();
|
|
var getDir = jQuery(this).attr('alt');
|
|
var splitChar = getDir.split('\\');
|
|
var charCount = (splitChar.length-1);
|
|
var url = "backupLocation.php?fullPath="+encodeURIComponent(getDir)+"&length="+charCount;
|
|
|
|
var dirListVal = dynamicRemoteDirList[getDir];
|
|
|
|
var splitDir = getDir.split('/');
|
|
|
|
var breadCrumb = '<a href="javascript:void(0);" alt="/" title="/" class="getBackupDirList">/</a>';
|
|
var currDir = "";
|
|
splitDir = splitDir.filter(function(val) {
|
|
if(!(val === "" || typeof val == "undefined" || val === null)){
|
|
currDir += '/'+val;
|
|
var title = currDir;
|
|
if(machine=='twotier'){
|
|
title = currDir.substring(sharedFolderPathLength);
|
|
}
|
|
breadCrumb += '<a href="javascript:void(0);" alt="'+htmlEntities(currDir)+'" title="'+title+'" class="getBackupDirList">'+val+'</a>';
|
|
}
|
|
});
|
|
jQuery('.preferenceBreadCrumb').html(breadCrumb);
|
|
responsiveBreadcrumb('.preferenceBreadCrumb','getBackupDirList');
|
|
/* To highlight the selected backup location */
|
|
var markSelected = jQuery('input#backupLocation').val();
|
|
if(markSelected.charAt(0)!='/'){
|
|
markSelected = '/'+markSelected;
|
|
}
|
|
markSelected = markSelected.replace('"','"');
|
|
jQuery('#maincheck').siblings('label').css('visibility','visible');
|
|
loadRemoteFiles(getDir, 'loadBackupLocation', 'backupLocationBreadCrumb');
|
|
|
|
/* To highlight the selected backup location */
|
|
jQuery('#loadBackupLocation input[value*= "'+markSelected+'/"]').closest('tr').addClass('selected_row').css("background-color","#CDDAE1");
|
|
});
|
|
/* Load Backup Locations - End */
|
|
|
|
/* Select Backup Location - Start */
|
|
jQuery("div.wrapper section#content").die('click').on('click','.preferences #loadBackupLocation tr:not("a")',function(){
|
|
var className = jQuery(this).attr('class');
|
|
if(className!=undefined){
|
|
jQuery(this).removeAttr('class').removeAttr('style');
|
|
} else {
|
|
jQuery('#excludeFilesPath tr').removeAttr('class').removeAttr('style');
|
|
jQuery(this).addClass('selected_row').css("background-color","#CDDAE1");
|
|
jQuery('#permissionError').hide();
|
|
startTimeoutForAutoPost('preferences'); //Auto POST
|
|
}
|
|
});
|
|
|
|
jQuery("div.wrapper section#content").die('click').on('click','#addLocation',function(){
|
|
|
|
var location = jQuery('.selected_row').find("a").attr('alt');
|
|
var location1 = jQuery('#backupLocationBreadCrumb a:last').attr('alt');
|
|
|
|
if(location!='' && location!=undefined && location!=null ){
|
|
jQuery('#backupLocation').val(location).focus().attr('title', location);
|
|
actionRequired=2;
|
|
backupLocationValue = location;
|
|
} else if(location1=='/'){
|
|
showErrorMessages('#permissionError',SELECT_BACKUP_LOCATION);
|
|
return false;
|
|
} else if(location1!='' && location1!=undefined && location1!=null){
|
|
jQuery('#backupLocation').val(location1).focus().attr('title', location1);
|
|
backupLocationValue = location1;
|
|
actionRequired=2;
|
|
}
|
|
$.popContainerHide();
|
|
});
|
|
/* Select Backup Location - End */
|
|
|
|
/* Keeping the added Exclude Full Paths*/
|
|
function storeAddedFullPath(){
|
|
var addedFullPath = jQuery('#fullPathForm input[type="checkbox"]').length;
|
|
excludedFullPathArray = [];
|
|
excludedFullPathTypeArray=[];
|
|
|
|
tempExcludedFullPathArray = [];
|
|
tempExcludedFullPathTypeArray=[];
|
|
tempExcludedFullPathMissingArray=[];
|
|
|
|
if(addedFullPath>0){
|
|
jQuery('#fullPathForm tr').each(function(){
|
|
var path = jQuery(this).find('input[type="hidden"]').eq(0).val();
|
|
var imgType = jQuery(this).find('input[type="hidden"]').eq(1).val();
|
|
excludedFullPathArray.push(path);
|
|
tempExcludedFullPathArray.push(path);
|
|
tempExcludedFullPathTypeArray.push(imgType);
|
|
if (jQuery(this).hasClass('file_missing'))
|
|
tempExcludedFullPathMissingArray.push(path);
|
|
});
|
|
}
|
|
|
|
jQuery('#loadFullPath tr').removeAttr('class').find('input').removeAttr('checked').siblings('label').removeAttr('class');
|
|
}
|
|
|
|
jQuery("div.wrapper section#content").die('click').on('click','input#enablePath',function(){
|
|
var checked = jQuery(this).attr('checked');
|
|
if(checked=='checked' || checked==true){
|
|
jQuery('select.path_selected').attr('disabled',false);
|
|
} else {
|
|
jQuery('select.path_selected').attr('disabled',true);
|
|
}
|
|
});
|
|
|
|
//Function to select/unselect items
|
|
jQuery(document).on('click','.preferences #excludeFilesPath td.file_check, .preferences .excludeBackupFilePath .header_part .file_check',function(e){
|
|
|
|
//Checking whether clicked on Checkbox or TD
|
|
var clickedLabel = e.target.nodeName;
|
|
if(clickedLabel != 'LABEL'){
|
|
return false;
|
|
}
|
|
//To load Full path freshly
|
|
var checkElement = jQuery(this);
|
|
|
|
if(checkElement.find('label').hasClass('label_checked')){
|
|
if(checkElement.find('label').html()=="All"){
|
|
addExcludeFilesList("All");
|
|
} else {
|
|
addExcludeFilesList(checkElement);
|
|
}
|
|
} else {
|
|
if(checkElement.find('label').html()=="All"){
|
|
removeExcludeFilesList("All");
|
|
} else {
|
|
removeExcludeFilesList(checkElement);
|
|
}
|
|
}
|
|
});
|
|
|
|
//Function to add exclude list to array
|
|
function addExcludeFilesList(args) {
|
|
|
|
/* Add selected files/folders - Start */
|
|
if(args!="All"){
|
|
var fileCheckLabel = jQuery('.excludeBackupFilePath .header_part .file_check label');
|
|
if(fileCheckLabel.hasClass('label_checked')){
|
|
args=='All';
|
|
}
|
|
}
|
|
|
|
if(args=="All" && currDirPath=='/'){
|
|
tempExcludedFullPathArray = [];
|
|
tempExcludedFullPathTypeArray = [];
|
|
tempExcludedFullPathMissingArray = [];
|
|
|
|
jQuery('#loadFullPath input').each(function(){
|
|
var selected = jQuery(this).val();
|
|
var imgSrc = jQuery(this).closest('td').next().find('img').attr('src');
|
|
var imgSubstr = imgSrc.substring(23);
|
|
var itemType = imgSubstr.replace('.png','');
|
|
|
|
//To skip if the file/folder is hidden
|
|
if((sh=='Hide' && selected.indexOf('/.')>=1)){
|
|
return true;
|
|
}
|
|
if(tempExcludedFullPathArray.length>0){
|
|
var check_parent = array_search(tempExcludedFullPathArray,selected+'/');
|
|
|
|
if(check_parent.length>0){
|
|
removeExcludeSubDirecories(check_parent);
|
|
}
|
|
}
|
|
tempExcludedFullPathArray.push(selected);
|
|
tempExcludedFullPathTypeArray.push(itemType);
|
|
});
|
|
|
|
} else {
|
|
var breadcrumCall = false;
|
|
if(args=='All'){
|
|
breadcrumCall = true;
|
|
args = currDirPath.replace(/\/$/, '');
|
|
var selected = args;
|
|
var itemType = 'folder';
|
|
}
|
|
else if(typeof args != 'string'){
|
|
var selected = args.find('input').val();
|
|
var imgSrc = args.closest('td').next().find('img').attr('src');
|
|
var imgSubstr = imgSrc.substring(23);
|
|
var itemType = imgSubstr.replace('.png','');
|
|
}
|
|
|
|
if(breadcrumCall == true){
|
|
var checkParent = array_search_reverse(tempExcludedFullPathArray, selected + '/');
|
|
if(checkParent.length > 0) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if(tempExcludedFullPathArray.indexOf(selected)==-1){
|
|
if(tempExcludedFullPathArray.length>0){
|
|
var check_parent = array_search(tempExcludedFullPathArray,selected+'/');
|
|
if(check_parent.length>0){
|
|
removeExcludeSubDirecories(check_parent);
|
|
}
|
|
}
|
|
|
|
tempExcludedFullPathArray.push(selected);
|
|
tempExcludedFullPathTypeArray.push(itemType);
|
|
markMaincheckAfterRemove('loadFullPath');
|
|
}
|
|
}
|
|
/* Add selected files/folders - End */
|
|
}
|
|
|
|
//Function to remove exclude list from array
|
|
function removeExcludeFilesList(args){
|
|
/* remove selected files/folders - Start */
|
|
if(args=="All" && currDirPath =='/'){
|
|
tempExcludedFullPathArray=[];
|
|
tempExcludedFullPathTypeArray=[];
|
|
} else {
|
|
var checkedElement = jQuery('#loadFullPath tr.chk input:checked');
|
|
if(args=="All")
|
|
selected = currDirPath;
|
|
else
|
|
selected = args.find('input').val();
|
|
|
|
var index = tempExcludedFullPathArray.indexOf(selected);
|
|
if(index>=0){
|
|
tempExcludedFullPathArray.splice(index, 1);
|
|
tempExcludedFullPathTypeArray.splice(index, 1);
|
|
} else {
|
|
var index = tempExcludedFullPathArray.indexOf(currDirPath.substring(0, currDirPath.length-1));
|
|
if(index>=0){
|
|
tempExcludedFullPathArray.splice(index, 1);
|
|
tempExcludedFullPathTypeArray.splice(index, 1);
|
|
//addSelectedShareItemExceptUnchecked(checkedElement,clickedDirPath); // Call function to add other items
|
|
} else {
|
|
if(args=="All"){
|
|
var allClickedDirPath = currDirPath.split('/');
|
|
allClickedDirPath.pop();
|
|
var parentPath = allClickedDirPath.join("/");
|
|
}
|
|
else{
|
|
var parentPath = currDirPath;
|
|
}
|
|
var index = tempExcludedFullPathArray.indexOf(parentPath);
|
|
if(index>=0 && args!="All"){
|
|
|
|
tempExcludedFullPathArray.splice(index, 1);
|
|
tempExcludedFullPathTypeArray.splice(index, 1);
|
|
|
|
addItemsExceptUnchecked(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<clickedDirPathSplitCount; i++){
|
|
pathAppend += '/'+clickedDirPathSplit[i];
|
|
pathSearch.push(pathAppend);
|
|
}
|
|
addItemsExceptUnchecked(checkedElement,parentPath); // Call function to add other items
|
|
|
|
for(var j=(pathSearch.length-1); j>=0; j--){
|
|
var index = tempExcludedFullPathArray.indexOf(pathSearch[j]);
|
|
addItemsExceptUnchecked('',pathSearch[j]); //Call function to add other items
|
|
if(index>=0){
|
|
tempExcludedFullPathArray.splice(index, 1);
|
|
tempExcludedFullPathTypeArray.splice(index, 1);
|
|
break;
|
|
}
|
|
}
|
|
} //End
|
|
}}
|
|
}
|
|
/* remove selected files/folders - End */
|
|
}
|
|
|
|
//Function add remaining items after unchecking child element
|
|
function addItemsExceptUnchecked(checkedElement,currDirPath1){
|
|
var selected='';
|
|
var backupArray1 = tempExcludedFullPathArray;
|
|
var backupArray3 = tempExcludedFullPathTypeArray;
|
|
|
|
if(checkedElement!=''){
|
|
checkedElement.each(function(){
|
|
selected = jQuery(this).val();
|
|
|
|
var imgSrc = jQuery(this).parent().next().find('img').attr('src');
|
|
var imgSubstr = imgSrc.substring(23);
|
|
var itemType = imgSubstr.replace('.png','');
|
|
|
|
if(backupArray1.indexOf(selected)==-1){
|
|
var selected_dir = selected+"/";
|
|
backupArray1.push(selected);
|
|
backupArray3.push(itemType);
|
|
}
|
|
});
|
|
|
|
} else {
|
|
var dirListVal = dynamicArray[currDirPath1];
|
|
var dirTypeVal = dynamicType[currDirPath1];
|
|
|
|
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;
|
|
var isInString = currDirPath.indexOf(selected+'/');
|
|
if(backupArray1.indexOf(selected)==-1 && isInString==-1 && currDirPath!=selected){
|
|
var selected_dir = selected+"/";
|
|
backupArray1.push(selected);
|
|
backupArray3.push(itemType);
|
|
}
|
|
}
|
|
}
|
|
|
|
//Exclude List
|
|
tempExcludedFullPathArray = backupArray1;
|
|
tempExcludedFullPathTypeArray = backupArray3;
|
|
}
|
|
|
|
/* Function to remove already selected sub-directories while selecting its parent */
|
|
function removeExcludeSubDirecories(args){
|
|
arr_length = args.length;
|
|
|
|
for(var i=0;i<arr_length;i++){
|
|
|
|
selected = args[i];
|
|
|
|
var index = tempExcludedFullPathArray.indexOf(selected);
|
|
|
|
tempExcludedFullPathArray.splice(index, 1);
|
|
tempExcludedFullPathTypeArray.splice(index, 1);
|
|
}
|
|
}
|
|
|
|
//Function to check the IP address format
|
|
jQuery("div.wrapper section#content").die('mouseout').on('mouseout','input[name="ipAddress"]',function(){
|
|
if(checkIPformat()===false){
|
|
document.getElementById('ipAddress').focus();
|
|
return false;
|
|
}
|
|
});
|
|
|
|
//Function to validate inputs
|
|
jQuery("div.wrapper section#content").die('click').on('click','input[name="port"],input[name="userName"],input[name="password"],#proxyServerPassword',function(e){
|
|
if(checkIPformat()===false){
|
|
document.getElementById('ipAddress').focus();
|
|
return false;
|
|
}
|
|
if(jQuery(this).attr('name')=='password' && jQuery('input[name="userName"]').val()==''){
|
|
jQuery('input[name="userName"]').focus();
|
|
return false;
|
|
}
|
|
});
|
|
|
|
//Function to check the PORT number
|
|
jQuery("div.wrapper section#content").die('keydown').on('keydown','input[name="port"]',function(e){
|
|
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1){
|
|
return;
|
|
}
|
|
|
|
// Ensure that it is a number and stop the keypress
|
|
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)&& (e.keyCode < 37 || e.keyCode > 40)) {
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
|
|
//Function to check the IP address or domain name value.
|
|
jQuery("div.wrapper section#content").die('keydown').on('keydown','input[name="ipAddress"]',function(e){
|
|
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1){
|
|
return;
|
|
}
|
|
// need to update alphabet keys to allow domain names here.
|
|
// Ensure that it is a number and stop the keypress
|
|
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105) && ((e.keyCode < 65 || e.keyCode > 90)) && (e.keyCode < 37 || e.keyCode > 40)) {
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
|
|
//Funtion to observe user's activity
|
|
jQuery("div.wrapper section#content").die('click').on('click','.preference form input,.preference form select',function(){
|
|
startTimeoutForAutoPost('preferences'); //Auto POST
|
|
});
|
|
|
|
|
|
jQuery("div.wrapper section#content").die('click').on('click','#showHide',function(){
|
|
var isChecked = $(this).prop('checked');//hidden_status
|
|
$("#displayRoot").val((($("#displayRootChk").prop("checked") == true)? 1 : 0));
|
|
|
|
preferenceChanged=1;
|
|
showHiddenClicked = true;
|
|
if(isChecked==true || isChecked=='checked'){
|
|
jQuery("#hiddenStatus").val('1');
|
|
sh="Show";
|
|
}else{
|
|
sh="Hide";
|
|
jQuery("#hiddenStatus").val('2');
|
|
}
|
|
preferenceSettings();
|
|
});
|
|
|
|
jQuery("div.wrapper section#content").die('click').on('click','#multipleEngineEnable',function(){
|
|
var isChecked = $(this).prop('checked');//hidden_status
|
|
$("#displayRoot").val((($("#displayRootChk").prop("checked") == true)? 1 : 0));
|
|
|
|
preferenceChanged=1;
|
|
if(isChecked==true || isChecked=='checked'){
|
|
jQuery("#hiddenEngineStatus").val('4');
|
|
}else{
|
|
jQuery("#hiddenEngineStatus").val('2');
|
|
}
|
|
//preferenceSettings();
|
|
});
|
|
|
|
//
|
|
var rootDisplayChanged = false;
|
|
jQuery(document).on('click', '#displayRootChk', function() {
|
|
$("#displayRoot").val((($(this).prop("checked") == true)? 1 : 0));
|
|
preferenceChanged = 1;
|
|
//showHiddenClicked = true;
|
|
rootDisplayChanged = true;
|
|
preferenceSettings();
|
|
});
|
|
|
|
//calling send error report popup..
|
|
(function($) {
|
|
var logWarning = '';
|
|
$(document).on('click', '#sendErrLink', function() {
|
|
SendErrorReport();
|
|
});
|
|
|
|
function SendErrorReport() {
|
|
$.popContainerHide();
|
|
$.popContainer();
|
|
|
|
var url = "action.php?action=readErrorInfo";
|
|
$.ajax({
|
|
type: "POST",
|
|
url: url,
|
|
dataType : 'json',
|
|
success: function(data) {
|
|
$("#errusername").val(data.username);
|
|
|
|
if(typeof data.username == "undefined" || data.username == "" || data.username == null) {
|
|
$("#errusername").prop('readonly', false);
|
|
}
|
|
|
|
$("#email_error_report").val(data.email);
|
|
$("#contact_number").val(data.number);
|
|
//checking username and email are equal
|
|
if(data.username == data.email) {
|
|
$("#email_error_report").val(data.username);
|
|
} else {
|
|
$("#email_error_report").val(data.email);
|
|
}
|
|
|
|
if(typeof data.logSendWarning != "undefined" && data.logSendWarning != '') {
|
|
logWarning = data.logSendWarning;
|
|
}
|
|
}
|
|
});
|
|
|
|
if($('div.send_error_report').length > 0) {
|
|
$('div.send_error_report').remove();
|
|
}
|
|
|
|
var parentEle = $('.sec_pos_container');
|
|
parentEle.append($('<div>', {'class': 'popup_container send_error_report'})
|
|
.append($('<section>', {'class': 'popup_header'})
|
|
.append($('<h4>').text('Send Error Report'))
|
|
.append($('<span>', {'class': 'popup_close_btn hide_popup'})))
|
|
.append($('<section>', {'class': 'popup_body'})
|
|
.append($('<div>', {'id':'resultDiv','class': 'common_msg error_msg', 'style': 'display:none'})
|
|
.append($('<p>',{'id':'errorDiv'}).text(''))
|
|
.append($('<a>', {'href':'#', 'class': 'close_info'})
|
|
.append($('<img>', {'width': "16", 'height': "16", 'title': "Close", 'alt': "close", 'src': "include/images/close.png"}))))
|
|
.append($('<div>')
|
|
.append($('<ul>', {'class': "ser_ul"})
|
|
.append($('<li>')
|
|
.append($('<div>', {'class': "form_box"})
|
|
.append($('<label>').text('Username')
|
|
.append($('<span>', {'class' : 'send_error_mand'}).text(' *')))
|
|
.append($('<input>', {'type': "text", 'id':"errusername", 'value': '', 'class': "ErrorReport_input",'readonly':true,'maxlength' : "256"}))))
|
|
.append($('<li>')
|
|
.append($('<div>', {'class': "form_box"})
|
|
.append($('<label>').text('Email Address')
|
|
.append($('<span>', {'class' : 'send_error_mand'}).text(' *')))
|
|
.append($('<input>', {'type': "text", 'id':"email_error_report", 'value': '', 'class': "ErrorReport_input",'maxlength':"50"}))))
|
|
.append($('<li>')
|
|
.append($('<div>', {'class': "form_box"})
|
|
.append($('<label>').text('Contact No'))
|
|
.append($('<input>', {'type': "text", 'id':"contact_number", 'value': "", 'class': "ErrorReport_input",'maxlength':"30"}))))
|
|
.append($('<li>')
|
|
.append($('<div>', {'class': "form_box"})
|
|
.append($('<label>').text('Trouble ticket number (if created already)'))
|
|
.append($('<input>', {'type': "text",'id':"ticket_number", 'value': "", 'class': "ErrorReport_input",'maxlength':"20"}))))
|
|
.append($('<li>')
|
|
.append($('<div>', {'class': "form_box"})
|
|
.append($('<label>').text('Message')
|
|
.append($('<span>', {'class' : 'send_error_mand'}).text(' *')))
|
|
.append($('<textarea>', {'id':"errmessage", 'value': "", 'class': "ErrorReport_textarea",'maxlength':"1024*10"}))))))
|
|
.append($('<div>', {'class': "clear"})))
|
|
.append($('<section>', {'class': "popup_footer"})
|
|
.append($('<div>', {'class': "btncontainer", 'id':"send-error-btn-con"})
|
|
.append($('<input>', {'type': "button", 'class': "scheduleBtn",'id':"sendError" ,'value': " Send "}))
|
|
.append($('<div>', {'class': "sendingLoader",'style': 'display:none'}))
|
|
.append($('<span>', {'class': "scheduleBtn",'id':"sendingmessage" ,'text': " Sending "})))));
|
|
}
|
|
|
|
// Clicking send button
|
|
$(document).on('click', '#sendError', function() {
|
|
var email = $("#email_error_report").val();
|
|
var uname = $("#errusername").val();
|
|
var msg = $("#errmessage").val().trim();
|
|
// 'number' is a reserved keyword in modern browsers. This is for future enhancements/extensions
|
|
var cnumber = $("#contact_number").val();
|
|
var ticketnum = $("#ticket_number").val();
|
|
var result = null;
|
|
var txt = '';
|
|
|
|
if(email != "") {
|
|
var emailValid = validateEmail(email);
|
|
}
|
|
|
|
if(emailValid == true && uname != "" && msg != "") {
|
|
$('#sendError').hide();
|
|
$('#sendingmessage').show();
|
|
$('#sendingmessage').attr("disabled",true);
|
|
$('.sendingLoader').show();
|
|
var url = "sendErrorReport.php";
|
|
|
|
if(typeof logWarning != "undefined" && logWarning != '') {
|
|
$("#resultDiv")
|
|
.removeClass("error_msg")
|
|
.addClass("common_msg welcome_message");
|
|
displayWarning("#resultDiv", logWarning);
|
|
logWarning = '';
|
|
}
|
|
|
|
$.post(url, {email: email, uname: uname, msg: msg, "number": cnumber, ticketnum: ticketnum}, function(data) {
|
|
$('#sendingmessage').hide();
|
|
$('.sendingLoader').hide();
|
|
result = urldecode(data);
|
|
$("#resultDiv").removeClass("error_msg");
|
|
$("#resultDiv").addClass("common_msg welcome_message");
|
|
showErrorMessages("#resultDiv", result);
|
|
$('#sendError').show();
|
|
|
|
myVar = setTimeout($.popContainerHide, 2000);
|
|
});
|
|
} else {
|
|
if(uname == "") {
|
|
txt = "User Name field empty <br >";
|
|
} else if(email == "" && uname != "") {
|
|
txt = txt + "Email field is empty <br>";
|
|
} else if(email != "" && emailValid == false) {
|
|
txt = txt + "Please enter a valid Email Address";
|
|
} else if(email != "" && uname != "" && msg == "" || check == true) {
|
|
txt = txt + "Message field empty ";
|
|
} else if(uname !== "" && emailValid == true && msg == "" && cnumber != "" && check == false) {
|
|
txt = txt + "Please enter a valid contact number ";
|
|
}
|
|
|
|
$("#resultDiv").removeClass("welcome_message");
|
|
$("#resultDiv").addClass("error_msg");
|
|
showErrorMessages("#resultDiv", txt);
|
|
}
|
|
});
|
|
|
|
function displayWarning(elem, message)
|
|
{
|
|
$(elem).find('p').html(message);
|
|
$(elem).slideDown(200, function(){
|
|
setTimeout(function() {
|
|
$(elem).slideUp(200);
|
|
}, 15000);
|
|
});
|
|
|
|
$('html,body').scrollTop(0);
|
|
}
|
|
|
|
$('#contact_number').die('keypress').live('keypress', function(event) {
|
|
var keyCode = event.charCode;
|
|
|
|
if (keyCode == undefined) {
|
|
keyCode = event.keyCode;
|
|
}
|
|
|
|
if(!((keyCode >= 48 && keyCode <= 57) || (keyCode == 40) || (keyCode == 0) || (keyCode == 41) || (keyCode == 43) || (keyCode == 45))) {
|
|
event.preventDefault();
|
|
showErrorMessages('#resultDiv', 'Please enter a valid contact number.');
|
|
}
|
|
});
|
|
|
|
$('#ticket_number').die('keypress').live('keypress', function(event) {
|
|
var keyCode = event.charCode;
|
|
|
|
if (keyCode == undefined) {
|
|
keyCode = event.keyCode;
|
|
}
|
|
|
|
if(!((keyCode >= 48 && keyCode <= 57) || (keyCode >= 65 && keyCode <= 90) || (keyCode >= 97 && keyCode <= 122) || (keyCode == 0))) {
|
|
event.preventDefault();
|
|
showErrorMessages('#resultDiv', 'Please enter a valid Ticket number.');
|
|
}
|
|
});
|
|
})(jQuery);
|
|
|
|
|
|
function validateEmail(email){
|
|
var emailReg = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
|
|
var valid = emailReg.test(email);
|
|
|
|
if(!valid) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
function getCookie(c_name)
|
|
{
|
|
var c_value = " " + document.cookie;
|
|
var c_start = c_value.indexOf(" " + c_name + "=");
|
|
if (c_start == -1) {
|
|
c_value = null;
|
|
} else {
|
|
c_start = c_value.indexOf("=", c_start) + 1;
|
|
var c_end = c_value.indexOf(";", c_start);
|
|
if (c_end == -1) {
|
|
c_end = c_value.length;
|
|
}
|
|
|
|
c_value = unescape(c_value.substring(c_start, c_end));
|
|
}
|
|
|
|
return c_value;
|
|
}
|