var opts={lines:15,length:18,width:9,radius:61,scale:2,corners:1,color:"#000",opacity:0.2,rotate:13,direction:1,speed:0.5,trail:50,fps:20,zIndex:2000000000,className:"spinner",top:"50%",left:"50%",shadow:false,hwaccel:false,position:"absolute"};var sel_tgts=[];$(function(){var a=document.getElementById("loading");var b=new Spinner(opts).spin(a);$(".close, .backdrop").click(function(){close_box()});$(".notes").click(function(){$(this).siblings("span").show()});$(".toggler").click(collapse_expand);$(".target-notes").click(get_target_notes);$("#save-tgt-notes").click(save_target_notes)});function update_tgt_chk(a){if($(a).is(":checked")){sel_tgts.push($(a).val())}else{sel_tgts.splice($.inArray($(a).val(),sel_tgts),1)}}function open_move_to(){if($("#ste").val()<1){alert("Please select an ST&E");return}if($(":checkbox:checked").length<1){alert("Please select a device to move");return}$("#move_to").animate({opacity:"1.00"},300,"linear");$("#move_to").css("display","block");view_box()}function edit_cat(e){if($("#ste").val()<1){alert("Please select an ST&E");return}for(var a in $("#scan_sources option")){$("#scan_sources option").eq(a).attr("selected",false)}var b=$("#cat_name_"+e).text();var d=b.match(/\s+\(([\d]+)\)\s+\(([^\d][ \w]+)\)|\s+\(([\d]+)\)/i);b=b.replace(/\s+\(([\d]+)\)\s+\(([^\d][ \w]+)\)|\s+\(([\d]+)\)/i,"");b=b.replace(/\s{2,}/g,"");$("#new_cat_name").val(b);$("#selected_cat").val(e);if(d&&typeof d[2]!=="undefined"){$("#analyst").val(d[2])}else{$("#analyst").val("")}var c=JSON.parse($("#cat_sources_"+e).val());for(var a in c){$("#src_"+c[a]).attr("selected",true)}$("#edit_cat").animate({opacity:"1.00"},300,"linear");$("#edit_cat").css("display","block");view_box()}function merge_target(){$("#merge_target").animate({opacity:"1.00"},300,"linear");$("#merge_target").css("display","block");view_box()}function delete_cat(a){if($("#ste").val()<1){alert("Please select an ST&E");return}if(!confirm("Are you sure you want to delete this category? Currently assigned targets will be set to the 'Unassigned' category.")){return}$.ajax("/ajax.php",{data:{action:"delete-cat",ste_id:$("#ste").val(),cat_id:a},success:function(b){if(b.error){alert(b.error)}else{location.reload()}},error:function(d,b,c){console.error(c)},dataType:"json",method:"post",timeout:3000})}function del_target(){if(!confirm("Are you sure you want to delete the target? This will also delete all findings and interfaces for the selected targets and is irreversible")){return}}function add_cat(){if($("#ste").val()<1){alert("Please select an ST&E");return}$("#add_ste").val($("#ste").val());$("#add_cat").animate({opacity:"1.00"},300,"linear");$("#add_cat").css("display","block");view_box()}function get_category(a){$.ajax("/ajax.php",{data:{action:"get_category_details",cat_id:a},success:function(c){$("#new_cat_name").val(c.name);for(var b in c.sources){$("#src_"+c.sources[b].id).attr("selected",true)}},datatype:"json",method:"post"})}function close_box(){$(".backdrop, .box").animate({opacity:"0"},300,"linear",function(){$(".backdrop, .box").css("display","none")})}function view_box(){$(".backdrop").animate({opacity:".5"},300,"linear");$(".backdrop").css("display","block")}function update_Status(a){if($(a).val()<1){return false}if($(":checkbox:checked").length<1){alert("Please select a device to update");return false}return true}function collapse_expand(){var a=$(this).data("id");if(!$(".cat_"+a).length){get_hosts(a)}$(this).toggleClass("fa-minus-square fa-plus-square");$(".cat_"+a).toggle(300)}function select(a){$(".cat_"+a+" input[type=checkbox]").each(function(){this.checked=!this.checked;update_tgt_chk(this)})}function assign(b){var a=prompt('Who do you want to assign this category to?\n\nEnter "none" to clear out assignment');if(a){$("#analyst_"+b).val(a);$("#assign_"+b).submit()}}function upload_host_list(){if($("#ste").val()<1){alert("Please select an ST&E");return}$("#import_host_list").animate({opacity:"1.00"},300,"linear");$("#import_host_list").css("display","block");view_box()}function get_hosts(a){$.ajax("/ajax.php",{data:{action:"get_hosts",cat_id:a},beforeSend:function(){$("#loading,#waiting").show();$("#waiting").animate({opacity:"0.5"},300,"linear")},success:function(b){if($("#ops-page").val()=="main"){display_ops_hosts(b)}else{if($("#ops-page").val()=="stats"){display_stats_hosts(b)}else{if($("#ops-page").val()=="task"){display_task_hosts(b)}}}},error:function(d,b,c){console.error(c)},complete:function(){$("#loading,#waiting").hide();$("#waiting").animate({opacity:"0"},300,"linear")},dataType:"json",method:"post"})}function display_ops_hosts(c){if(c.error){console.error(c.error)}else{var e=c.cat_id;var b=$("#cat_"+e);var d=true;for(var a in c.targets){$(b).after("