-
- 连接类型
- 优先级
- 上传流量
- 下载流量
- 协议
- 源端口
- 目的端口
- 目标地址
- 外网接口
- 连接状态
`)
//添加排序元素
$(".listTableHead>li").append(`
`)
//CSS-----------------------
{
$("#currentIP").parent().parent().find("li").css({
width:"200px",
display:"flex",
alignItems:"center"
});
$(".selCss>option").css({
border:"1px solid #f0f0f0",
})
$(".listTableHead>li").css({
cursor: "pointer",
userSelect: "none",
transition: "all .2s linear"
})
$("#listTableWrapper>li>ul").css({
display:"flex"
})
$("#listTableWrapper>li>ul>li").css({
width:"10%",
height:"40px",
display:"flex",
justifyContent: "center",
alignItems: "center",
borderBottom:"1px solid #f0f0f0",
})
$("#listTableWrapper>li>ul").eq(0).children('li').css({
backgroundColor:"#fafafa",
fontWeight: "bold",
height:"40px"
})
//hover-------------------
//查看按钮hover
$("#searchBtn").hover(function(){
// 移入
$(this).css("background-color","#39ade6")
}, function(){
// 移出
$(this).css("background-color","#26a3e9")
});
// 遮罩层关闭按钮hover
$("#colseBtn").hover(function(){
$(this).css("color","#ff7875")
$(this).css("background-color","#fff2f0")
}, function(){
$(this).css("color","#ff4d4f")
$(this).css("background-color","#fff")
});
//按钮hover
$("#searchBtn,#reloadBtn,#okHideBtn,#StartStopBtn,#ipQueryBtn1,#ipQueryBtn2").hover(function(){
// 移入
$(this).css("background-color","#39ade6")
}, function(){
// 移出
$(this).css("background-color","#26a3e9")
});
//重置、清空hover
$("#resetHideBtn,#ipQueryClear1,#ipQueryClear2").hover(function(){
$(this).css("color","#39ade6")
}, function(){
$(this).css("color","#666")
});
//列表头部排序hover
$(".listTableHead>li").hover(function(){
// 鼠标移入时的处理逻辑
$(this).css("background-color","#efefef")
}, function(){
// 鼠标移出时的处理逻辑
$(this).css("background-color","#fafafa")
});
//回到顶部按钮hover
$("#back-to-top").hover(function(){
// 鼠标移入时的处理逻辑
$(this).css("background-color","#f0f0f0")
}, function(){
// 鼠标移出时的处理逻辑
$(this).css("background-color","#fff")
});
}
}
//ip详情列表样式
function ipListTableCss(){
$("#listTableWrapper>li>ul").css({
display:"flex"
})
$("#listTableWrapper>li>ul>li").css({
width:"10%",
height:"30px",
display:"flex",
justifyContent: "center",
alignItems: "center",
borderBottom:"1px solid #f0f0f0",
})
$("#listTableWrapper>li>ul>li:first-child").css({ width:"11%", })
$("#listTableWrapper>li>ul>li:nth-child(2)").css({ width:"9%", })
$("#listTableWrapper>li:gt(0)>ul").css({
transition: "all .2s linear"
})
//hover-------------------
//除第一个li其他选中
$("#listTableWrapper>li:gt(0)>ul").hover(function(){
// 鼠标移入时的处理逻辑
if($(this).children().last().text()=="稳定")
$(this).css("background-color","#fafafa")
}, function(){
// 鼠标移出时的处理逻辑
if($(this).children().last().text()=="稳定")
$(this).css("background-color","#fff")
});
}
let timerReload=null;//刷新定时器
let isStart=false;//是否开始
let sort={state:0,type:'down'};//排序
let ipListData=[];//ip详情数据
//查看按钮点击事件
$(document).on("click", "#searchBtn",ipDetail);
//隐藏重置点击事件
$(document).on("click", "#resetHideBtn", function(){
$("#hideInp").val('')
$("#hideInp2").val('')
sessionStorage.removeItem('hideEntry')
getIpList()//发起请求
message('', '已重置')
});
//隐藏输入框添加键盘事件
$('#hideInp').keydown(function(event) {
// 使用 event.key 来判断按键
if (event.key === 'Enter') {
hideOk();
}
});
//隐藏确认点击事件
$(document).on("click", "#okHideBtn",hideOk);
//切换hideType下拉选项事件
$('#hideType').change(function() {
let selectedValue = $(this).val();
//判断筛选类型是否为源端口与目的端口
if((selectedValue == 'sport') || (selectedValue == 'dport')){
$('#endInp').css("display","inline")
}else{
$('#endInp').css("display","none")
}
});
//自动刷新输入框添加键盘事件
$('#refreshTimeInp').keydown(function(event) {
// 使用 event.key 来判断按键
if (event.key === 'Enter') {
if($("#refreshTimeInp").val()>0){
clearInterval(timerReload)
$("#StartStopBtn").text('停止')
isStart=true
timerReload=setInterval(getIpList,$("#refreshTimeInp").val()*1000)
}else{
message('warning','大于 0 生效!')
}
}
});
//启/停定时按钮
$(document).on("click", "#StartStopBtn", function(){
if(isStart){
$("#StartStopBtn").text('开始')
clearInterval(timerReload)
isStart=false
message('', '已停止!')
}else{
if($("#refreshTimeInp").val()>0){
message('success', '已开始!')
$("#StartStopBtn").text('停止')
isStart=true
timerReload=setInterval(getIpList,$("#refreshTimeInp").val()*1000)
}else{
message('warning', '大于 0 生效!')
}
}
});
//立即刷新按钮
$(document).on("click", "#reloadBtn", function(){
getIpList()
$("#StartStopBtn").text('开始')
clearInterval(timerReload)
isStart=false
});
//排序点击事件
$(document).on("click", ".listTableHead>li", function(){
$(".listTableHead>li>div").each(function() {
$(this).children().eq(0).css("border-bottom-color","#b1b1b1");
$(this).children().eq(1).css("border-top-color","#b1b1b1");
})
if(sort.type==this.dataset.type){
if(sort.state<2){
sort.state+=1
}else{
sort.state=0
}
}else{
sort.state=1;
sort.type=this.dataset.type;
}
switch(sort.state){
case 1:$(this).children().children().eq(0).css("border-bottom-color","#1677ff");
$(this).children().children().eq(1).css("border-top-color","#b1b1b1");break;
case 2:$(this).children().children().eq(0).css("border-bottom-color","#b1b1b1");
$(this).children().children().eq(1).css("border-top-color","#1677ff");break;
}
addIpList()
});
// ip详情列表
function ipDetail(e,a=false){
getIpList(a);
//初始显示隐藏组件
let hideEntryInp = sessionStorage.getItem('hideEntry')?JSON.parse(sessionStorage.getItem('hideEntry')):'';
if(Object.prototype.toString.call(hideEntryInp) === '[object Object]'){
const keys = Object.keys(hideEntryInp);
const values = Object.values(hideEntryInp);
$("#hideType").val(keys[0])
if(keys[0]=='pri'){
switch(values[0]){
case "1":$('#hideInp').val("最高");break;
case "2":$('#hideInp').val("高");break;
case "3":$('#hideInp').val("中");break;
case "4":$('#hideInp').val("低");break;
case "5":$('#hideInp').val("最低");break;
}
}else{
$('#hideInp').val(values[0][0]);
if(values[0][1]!=false)$('#hideInp2').val(values[0][1]);
$('#isHide').val(hideEntryInp.isHide);
}
}else{
$('#hideInp').val('');
$('#isHide').val(1);
}
}
// 隐藏确认
function hideOk(){
let hideType = $("#hideType").val()
let hideVal = $("#hideInp").val().trim()
let hideVal2 = $("#hideInp2").val().trim()
let isOk = true
if(hideType=="pri"){
if(/^[\u4e00-\u9fa5]{1,2}$/.test(hideVal)){
switch(hideVal){
case "最高":hideVal="1";break;
case "高":hideVal="2";break;
case "中":hideVal="3";break;
case "低":hideVal="4";break;
case "最低":hideVal="5";break;
default:isOk = false;
}
}else{
isOk = false;
}
}else if(hideType=="proto"){
if(!(/TCP/i.test(hideVal) || /UDP/i.test(hideVal) || /ICMP/i.test(hideVal)))isOk = false;
}else if(hideType=="sport"||hideType=="dport"){
const num = parseInt(hideVal, 10);
if(!(!isNaN(num) && num >= 0 && num <= 65535))isOk = false;
const num2 = parseInt(hideVal2, 10);
if(isOk && (!(!isNaN(num2) && num2 >= 0 && num2 <= 65535))){
$("#hideInp2").val(hideVal);
hideVal2 = hideVal
}
}else if(hideType=="daddr"){
const pattern = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
if(!pattern.test(hideVal))isOk = false;
}else if(hideType=="wan"){
if(!((hideVal.indexOf('wan')!=-1)||(hideVal.indexOf('LAN')!=-1)||(hideVal.indexOf('l2tp')!=-1)||(hideVal.indexOf('pptp')!=-1)))isOk = false;
}else if(hideType=="status"){
if(hideVal=="未响应"){
hideVal = 1
}else if(hideVal=="稳定"){
hideVal = 2
}else{
isOk = false
}
}else if(hideType=="appstat"){
console.log(isOk,hideType,hideVal)
}
console.log({[hideType]:[hideVal,hideVal2],isHide:$("#isHide").val()})
if(isOk&&hideVal){
//message('success', 'OK!')
let filterVal = []
filterVal[0]=hideVal
if(hideType=='sport' || hideType=='dport'){
filterVal[1]=hideVal2
}else{
filterVal[1]= false
}
sessionStorage.setItem('hideEntry',JSON.stringify({[hideType]:filterVal,isHide:$("#isHide").val()}))
getIpList()//发起请求
}else{
console.log(isOk,hideType,hideVal)
message('warning', '类型与值不匹配!')
}
//console.log(isOk,hideType,hideVal)
}
// 请求获取ip详情列表
function getIpList(i){
let ip = i||$("#ipInp")[0].value
$("#currentIP").text(ip)
localStorage.setItem("ipVal",ip)
//判断输入IP是否正确
if (ipaddress.test(ip)) {
message('', '加载中...')
$("#ipInp")[0].value=ip
let data = JSON.stringify({ ip, wan: $(".sel_line option:selected").attr("data") })
//请求数据
$.get('/action/show_connect.htm?false', { data }, function (msg) {
//console.log(msg)
if (msg.length > 0) {
if(Array.isArray(msg[0])){
message('','有子数组');
}else{
let UnresponsiveNum = 0
ipListData = msg;
$("#conn_num").text(msg.length)
msg.forEach(item=>{
if(item.status==1){
UnresponsiveNum++;
}
})
$("#Unresponsive").text(UnresponsiveNum)
addIpList()
}
$("#mask").css("display","block")
} else {
//没有查到数据
message('warning',"该IP无数据!")
}
}, "JSON")
} else {
message('error',"IP有误!")
}
}
// 添加ip详情列表数据
function addIpList(){
//console.log(sort.state,sort.type);
$("#listTableWrapper>li:gt(0)").remove()
let sortData=JSON.parse(JSON.stringify(ipListData));
let hideEntry = sessionStorage.getItem('hideEntry')?JSON.parse(sessionStorage.getItem('hideEntry')):''
let hideEntryKey = '';
if(Object.prototype.toString.call(hideEntry) === '[object Object]'){
hideEntryKey = Object.keys(hideEntry)[0];
}else{
}
switch(sort.state){
case 1:sortData.sort(function(a,b){return a[sort.type]-b[sort.type]});break;
case 2:sortData.sort(function(a,b){return b[sort.type]-a[sort.type]});break;
}
let html = ''
sortData=sort.state==0?ipListData:sortData
sortData.forEach(function(item,index){
if(hideEntryKey){
if(hideEntry.isHide==1){
if((hideEntryKey == 'sport') || (hideEntryKey == 'dport')){
if(item[hideEntryKey]*1>=hideEntry[hideEntryKey][0]*1&&item[hideEntryKey]*1<=hideEntry[hideEntryKey][1]*1)return;
}else{
if(item[hideEntryKey]==hideEntry[hideEntryKey][0])return;
}
}else{
if((hideEntryKey == 'sport') || (hideEntryKey == 'dport')){
if(item[hideEntryKey]*1
hideEntry[hideEntryKey][1]*1)return;
}else{
if(item[hideEntryKey]!=hideEntry[hideEntryKey][0])return;
}
}
}
html +=`
- ${item.appstat}
- ${(function(){
switch(item.pri){
case "1":return "最高";
case "2":return "高";
case "3":return "中";
case "4":return "低";
case "5":return "最低";
}
})()}
- ${formatFileSize(item.up)}
- ${formatFileSize(item.down)}
- ${item.proto}
- ${item.sport}
- ${item.dport}
- ${item.daddr}
- ${item.wan}
- ${item.status==1?"未响应":"稳定"}
`
})
if(html=='')html=`
`
$("#listTableWrapper").append(html)
message('success', '刷新成功!')
ipListTableCss()
}
$(document).ready(function() {
//返回顶部按钮
// 绑定到某个元素(如按钮)的点击事件上
$('#back-to-top').click(function() {
// 使用animate()方法来平滑地滚动到页面顶部
$('body, html').animate({
scrollTop: 0
}, 500); // 500是动画的持续时间,以毫秒为单位
return false; // 阻止链接的默认行为(如果有的话)
});
//手动刷新
//$(".auto-flush").val(0)
//初始隐藏组件
let hideEntryInp = sessionStorage.getItem('hideEntry')?JSON.parse(sessionStorage.getItem('hideEntry')):'';
if(Object.prototype.toString.call(hideEntryInp) === '[object Object]'){
const keys = Object.keys(hideEntryInp);
const values = Object.values(hideEntryInp);
$("#hideType").val(keys[0])
$('#hideInp').val(values[0][0]);
if(values[0][1]!=false)$('#hideInp2').val(values[0][1]);
$('#isHide').val(hideEntryInp.isHide);
}else{
$('#hideInp').val('');
$('#hideInp2').val('');
$('#isHide').val(1);
}
//判断筛选类型是否为源端口与目的端口
let selectedValue = $('#hideType').val();
if((selectedValue == 'sport') || (selectedValue == 'dport')){
$('#endInp').css("display","inline")
}else{
$('#endInp').css("display","none")
}
$("#mask").attr('tabindex', '0').focus()
//添加键盘事件
$("#mask").keydown(function(event) {
//console.log(event.keyCode)
// 检查是否按下了空格键
if ((event.key === ' ' || event.keyCode === 32)&&timerReload) {
message('', '已停止!')
//停止自动刷新
$("#StartStopBtn").text('开始')
clearInterval(timerReload)
isStart=false
// 阻止事件的默认行为
event.preventDefault();
return false; // 在jQuery中,返回false也会阻止事件冒泡
}else if(event.keyCode ===82){//R键
//立即刷新
$("#reloadBtn").click()
}else if(event.keyCode ===84){
//回到顶部
$('#back-to-top').click()
}else if(event.keyCode ===27){
$('#colseBtn').click()
}
});
});
//遮罩层关闭按钮
$("#colseBtn").click(function(){
$("#mask").css("display","none")
$('#hideInp').val('');
clearInterval(timerReload)
isStart=false
$("#refreshTimeInp").val('')
$("#StartStopBtn").text('开始')
})
let currentIP = ''
let currentIPData = []
const ip_btn_css = `border-radius:4px;border:none;cursor:pointer;padding:3px 10px;white-space:nowrap;transition: 0.2s linear;color:#26a3e9;border:1px solid #26a3e9;background-color:#fff;`
const bound_domain_li_css = `display:flex;width:100%;justify-content:space-between;align-items:center;padding:5px 20px;box-sizing:border-box;color:`
$('#listModal').append(`
`)
//hover
$('#bound_domain_wrapper').on({mouseenter: function() {$(this).css("background-color","#fafafa")},
mouseleave: function() { $(this).css("background-color","#fff")} }, '.hover_li');
$('#appid_info_wrapper').on({mouseenter: function() {$(this).css({'color':'#fff',"background-color":"#39ade6"})},
mouseleave: function() { $(this).css({'color':'#26a3e9',"background-color":"#fff"})} }, '#save_appid_name');
$('#ip_domain_info_wrapper').on({mouseenter: function() {$(this).css({'color':'#fff',"background-color":"#39ade6"})},
mouseleave: function() { $(this).css({'color':'#26a3e9',"background-color":"#fff"})} }, '.query_ip_btn,#save_custom_name');
$('#curstom_name_val,#appid_name').focus(function(){
$(this).css('border-color','#26a3e9')
})
$('#curstom_name_val,#appid_name').blur(function(){
$(this).css('border-color','#fff')
})
$('#curstom_name_val,#appid_name').hover(function(){
$(this).css('outline','1px solid #26a3e9')
},function(){
$(this).css('outline','1px solid #fff')
})
$(document).on({mouseenter: function() { $(this).css({cursor:"pointer",color:"#26a3e9"});},
mouseleave: function() { $(this).css({color:"#505459"}) } }, '#ip_info_ip');
$("#ip_info_ip").click(function () {
let str = $('#ip_info_ip').text();
if (str!== ""){
let $temp = $('');
$('body').append($temp);
$temp.val(str).select();
document.execCommand('copy');
$temp.remove();
message('success', '已复制')
}
})
$('.query_ip_btn').on('click',function(){
//let ip = $(this).parent().find('#ip_info_ip').text()
let website = ($(this).text().indexOf('ip138')!=-1)? 'site.ip138.com' : 'ipchaxun.com'
let url = `https://${website}/${currentIP}/`
website.indexOf('ip138')!=-1? window.open(url, '_blank') : window.open(url, '_blank')
})
$('#ip_domain_info_wrapper').on('click','.use_ip_domain',function(){
$('#curstom_name_val').val($(this).attr('data-domain'))
})
$('#save_custom_name').on('click',function(){
let curstom_name_val = $('#curstom_name_val').val();
//console.log(currentIPData[0])
if(curstom_name_val || currentIPData[0]&¤tIPData[0].bound_domain){
if (confirm("确定保存吗?")) {
let data = [{
ip:currentIP,
custom_name:curstom_name_val?[{domain:curstom_name_val,date:formatDate(new Date())}]:[],
ipshudi:currentIPData[0]?currentIPData[0].ipshudi:'',
default_key:curstom_name_val?'custom_name':'bound_domain',
website:currentIPData[0]?currentIPData[0].website:''
}]
$.post('https://moodtracks.cn:6789/_update_rdns',{data : JSON.stringify(data)},(res)=>{
if(res.status==200){
$('#ip_domain_info_wrapper').hide()
message('success','保存成功')
}else{
message('error','保存失败')
}
//console.log(data)
console.log(res)
},"json")
}
}else{
message('warning','内容不能为空,需要先查询')
}
})
//添加滑块开关
$("div.pdg20-LR>div.box-tit").append(`
`)
// 滑块开关点击事件
let change_show_domain = JSON.parse(localStorage.getItem('change_show_domain'))!=null?JSON.parse(localStorage.getItem('change_show_domain')):true;
$("#change_show_domain")[0].checked = change_show_domain
$("#change_show_domain").click(function(){
if($("#change_show_domain")[0].checked){
change_show_domain = true
JSON.stringify(localStorage.setItem('change_show_domain',true))
}else{
change_show_domain = false
JSON.stringify(localStorage.setItem('change_show_domain',false))
}
})
let DNSptrData = []
let timer;
function handlerIPs(){
clearTimeout(timer)
if(change_show_domain){
//if(DNSptrData.length!=0){
timer = setTimeout(()=>{
let elementsType = $('.self-table.connect_table>tbody tr>td:nth-child(1)')
let filteredElementsType = elementsType.toArray().filter(function(item,index) {
let $item = $(item);
let cid = $item.text()
if(cid.indexOf('00') !=-1 && cid != '00000000'){
//console.log(cid)
$item.text('');
$item.append(`${cid}`);
}
})
//console.log(elementsType)
let elementsIP = $('.self-table.connect_table>tbody tr>td:nth-child(8)')
let filteredElementsIP = elementsIP.toArray().filter(function(item,index) {
let $item = $(item);
let cip = $item.text()
if((cip.indexOf('d')==-1)&&isPublicIPv4(cip)){
$item.text('');
for(let i=0;i${str.length>17?'..'+str.slice(-16):str}${IPStatusHTML(custom_name.length>0,bound_domain.length>0)}`);
}else{
$item.append(`${cip}${IPStatusHTML(custom_name.length>0,bound_domain.length>0)}`);
}
//console.log(str,cName)
return true;
}
}
$item.append(`${cip}`);
}
});
let $filteredElementsIP = $(filteredElementsIP);
//console.log(filteredElementsIP[0])
//console.log($filteredElementsIP)
$('.id_info,.ip_info').hover(function(){$(this).css("text-decoration","underline")},function(){$(this).css("text-decoration","none")})
},500)
}
}
function IPStatusHTML(a=false,b=false){
let ulCSS = `position: absolute;top:0;bottom:0;right:-30px;width:25px;height:20px;display: flex;justify-content: center;align-items: center;`
let liCSS = `width:5px;height:5px;border:1px solid #999;border-radius: 50%;margin-right:2px;`
let AcheckedCSS = `background: #4bae4f;border-color:#4bae4f;`
let BcheckedCSS = `background: #999;`
let html = ``
return html
}
//获取域名反查
function getDNSptr(data){
let IPs = data.map(item=>item.daddr).filter(item=>item.dport!='53')
let tempIPs = IPs.filter(item=>(isPublicIPv4(item))&&item.indexOf('d')==-1)
let newIPs = [...new Set(tempIPs)];
if(newIPs.length>500)newIPs.length=500
if(change_show_domain)$.post('https://www.moodtracks.cn:6789/get_rdns',{data : JSON.stringify(newIPs)},(res)=>{
if(res.status==200){
let data = res.data
//console.log(data)
DNSptrData = data
handlerIPs()
}
},"json")
}
//CSS
const ip_info_css=`position: absolute;bottom:0;left:0;border:1px solid red;width:100px;height:50px;`
// 点击查看连接类型
$('#listModal').on('click','.id_info',function(){
let cid = $(this).text()
$("#id_info").text(cid)
$("#id_update_time").text('')
$("#appid_name").val('')
$("#save_appid_name").prop("disabled",true)
$(".appid_name_mask").show()
$.post('https://www.moodtracks.cn:8888/get_name',{data : JSON.stringify([cid])},(res)=>{
if(res.status==200){
let data = res.data
//console.log(data)
if(data.length && data.length > 0){
data.forEach(item=>{
if(item.id == cid){
$("#appid_name").val(item.current_name)
$("#id_update_time").text("更新时间:"+item.update_time)
}
})
}
$(".appid_name_mask").hide()
$("#save_appid_name").prop("disabled",false)
}else{
message("warning","请求失败2")
console.log("https://www.moodtracks.cn:8888/get_name请求失败")
}
},"json")
$("#appid_info_wrapper").show()
$('#ip_domain_info_wrapper').hide()
})
$('#listModal').on('click','#save_appid_name',function(){
//console.log($("#id_info").text(),$("#appid_name").val())
if (confirm("确定保存吗?")) {
$.post('https://www.moodtracks.cn:8888/_update_name',{data : JSON.stringify([{
id:$("#id_info").text(),
current_name:$("#appid_name").val()
}])},(res)=>{
if(res.status==200){
message("success","保存成功")
$("#appid_info_wrapper").hide()
}else{
message("warning","保存失败2")
console.log("https://www.moodtracks.cn:8888/_update_name保存失败2")
}
},"json")
}
})
$('#listModal').on('click','.ip_info',function(){
currentIP = $(this).attr('data-ip')
currentIPData = DNSptrData.filter(item=>item.ip == currentIP)
$('#ip_info_ip').text(currentIP)
let html = ''
if(currentIPData.length>0){
$('#ip_info_isp').text(currentIPData[0].ipshudi)
let bound_domain_data = currentIPData[0].bound_domain?JSON.parse(currentIPData[0].bound_domain) : []
let custom_name_data = currentIPData[0].custom_name?JSON.parse(currentIPData[0].custom_name) : []
if(bound_domain_data.length>0){
bound_domain_data.forEach(item=>{
html += `
${item.domain}
${item.date}
`
})
}else{
html = ` `
}
if(custom_name_data.length>0){
$('#curstom_name_val').val(custom_name_data[0].domain)
$('#curstom_name_update').text(custom_name_data[0].date)
}else{
$('#curstom_name_val').val('')
$('#curstom_name_update').text('')
}
$('#ip_info_update').text('更新时间:'+currentIPData[0].update_time)
}else{
$('#ip_info_isp').text('')
html = ` `
$('#curstom_name_val').val('')
$('#curstom_name_update').text('')
$('#ip_info_update').text('')
}
$('#bound_domain_wrapper').html(html)
$('#ip_domain_info_wrapper').show()
//console.log(currentIP,currentIPData)
})
// 点击连接数查看详情
{
//setInterval(()=>{ $("#tblMain>tr>.conntrack").off('click'); },100)
setTimeout(()=>{ $(document).on("click","#tblMain>tr>td.txt",function(){ ipDetail(0,$(this).parent().find('.ip').attr("data")) }) })
if(0)$(document).on({mouseenter: function() { $(this).css({cursor:"pointer",color:"#26a3e9"});},
mouseleave: function() { $(this).css({color:"#505459"}) } }, '#tblMain>tr>td:first-child');
//CSS
$(document).on({mouseenter: function() { $(this).css({cursor:"pointer",color:"#26a3e9"});},
mouseleave: function() { $(this).css({color:"#505459"}) } }, '#tblMain>tr>td.txt');
$(document).on({mouseenter: function() { $(this).css({cursor:"pointer",color:"#26a3e9"});},
mouseleave: function() { $(this).css({color:"#505459"}) } }, '.connect_table>.tbody>tr');
let currentBgc = ''
$('#listModal').on({mouseenter: function() { currentBgc = $(this).css("background-color");if(change_show_domain)$(this).css("background-color","#b6e0f7")},
mouseleave: function() { if(change_show_domain)$(this).css("background-color",currentBgc) } }, '.self-table.connect_table>tbody tr');
//排序点击事件
$('.do_sort_connect').on('click', function() {
//console.log('排序点击事件')
handlerIPs()
});
//上下页点击事件
$(".page-box:eq(1) .jump-page.next,.page-box:eq(1) .jump-page.prev").click(()=>{
//console.log('分页点击事件')
handlerIPs()
})
//跳转按钮点击事件
$(".jump_btn_connect").on('click', function() {
//console.log('跳转按钮点击事件')
handlerIPs()
});
//连接列表关闭按钮
$(".sure").on('click', function() {
//console.log('连接列表关闭按钮事件')
$('#ip_domain_info_wrapper,#appid_info_wrapper').hide()
});
//内网主机列表点击事件
$("#tblMain").on('click', function() {
//console.log('内网主机列表点击事件')
$('#ip_domain_info_wrapper,#appid_info_wrapper').hide()
});
// 请求过滤器
$.ajaxPrefilter(function (options, originalOptions, jqXHR) {
if(options.url.indexOf('/show_connect.htm')!=-1){
//console.log(options)
//console.log(options.data)
try{
show_connectData = JSON.parse(decodeURIComponent(options.data.split('=')[1]))
}catch(e){
console.log('请求过滤器出错:/show_connect.htm',e)
show_connectData = {ip: '', wan: 'all'}
}
// 保存原始的success回调函数
let originalSuccess = options.success;
// 修改options.success来添加自定义的回调
options.success = function(data, status, jqXHR) {
//console.log(data)
// 在这里修改响应数据
//let modifiedData = data;
// 调用原始的success回调函数,传入修改后的数据
if (originalSuccess) {
originalSuccess(data, status, jqXHR);
}
//console.log(data)
if(options.url.indexOf('false')==-1) getDNSptr(data)
};
}
})
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// 流控设置
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if(0&&$(".sidebar_nav>li").eq(3).find("span").text()=="流控设置")$(".sidebar_nav>li").eq(3).click(()=>{
location.href = "/index.htm?PAGE=fluid&new=1"
})
if (location.search.indexOf("?PAGE=fluid&new=1") !== -1) {
$(".sidebar_nav>li:nth(3) a:nth(0)").css("color","#484848")
$(".sidebar_nav>li:nth(3) a:nth(0)").hover(function(){$(this).css("color","#1592d8")},function(){$(this).css("color","#484848")})
$(".back_center>div.box").html(`
`)
$("#intelligent_flow_control")
}
// 流量识别
if (isFlowIdentifi && location.search=="?PAGE=flow_identifi"){
//添加滑块开关
$("div.pdg20-LR>div.box-tit").append(`
`)
$("body>div.right").css("overflow","visible")
$("div.pdg20-LR").css("position","relative")
$("div.pdg20-LR>div.box-tit>a")?.remove()
$("div.seitchH-radio").after(`
`)
// CSS
{
$("ul.all_identifi>li").css({
display:"flex",
justifyContent:"space-between",
width:"170px",
marginRight:"70px",
})
//hover
$(".save_identifi_btn,.add_identifi_btn").hover(function () { $(this).css({backgroundColor:"#39ade6"}) }, function () { $(this).css({backgroundColor:"#26a3e9"}) });
$(".delAll_identifi_btn").hover(function () { $(this).css({color:"#ff7875"}) }, function () { $(this).css({color:"#ff4d4f"}) });
$(".open_identifi_btn").hover(function () { $(this).css({backgroundColor:"#f0f0f0"}) }, function () { $(this).css({backgroundColor:"#fff"}) });
$(document).on({mouseenter: function() { $(this).css({color:"#79baff"}) },
mouseleave: function() { $(this).css({color:"#26a3e9"}) } }, '.edit_customize_identifi');
$(document).on({mouseenter: function() { $(this).css({color:"#ff7875"}) },
mouseleave: function() { $(this).css({color:"#ff4d4f"}) } }, '.del_customize_identifi');
}
// 初始化识别状态
initIdentifiState()
// 滑块开关点击事件
let changeFlowIde = JSON.parse(localStorage.getItem('changeFlowIde'))!=null?JSON.parse(localStorage.getItem('changeFlowIde')):true;
$("#changeFlowIde")[0].checked = changeFlowIde
$("#all_identifi").css("z-index",changeFlowIde?"1":"-1")
$("#all_identifi").css("opacity",changeFlowIde?"1":"0")
changeFlowIde?$("ul.fluid>li:last-child").css("display","block"):''
$("#changeFlowIde").click(function(){
if($("#changeFlowIde")[0].checked){
$("ul.fluid>li:last-child").css("display","block")
initIdentifiState()
JSON.stringify(localStorage.setItem('changeFlowIde',true))
$("#all_identifi").css("z-index","1")
$("#all_identifi").css("opacity","1")
}else{
if($('div.menu>label input[type="radio"]:checked').val()!=='自定义识别')$("ul.fluid>li:last-child").css("display","none");
JSON.stringify(localStorage.setItem('changeFlowIde',false))
$("#all_identifi").css("z-index","-1")
$("#all_identifi").css("opacity","0")
}
})
$(".save_identifi_btn").click(()=>{
let saveState = 0
let failRecord = ''
$.get('/action/code_ident2.htm',{data:JSON.stringify({able:$("#s10").prop('checked')?'1':'0',var:$(".property_cont .var_tip").text(),})},(msg)=>{
if (msg.state == 1) { saveState++ }else{ failRecord += '(特征库识别)'; }
$.get('/action/auto_ident2.htm',{data:JSON.stringify({able:$("#s20").prop('checked')?'1':'0'})},(msg)=>{
if (msg.state == 1) { saveState++ }else{ failRecord += '(流量智能识别)'; }
$.get('/action/cloud_ident2.htm',{data:JSON.stringify({able:$("#s30").prop('checked')?'1':'0'})},(msg)=>{
if (msg.state == 1) { saveState++ }else{ failRecord += '(智能云识别)'; }
$.get('/action/client_ident_write.htm',{data:JSON.stringify({able:$("#s40").prop('checked')?'1':'0'})},(msg)=>{
if (msg.state == 1) { saveState++ }else{ failRecord += '(客户端识别)'; }
if(saveState==4) {
message('success','保存成功...',true,2000)
setTimeout(()=>{ location.reload() },1000)
}
}, 'json');
}, 'json');
}, 'json');
}, 'json');
setTimeout(()=>{ if(saveState!==4) {message('warning',failRecord+'保存失败!')} },5000)
})
$(".open_identifi_btn").click(()=>{ $("#s10,#s20,#s30,#s40").prop('checked', true) })
$(".add_identifi_btn").click(()=>{
//$('#add_edit_mask').css("display","flex")
// 原版模态框
showKeyFilterForm()
})
$(".delAll_identifi_btn").click(()=>{
if(confirm("确认删除全部?")){
//删除全部
$.post('/action/protocol_diy_write.htm',{data : JSON.stringify([])},(msg)=>{ if (msg.state == 1){
message('success','删除成功...',true,2000);
} }, 'json');
}
})
$(document).on('click','#customize_identifi span.edit_customize_identifi',(e)=>{
//console.log($(e.currentTarget).attr('data'))
//$('#add_edit_mask').css("display","flex")
// 原版模态框
editKeyFilter($(e.currentTarget).attr('data'))
//console.log()
})
$(document).on('click','#customize_identifi span.del_customize_identifi',(e)=>{
if(confirm("确认删除?")){
data["keyfilterpage"].splice($(e.currentTarget).attr('data'), 1)
$.post('/action/protocol_diy_write.htm',{data : JSON.stringify(data["keyfilterpage"])},(msg)=>{ if (msg.state == 1){
message('success','删除成功...',true,2000);
} }, 'json');
}
})
// 初始化识别状态
function initIdentifiState(){
const columns = [
{
title: '状态',
dataIndex: 'able',
key: 'able',
},
{
title: '地址范围',
dataIndex: 'addrDomain',
key: 'addrDomain',
},
{
title: '协议',
dataIndex: 'proto',
key: 'proto',
},
{
title: '端口',
dataIndex: 'port',
key: 'port',
},
{
title: '匹配策略',
dataIndex: 'martch',
key: 'martch',
},
{
title: '关键信息',
dataIndex: 'keyInfo',
key: 'keyInfo',
},
{
title: '数据类型',
dataIndex: 'dataType',
key: 'dataType',
},
{
title: '备注',
dataIndex: 'note',
key: 'note',
},
{
title: '操作',
dataIndex: 'action',
key: 'action',
},
]
const dataSource = []
$.get('/action/code_ident.htm',(msg)=>{ $("#s10").prop("checked",msg.able==1?true:false); },'json');
$.get('/action/auto_ident.htm',(msg)=>{ $("#s20").prop("checked",msg.able==1?true:false); },'json');
$.get('/action/cloud_ident.htm',(msg)=>{ $("#s30").prop("checked",msg.able==1?true:false); },'json');
$.get('/action/client_ident_read.htm',(msg)=>{ $("#s40").prop("checked",msg.able==1?true:false); },'json');
$.get('/action/protocol_diy_read.htm',(msg)=>{
if(msg.length&&msg.length>0){
msg.forEach((item,index)=>{
dataSource.push({
key:index,
able: item.able=='1'?`启用`:"禁用",
addrDomain: item.sip+'-'+item.eip,
proto: item.proto,
port: item.sport+'-'+item.eport,
martch: martchConvert(item.martch),
keyInfo: item.key.length?(item.key[0]?(item.key.length>1?(item.key[0]+' ...'):item.key[0]):'无'):'-',
dataType: dataTypeConvert(item.action),
note: item.note,
action: `编辑
删除`,
})
})
}
table("#customize_identifi", dataSource, columns,false,{isSort:false,height:"40px"})
},'json');
function martchConvert(a){
if(a=='bin'){return '特征码'}else if(a=='long'){return '特征码长度'}else if(a=='ip'){return 'IP'}else if(a=='none'){return '无'}else{return '-'}
}
function dataTypeConvert(a){
if(a=='game'){return '游戏'}else if(a=='down'){return '网页下载'}else if(a=='http'){return '网页资源'}else if(a=='p2p'){return 'p2p下载'}else{return '-'}
}
}
}
// 优先级设置
if (location.search == "?PAGE=soft_pro") {
// 一键默认按钮
if(isSoftPro){
$("div.div-tab.fl.fc").append(`
一键默认
`)
//hover
$(".soft_pro_default").hover(function () {
$(this).css({backgroundColor:"#f0f0f0"})
//$(".bottom_line").css({width: "48px",marginLeft:"0px"})
}, function () {
$(this).css({backgroundColor:"#fff"})
//$(".bottom_line").css({width: "0px",marginLeft:"24px"})
});
$(".soft_pro_default").click(()=>{
$(".game").val('0');
$(".pat").val('0');
$(".http").val('0');
$(".im").val('0');
$(".soft").val('0');
$(".down").val('0');
$(".vio").val('0');
$(".unknow").val('0');
$(".p2p").val('0');
})
}
// 显示所有
if(1){
//添加滑块开关
$("div.pdg20-LR>div.box-tit").append(`
`)
// 滑块开关点击事件
let changeSoftPro = JSON.parse(localStorage.getItem('changeSoftPro'))!=null?JSON.parse(localStorage.getItem('changeSoftPro')):true;
$("#change_soft_pro")[0].checked = changeSoftPro
$(".pdg20-LR>ul.fluid>li:last-child").before(`
端口优先级
`)
$(".pdg20-LR>ul.fluid>li.smart_cont tr:last-child>td").css("padding-bottom","80px")
if(changeSoftPro){
$(".soft_pro_title").css("display","block");
$(".pdg20-LR>ul.fluid>li").css("display","list-item")
$(".seitchH-radio+div.H20").css("display","none")
$(".seitchH-radio").css("display","none")
}
$("#change_soft_pro").click(function(){
if($("#change_soft_pro")[0].checked){
JSON.stringify(localStorage.setItem('changeSoftPro',true))
$(".seitchH-radio+div.H20").css("display","none")
$(".pdg20-LR>ul.fluid>li").css("display","list-item")
$(".soft_pro_title").css("display","block");
$(".seitchH-radio").css("display","none")
}else{
JSON.stringify(localStorage.setItem('changeSoftPro',false))
$(".seitchH-radio+div.H20").css("display","block");
$("ul.fluid>li:not(:first-child)").css("display","none");
$(".soft_pro_title").css("display","none");
$(".seitchH-radio").css("display","block")
if($('div.menu>label input[type="radio"]:checked').val()=='端口优先级'){
$('.radio:first-child').click()
}
}
})
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// 线路分流
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// 应用软件分流
if (location.search.indexOf("?PAGE=software") !== -1) {
// 拖拽调整优先级
if(0)setTimeout(()=>{
// hover
let currentBgc = ''
$(".li1, .li2, .li3").on({mouseenter: function() { currentBgc = $(this).css("background-color");if(true)$(this).css("background-color","#b6e0f7")},
mouseleave: function() { if(true)$(this).css("background-color",currentBgc) } }, 'tbody:first tr');
$(".li1, .li2, .li3").find("tbody:eq(0) tr td:last-child").each(function() {
// 使用 jQuery 的 filter 方法来选择索引大于或等于3的 img 元素
$(this).find("img").filter(index => index >= 3).remove(); // 直接移除选中的元素
});
$(".li1, .li2, .li3").find("tbody:eq(0) tr td:last-child").append(`
`)
$(".li1, .li2, .li3").find("tbody:eq(0) tr td:last-child").css("position","relative")
const $draggables = $('.moveTr');
let $draggedElement = null;
let $draggedElementTop = null;
let $table = null;
let offsetY = 0; //鼠标相对于拖拽元素的垂直偏移量
let $placeholder = $('').hide(); // 占位符元素
$($draggables).on('mousedown', function (e) {
// 禁用文本选择
$('body').css('user-select', 'none');
// 添加占位符到DOM中
$('body').append($placeholder);
$draggedElement = $(this).parent().parent();
$draggedElementTop = $draggedElement.offset().top;
$table = $draggedElement.parent().parent();
offsetY = e.pageY - $draggedElement.offset().top;//当前元素tr高度
currentBgc = $draggedElement.css("background-color")
currentBgc = (currentBgc.indexOf('240')==-1)?'#fff':currentBgc
$draggedElement.css("background-color",currentBgc)
//$draggedElement.parent().css("position","relative")
let $hideEle = $('
').append($draggedElement.html())
$hideEle.find("td:first")//.append(``)
$draggedElement.parent().append($hideEle)
$table.after(``)
//console.log(e.pageY,$draggedElement.offset().top,$(".currentEle").offset().top)
let oldTranslateY = -$(".currentEle").offset().top-offsetY
$draggedElement.css({"opacity":".3","border":"2px dashed #0073e1"})
$(".currentEle").css('transform','translateY('+ (oldTranslateY + e.pageY) + 'px)');
$(".tbody_mask").css("bottom",oldTranslateY + e.pageY)
// 开始拖拽时,监听全局的mousemove和mouseup事件
$(document).on('mousemove.drag', function (e) {
if ($draggedElement) {
//let newTranslateY = e.pageY-oldTranslateY
let newTranslateY = oldTranslateY + e.pageY
const newTop = e.pageY - offsetY;
//console.log(e.pageY , offsetY,newTop)
//console.log($draggedElement,newTranslateY)
$(".currentEle").css('transform','translateY('+ newTranslateY + 'px)');
$(".tbody_mask").css("bottom",newTranslateY)
// 检查是否与其他拖拽元素重叠,并插入占位符
$draggables.parent().parent().not($draggedElement).each(function () {
const $this = $(this);
const thisTop = $this.offset().top;
const thisHeight = $this.outerHeight();
$this.css("background-color",(($this.css("background-color").indexOf("240")!=-1)?$this.css("background-color"):"#fff"))
console.log($this.find(".note").text(),thisTop,thisHeight)
if(0)if(newTop>$draggedElementTop+$draggedElement.outerHeight()+(thisHeight/2)&&thisHeight/2!=0){
console.log(newTop,$draggedElementTop,thisHeight/2)
if(newTop-(thisHeight/2)thisTop){
console.log(newTop,thisTop);
$this.css('transform','translateY('+ (-$draggedElement.outerHeight()+1) + 'px)');
}
});
}
});
$(document).on('mouseup.drag', function (e) {
if ($draggedElement) {
//console.log(currentBgc)
$draggedElement.css({"backgroundColor":currentBgc,"border":"none",'transform':'translateY(0px)',"opacity":"1"})
$(".currentEle").css('transform','translateY(0px)');
$(".currentEle").remove()
$(".tr_mask").remove()
// 停止拖拽时,移除全局事件监听器
$(document).off('.drag');
// 启用文本选择
$('body').css('user-select', '');
// 隐藏占位符
$placeholder.hide();
// 重置拖拽元素变量
$draggedElement = null;
}
});
// 阻止默认行为和冒泡
e.preventDefault();
e.stopPropagation();
});
/*$("body").mouseup(function(event) {
if (event.which === 1) {
}
});*/
if(0)$(".li1, .li2, .li3").mouseleave(function(){
// 当鼠标离开元素时执行的代码
console.log("鼠标已离开元素!");
// 你可以在这里添加任何你想要的逻辑,比如停止拖拽
// 重新启用文本选择
$('body').css('user-select', '');
});
},1000)
}
if(0&&$(".sidebar_nav>li").eq(4).find("span").text()=="线路分流")$(".sidebar_nav>li").eq(4).click(()=>{
location.href = "/index.htm?PAGE=software&new=1"
})
if (location.search.indexOf("?PAGE=software&new=1") !== -1) {
$(".sidebar_nav>li:nth(4) a:nth(0)").css("color","#484848")
$(".sidebar_nav>li:nth(4) a:nth(0)").hover(function(){$(this).css("color","#1592d8")},function(){$(this).css("color","#484848")})
//$(".back_center>div.box").html(``)
}
// 协议分流
if (location.search.indexOf("?PAGE=protocol") !== -1) {
// 拖拽调整优先级
if(0)setTimeout(()=>{
// hover
let currentBgc = ''
$("li.PPPOE_div").on({mouseenter: function() { currentBgc = $(this).css("background-color");if(true)$(this).css("background-color","#b6e0f7")},
mouseleave: function() { if(true)$(this).css("background-color",currentBgc) } }, 'tbody:first tr');
$("li.PPPOE_div").find("tbody:eq(0) tr td:last-child").each(function() {
// 使用 jQuery 的 filter 方法来选择索引大于或等于3的 img 元素
$(this).find("img").filter(index => index >= 3).remove(); // 直接移除选中的元素
});
$("li.PPPOE_div").find("tbody:eq(0) tr td:last-child").append(`
`)
$("li.PPPOE_div").find("tbody:eq(0) tr td:last-child").css("position","relative")
let num = 0
$("li.PPPOE_div").find("tbody:eq(0) tr").each(function(index){
$(this).addClass('priority'+index)
$(this).attr('data-priority', index)
$(this).attr('data-index', index)
$(this).css('transition', 'all .3s linear')
})
const $draggables = $('.moveTr');
let $draggedElement = null;
let $draggedElementTop = null;
let $table = null;
let offsetY = 0; //鼠标相对于拖拽元素的垂直偏移量
let $placeholder = $('').hide(); // 占位符元素
let moveli = []; //优先级调整暂存
let tempClass = '';
$($draggables).on('mousedown', function (e) {
// 禁用文本选择
$('body').css('user-select', 'none');
// 添加占位符到DOM中
$('body').append($placeholder);
moveli = []
tempClass = ''
let test1 = 0
$draggedElement = $(this).parent().parent();
let currentClass = $draggedElement.attr('class');
$draggedElementTop = $draggedElement.offset().top;
$table = $draggedElement.parent().parent();
offsetY = e.pageY - $draggedElement.offset().top;//当前元素tr高度
currentBgc = $draggedElement.css("background-color")
currentBgc = (currentBgc.indexOf('240')==-1)?'#fff':currentBgc
$draggedElement.css("background-color",currentBgc)
//$draggedElement.parent().css("position","relative")
let $hideEle = $('
').append($draggedElement.html())
$hideEle.find("td:first")//.append(``)
$draggedElement.parent().append($hideEle)
$table.after(``)
//console.log(e.pageY,$draggedElement.offset().top,$(".currentEle").offset().top)
let oldTranslateY = -$(".currentEle").offset().top-offsetY
$draggedElement.css({"opacity":".3","border":"1px dashed #0073e1"})
$(".currentEle").css('transform','translateY('+ (oldTranslateY + e.pageY) + 'px)');
$(".tbody_mask").css("bottom",oldTranslateY + e.pageY)
// 开始拖拽时,监听全局的mousemove和mouseup事件
$(document).on('mousemove.drag', function (e) {
if ($draggedElement) {
//let newTranslateY = e.pageY-oldTranslateY
let newTranslateY = oldTranslateY + e.pageY
const newTop = e.pageY - offsetY;
//console.log(e.pageY , offsetY,newTop)
//console.log($draggedElement,newTranslateY)
$(".currentEle").css('transform','translateY('+ newTranslateY + 'px)');
$(".tbody_mask").css("bottom",newTranslateY)
// 检查是否与其他拖拽元素重叠,并插入占位符
$draggables.parent().parent().not($draggedElement).each(function () {
const $this = $(this);
const thisTop = $this.offset().top;
const thisHeight = $this.outerHeight();
$this.css("background-color",(($this.css("background-color").indexOf("240")!=-1)?$this.css("background-color"):"#fff"))
//console.log($this.find(".note").text(),thisTop,thisHeight)
//console.log(e.pageY-offsetY) //当前拖动元素的top
// 拖动元素与其他元素重叠
if(thisTop - (thisHeight/2) < (e.pageY-offsetY) && (thisTop + (thisHeight/2) > (e.pageY-offsetY))){
//console.log($this.find(".note").text(),thisTop,thisHeight,e.pageY)
if(tempClass != $this.attr('class')){
tempClass = $this.attr('class')
console.log($draggedElement.attr('data-index'),$this.attr('data-index'),thisTop)
let test2 = thisTop
if(test1 thisTop ? 1 : 0,$draggables.parent().parent(),$draggedElement,{test1,test2})
}
}
if(0)if(newTop>$draggedElementTop+$draggedElement.outerHeight()+(thisHeight/2)&&thisHeight/2!=0){
console.log(newTop,$draggedElementTop,thisHeight/2)
if(newTop-(thisHeight/2)thisTop){
console.log(newTop,thisTop);
$this.css('transform','translateY('+ (-$draggedElement.outerHeight()+1) + 'px)');
}
});
}
});
$(document).on('mouseup.drag', function (e) {
if ($draggedElement) {
//console.log(currentBgc)
//$draggedElement.css({"backgroundColor":currentBgc,"border":"none",'transform':'translateY(0px)',"opacity":"1"})
$draggedElement.css({"backgroundColor":currentBgc,"border":"none","opacity":"1"})
//$(".currentEle").css('transform','translateY(0px)');
$(".currentEle").remove()
$(".tr_mask").remove()
// 停止拖拽时,移除全局事件监听器
$(document).off('.drag');
// 启用文本选择
$('body').css('user-select', '');
// 隐藏占位符
$placeholder.hide();
// 重置拖拽元素变量
$draggedElement = null;
}
});
// 阻止默认行为和冒泡
e.preventDefault();
e.stopPropagation();
});
function handlerPri(_cruCla,_class,_isUp,_allTr,_$draggedElement,_dir_size){
console.log(_dir_size)
let curH = $('.'+_cruCla).height() + 2
let newAllTr = _allTr.filter(index => {
let startI = 0
let endI = 0
if($draggedElement.attr('data-index') - $('.'+_class).attr('data-index') > 0){
startI = $('.'+_class).attr('data-index') * 1
endI = $draggedElement.attr('data-index') * 1
return index >= startI && index < endI
}else{
startI = $draggedElement.attr('data-index') * 1
endI = $('.'+_class).attr('data-index') * 1
return index > startI && index <= endI
}
})
newAllTr.each(function (){
const $this = $(this);
if(_isUp){
/*if($this.css('transform').indexOf('translateY(0px)')!=-1){
$this.css('transform','translateY('+ curH + 'px)')
}else{
$this.css('transform','translateY(0px)')
}*/
$this.attr('data-translateY', curH);
$this.css('transform','translateY('+ curH + 'px)')
}else{
/*if($this.css('transform').indexOf('translateY(0px)')!=-1){
$this.css('transform','translateY(-'+ curH + 'px)')
}else{
$this.css('transform','translateY(0px)')
}*/
$this.attr('data-translateY', -curH);
$this.css('transform','translateY(-'+ curH + 'px)')
}
//console.log($this[0])
})
console.log(
curH,
_class,
_isUp?'上':'下',
// _allTr
)
if(_isUp){
_$draggedElement.attr('data-translateY',_$draggedElement.attr('data-translateY')? _$draggedElement.attr('data-translateY')-curH : -curH);
_$draggedElement.css('transform','translateY('+ _$draggedElement.attr('data-translateY') + 'px)')
}else{
_$draggedElement.attr('data-translateY',_$draggedElement.attr('data-translateY')? _$draggedElement.attr('data-translateY')-curH : -curH);
_$draggedElement.css('transform','translateY('+(-_$draggedElement.attr('data-translateY') + 'px)'))
}
//console.log(-_$draggedElement.attr('data-translateY'))
}
/*$("body").mouseup(function(event) {
if (event.which === 1) {
}
});*/
if(0)$(".li1, .li2, .li3").mouseleave(function(){
// 当鼠标离开元素时执行的代码
console.log("鼠标已离开元素!");
// 你可以在这里添加任何你想要的逻辑,比如停止拖拽
// 重新启用文本选择
$('body').css('user-select', '');
});
},1000)
}
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//Ping检测
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if (location.search.indexOf("?PAGE=ping") !== -1) {
// Ping
sdPing()
// 检测日志
if(isOnPingLog)checkLog()
function sdPing(){
let checkPingTimer
let pingLength = 0
let isBottom = 1
$(".result").parent().parent().parent().append(`
置底 |
|
`)
$("#isBottom")[0].checked = true
$("#isBottom").click(function(){
if(this.checked){
isBottom = 1
}else{
isBottom = 0
}
})
$.get('/action/ping.htm',function(msg){
//console.log(msg)
if(msg && msg.if) setTimeout(()=>{$('.if').val(msg.if)},500)
},"JSON")
checkPingTimer = setInterval(function(){
$.get('/action/ping_result.htm',function(msg){
try{
if(pingLength == msg.length){
//console.log("停止")
$(".stop").hide();
clearInterval(checkPingTimer);
}else{
//console.log("正在ping")
pingLength==0 || $(".stop").show();
$(".result").css("width","100%");
$(".result").val(msg);
}
pingLength = msg.length
}catch(e){
console.log("错误:",e)
clearInterval(checkPingTimer);
}
});
},1000);
// 请求过滤器
$.ajaxPrefilter(function (options, originalOptions, jqXHR) {
if(options.url.indexOf('/ping_result.htm')!=-1){
//console.log(options)
//console.log(options.data)
// 保存原始的success回调函数
let originalSuccess = options.success;
// 修改options.success来添加自定义的回调
options.success = function(data, status, jqXHR) {
//console.log(data)
// 在这里修改响应数据
//let modifiedData = data;
// 调用原始的success回调函数,传入修改后的数据
if (originalSuccess) {
originalSuccess(data, status, jqXHR);
}
if(isBottom){
// 或使用平滑滚动动画
$('.result').animate({
scrollTop: $('.result').prop('scrollHeight')
}, 500); // 500ms为动画时长
}
};
}
})
}
function checkLog(){
let changeLog = JSON.parse(localStorage.getItem('changeLog'))!=null?JSON.parse(localStorage.getItem('changeLog')):true;
$("ul.detail-info>li").eq(3).append(``)
$("#ping_check_log_wra").append(` ↑
`)
//回到顶部按钮
$("#back-to-top").hover(function(){
// 鼠标移入时的处理逻辑
$(this).css("background-color","#f0f0f0")
}, function(){
// 鼠标移出时的处理逻辑
$(this).css("background-color","#fff")
});
$('#back-to-top').click(function() {
// 使用animate()方法来平滑地滚动到页面顶部
$('body, html').animate({
scrollTop: 0
}, 500); // 500是动画的持续时间,以毫秒为单位
return false; // 阻止链接的默认行为(如果有的话)
});
//监听滚动条
$(window).scroll(function() {
if ($(window).scrollTop() > 666) {
$("#back-to-top").css("display","block")
}else{
$("#back-to-top").css("display","none")
}
});
//获取线路并添加到下拉列表
$.get('/action/wan_line_name_show.htm',(res)=>{
let ele = '