opt
/
kaspersky
/
kav4fs
/
share
/
wmconsole
/
html
/
js
➕ New
📤 Upload
✎ Editing:
misc.js
← Back
/* extend jQuery object to simplify programming */ jQuery.fn.extend({ i_val: function(){ return parseInt(this.val()); }, enable : function(){ return this.each(function() { if((this.tagName == 'INPUT') || (this.tagName == 'SELECT')) { $(this).removeAttr('disabled') } else if(this.tagName == 'A') { if($(this).hasClass('disabledLink')) { if(this.activeClone) $(this).replaceWith(this.activeClone); $(this).removeClass('disabledLink') } } else alert('Unsupported element "' + this.tagName + '" for $.enable()'); }) }, disable : function(){ return this.each(function(){ if((this.tagName == 'INPUT') || (this.tagName == 'SELECT')) { $(this).attr('disabled', true); } else if(this.tagName == 'A') { if( $(this).hasClass('disabledLink') ) return; // already disabled this.activeClone = $(this).clone(true); $(this).removeAttr('href'); $(this).addClass('disabledLink'); $(this).unbind('click'); } else alert('Unsupported element "' + this.tagName + '" for $.disable()'); }) }, selfHtml : function(){ var html = this.wrap('<span></span>').parent('span').html(); this.attr('ic_selfHtml', html).parent('span').replaceWith(html); return html; }, visible : function(){ return this.css({'visibility' : 'visible'}) }, hidden : function(){ return this.css({'visibility' : 'hidden' }) }, updateHtml : function(content){ if(typeof(content) != 'string') content = content + ''; if(this.html() != content) this.html(content); }, sortEmpty : function(){ return this.removeClass('sort_down').removeClass('sort_up'); }, sortUp : function(){ return this.sortEmpty().addClass('sort_up'); }, sortDown : function(){ return this.sortEmpty().addClass('sort_down'); } }) function _res(resid) { if(typeof(Resource) == 'undefined') return resid; return Resource[resid] || resid; } function _resTmpl(resid, params) { return new Template(_res(resid)).evaluate(params); } jQuery.enableLocalize = false; jQuery.fn.localize = function() { if(false == jQuery.enableLocalize) return this; if(typeof(ic_resourceRegex) == 'undefined'){ ic_resourceRegex = new RegExp(); ic_resourceRegex.compile("\\bres:(\\S+)\\b"); } function appResByClassName(){ var $this = $(this); var classname = $this.attr('class'); var m = ic_resourceRegex.exec(classname); if((m != null) && (m.length > 1)) { // remove 'res:' first!!! $this.removeClass('res:'+m[1]); $this.attr('ic_res',m[1]); if(this.tagName == 'INPUT') $this.val( _res(m[1]) ); else{ $this.html( _res(m[1]) ); } } } function applyResByTag(tag) { var $this = $(this); var title = $this.attr(tag); if(title.substr(0, 4) == 'res:') { var resName = title.substr(4); $this.attr(tag, _res(resName)); } } function appResByTitle() { applyResByTag.call(this, 'title') } function appResByAlt() { applyResByTag.call(this, 'alt') } this.each(appResByClassName); this.find('[class*=res]').each(appResByClassName); this.find('[title^=res]').each(appResByTitle); this.find('[alt^=res]').each(appResByAlt); return this; } jQuery.fn.localizeForce = function() { function appResByClassName(){ var $this = $(this); if($this.attr('ic_res') != 'undefined') { var classname = $this.attr('ic_res'); if(this.tagName == 'INPUT'){ if(_res(classname) != $this.val()) $this.val(_res(classname)); }else{ if(_res(classname) != $this.html()) $this.html(_res(classname)); } } } this.each(appResByClassName); this.find('[ic_res]').each(appResByClassName); return this; } jQuery.fn.nativeDomManip = jQuery.fn.domManip; jQuery.fn.domManip = function( args, table, callback ) { return this.nativeDomManip(args, table, function(elem){ callback.call(this, elem); if(this.nodeType == 1){ try { $(this).localize() } catch(e){} } }); } // jQuery.fn.nativeAttr = jQuery.fn.attr; // jQuery.fn.attr = function( name, value, type ) // { // if(name == 'ic_res' && value) // this.html(_res(value)); // // return this.nativeAttr(name, value, type); // }; /* failsafe OnChange trigger. work even copy/paste */ var fastChangeTimer = 0; jQuery.fn.fastChange = function(callback) { return this.each(function() { var _this = this; function resetTimeout(func) { clearTimeout(fastChangeTimer); fastChangeTimer = setTimeout(func, 100); } function eventFunc() { if($(_this).val() !== $(_this).attr('ic_prevVal')) { $(_this).attr('ic_prevVal', _this.value); $(_this).trigger('fastChange'); } resetTimeout(eventFunc); return true; } function focusFunc() { $(_this).attr('ic_prevVal', _this.value); resetTimeout(eventFunc); } $(this) .bind('fastChange' ,callback) .blur(function(){ clearTimeout(fastChangeTimer) }) .focus(focusFunc) .mouseup (focusFunc) .keypress (focusFunc) }); } jQuery.fn.onEnter = function(callback) { return this.each(function() { function eventFunc(e) { if(e && e.which && e.which == 13) $(this).trigger('onEnter'); } $(this).bind('onEnter', callback).keyup(eventFunc); }); } Date.prototype.getUnixtime = function() { return Math.floor(this.getTime() / 1000); } Date.prototype.setUnixtime = function(unixtime) { this.setTime(Math.floor(unixtime * 1000)); } if(typeof(ic) === 'undefined') ic = new Object(); /* this function bind some html element to object so changes of html element reflected in object */ var isInitRTPSettings = true function bindChangeValuesById( domNs, object, checks, callback) { $(checks).each(function() { var domId = this[0]; var field = this[1]; var transformFunc = this[2]; var obj = object; var $id = ( typeof(domNs) == 'string' ? $(domNs + ' #' + domId) : domNs.find('#'+domId) ); if($id.length == 0) return; $id.unbind(); var isCheckbox = ($id.attr('type') == 'checkbox'); var isRadio = ($id.attr('type') == 'radio'); var isInput = ($id.attr('type') == 'text'); var isTextarea = ($id.attr('type') == 'textarea'); var isSelect = ($id.get(0).tagName == 'SELECT'); if(isCheckbox) { function checkboxClick() { obj[field] = this.checked; if(jQuery.isFunction(callback)) return callback.call(this); } $id.click(checkboxClick).attr('checked', obj[field]); } else if(isRadio) { $id.click(function(){ obj[field] = this.value; if(jQuery.isFunction(callback)) return callback.call(this); }); if(obj[field] == $id.attr('value')) $id.attr('checked', true); } else if(isSelect) { $id.change(function(){ obj[field] = this.value; if(jQuery.isFunction(callback)) return callback.call(this); }) $id.val(obj[field]); } else if(isInput) { if(!jQuery.isFunction(transformFunc)) transformFunc = function(a){return a}; $id.fastChange(function(){ obj[field] = transformFunc(this.value, false); if(jQuery.isFunction(callback)) return callback.call(this); }); $id.val(transformFunc(obj[field], true)); } else if(isTextarea) { if(!jQuery.isFunction(transformFunc)) transformFunc = function(a){return a}; $id.fastChange(function(){ obj[field] = transformFunc(this.value, false); if(jQuery.isFunction(callback)) return callback.call(this); }); $id.val(transformFunc(obj[field], true)); } }); } function misc_describeTaskByLocationImpl() { var tokens = window.location.hash.split('/'); if(tokens[0] == '#rtp') return { clazz : ic.TaskClass.OAS }; if(tokens[0] == '#ods') { if(tokens[1] == 'task') return { clazz : ic.TaskClass.ODS, id : parseInt(tokens[2]) }; else return { clazz : ic.TaskClass.ODS }; } if(tokens[0] == '#ods_qs') { if(tokens[1] == 'task') return { clazz : ic.TaskClass.QS, id : parseInt(tokens[2]) }; else return { clazz : ic.TaskClass.QS }; } if(tokens[0] == '#update') { if(tokens[1] == 'task') return { clazz : ic.TaskClass.Update, id : parseInt(tokens[2]) }; else return { clazz : ic.TaskClass.Update }; } if(tokens[0] == '#notifications') { return { clazz : ic.TaskClass.Notifier }; } if(tokens[0] == '#snmp') { return { clazz : ic.TaskClass.Snmp }; } return { clazz : ic.TaskClass.Unknown }; } // This function read location anchor (window.location.hash member) // and tries to extract information about task to be shown function describeTaskByLocation() { if(typeof(__lastHash) != 'undefined' && __lastHash === window.location.hash) return __lastTaskDesc; __lastHash = window.location.hash; __lastTaskDesc = misc_describeTaskByLocationImpl(); return __lastTaskDesc; } function misc_describeTaskByLocation() { return describeTaskByLocation(); } // Reduces name of file to fit in table cell function reduceFilename(filename) { if(typeof(filename) === 'undefined') return ''; var maxlen = 40; if(filename.length <= maxlen) return filename; return filename.substr(0, 17) + '...' + filename.substr(filename.length - 20, 20); } function misc_writeLongName($widthNS, $contentNS, name, nameReduceFunc) { var result = 0; var initialWidth = $widthNS.width(); $contentNS.html(nameReduceFunc(name, name.length)); if($widthNS.width() > initialWidth) { var found = 0; var remain = name.length; while(remain > 1) { var c = Math.floor( remain * 0.5 ); $contentNS.html(nameReduceFunc(name, found + c)); if( $widthNS.width() > initialWidth ) { remain = c; } else { found += c; remain -= c; } } $contentNS.html(nameReduceFunc(name, found)); } return result; } function misc_reduceFilename(name, maxlen) { if(typeof(name) === 'undefined') return ''; if(name.length == maxlen) return name; p1 = Math.floor(maxlen * 0.5); p2 = maxlen - p1; return name.substring(0, p1) + '...' + name.substring(name.length - p2); } function misc_shortizeName(name, len) { if(typeof(name) == 'undefined') return name; if(name.length > len) return name.substr(0, len) + '...'; return name; } // Finds key in object which value is value_. Returns defaultResult if not found. function getObjectKeyByValue(object, value_, defaultResult) { for(var prop in object) if(object[prop] == value_) return prop; if(defaultResult) return defaultResult; } // Array Remove - By John Resig (MIT Licensed) Array.prototype.remove = function(from, to) { var rest = this.slice((to || from) + 1 || this.length); this.length = from < 0 ? this.length + from : from; return this.push.apply(this, rest); }; Array.prototype.removeValue = function(s) { for(var i = 0, len = this.length; i < len; i++) { if(s == this[i]) { this.splice(i, 1) len--; } } }; Array.prototype.remove_if = function(func) { for(var i = 0, len = this.length; i < len; i++) { if(func(this[i])) { this.splice(i, 1) len--; } } }; // VerdictType for various views ic.VerdictTypeView=new Object; for(verdict_ in ic.VerdictType){ if (verdict_ != 'Undefined' ) ic.VerdictTypeView[verdict_] = ic.VerdictType[verdict_]; }; ic.strftime = function(fmt, sec) { var date = new Date(); date.setTime(sec * 1000); return $.strftime( fmt , date ); } function misc_ctime(t) { var d = new Date(); d.setTime(t * 1000); return d.toLocaleString(); } function misc_formatTime(t) { return ic.strftime(_res('TIME_FORMAT'), t); } function misc_formatDate(t) { return ic.strftime(_res('DATE_FORMAT'), t); } ic.timeToString = function(sec){ return misc_formatTime(sec); } ic.licenseDateToSring = function(date){ var tmp_dt_ = new Date(date.Year, date.Month - 1, date.Day); return $.strftime(_res('DATE_FORMAT'), tmp_dt_ ); } function misc_keepNDigits(size, n) { return Math.round(size * Math.pow(10,n)) / Math.pow(10,n); } function misc_keepTwoDigits(size) { return misc_keepNDigits(size, 2); } ic.convSizeToString = function(size) { var isize = parseInt(size); if(isize > 1073741824 )//1024*1024*1024 return {value: misc_keepTwoDigits(isize/(1073741824)), units: 'Gb'}; if(isize > 1048576 ) //1024*1024 return {value: misc_keepTwoDigits(isize/(1048576)), units: 'Mb'}; if(isize > 1024 ) return {value: misc_keepTwoDigits(isize/1024), units: 'Kb'}; return {value: isize, units: 'b'}; } // Stepper ic.loading = { elem : {}, count : 0, show : function(){ this.elem.show(); this.count++; }, hide : function(){ if (this.count > 0) this.count--; if (!this.count) this.elem.hide(); } }; function setEnableStepper(el,f){ if (f) el.attr("disabled","") else el.attr("disabled","disabled") } function htmlEncode(str){ if(!str.length) return str; return str.replace(/([\<\>\"\&])/gim, function (a) { return ({ "<": "<", ">": ">", "\"": """, "<": "<", "&": "&" })[a] || a; }); } function misc_preparetoView(str) { if(typeof(str) == 'undefined' || str == null) return ''; return htmlEncode(str); } function misc_formatLongName(name) { return '<span class="toggleable" href="javascript:void(0)" title="' + misc_preparetoView(name) + '" class="longName">' + misc_preparetoView(reduceFilename(name)) + '</span>'; } // Construct <select> using specified options // and returns the <select> width in pixels function misc_predictSelectWidth(optionsHtml) { if( $('#__dummySelect').length == 0 ) $('body').append('<select id="__dummySelect" ' + 'style="visibility : hidden"></select>'); var ds = $('#__dummySelect'); var res = ds.append(optionsHtml).width(); ds.empty(); return res; } function setLocalTextID(id){ setLocalText(id,$('#' + id).html()) } function setLocalText(id,key) { setText(id, _res([key])); } function setText(id,txt) { $('#' + id).html(txt) } function getLocalString(key) { return _res([key]) } function misc_megabyteTransform(a, back) { a = parseFloat(a); if(isNaN(a)) return 0; if(back) return misc_keepTwoDigits(a / (1024 * 1024)); return Math.floor(a * 1024 * 1024); } // Setup pair of date pickers which correspond to start time and end time function misc_setupDatePicker($elem, unixtime, initViaUnixtime) { var date = new Date(); date.setUnixtime(unixtime); function rstDisableTime($elem){ $elem.timeEntry('disable'); } var $timePick = $('<input type="text" class="time-picker" style="vertical-align:middle;width:67px;"/>'); $elem.wrap('<table style="border:0px none;padding:1px;">'+ '<tr style="border:0px none;padding:1px;">'+ '<td style="border:0px none;padding:1px;width:'+(parseInt($elem.css('width'))+34)+'px;">'+ '<span class="nobr"/>'+ '</td>'+ '</tr></table>'); $elem.parent().parent().after($timePick); $timePick.wrap('<td style="border:0px none;padding:1px;"/>'); $timePick.timeEntry({showSeconds: true}); $timePick .timeEntry('setTime', new Date(0, 0, 0, 0, 0, 0)) .change(function(){ var hourMin = new Date($timePick.timeEntry('getTime')); var ret = new Date(); ret.setUnixtime($elem.attr('ic_unixtime')); ret.setHours(hourMin.getHours()); ret.setMinutes(hourMin.getMinutes()); ret.setSeconds(hourMin.getSeconds()); $elem .attr('ic_unixtime', ret.getUnixtime()) .change(); return ret; }); $elem .attr({ 'readOnly' : true, 'ic_unixtime': unixtime, 'dp:unixtime': unixtime, 'dp:value' : $elem.val() }) .datepick({'onSelect':function(timeStrLocal,obj){ if(timeStrLocal.length) { $timePick.timeEntry('enable'); date = $timePick.timeEntry('getTime'); date.setDate(obj.currentDay); date.setMonth(obj.currentMonth); date.setYear(obj.currentYear); $elem .attr('ic_unixtime',date.getUnixtime()) .change(); } else { rstDisableTime($timePick); $elem.attr('ic_unixtime',$elem.attr('dp:unixtime')).val($elem.attr('dp:value')); } }}) .bind('dpDisable',function(){ $elem.attr({ 'ic_unixtime': unixtime, 'dp:unixtime': unixtime, 'dp:value' : '' }) .datepick('setDate','') .datepick('disable'); $timePick.timeEntry('setTime', new Date(0, 0, 0, 0, 0, 0)) .timeEntry('disable'); }) .bind('dpEnable',function(){ $elem.datepick('enable'); $timePick.timeEntry('enable'); }); if(initViaUnixtime){ $timePick.timeEntry('setTime', date); $elem.datepick('setDate', date); }else rstDisableTime($timePick); } function misc_setupIntervalDatePickers( $startTime, $endTime ) { misc_setupDatePicker( $startTime, 0 ); misc_setupDatePicker( $endTime, 2000000000 ); } function misc_validateStartEndTime( startTime, endTime ) { if(startTime > endTime){ alert(_res('START_TIME_GREATER_THAN_END_TIME')); throw 'exception'; } } // $elem - selector // params - object // params.max - maximum value // params.min - minimum value // params.parseFunc - parse function (parseInt, parseFloat, etc) // contacts: eldar.kononov function misc_setupSizeCorrector( $elem, params ) { if(typeof(params) !== 'object') params = {}; var parseFunc; if(typeof(params.parseFunc) === 'undefined') parseFunc = parseFloat; else parseFunc = params.parseFunc; function correctQuaSize( elem ) { var $elem = $(elem); var val = parseFunc( $elem.val() ); var sval = val + ''; if(sval === 'NaN') $elem.val(0); else if (parseFunc === parseFloat && (($elem.val().match(/[^0-9.]/i) || $elem.val().split('.').length > 2) || (sval !== $elem.val()) && $elem.val().indexOf('.') == -1)) { $elem.val(val); } else if((sval !== $elem.val()) && ($elem.val() !== (sval + '.'))) { $elem.val(val); } if((typeof(params.max) === 'number') && (val >= params.max)) $elem.val(params.max); if((typeof(params.min) === 'number') && (val < params.min)) $elem.val(params.min); } function correctQuaSizePeriodically(element) { function onTimeout(){ correctQuaSizePeriodically(element); } $(element).setTimeout('ic_correctTimeout', onTimeout, 200); correctQuaSize(element); } function onfocus(){ correctQuaSizePeriodically(this); } function onblur(){ $(this).clearTimeout('ic_correctTimeout'); } function onchange(){ correctQuaSize(this); } function onkeyup(e){ $(this).clearTimeout('ic_autoIncTimeout'); $(this).change(); } function setAutoIncTimeout($elem, func, timeout){ $elem.setTimeout('ic_autoIncTimeout', func, timeout); } function add($elem, val) { var currentVal = $elem.val(); var newval = parseFunc(currentVal) + val; var dotidx = currentVal.indexOf('.'); if(dotidx > -1) { var numdigits = currentVal.length - dotidx - 1; newval = misc_keepNDigits(newval, numdigits); } $elem.val(newval); } var steps = { 38 : 1, // UP 40 : -1, // DOWN 33 : 10, // PAGE UP 34 : -10 // PAGE DOWN }; function onkeydown(e) { if(typeof(steps[e.which]) === 'undefined') return; var $this = $(this); function addFunc(){ add($this, steps[e.which]); } function autoIncrement(){ addFunc(); setAutoIncTimeout($this, autoIncrement, 100); } addFunc(); setAutoIncTimeout($this, autoIncrement, 1000); } $elem.focus(onfocus) .blur(onblur) .change(onchange) .keyup(onkeyup) .keydown(onkeydown); } function localizeBLError(reason) { var key = getObjectKeyByValue(ic.BLError, reason); return _res('BLERROR_' + key); } var misc_waitFor_timers = new Object(); // FIXME: function didn't work for two paralel call function misc_waitFor( checkFunc, func ) { if(typeof(misc_waitFor_timers[func]) != 'undefined') misc_waitFor_timers[func].clear(); if(checkFunc()) { ic.loading.show(); func(); ic.loading.hide(); return; } if(typeof(misc_waitFor_timers[func]) == 'undefined') misc_waitFor_timers[func] = new Timer(function(){ ic.loading.show(); misc_waitFor(checkFunc, func); ic.loading.hide(); }); misc_waitFor_timers[func].set(100); } function misc_loginFormActive() { return $('#div_login').is(':visible'); } function misc_showModalBackground(callback) { $('#div_overlay').fadeTo("fast", 0.1, function(){ $('#div_overlay').show(); $('#div_overlay').fadeTo("slow", 0.5); callback(); }); } function misc_hideModalBackground() { $('#div_overlay').fadeTo("slow", 0.1, function(){ $('#div_overlay').hide(); }); } function misc_showLoginForm() { misc_showModalBackground(function(){ $('#div_login').show() $('#div_login #userpass').each(function(){ this.focus() }) }) } function misc_hideLoginForm() { $('#div_login').hide(); misc_hideModalBackground(); } jQuery.fn.icHistory = function(callback) { var href_ = this.attr('hash'); var id_ = this.attr('id'); if(id_ && href_) { var hiddenId = href_.replace(/#/g, '').replace(/\//g, '_'); if( $('#actionsStorage #' + hiddenId).length === 0 ) $('<a></a>') .attr('href', href_) .attr('id', hiddenId) .click(function(){ return false; }) .appendTo($('#actionsStorage')); } return this.history(callback); } function misc_callAsync(func) { setTimeout(func); } function misc_getPluralForm(num, array_prefix){ /* some language plural equations may be found here: }*/ var n = num; var days_form_idx = eval(_res('PLURAL_EVAL')); return (n+' '+_res(array_prefix + days_form_idx)); } jQuery.fn.treeDialog = function(_options) { return this.each(function(){ var params = { FSPath : '', FSName : '', FSType : '', Dirs : true, Files : false, title : _res('LABEL_CHOOSE_FILE') }; $.extend(params, _options); var $elem = $(this); params.ctlFSPath = params.ctlFSPath || $elem; $elem.ic_treeDialog = $('<div style="overflow:auto;border: 1px solid #C3C3C3;"/>'); if(params.browseBtn) $elem.ic_browseBtn = params.browseBtn; else if($(this).attr('ic_browseBtn')) $elem.ic_browseBtn = $('#'+$(this).attr('ic_browseBtn')); else { $elem.css('float', 'left'); $elem.ic_browseBtn = $('<input type="button" value="'+_res('BUTTON_LABEL_BROWSE')+'"/>'); $elem.after($elem.ic_browseBtn); } $elem. bind('treeDialog_disable', function(){ if(params.browseBtn) $elem.ic_browseBtn.trigger('treeDialog_disable'); else $elem.ic_browseBtn.attr('disabled','true'); $elem.ic_treeDialog.dialog('close'); }) .bind('treeDialog_enable', function(){ if(params.browseBtn) $elem.ic_browseBtn.trigger('treeDialog_enable'); else $elem.ic_browseBtn.removeAttr('disabled'); }); var bttns = {}; bttns[_res('BUTTON_REVERT')] = function() { if(params.ctlFSType) params.ctlFSType.val($elem._prevFSType);//.change(); if(params.ctlFSName) params.ctlFSName.val($elem._prevFSName);//.change(); params.ctlFSPath.val($elem._prevFSPath);//.change(); $elem.ic_treeDialog.dialog('close'); } bttns[_res('BUTTON_OK')] = function() { if(params.ctlFSType) params.ctlFSType.trigger('fastChange'); if(params.ctlFSName) params.ctlFSName.trigger('fastChange'); params.ctlFSPath.trigger('fastChange'); $elem.ic_treeDialog.dialog('close'); } $elem.ic_browseBtn.click(function(){ $elem.ic_treeDialog.dialog('open') }); $elem.ic_treeDialog .dynatree({ rootVisible : (params.FSPath == '/' ? true : false), title : params.FSPath, selectMode: 1, clickFolderMode: 1, onLazyRead: function(dtnode){ dtnode.appendAjax({ url:'cgi-bin/cgictl', data:{ action:'getTree', FSType:dtnode.data.FSType, FSName:dtnode.data.FSName, FSPath:dtnode.data.FSPath, Dirs:params.Dirs, Files:params.Files } }); }, onActivate: function(dtnode){ var FSName = parseInt(dtnode.data.FSName); var FSType = parseInt(dtnode.data.FSType); var ind = 0; for(ind in scopePage_synchronizer.convertData) { if(scopePage_synchronizer.convertData[ind][1] == FSType && scopePage_synchronizer.convertData[ind][2] == FSName) { params.ctlFSPath.val(dtnode.data.FSPath);//.change(); if(params.ctlFSType) params.ctlFSType.val(ind);//.change(); if(params.ctlFSName) params.ctlFSName.val(ind);//.change(); } } }, strings: { loading: _res('LABEL_TREE_LOADING'), loadError: _res('LABEL_TREE_LOAD_ERROR') } }) .dialog({ bindToElement : $elem.parent(), autoOpen: false, bgiframe: true, buttons: bttns, // modal: true, title: params.title, resizable: true, width: 400, height: 430, close:function(){ $elem.ic_treeDialog.dynatree('getRoot').removeChildren(); }, open:function(){ $elem.ic_treeDialog.dynatree('getRoot').appendAjax({ url:'cgi-bin/cgictl', data: { action:'getTree', FSType:params.FSType, FSName:params.FSName, FSPath:params.FSPath, Dirs:params.Dirs, Files:params.Files } }); if(params.ctlFSType) $elem._prevFSType = params.ctlFSType.val(); if(params.ctlFSName) $elem._prevFSName = params.ctlFSName.val(); $elem._prevFSPath = params.ctlFSPath.val(); } }); }); } function misc_createTask(taskName, callback) { if(currTaskClass == ic.TaskClass.Update) { ic.loading.show(); ic.createTask( taskName, ic.TaskClass.Update, ic.create_UpdateSettings(), function(response){ ic.loading.hide(); if(!ic.ajaxError(response)) { if(!!callback) callback(); LocationChanged('#update/task/' + response.id + '/__source__'); } else if(response.errorMsg.indexOf('Name already exist') > -1) alert(_res('ERROR_TASK_NAME_ALREADY_EXISTS')); }); } else if(currTaskClass == ic.TaskClass.ODS) { ic.loading.show(); var settings = ic.create_ODSSettings(); var scanArea = ic.create_ODSSettings_ScanArea(); scanArea.AreaMask.push("*"); scopePage_model.setDefaultScanSettings(scopePage_model.use_ods_seclevel(), 2, scanArea.ScanSettings); scanArea.AreaDesc = _res('SCANAREA_DEFAULT_DESCRIPTION'); scanArea.AreaPath.Path = '/'; settings.ScanScope.push(scanArea); if(ic.storage.get('useWZRDods') === 'true') { if(!!callback) callback(); getDialog('taskWizard_' + ic.TaskClass.ODS).open(taskName, settings); ic.loading.hide(); } else ic.createTask( taskName, ic.TaskClass.ODS, settings, function(response){ ic.loading.hide(); if(!ic.ajaxError(response)) { if(!!callback) callback(); LocationChanged('#ods/task/' + response.id + '/__scope__'); } else if(response.errorMsg.indexOf('Name already exist') > -1) alert(_res('ERROR_TASK_NAME_ALREADY_EXISTS')); }); } } /* create task dialog */ function dlgCreateTask(_options) { var params = { is_tabHide:true, innerTitle : 'UNKNOWN', title: 'UNKNOWN', useWzrd: false, useContur: false }; $.extend(params, _options); var dlg = this; dlg.open = function() { setTimeout(function(){ dlg.open() }, 100) } $('<div/>').loadCache('pages/vo_dialog.html', function(){ dlg.voDialog = new voDialog(this, params); if(params.useWzrd) dlg.voDialog.setCtl('DLG_USE_WZRD_LABEL') .change(function(e){ ic.storage.save('useWZRDods', $(this).attr('checked')); }); dlg.voDialog.addTab({}, $('<div/>').loadCache('pages/task_create_dlg.html', function(){ dlg.voTaskName = voTaskName_get.call(this) .fastChange(function(){ if(this.value.length > 0) $(this).trigger('addBtnEnable.voDialog'); else $(this).trigger('addBtnDisable.voDialog'); }) .onEnter(function(){ if(this.value.length > 0) $(this).trigger('createTask.voDialog',[this.value]); }); dlg.voDialog.elem.bind('beforClose.voDialog', function(e) { e.stopPropagation(); dlg.voTaskName.val('').trigger('fastChange'); }); })); dlg.voDialog.addBtn('BUTTON_ADD').click(function(){ $(this).trigger('createTask.voDialog', [dlg.voTaskName.val()]); }); dlg.voDialog.addBtn('BUTTON_CANCEL').click(function(){ $(this).trigger('close.voDialog'); }); dlg.voDialog.setActiveTab(0); dlg.voDialog.elem .bind('addBtnEnable.voDialog', function(e){ e.stopPropagation(); dlg.voDialog.btns['BUTTON_ADD'].enable(); }) .bind('addBtnDisable.voDialog', function(e){ e.stopPropagation(); dlg.voDialog.btns['BUTTON_ADD'].disable(); }) .bind('createTask.voDialog', function(e, taskName){ e.stopPropagation(); var $cThis = $(this); misc_createTask(taskName, function(){ $cThis.trigger('close.voDialog'); }); }); dlg.open = function(){ if(params.useWzrd) ic.storage.get('useWZRDods') === 'true' ? dlg.voDialog.useWzrd.attr('checked', 1) : dlg.voDialog.useWzrd.removeAttr('checked'); dlg.voDialog.elem .trigger('addBtnDisable.voDialog') .trigger('open.voDialog'); }; dlg.close = function(){ dlg.voDialog.elem.trigger('close.voDialog'); }; }); } function misc_cloneObj(dst, src, deep) { if(deep != 0 && (typeof(src) == 'object' || typeof(src) == 'array')) for(var prop in src) if(typeof(src[prop]) == 'object') misc_cloneObj((dst[prop] = {}), src[prop], --deep); else dst[prop] = src[prop]; } jQuery.fn.outerHTML = function(){ return $('<div/>').html(this.clone()).html(); }; var virOptions = [ [''+ic.OAS.Action.Remove+ic.OAS.Action.Cure, 'TSA_SELECT_OPTION_Remove_Cure' ], [''+ic.OAS.Action.Remove+ic.OAS.Action.Skip, 'TSA_SELECT_OPTION_Remove_Skip' ], [''+ic.OAS.Action.Recommended+ic.OAS.Action.Remove, 'TSA_SELECT_OPTION_Recommended_Remove' ], [''+ic.OAS.Action.Recommended+ic.OAS.Action.Cure, 'TSA_SELECT_OPTION_Recommended_Cure' ], [''+ic.OAS.Action.Recommended+ic.OAS.Action.Skip, 'TSA_SELECT_OPTION_Recommended_Skip' ], [''+ic.OAS.Action.Quarantine+ic.OAS.Action.Remove, 'TSA_SELECT_OPTION_Quarantine_Remove' ], [''+ic.OAS.Action.Quarantine+ic.OAS.Action.Cure, 'TSA_SELECT_OPTION_Quarantine_Cure' ], [''+ic.OAS.Action.Quarantine+ic.OAS.Action.Skip, 'TSA_SELECT_OPTION_Quarantine_Skip' ], [''+ic.OAS.Action.Cure+ic.OAS.Action.Remove, 'TSA_SELECT_OPTION_Cure_Remove' ], [''+ic.OAS.Action.Cure+ic.OAS.Action.Quarantine, 'TSA_SELECT_OPTION_Cure_Quarantine' ], [''+ic.OAS.Action.Cure+ic.OAS.Action.Skip, 'TSA_SELECT_OPTION_Cure_Skip' ], [''+ic.OAS.Action.Skip+ic.OAS.Action.Skip, 'TSA_SELECT_OPTION_Skip_Skip'] ]; var otherOptions = [ [''+ic.OAS.Action.Remove+ic.OAS.Action.Skip, 'TSA_SELECT_OPTION_Remove_Skip' ], [''+ic.OAS.Action.Recommended+ic.OAS.Action.Remove, 'TSA_SELECT_OPTION_Recommended_Remove' ], [''+ic.OAS.Action.Recommended+ic.OAS.Action.Skip, 'TSA_SELECT_OPTION_Recommended_Skip' ], [''+ic.OAS.Action.Quarantine+ic.OAS.Action.Remove, 'TSA_SELECT_OPTION_Quarantine_Remove' ], [''+ic.OAS.Action.Quarantine+ic.OAS.Action.Skip, 'TSA_SELECT_OPTION_Quarantine_Skip' ], [''+ic.OAS.Action.Skip+ic.OAS.Action.Skip, 'TSA_SELECT_OPTION_Skip_Skip' ] ]; function dlgAdvActions(params) { var dlg = this; dlg._opt = { is_tabHide: true, innerTitle: _res('DLG_EDIT_ADV_ACTIONS'), title: _res('DLG_EDIT_ADV_ACTIONS'), useContur: false }; $.extend(dlg._opt, params); $('<div/>').loadCache('pages/vo_dialog.html', function(){ dlg.voDlg = new voDialog(this, dlg._opt); // add tabs dlg.voDlg.addTab( {}, $('<div/>').loadCache('pages/dlg_custom_actions.html', function(){ dlg.voCustomAction = new voCustomActions(this); for(var verdict in ic.VerdictType) if(ic.VerdictType[verdict] !== ic.VerdictType.Undefined) dlg.voCustomAction.addAction(verdict, virOptions); })); dlg.voDlg.setActiveTab(0); //add buttons dlg.voDlg.addBtn('BUTTON_OK') .click(function(e){ $(this).trigger('ok.dlgAdvActions'); $(this).trigger('close.voDialog'); }); dlg.voDlg.addBtn('BUTTON_CANCEL') .click(function(e){ $(this).trigger('close.voDialog'); }); //events //functions dlg.open = function(initialVerdicts){ dlg.voCustomAction.reset(); if(typeof(initialVerdicts) !== 'undefined') for(var i = 0, len = initialVerdicts.length; i < len; i++) dlg.voCustomAction.updateVerdict( initialVerdicts[i].Verdict, initialVerdicts[i].FirstAction, initialVerdicts[i].SecondAction); dlg.voDlg.elem.dialog('open'); }; dlg.close = function(){ dlg.voDlg.elem.dialog('close'); }; }); // prevent undefined reference before vo_dialog.html is loaded dlg.open = function(){} dlg.close = function(){} } /* notify properties dialog */ function dlgNotifyProp(params) { this.options_ = { is_tabHide:false, innerTitle : 'UNKNOWN', title: 'UNKNOWN', propertiesChange: function(){}, propertiesClose: function(){}, macroListSetup:function(){}, editTask:'', settingsId:0, eventId:0 }; $.extend(this.options_, params); var dlg = this; dlg.open = function(params) { setTimeout(function(){ dlg.open(params) }, 100); } dlg.onLoadVoNS = function(){} $('<div/>').loadCache('pages/vo_dialog.html', function(){ dlg.voDialog = new voDialog(this, params); dlg.voDialog.addTab({}, $('<div/>').loadCache('pages/notify/notify_prop_dlg.html', function(){ dlg.voNS = new voNotifySettings(this, this.options_); dlg.onLoadVoNS(); dlg.onLoadVoNS = 0; })); dlg.voDialog.addBtn('BUTTON_OK').click(function(e){ dlg.options_.editTask.SettingsTask.notifier.SmtpNotifies[dlg.options_.settingsId] = dlg.currentNotifySettings; dlg.options_.propertiesClose(); dlg.voDialog.elem.trigger('close.voDialog'); }); dlg.voDialog.addBtn('BUTTON_CANCEL').click(function(){ dlg.options_.propertiesClose(); $(this).trigger('close.voDialog'); }); dlg.voDialog.setActiveTab(0); dlg.voDialog.elem .bind('addBtnEnable.voDialog', function(e){ e.stopPropagation(); dlg.voDialog.btns['BUTTON_OK'].enable(); }) .bind('addBtnDisable.voDialog', function(e){ e.stopPropagation(); dlg.voDialog.btns['BUTTON_OK'].disable(); }) .bind('saveProperties.voDialog', function(e, taskName){ e.stopPropagation(); alert("Save"); $(this).trigger('close.voDialog'); }); dlg.open = function(params){ if(typeof(dlg.voNS) === 'undefined') { dlg.onLoadVoNS = function(){ dlg.open(params) } return; } $.extend(this.options_, params); dlg.voDialog.innerTitle.html(dlg.options_.innerTitle); dlg.currentNotifySettings = Object.clone(dlg.options_.editTask.SettingsTask.notifier.SmtpNotifies[dlg.options_.settingsId]); dlg.notifyRcptList = new multiSelectList({ base_name: dlg.voNS.rcptListBaseName, width: 200, height: 130, store: dlg.currentNotifySettings.Recipients, onchange: dlg.options_.propertiesChange, elem: dlg.voNS.rcptListArea }); dlg.options_.macroListSetup(dlg.voNS.elem, dlg.voNS.notifyBody, dlg.options_.eventId); function dlgPropChanged(){ dlg.voDialog.elem.trigger('addBtnEnable.voDialog') dlg.options_.propertiesChange(); } function handleRcptListMode(){ var mode = dlg.voNS.rcptListMode.val(); if(mode==2){ dlg.notifyRcptList.enableList(false); }else{ dlg.notifyRcptList.enableList(true); } dlgPropChanged(); } bindChangeValuesById(dlg.voNS.elem, dlg.currentNotifySettings, dlg.voNS.main_map_controls, dlgPropChanged); bindChangeValuesById(dlg.voNS.elem, dlg.currentNotifySettings, dlg.voNS.recipients_map_controls, handleRcptListMode); handleRcptListMode(); dlg.voDialog.elem .trigger('addBtnDisable.voDialog') .trigger('open.voDialog'); }; dlg.close = function(){ dlg.options_.propertiesClose(); dlg.voDialog.elem.trigger('close.voDialog'); }; }); } /* actions properties dialog */ function dlgActionProp(params) { this.options_ = { is_tabHide:false, innerTitle : 'UNKNOWN', title: 'UNKNOWN', propertiesChange: function(){}, propertiesClose: function(){}, macroListSetup:function(){}, editTask:'', settingsId:0, eventId:0 }; $.extend(this.options_, params); var dlg = this; dlg.open = function(params) { setTimeout(function(){ dlg.open(params); }, 100) } dlg.onLoadVoAS = function(){} $('<div/>').loadCache('pages/vo_dialog.html', function(){ dlg.voDialog = new voDialog(this, params); dlg.voDialog.addTab({}, $('<div/>').loadCache('pages/notify/action_prop_dlg.html', function(){ dlg.voAS = new voActionSettings(this, this.options_); dlg.onLoadVoAS(); dlg.onLoadVoAS = 0; })); dlg.voDialog.addBtn('BUTTON_OK').click(function(e){ dlg.options_.editTask.SettingsTask.notifier.Actions[dlg.options_.settingsId] = dlg.currentActionSettings; dlg.options_.propertiesClose(); dlg.voDialog.elem.trigger('close.voDialog'); }); dlg.voDialog.addBtn('BUTTON_CANCEL').click(function(){ dlg.options_.propertiesClose(); $(this).trigger('close.voDialog'); }); dlg.voDialog.setActiveTab(0); dlg.voDialog.elem .bind('addBtnEnable.voDialog', function(e){ e.stopPropagation(); dlg.voDialog.btns['BUTTON_OK'].enable(); }) .bind('addBtnDisable.voDialog', function(e){ e.stopPropagation(); dlg.voDialog.btns['BUTTON_OK'].disable(); }) .bind('saveProperties.voDialog', function(e, taskName){ e.stopPropagation(); alert("Save"); $(this).trigger('close.voDialog'); }); dlg.open = function(params){ if(typeof(dlg.voAS) === 'undefined') { dlg.onLoadVoAS = function(){ dlg.open(params); } return; } $.extend(this.options_, params); dlg.voDialog.innerTitle.html(dlg.options_.innerTitle); dlg.currentActionSettings = Object.clone(dlg.options_.editTask.SettingsTask.notifier.Actions[dlg.options_.settingsId]); dlg.options_.macroListSetup(dlg.voAS.elem, dlg.voAS.actionCmd, dlg.options_.eventId); function dlgPropChanged(){ dlg.voDialog.elem.trigger('addBtnEnable.voDialog') dlg.options_.propertiesChange(); } bindChangeValuesById(dlg.voAS.elem, dlg.currentActionSettings, dlg.voAS.main_map_controls, dlgPropChanged); dlg.voDialog.elem .trigger('addBtnDisable.voDialog') .trigger('open.voDialog'); }; dlg.close = function(){ dlg.options_.propertiesClose(); dlg.voDialog.elem.trigger('close.voDialog'); }; }); } function voDialog(elem, params) { var startTime = new Date().getTime(); var _this = this; this.elem = $(elem).find('#vo_dialog'); this.opt = $.extend({ is_tabHide : true, hideInnerTitle: false, useContur: true, innerTitle : 'Unknown' }, params); this.tabCount = 0; this.tabActive = -1; this.innerTitle = this.elem.find('#vo_dlg_innerTitle'); this.tabsTpl = new Template(this.elem.find('#vo_dlg_tabs').html()); this.btnsTpl = this.elem.find('#vo_dlg_btnPane>input:firsr-chuld').clone(); this.tabPane = this.elem.find('#vo_dlg_tabs'); this.tabs = {}; this.btnPane = this.elem.find('#vo_dlg_btnPane'); this.btns = {}; this.content = this.elem.find('#vo_dlg_content_' + (this.opt.useContur ? 2 : 1) ); this.ctlPane = this.elem.find('#ctlPane'); this.useWzrd = this.ctlPane.find('#ctl_cb'); this.ctl_cb_lbl = this.ctlPane.find('#ctl_cb_lbl') .click(function(e){ e.stopPropagation(); _this.useWzrd.click().change(); }); ; this.setCtl = function(resID){ this.ctlPane.show(); this.ctl_cb_lbl.removeAttr('ic_res').addClass('res:'+resID); return this.useWzrd; }; this.showTab = function(idx){ this.tabs[idx].tab.addClass('active'); this.tabs[idx].content.css('display',''); }; this.hideTab = function(idx){ this.tabs[idx].tab.removeClass('active'); this.tabs[idx].content.css('display','none'); }; this.setActiveTab = function(idx, withEvents){ if(typeof(withEvents) == 'undefined') withEvents = false; if(this.tabActive == idx) return; if(idx >= this.tabCount) idx = this.tabCount - 1; if(!this.elem.trigger('beforChangeTab.voDialog')) return; if(this.tabActive > -1) for(var i in this.tabs) this.hideTab(i); this.showTab(idx); this.tabActive = idx; if(!withEvents) return; this.elem.trigger('onChangeTab.voDialog'); if(this.tabActive == (this.tabCount - 1)) this.elem.trigger('onLastTab.voDialog'); }; this.addTab = function(name,value){ var idx = this.tabCount; this.tabs[idx] = { tab : $(this.tabsTpl.evaluate(name)).click(function(){ $(this).trigger('setActiveTab.voDialog', [idx, true]); }), content: $(value) }; this.hideTab(idx); this.tabPane.append(this.tabs[idx].tab); this.content.append(this.tabs[idx].content); ++this.tabCount; return this.tabs[idx]; }; this.addBtn = function(btn){ this.btns[btn] = this.btnsTpl.clone().val(_res(btn)); this.btnPane.append(this.btns[btn]); return this.btns[btn]; }; this.ctlPane.hide(); if(this.opt.is_tabHide) { this.tabPane.parent().css('display','none'); this.elem.find('#vo_dlg_tab_on').css('display','none'); } else this.elem.find('#vo_dlg_tab_off').css('display','none'); if(this.opt.hideInnerTitle) this.innerTitle.css('display','none'); this.innerTitle.html(this.opt.innerTitle); this.tabPane.empty(); this.btnPane.empty(); this.content.empty(); this.elem.dialog({ bindToElement : document.body, autoOpen: false, bgiframe: true, modal: true, title: params.title, resizable: false, width: 'auto', height: 'auto', beforeclose : function(){ $(this).trigger('beforClose.voDialog'); } }); this.elem .bind('setActiveTab.voDialog', function(e, idx, withEvents){ e.stopPropagation(); _this.setActiveTab(idx, withEvents); }) .bind('nextTab.voDialog', function(e){ e.stopPropagation(); _this.setActiveTab(_this.tabActive + 1, true); }) .bind('close.voDialog', function(e){ e.stopPropagation(); $(this).dialog('close'); }) .bind('open.voDialog', function(e){ e.stopPropagation(); $(this).dialog('open'); }); } function dlgNewReport(params) { var dlg = this; dlg.opt = $.extend({}, params); dlg.open = function(){ setTimeout(function(){ dlg.open() }, 100); }; $('<div/>').loadCache('pages/vo_dialog.html', function(){ dlg.impl = new voDialog(this, dlg.opt); dlg.impl.addTab({}, $('<div/>').loadCache( 'pages/dlg_new_report.html', function(){ dlg.voReport = new voReport(this); dlg.impl.addBtn('BUTTON_CREATE').click(function(e){ var params = { reportName : dlg.voReport.reportName.val(), resourceFile : getCurrentResourceFile(), periodType : dlg.voReport.dateType.val() }; if(dlg.voReport.dateFrom.val()) params.dateFrom = parseInt(dlg.voReport.dateFrom.attr('ic_unixtime')); if(dlg.voReport.dateTo.val()) params.dateTo = parseInt(dlg.voReport.dateTo.attr('ic_unixtime')); try { misc_validateStartEndTime( params.dateFrom, params.dateTo ); ic.createReport(params, function(response){ if(ic.ajaxError(response)) return; dlg.impl.elem.trigger('close.voDialog'); $('#resultTable #tableStatus').remove(); response.reportName = params.reportName; if(typeof(reportListCallback) != 'undefined') { reportList.splice(0, 0, response); reportListCallback(reportList); } }) } catch(e){ dlg.impl.elem.trigger('close.voDialog'); } }); dlg.impl.addBtn('BUTTON_CANCEL').click(function(e){ dlg.impl.elem.trigger('close.voDialog'); }); dlg.voReport.reportName .fastChange(function(){ dlg.voReport.reportName.val().length ? dlg.impl.btns['BUTTON_CREATE'].enable() : dlg.impl.btns['BUTTON_CREATE'].disable(); }) .onEnter(function(){ dlg.impl.btns['BUTTON_CREATE'].click(); }); dlg.impl.elem .bind('beforClose.voDialog', function(e){ dlg.voReport.clear(); dlg.impl.btns['BUTTON_CREATE'].disable(); }); dlg.open = function(){ dlg.impl.btns['BUTTON_CREATE'].disable(); dlg.impl.elem.trigger('open.voDialog'); }; dlg.close = function(){ dlg.impl.elem.trigger('close.voDialog'); }; } )); dlg.impl.setActiveTab(0); }); } function dlgNewUpdateSource(params) { var dlg = this; dlg.opt = $.extend({ is_tabHide:true, innerTitle : 'UNKNOWN', title: 'UNKNOWN', useWzrd: false, useContur: false }, params); dlg.open = function() { setTimeout(function(){ dlg.open() }, 100) } $('<div/>').loadCache('pages/vo_dialog.html', function(){ dlg.voDialog = new voDialog(this, dlg.opt); dlg.voDialog.addTab({}, $('<div/>').loadCache('pages/dlg_new_update_source.html', function(){ dlg.voUS = new voUpdateSource(this); dlg.voDialog.elem.bind('beforClose.voDialog', function(e) { e.stopPropagation(); dlg.voUS.updateSource.val('').trigger('fastChange'); }); dlg.voDialog.addBtn('BUTTON_ADD').click(function(){ addSourceUpdate(dlg.voUS.updateSource.val()); $(this).trigger('close.voDialog'); }); dlg.voDialog.addBtn('BUTTON_CANCEL').click(function(){ $(this).trigger('close.voDialog'); }); dlg.voUS.updateSource.fastChange(function(e){ e.stopPropagation(); if(this.value.length > 0) dlg.voDialog.btns['BUTTON_ADD'].enable(); else dlg.voDialog.btns['BUTTON_ADD'].disable(); }) .onEnter(function(e){ e.stopPropagation(); if(this.value.length > 0) dlg.voDialog.btns['BUTTON_ADD'].click(); }); dlg.open = function(){ dlg.voDialog.elem.trigger('open.voDialog'); dlg.voUS.updateSource.val('').trigger('fastChange'); }; })); dlg.voDialog.setActiveTab(0); }); }
💾 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