opt
/
kaspersky
/
kav4fs
/
share
/
wmconsole
/
html
/
js
➕ New
📤 Upload
✎ Editing:
qnb.js
← Back
function QNBUtil() { var longViews_ = []; var shortViews_ = []; var rowId_ = 0; this.toggleLongThreatNames = function(idx) { var $box = $('#threatsBox_' + idx); if( $box.find('#moreLink').length > 0 ) $box.html(longViews_[idx]); else { $box.html(shortViews_[idx]); var loc = window.location.href; window.location.href = '#showView_' + idx; window.location.href = loc; } } var expandLinkTmpl_ = new Template('<br />' + '<a href="javascript:qnbutil.toggleLongThreatNames(#{ROWID})"' + ' id="#{ID}" class="threatsListLink nobr">#{CONTENT}</a>' ); this.formatThreatNames = function(threatNames) { rowId_++; var maxThreatsView = 7; var threats = threatNames.split(','); var shortView = '<a name="showView_' + rowId_ + '"></a>'; var longView = ''; for(var i = 0; i < threats.length; i++) { if(i < maxThreatsView) shortView += threats[i] + '<br />' longView += threats[i] + '<br />' } if(threats.length > maxThreatsView) { var expandTpl = new Template(Resource["QNB_THREAT_NAMES_EXPAND"]); shortView += expandLinkTmpl_.evaluate({ ID : 'moreLink', ROWID : rowId_, CONTENT : expandTpl.evaluate({ NUMTHREATS : threats.length }) }); longView += expandLinkTmpl_.evaluate({ ROWID : rowId_, CONTENT : Resource["QNB_THREAT_NAMES_COLLAPSE"] }); } longViews_[rowId_] = longView; shortViews_[rowId_] = shortView; return '<span id="threatsBox_' + rowId_ + '">' + shortView + '</span>'; } }; var qnbutil = new QNBUtil(); function qnb_setupSize(value, $size, $units) { var size = ic.convSizeToString(value); $size.updateHtml(size.value); $units.updateHtml(_res('SETTINGS_QNB_SIZE_' + size.units)); } function qnb_getSimpleSearchParam() { return { objectName : $('#objectNameInput').val(), threatName : $('#threatNameInput').val() }; } function qnb_getAdvSearchParams() { var params = { isAdvanced : 1, types : [], danger : [], certainty : [] }; var $selection = $('#searchForm #statusesSelection'); for(prop in ic.QStatus) if( $selection.find('#advSearch_' + prop + ':checked').length > 0 ) params.types.push( ic.QStatus[prop] ); if( $selection.find('#advSearch_Infected_Sure:checked').length > 0 ) { params.types.push(ic.QStatus.Infected); params.certainty.push(ic.DetectCertainty.Sure); } if( $selection.find('#advSearch_Infected_Suspicion:checked').length > 0 ) { params.types.push(ic.QStatus.Infected); params.certainty.push(ic.DetectCertainty.Suspicion); params.certainty.push(ic.DetectCertainty.Warning); } $selection = $('#searchForm #dangerSelection'); for(prop in ic.DangerLevel) if( $selection.find('#advSearch_' + prop + ':checked').length > 0 ) params.danger.push( ic.DangerLevel[prop] ); params.objectName = $('#objectNameInput').val(); params.threatName = $('#threatNameInput').val(); params.fromDate = parseInt( $('#fromDate').attr('ic_unixtime') ); params.toDate = parseInt( $('#toDate').attr('ic_unixtime') ); params.dateType = $('#selectDateType').val(); misc_validateStartEndTime( params.fromDate, params.toDate ); return params; } function qnb_onSimplePageLoaded(advParams) { $('#objectNameInput').val(advParams.objectName); $('#threatNameInput').val(advParams.threatName); } function qnb_onAdvancedPageLoaded(simpleParams) { $('#objectNameInput').val(simpleParams.objectName); $('#threatNameInput').val(simpleParams.threatName); } var quaRowTmpl = new Template( '<tr id="tr_#{ID}">'+ '<td class="w5 l ec"><input type="checkbox" class="checkBox" id="cb_#{ID}" /></td>'+ '<td class="w25">#{LimitedFilename}</td>'+ '<td class="res:QNB_STATUS_#{Status}"></td>'+ '<td class="res:QNB_DANGER_LEVEL_#{Severity}"></td>'+ '<td>#{ThreatNames}</td>'+ '<td>#{UserName}:#{GroupName}</td>'+ '<td>#{Timestamp}</td>'+ '</tr>'); var backupRowTmpl = new Template( '<tr id="tr_#{ID}">'+ '<td class="w5 l ec"><input type="checkbox" class="checkBox" id="cb_#{ID}" /></td>'+ '<td class="w25">#{LimitedFilename}</td>'+ '<td class="res:QNB_DANGER_LEVEL_#{Severity}"></td>'+ '<td>#{ThreatNames}</td>'+ '<td>#{UserName}:#{GroupName}</td>'+ '<td>#{Timestamp}</td>'+ '</tr>'); function qnb_isQuarantine() { return (window.location.hash.indexOf('#qua') == 0); } function qnb_fireResultItem(item) { item.ThreatNames = qnbutil.formatThreatNames( item.ThreatNames ); item.LimitedFilename = misc_formatLongName(item.Filename); item.Status = getObjectKeyByValue(ic.QStatus, item.Type, "Unknown"); if (item.Status == "Infected"){ var detectCertainty = getObjectKeyByValue(ic.DetectCertainty, item.DetectCertainty, "Unknown"); if (detectCertainty == "Warning" || detectCertainty == "Suspicion") item.Status = "Suspicious"; } item.Severity = getObjectKeyByValue(ic.DangerLevel, item.DangerLevel, "Unknown"); item.Timestamp = ic.timeToString( item.AddTimestamp ) if(qnb_isQuarantine()) return quaRowTmpl.evaluate(item); else return backupRowTmpl.evaluate(item); } function qnb_onSearchResultEnd() { var $cells = $('#resultTable > tbody > tr > td:has(> a.toggleable)'); var $cell = $cells.filter(':first'); var initialWidth = $cell.width(); $cells.find('> a.toggleable').click(function(){ if( $(this).attr('ic_opened') == '1' ) { $(this).html( $(this).attr('ic_reducedFilename') ); $(this).attr('ic_opened', '0'); } else { $(this).attr('ic_reducedFilename', $(this).html()); $(this).attr('ic_opened', '1'); var newcontent = this.title.substring(0, 10); for(var i = 10; i < this.title.length; i++) { $(this).html(newcontent + this.title.charAt(i)); if( $cell.width() > initialWidth ) { newcontent += ' '; newcontent += this.title.charAt(i); $(this).html(newcontent); } else newcontent += this.title.charAt(i); } $(this).html(newcontent); } }); // try to fit filenames in whole column width. // but don't work more than 2 seconds try { var cellWidth = $cells.find(':first').width(); var startTime = new Date().getTime(); var counter = 0; $cells.each(function(){ var $filename = $(this).find('a.toggleable'); misc_writeLongName( $(this), $filename, $filename.attr('title'), misc_reduceFilename ); if(((++counter % 5) == 0) && (new Date()).getTime() - startTime > 2000) throw 'out_of_time'; }) } catch(e){} } function qnb_updateQnbInfo(data) { $shortStatTable = $('#table_shortStatistics'); qnb_setupSize(data.qStorageSize, $shortStatTable.find('#qStorageSize'), $shortStatTable.find('#qStorageSizeUnits')); qnb_setupSize(data.qMaxStorageSize, $shortStatTable.find('#qMaxStorageSize'), $shortStatTable.find('#qMaxStorageSizeUnits')); $fullStatTable = $('#table_fullStatistics'); qnb_setupSize(data.qStorageSize, $fullStatTable.find('#qStorageSize'), $fullStatTable.find('#qStorageSizeUnits')); qnb_setupSize(data.qMaxStorageSize, $fullStatTable.find('#qMaxStorageSize'), $fullStatTable.find('#qMaxStorageSizeUnits')); ['qNumInfeObjects' ,'qNumCleanObjects' ,'qNumSuspObjects' ,'qNumPwProt' ,'qNumFalse' ,'qNumCorrupted' ,'qNumManual'].each(function(val) { $shortStatTable.find('#' + val).updateHtml(data[val]); $fullStatTable.find('#' + val).updateHtml(data[val]); }) if($('#qTotalObjects').html() !== (''+data.qTotalObjects)) { $('#qTotalObjects').updateHtml(data.qTotalObjects); if($('#qTotalObjects').html() != searchForm.total) { searchForm.doSearch(); return true; } } return false; } connectLostState = {}; ic.registerConnectionErrorHandler(function(connLostId){ if(0 == $('#quaPageMarker,#backupPageMarker').length ) return; if(connectLostState.connLostId == connLostId) return; connectLostState = { connLostId : connLostId, restoreButton : ($('a#restoreButton:not(.disabledLink)').length > 0), deleteButton : ($('a#deleteButton:not(.disabledLink)').length > 0), refreshButton : ($('a#refreshButton:not(.disabledLink)').length > 0), firstPageButton : ($('#firstPageButton:enabled').length > 0), prevPageButton : ($('#prevPageButton:enabled').length > 0), nextPageButton : ($('#nextPageButton:enabled').length > 0), lastPageButton : ($('#lastPageButton:enabled').length > 0) }; if(connectLostState.restoreButton) searchForm.toggleRestoreButtonState(false); if(connectLostState.deleteButton) searchForm.toggleDeleteButtonState(false); if(connectLostState.refreshButton) searchForm.toggleRefreshButtonState(false); if(connectLostState.firstPageButton) $('#firstPageButton').disable(); if(connectLostState.prevPageButton) $('#prevPageButton').disable(); if(connectLostState.nextPageButton) $('#nextPageButton').disable(); if(connectLostState.lastPageButton) $('#lastPageButton').disable(); $('#statNotAvailable').show(); $('#resultTable :checkbox').disable(); $('#resultTable a').disable(); $('#searchButton').disable(); $('#searchForm a').hide(); $('#table_commonInfo,#table_shortStatistics,#table_fullStatistics,#massRemoveBox').hide(); }) ic.registerConnectionRestoredHandler(function(){ if(0 == $('#quaPageMarker,#backupPageMarker').length) return; if(connectLostState.restoreButton) searchForm.toggleRestoreButtonState(true); if(connectLostState.deleteButton) searchForm.toggleDeleteButtonState(true); if(connectLostState.refreshButton) searchForm.toggleRefreshButtonState(true); if(connectLostState.firstPageButton) $('#firstPageButton').enable(); if(connectLostState.prevPageButton) $('#prevPageButton').enable(); if(connectLostState.nextPageButton) $('#nextPageButton').enable(); if(connectLostState.lastPageButton) $('#lastPageButton').enable(); $('#statNotAvailable').hide(); $('#resultTable :checkbox').enable(); $('#resultTable a').enable(); $('#searchButton').enable(); $('#searchForm a').show(); $('#table_commonInfo,#table_shortStatistics,#table_fullStatistics,#massRemoveBox').show(); $('#table_fullStatistics').hide(); if($('#quaPageMarker').length > 0) qnb_getQuaInfo(); if($('#backupPageMarker').length > 0) qnb_getBackupInfo(); }) function qnb_toggleFullShortStat() { if( $('#table_shortStatistics:visible').length > 0 ) { $('#table_shortStatistics').hide(); $('#table_fullStatistics').show(); $('#statToggleLink') .removeClass('showdown') .addClass('showup') .html(_res('QNB_SHORT_STAT_LINK')) } else { $('#table_shortStatistics').show(); $('#table_fullStatistics').hide(); $('#statToggleLink') .removeClass('showup') .addClass('showdown') .html(_res('QNB_FULL_STAT_LINK')) } } function qnb_toggleQSLinkState( $ns, imgName, state ) { if( state ) $ns.enable(); else { $ns.disable(); $ns.find('> img').attr('src', '../img/buttons/' + imgName + '_dis.gif') } } function qnb_setupStartStopPause( $ns, start, pause, stop ) { qnb_toggleQSLinkState( $ns.find('.a_qsStart'), 'start', start ); qnb_toggleQSLinkState( $ns.find('.a_qsStop'), 'stop', stop ); qnb_toggleQSLinkState( $ns.find('.a_qsPause'), 'pause', pause ); if( start ) $ns.find('.img_qsProgress').hide(); if( stop ) $ns.find('.img_qsProgress').show(); } function qnb_setupQSLinks( $ns, state, total ) { var currentState = $ns.attr('wmc_qsState'); var currentTotal = $ns.attr('wmc_total'); if((currentState == state) && (currentTotal == total)) return state; switch(state) { case ic.TaskState.Stopped: qnb_setupStartStopPause( $ns, (total > 0), false, false ); break; case ic.TaskState.Started: case ic.TaskState.Resumed: qnb_setupStartStopPause( $ns, false, true, true ); break; case ic.TaskState.Suspended: qnb_setupStartStopPause( $ns, true, false, true ); break; default: qnb_setupStartStopPause( $ns, false, false, false ); } $ns.attr('wmc_qsState', state); $ns.attr('wmc_total', total); return currentState; } function qnb_qsStart() { qnb_massRemoveBoxDisable(); var currentState = $('#table_fullStatistics').attr('wmc_qsState'); quaInfoTimer.clear(); qnb_setupQSLinks( $('#table_fullStatistics'), ic.TaskState.Starting ); qnb_setupQSLinks( $('#table_shortStatistics'), ic.TaskState.Starting ); qnb_setQSStatusScanning(); function onResponse(response) { if(ic.ajaxError(response)){ searchForm.setSearchingState(false); searchForm.setTableStatus('QNB_TABLE_STATUS_QS_START_FAILED'); } quaInfoTimer.set(3000); } if(currentState == ic.TaskState.Suspended) ic.resumeTask( qsTaskId, onResponse ); else if(currentState == ic.TaskState.Stopped) ic.startTask( qsTaskId, onResponse ); else quaInfoTimer.set(3000); } function qnb_qsPause() { quaInfoTimer.clear(); qnb_setupQSLinks( $('#table_fullStatistics'), ic.TaskState.Suspending ); qnb_setupQSLinks( $('#table_shortStatistics'), ic.TaskState.Suspending ); ic.suspendTask(qsTaskId, function(response){ if(ic.ajaxError(response)) searchForm.setTableStatus('QNB_TABLE_STATUS_QS_STOP_FAILED'); quaInfoTimer.set(3000); }) } function qnb_qsStop() { quaInfoTimer.clear(); qnb_setupQSLinks( $('#table_fullStatistics'), ic.TaskState.Stopping ); qnb_setupQSLinks( $('#table_shortStatistics'), ic.TaskState.Stopping ); ic.stopTask(qsTaskId, function(response){ if(ic.ajaxError(response)) searchForm.setTableStatus('QNB_TABLE_STATUS_QS_STOP_FAILED'); quaInfoTimer.set(3000); }) } function qnb_setQSStatusScanning() { searchForm.setSearchingState(true); searchForm.setTableStatus('QNB_TABLE_STATUS_QS_SCANNING'); } function qnb_clearQuarantine() { quaInfoTimer.clear(); qnb_massRemoveBoxDisable(); searchForm.setSearchingState(true); ic.clearQuarantine(function(response){ ic.ajaxError(response, $('#errorBox')); searchForm.setSearchingState(false); searchForm.drawEmptyTable(); qnb_getQuaInfo(); }) } function qnb_clearBackup() { quaInfoTimer.clear(); qnb_massRemoveBoxDisable(); searchForm.setSearchingState(true); ic.clearBackup(function(response){ ic.ajaxError(response, $('#errorBox')); searchForm.setSearchingState(false); searchForm.drawEmptyTable(); qnb_getBackupInfo(); }) } function qnb_getQuaInfo() { quaInfoTimer.clear(); ic.qinfo(function(data) { var seq = searchForm.doSearchSequence; if(data.errorMsg) { quaInfoTimer.set(30000); return; } qsTaskId = data.qsTaskId; qnb_updateQnbInfo(data); var $fstat = $('#table_fullStatistics'); var $sstat = $('#table_shortStatistics'); qnb_setupQSLinks( $fstat, data.qsTaskState, data.qTotalObjects ); var prevState = qnb_setupQSLinks( $sstat, data.qsTaskState, data.qTotalObjects ); if(prevState != data.qsTaskState) { if( data.qsTaskState == ic.TaskState.Stopped ) { if( data.qTotalObjects == 0 ) searchForm.drawEmptyTable(); else if( seq == searchForm.doSearchSequence ) { searchForm.searching = false; searchForm.doSearch(); } } else if( data.qsTaskState == ic.TaskState.Started ) qnb_setQSStatusScanning(); } if((data.qTotalObjects != 0) && (data.qsTaskState == ic.TaskState.Stopped)) qnb_massRemoveBoxEnable(); else qnb_massRemoveBoxDisable(); if(seq != searchForm.doSearchSequence) // doSearch called quaInfoTimer.set(10000); else quaInfoTimer.set(5000); }) } function qnb_massRemoveBoxEnable() { $('#massRemoveBoxEnabled').show(); $('#massRemoveBoxDisabled').hide(); } function qnb_massRemoveBoxDisable() { $('#massRemoveBoxEnabled').hide(); $('#massRemoveBoxDisabled').show(); } function qnb_getBackupInfo() { quaInfoTimer.clear(); ic.backupInfo(function(data) { if(data.errorMsg) { quaInfoTimer.set(30000); return; } if(data.qTotalObjects != 0) qnb_massRemoveBoxEnable(); else qnb_massRemoveBoxDisable(); if(qnb_updateQnbInfo(data)) quaInfoTimer.set(10000); else quaInfoTimer.set(5000); }) }
💾 Save Changes
Cancel
📤 Upload File
×
Select File
Upload
Cancel
➕ Create New
×
Type
📄 File
📁 Folder
Name
Create
Cancel
✎ Rename Item
×
Current Name
New Name
Rename
Cancel
🔐 Change Permissions
×
Target File
Permission (e.g., 0755, 0644)
0755
0644
0777
Apply
Cancel