opt
/
kaspersky
/
kav4fs
/
share
/
wmconsole
/
html
/
js
/
awt
➕ New
📤 Upload
✎ Editing:
update.source.list.js
← Back
function UpdateSourceList(){ var model = this; this.bindDomElement = 'nonexistent'; this.scopes = 'undefined'; this.lastComboId = null; //needed to hide last combo this.lastEditRow = null; this.last_clicked = -1; this.shift_lock=false; this.isDisabled = false this.isEmptyShow = false this.oldValue = null function CloseEditUrl(source_){ val = $('#editURL').val() if (val!="" && val!=null) { //if (val!=source_.Url) setUpdateSettingsChange(); //source_.Url = val; model.fillSourceList() } } function showEditCustomSourceCell(ind,source_){ /*val = window.prompt("Enter the new value of the update source:",source_.Url) if (val!="" && val!=null) { if (val!=source_.Url) setUpdateSettingsChange(); source_.Url = val; model.fillSourceList() } */ var showCloseEditUrl = model.createLink( function(){ CloseEditUrl(source_) }, 'showCloseEditUrl'); var enterKeyHandler = function(event){ if(event.keyCode==13) model.fillSourceList() else { val = $('#editURL').val() if (val!="" && val!=null) { setUpdateSettingsChange(); source_.Url = val; } else { source_.Url = model.oldValue $('#editURL').val(source_.Url) $('#editURL').focus().select() } } }; model.oldValue = source_.Url $('#us_cuctom_url_edit_'+ind).html("<input id='editURL' type='text' value='"+source_.Url+"' class='w75'/> <a href=\""+showCloseEditUrl+"\" >Close</a>") $('#editURL').focus().select() $('#editURL').keyup( enterKeyHandler) } this.createLink = function(functor, desc) { return FunctionStore.createLink(functor, model.bindDomElement, desc); } this.addSourceUpdate = function(source_,ind) { var showEditCell0Link = model.createLink( function(){ showEditCustomSourceCell(ind,source_) }, 'showEditCustomSourceCell'); if (this.isDisabled) { str = '<td><span class="grey">'+source_.Url+'</span></TD>' +'<td class="nobr" width="15%" style="width:80px;"><input type="checkbox" id="us_cuctom_url_enabled_'+ind+'"/><span class="grey">'+getLocalString('LABEL_UPDATE_SOURCE_ENANLED')+'</span></td>'; } else { str = '<td id="us_cuctom_url_edit_'+ind+'"><a href="' + showEditCell0Link + '">'+misc_preparetoView(source_.Url)+'</a></TD>' +'<td class="nobr" width="15%" style="width:80px;"><input type="checkbox" id="us_cuctom_url_enabled_'+ind+'"/>'+getLocalString('LABEL_UPDATE_SOURCE_ENANLED')+'</td>'; } $('#'+model.bindDomElement+'>table>tbody>#empty_areas').remove(); $('#'+model.bindDomElement+'>table>tbody>tr:last').after( '<tr id="area'+ind+'">' +'<td width="1%"><input type="checkbox" id="area_select_'+ind+'"/></TD>' +str); // +'<td width="75%" id="us_cuctom_url_edit_'+ind+'"><a href="' + showEditCell0Link + '">'+source_.Url+'</a></TD>' // +'<td><input type="checkbox" id="us_cuctom_url_enabled_'+ind+'"/>Enabled</td>'); var id_=ind; if (source_.Enabled) $('#us_cuctom_url_enabled_'+ind).attr("checked",true) $('#us_cuctom_url_enabled_'+ind).click(function(){ source_.Enabled = $('#us_cuctom_url_enabled_'+ind).attr("checked") setUpdateSettingsChange(); } ) // $('#'+model.bindDomElement+'>table>tbody>tr#area'+ind+'>td>input[type=checkbox]') $('#area_select_'+ind) .click(function(ev){ model.shift_lock=(ev.shiftKey==1); model.InitButton();}) .change(function(){ if (model.last_clicked>=0 && model.last_clicked!=id_ && model.shift_lock && model.last_clicked<model.scopes.length && $('#area_select_'+ind).attr('checked') == $(this).attr('checked')){ /* select with shift >*/ d = (model.last_clicked - id_)/Math.abs(model.last_clicked-id_); ch=$(this).attr('checked'); for (i=id_;i!=model.last_clicked;i+=d){ $('#area_select_'+ind).attr('checked',ch); }; }; model.last_clicked=id_; }); }; this.fillSourceList = function(){ $('#'+model.bindDomElement+'>table>tbody>tr[id^=area]').remove(); $('#'+model.bindDomElement+'>table>tbody>tr[id^=editrow]').remove(); // lastComboSchHide(); var k = 0 if(model.scopes==null || model.scopes.length==0 ) { var numColumns = $('#tableArea table>tbody>tr>th').length; if (!this.isEmptyShow) $('#tableArea>table>tbody>tr:last').after( '<TR ID="empty_areas">'+ '<TD COLSPAN="3" id="empty_message">'+ getLocalString("EMPTY_LIST_CUSTOM_URL")+ '</TD></TR>'); this.isEmptyShow = true } else this.isEmptyShow = false $(model.scopes).each(function(ind){ model.addSourceUpdate(this,ind); }); $('#'+model.bindDomElement+'>table').trigger('update'); model.InitButton() }; this.InitButton =function (){ var count=0 var up = true; var down = true; $($('#'+model.bindDomElement+'>table>tbody>tr>td>input[id^=area_select]')).each(function(){ if ($(this).attr('checked')){ count++; ind=parseInt($(this).attr('id').substring(12)); if (ind==0) up = false if (ind==model.scopes.length-1) down= false }; }); if (count>0) { $('#panel_link_add_source [alt=Delete_grey]').hide() $('#panel_link_add_source [alt=Delete]').show() } else { up = false down = false $('#panel_link_add_source [alt=Delete]').hide() $('#panel_link_add_source [alt=Delete_grey]').show() } if (up) { $('#panel_link_add_source [alt=Up_grey]').hide() $('#panel_link_add_source [alt=Up]').show() } else { $('#panel_link_add_source [alt=Up]').hide() $('#panel_link_add_source [alt=Up_grey]').show() } if (down) { $('#panel_link_add_source [alt=Down_grey]').hide() $('#panel_link_add_source [alt=Down]').show() } else { $('#panel_link_add_source [alt=Down]').hide() $('#panel_link_add_source [alt=Down_grey]').show() } if (count!= model.scopes.length || count==0) $('#tableArea .w0 input').attr('checked',false) else $('#tableArea .w0 input').attr('checked',true) //alert("InitButton count="+count+" up="+up+" down="+down) } this.disabled = function(f) { this.isDisabled = f model.fillSourceList() if (f) { $('#tableArea .w0 input').attr('checked',false) $('#tableArea .w0 input').attr("disabled","disabled") $('#'+model.bindDomElement+'>table>tbody>tr>td>input[id^=area_select]').attr('checked',false); $('#'+model.bindDomElement+'>table>tbody>tr>td>input[id^=area_select]').attr("disabled","disabled") $('#'+model.bindDomElement+'>table>tbody>tr>td>input[id^=us_cuctom_url_enabled]').attr("disabled","disabled") $('#title_1').css("color","#999") $('#title_2').css("color","#999") $('#us_ch_KL_label').css("color","#999") $('#empty_message').css("color","#999") model.InitButton() } else { $('#tableArea .w0 input').attr("disabled","") $('#'+model.bindDomElement+'>table>tbody>tr>td>input[id^=area_select]').attr("disabled","") $('#'+model.bindDomElement+'>table>tbody>tr>td>input[id^=us_cuctom_url_enabled]').attr("disabled","") $('#title_1').css("color","") $('#title_2').css("color","") $('#us_ch_KL_label').css("color","") $('#empty_message').css("color","") } } this.run = function() { if(!this.bindDomElement){ alert('UpdateSourceList.bindDomElement should be set before running'); return; } if(!this.scopes){ alert('UpdateSourceList.scopes should be set before running'); return; } var main_checkbox; model.last_clicked=-1, model.shift_lock=false; $('#'+model.bindDomElement).html( '<table id="tasks_list" class="w100 tabl" cellpadding="0">' + '<tbody>' + '<tr class="title">'+ '<td width="1%" class="w0">'+ '<input type="checkbox"></td>'+ '<td id="title_1" class="res:TABLE_TITLE_TASK_SOURCE"></td>'+ '<td width="15%" style="width:80px;" id="title_2" class="res:TABLE_TITLE_TASK_STATUS"></td>'+ '</tr>'+ '</table>'); // handler for checkbox in the title main_checkbox = $('#'+model.bindDomElement+' .w0 INPUT').click(function(){ $('#' + model.bindDomElement + ' > table > tbody > tr > td > input[id^=area_select]').attr('checked',this.checked); model.InitButton(); }); function getSelectedSource() { rval=new Array; $($('#'+model.bindDomElement+'>table>tbody>tr>td>input[id^=area_select]')).each(function(){ if ($(this).attr('checked')){ ind=parseInt($(this).attr('id').substring(12)); rval.push(ind); }; }); rval.sort(); return rval; }; function setSelectedSource(ids){ $(ids).each(function(){ $('#area_select_'+this).attr('checked',true); }); model.InitButton() }; //delete button $('#panel_link_add_source [alt=Delete]').click(function(){ removed=0; ids=getSelectedSource(); model.scopes.removeIndexes(ids); $(main_checkbox).attr('checked',false); setUpdateSettingsChange(); model.fillSourceList(); }); $('#panel_link_add_source [alt=Down]').click(function(){ ids=getSelectedSource(); newids=[]; //do nothing if last selected in the bottom if (ids.length == 0 || ids[ids.length-1] == model.scopes.length-1) return; for(i=model.scopes.length-1;i>0;i--){ if (ids[ids.length-1]==i-1){ tmp=model.scopes[i]; model.scopes[i]=model.scopes[i-1]; model.scopes[i-1]=tmp; ids.pop(); newids.push(i) }; }; setUpdateSettingsChange(); model.fillSourceList(); setSelectedSource(newids); }); $('#panel_link_add_source [alt=Up]').click(function(){ ids=getSelectedSource(); newids=[]; //do nothing if first selected item at the top if (ids.length==0 || ids[0] == 0) return; for(i=0;i < model.scopes.length-1;i++){ if (ids[0]== i+1){ tmp = model.scopes[i]; model.scopes[i]=model.scopes[i+1]; model.scopes[i+1]=tmp; ids.splice(0,1); newids.push(i) }; }; setUpdateSettingsChange(); model.fillSourceList(); setSelectedSource(newids); }); model.fillSourceList(); } } // for update_source.html {{{ function setUpdateSource(id, value) { $('#'+id).click(function(){ obj.SourceType = value if (!init_US) setUpdateSettingsChange() if(value == UPDATE_SOURCE_TYPE_CUSTOM) { $('#panel_link_add_source #asu').show(); $('#panel_link_add_source #asudis').hide(); $('#us_ch_KL').enable() $('#us_ch_KL_s').css('color',''); ssm.disabled(false); } else { ssm.disabled(true) isAddSource = false $('#panel_link_add_source #asu').hide(); $('#panel_link_add_source #asudis').show(); $('#us_ch_KL').disable() $('#us_ch_KL_s').css('color','#999'); } }) } var isAddSource = false; function addSourceUpdateView() { if (!isAddSource){ isAddSource = true } else { isAddSource = false } getDialog('newUpdateSource').open(); } function addSourceUpdate(uri) { var el = ic.create_UpdateCommonSettings_UpdateCustomSource() el.Url = uri; el.Enabled = true; ssm.scopes.push(el) isAddSource = true addSourceUpdateView() ssm.fillSourceList() setUpdateSettingsChange(); } function updateSource_onLoad() { if( 0 == $('#isUpdateSourcePage').length ) return; init_US = true; ssm = new UpdateSourceList(); setUpdateSource('us_rb_KL', UPDATE_SOURCE_TYPE_KLSERVER) setUpdateSource('us_rb_AK', UPDATE_SOURCE_TYPE_AKSERVER) setUpdateSource('us_rb_Custom',UPDATE_SOURCE_TYPE_CUSTOM) $("#source_add_value") .fastChange(function(e){ }) .onEnter(function(){ if($(this).val().length) addSourceUpdate(); }); obj = editTask.SettingsTask.CommonSettings var select_id='us_rb_KL' switch(obj.SourceType){ case UPDATE_SOURCE_TYPE_KLSERVER: select_id='us_rb_KL' break case UPDATE_SOURCE_TYPE_AKSERVER: select_id='us_rb_AK' break case UPDATE_SOURCE_TYPE_CUSTOM: select_id='us_rb_Custom' break } $('#'+select_id).attr("checked",true) $('#us_ch_KL').attr("checked",obj.UseKLServersWhenUnavailable) $('#us_ch_KL').click(function() { obj.UseKLServersWhenUnavailable = $('#us_ch_KL').attr("checked") setUpdateSettingsChange() }) ssm.bindDomElement = 'tableArea'; ssm.scopes = editTask.SettingsTask.CommonSettings.CustomSources ssm.run(); $('#'+select_id).click(); init_US = false; taskSettings_addRevertFunc(updateSource_onLoad); } // }}} for update_source.html
💾 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