From 8f0d3de33ac1711da5ba26119f823f67dc8a886e Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Fri, 30 Apr 2021 17:00:14 +0800 Subject: [PATCH] fix: display misplaced when the content is too short --- README.md | 2 +- assets/js/main.js | 11 +++++------ assets/js/main.min.js | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6b04b04..f051ae1 100644 --- a/README.md +++ b/README.md @@ -317,7 +317,7 @@ Detail: 美国俄亥俄州哥伦布市DoD网络信息中心 数据库文件位于 `backend/qqwry.dat`,数据库更新脚本位于 `backend/qqwryUpdate.sh`,查询代码位于 `backend/qqwry.php`,数据解析服务位于 `backend/qqwryFormat/*` -Docker部署方式中,容器内已经预留了 `qqwry.dat` 的自动升级功能,每天00:00时会运行脚本拉取数据库更新。对于其他部署方式,可以配置 `crontab` 自动执行更新脚本,示例如下 +Docker部署方式中,容器内已经预留了 `qqwry.dat` 的自动升级功能,每天00:00时会运行脚本拉取数据库更新。对于常规部署方式,可以配置 `crontab` 自动执行更新脚本,示例如下 ``` # 打开crontab任务列表 diff --git a/assets/js/main.js b/assets/js/main.js index daeedd9..064e1d2 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -94,12 +94,11 @@ function unlockMap() { if (!isPortrait()) { return; } - $('.positioncontrol').css('left', '0'); - $('.positioncontrol').css('right', ''); - var objWidth = $(".positioncontrol").css('width'); - objWidth = objWidth.substr(0, objWidth.length - 2); - var left = ($(document).width() - objWidth) / 2; - $(".positioncontrol").css('left', left + 'px'); + var margin = $('#output').css('margin-left'); + if (margin !== '0px') { + $('.positioncontrol').css('left', margin); + $('.positioncontrol').css('right', margin); + } } function checkRange() { diff --git a/assets/js/main.min.js b/assets/js/main.min.js index d35eefd..cdfad4b 100644 --- a/assets/js/main.min.js +++ b/assets/js/main.min.js @@ -1 +1 @@ -var rangeSize=300,shareSize=61,shareX,shareY;function isPortrait(){return $(document).width()<$(document).height()||$(document).width()<800}function lockMap(){isPortrait()&&($(".positioncontrol").css("left","0"),$(".positioncontrol").css("right","0"))}function unlockMap(){if(isPortrait()){$(".positioncontrol").css("left","0"),$(".positioncontrol").css("right","");var objWidth=$(".positioncontrol").css("width");objWidth=objWidth.substr(0,objWidth.length-2);var left=($(document).width()-objWidth)/2;$(".positioncontrol").css("left",left+"px")}}function checkRange(){var distanceX=Math.abs(event.pageX-shareX),distanceY=Math.abs(event.pageY-shareY);(distanceX>=rangeSize||distanceY>=rangeSize)&&hideQRCode()}function hideQRCode(){$("#qrcode").is(":hidden")||$("#share").hide(200)}function showQRCode(){var ip=$("#ip").text();if("ok"==checkIP(ip)){var pageUri="https://"+window.location.host+"/?ip="+ip;$("#qrcode").attr("href",pageUri),$("#qrcode").empty(),$("#qrcode").qrcode({width:100,height:100,text:pageUri});var shareLeft=event.pageX-shareSize,shareTop=event.pageY-shareSize;shareLeft+2*shareSize>$(document).width()&&(shareLeft=$(document).width()-2*shareSize),shareTop+2*shareSize>$(document).height()&&(shareTop=$(document).height()-2*shareSize),shareLeft<0&&(shareLeft=0),shareTop<0&&(shareTop=0),shareX=shareLeft+shareSize,shareY=shareTop+shareSize,$("#qrcode").is(":hidden")?($("#share").css("left",shareLeft),$("#share").css("top",shareTop),$("#share").show(200)):$("#share").hide(100,(function(){$("#share").css("left",shareLeft),$("#share").css("top",shareTop),$("#share").show(150)}))}}function getInfo(){$.get("/info/"+$("input").val(),(function(data){if(console.log(data),"F"!=data.status){if($("input").val()||$("input").val(data.ip),$("button").text("Search"),$("#ip").text(data.ip),data.city=null==data.city?"Unknow":data.city,data.region=null==data.region?"Unknow":data.region,data.country=null==data.country?"Unknow":data.country,data.timezone=null==data.timezone?"Unknow":data.timezone,data.isp=null==data.isp?"Unknow":data.isp,data.scope=null==data.scope?"Unknow":data.scope,data.detail=null==data.detail||" "==data.detail?"Unknow":data.detail,$("#city").text(data.city),$("#region").text(data.region),$("#country").text(data.country),$("#timezone").text(data.timezone),$("#isp").text(data.isp),$("#scope").text(data.scope),$("#detail").text(data.detail),null==data.as)$("#as").text("Unknow");else{$("#as").text(data.as);var asUri="https://bgpview.io/asn/"+data.as.substr(2);$("#as").html(''+data.as+"")}if(null==data.loc)$("#loc").text("Unknow"),clear();else{var earthUri="https://earth.google.com/web/@"+data.loc+",9.963a,7999.357d,35y,-34.3h,45t,0r/data=KAI";$("#loc").html(''+data.loc+""),draw(parseFloat(data.loc.split(",")[0]),parseFloat(data.loc.split(",")[1]))}$("#table").show(500),setTimeout((function(){unlockMap()}),3e3)}else errorIP()}))}function getVersion(){$.get("/version",(function(data){console.log(data),data.qqwry=data.qqwry.slice(0,4)+"-"+data.qqwry.slice(4,6)+"-"+data.qqwry.slice(6,8),data.ipip=data.ipip.slice(0,4)+"-"+data.ipip.slice(4,6)+"-"+data.ipip.slice(6,8);var data_ver="";data_ver+="echoIP: "+data.echoip+"\n",data_ver+="纯真数据库: "+data.qqwry+"\n",data_ver+="IPIP.net数据库: "+data.ipip,alert(data_ver)}))}function trim(str){return str.replace(/(^\s*)|(\s*$)/g,"")}function errorIP(){$("button").text("Illegal IP"),$("button").css({"border-color":"#ff406f","background-color":"#ff406f"}),$("input").focus()}function checkIP(ipStr){if(null===ipStr)return"error";var regIPv4=/^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$/,regIPv6=/^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}(:[0-9A-Fa-f]{1,4}){1,2})|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){1,3})|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){1,4})|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){1,5})|([0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){1,6})|(:(:[0-9A-Fa-f]{1,4}){1,7})|(([0-9A-Fa-f]{1,4}:){6}(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){0,1}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|([0-9A-Fa-f]{1,4}:(:[0-9A-Fa-f]{1,4}){0,4}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(:(:[0-9A-Fa-f]{1,4}){0,5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}))$/,V4=ipStr.match(regIPv4),V6=ipStr.match(regIPv6);return null===V4&&null===V6?"error":"ok"}function getQuery(name){var reg=new RegExp("(^|&)"+name+"=([^&]*)(&|$)"),result=window.location.search.substr(1).match(reg);return null!=result?unescape(result[2]):null}function clear(){var map;new mapboxgl.Map({container:"map",style:"mapbox://styles/mapbox/streets-v11",center:[0,0],zoom:1}).on("load",(function(){console.log("reset map")}))}function draw(x,y){var size=100,map=new mapboxgl.Map({container:"map",style:"mapbox://styles/mapbox/streets-v11",center:[y,x],zoom:3}),pulsingDot={width:100,height:100,data:new Uint8Array(4e4),onAdd:function(){var canvas=document.createElement("canvas");canvas.width=this.width,canvas.height=this.height,this.context=canvas.getContext("2d")},render:function(){var duration=1e3,t=performance.now()%1e3/1e3,radius=15,outerRadius=35*t+15,context=this.context;return context.clearRect(0,0,this.width,this.height),context.beginPath(),context.arc(this.width/2,this.height/2,outerRadius,0,2*Math.PI),context.fillStyle="rgba(255, 200, 200,"+(1-t)+")",context.fill(),context.beginPath(),context.arc(this.width/2,this.height/2,15,0,2*Math.PI),context.fillStyle="rgba(255, 100, 100, 1)",context.strokeStyle="white",context.lineWidth=2+4*(1-t),context.fill(),context.stroke(),this.data=context.getImageData(0,0,this.width,this.height).data,map.triggerRepaint(),!0}};map.on("load",(function(){map.addImage("pulsing-dot",pulsingDot,{pixelRatio:2}),map.addLayer({id:"points",type:"symbol",source:{type:"geojson",data:{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[y,x]}}]}},layout:{"icon-image":"pulsing-dot"}})}))}mapboxgl.accessToken="pk.eyJ1Ijoic2hldm9ua3VhbiIsImEiOiJja20yMjlnNDYybGg2Mm5zNW40eTNnNnUwIn0.6xj6sgjWvdQgT_7OQUy_Jg",$(document).ready((function(){lockMap(),null===getQuery("ip")?getInfo():($("input").val(getQuery("ip")),getInfo()),$("#table").hide(),$("#share").hide(),$("button").click((function(){$(this).css({"border-color":"","background-color":""}),$(this).text("Searching..."),lockMap(),$("#table").hide(500),$("input").val(trim($("input").val())),""==$("input").val()||"ok"==checkIP($("input").val())?getInfo():errorIP()})),$("button").dblclick((function(event){event.stopPropagation(),getVersion()})),$("input").dblclick((function(event){event.stopPropagation()})),$("table").dblclick((function(event){event.stopPropagation()})),$("#output").dblclick((function(){showQRCode()})),$("#output").click((function(){hideQRCode()})),$("#map").click((function(){hideQRCode()})),$("body").mousemove((function(){checkRange()})),$("body").mouseleave((function(){hideQRCode()})),$(window).resize((function(){isPortrait()?($(".positioncontrol").css("left","0"),$(".positioncontrol").css("right","0"),$(".positioncontrol").css("transform","translate(0, 0)")):($(".positioncontrol").css("left","calc(80vw - 180px)"),$(".positioncontrol").css("right",""),$(".positioncontrol").css("transform","translate(-20%, 0)"))}))})),$(document).keydown((function(event){13==event.keyCode&&$("button").focus()})); \ No newline at end of file +var rangeSize=300,shareSize=61,shareX,shareY;function isPortrait(){return $(document).width()<$(document).height()||$(document).width()<800}function lockMap(){isPortrait()&&($(".positioncontrol").css("left","0"),$(".positioncontrol").css("right","0"))}function unlockMap(){if(isPortrait()){var margin=$("#output").css("margin-left");"0px"!==margin&&($(".positioncontrol").css("left",margin),$(".positioncontrol").css("right",margin))}}function checkRange(){var distanceX=Math.abs(event.pageX-shareX),distanceY=Math.abs(event.pageY-shareY);(distanceX>=rangeSize||distanceY>=rangeSize)&&hideQRCode()}function hideQRCode(){$("#qrcode").is(":hidden")||$("#share").hide(200)}function showQRCode(){var ip=$("#ip").text();if("ok"==checkIP(ip)){var pageUri="https://"+window.location.host+"/?ip="+ip;$("#qrcode").attr("href",pageUri),$("#qrcode").empty(),$("#qrcode").qrcode({width:100,height:100,text:pageUri});var shareLeft=event.pageX-shareSize,shareTop=event.pageY-shareSize;shareLeft+2*shareSize>$(document).width()&&(shareLeft=$(document).width()-2*shareSize),shareTop+2*shareSize>$(document).height()&&(shareTop=$(document).height()-2*shareSize),shareLeft<0&&(shareLeft=0),shareTop<0&&(shareTop=0),shareX=shareLeft+shareSize,shareY=shareTop+shareSize,$("#qrcode").is(":hidden")?($("#share").css("left",shareLeft),$("#share").css("top",shareTop),$("#share").show(200)):$("#share").hide(100,(function(){$("#share").css("left",shareLeft),$("#share").css("top",shareTop),$("#share").show(150)}))}}function getInfo(){$.get("/info/"+$("input").val(),(function(data){if(console.log(data),"F"!=data.status){if($("input").val()||$("input").val(data.ip),$("button").text("Search"),$("#ip").text(data.ip),data.city=null==data.city?"Unknow":data.city,data.region=null==data.region?"Unknow":data.region,data.country=null==data.country?"Unknow":data.country,data.timezone=null==data.timezone?"Unknow":data.timezone,data.isp=null==data.isp?"Unknow":data.isp,data.scope=null==data.scope?"Unknow":data.scope,data.detail=null==data.detail||" "==data.detail?"Unknow":data.detail,$("#city").text(data.city),$("#region").text(data.region),$("#country").text(data.country),$("#timezone").text(data.timezone),$("#isp").text(data.isp),$("#scope").text(data.scope),$("#detail").text(data.detail),null==data.as)$("#as").text("Unknow");else{$("#as").text(data.as);var asUri="https://bgpview.io/asn/"+data.as.substr(2);$("#as").html(''+data.as+"")}if(null==data.loc)$("#loc").text("Unknow"),clear();else{var earthUri="https://earth.google.com/web/@"+data.loc+",9.963a,7999.357d,35y,-34.3h,45t,0r/data=KAI";$("#loc").html(''+data.loc+""),draw(parseFloat(data.loc.split(",")[0]),parseFloat(data.loc.split(",")[1]))}$("#table").show(500),setTimeout((function(){unlockMap()}),3e3)}else errorIP()}))}function getVersion(){$.get("/version",(function(data){console.log(data),data.qqwry=data.qqwry.slice(0,4)+"-"+data.qqwry.slice(4,6)+"-"+data.qqwry.slice(6,8),data.ipip=data.ipip.slice(0,4)+"-"+data.ipip.slice(4,6)+"-"+data.ipip.slice(6,8);var data_ver="";data_ver+="echoIP: "+data.echoip+"\n",data_ver+="纯真数据库: "+data.qqwry+"\n",data_ver+="IPIP.net数据库: "+data.ipip,alert(data_ver)}))}function trim(str){return str.replace(/(^\s*)|(\s*$)/g,"")}function errorIP(){$("button").text("Illegal IP"),$("button").css({"border-color":"#ff406f","background-color":"#ff406f"}),$("input").focus()}function checkIP(ipStr){if(null===ipStr)return"error";var regIPv4=/^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$/,regIPv6=/^((([0-9A-Fa-f]{1,4}:){7}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|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3})|(:(:[0-9A-Fa-f]{1,4}){0,5}:(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}))$/,V4=ipStr.match(regIPv4),V6=ipStr.match(regIPv6);return null===V4&&null===V6?"error":"ok"}function getQuery(name){var reg=new RegExp("(^|&)"+name+"=([^&]*)(&|$)"),result=window.location.search.substr(1).match(reg);return null!=result?unescape(result[2]):null}function clear(){var map;new mapboxgl.Map({container:"map",style:"mapbox://styles/mapbox/streets-v11",center:[0,0],zoom:1}).on("load",(function(){console.log("reset map")}))}function draw(x,y){var size=100,map=new mapboxgl.Map({container:"map",style:"mapbox://styles/mapbox/streets-v11",center:[y,x],zoom:3}),pulsingDot={width:100,height:100,data:new Uint8Array(4e4),onAdd:function(){var canvas=document.createElement("canvas");canvas.width=this.width,canvas.height=this.height,this.context=canvas.getContext("2d")},render:function(){var duration=1e3,t=performance.now()%1e3/1e3,radius=15,outerRadius=35*t+15,context=this.context;return context.clearRect(0,0,this.width,this.height),context.beginPath(),context.arc(this.width/2,this.height/2,outerRadius,0,2*Math.PI),context.fillStyle="rgba(255, 200, 200,"+(1-t)+")",context.fill(),context.beginPath(),context.arc(this.width/2,this.height/2,15,0,2*Math.PI),context.fillStyle="rgba(255, 100, 100, 1)",context.strokeStyle="white",context.lineWidth=2+4*(1-t),context.fill(),context.stroke(),this.data=context.getImageData(0,0,this.width,this.height).data,map.triggerRepaint(),!0}};map.on("load",(function(){map.addImage("pulsing-dot",pulsingDot,{pixelRatio:2}),map.addLayer({id:"points",type:"symbol",source:{type:"geojson",data:{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[y,x]}}]}},layout:{"icon-image":"pulsing-dot"}})}))}mapboxgl.accessToken="pk.eyJ1Ijoic2hldm9ua3VhbiIsImEiOiJja20yMjlnNDYybGg2Mm5zNW40eTNnNnUwIn0.6xj6sgjWvdQgT_7OQUy_Jg",$(document).ready((function(){lockMap(),null===getQuery("ip")?getInfo():($("input").val(getQuery("ip")),getInfo()),$("#table").hide(),$("#share").hide(),$("button").click((function(){$(this).css({"border-color":"","background-color":""}),$(this).text("Searching..."),lockMap(),$("#table").hide(500),$("input").val(trim($("input").val())),""==$("input").val()||"ok"==checkIP($("input").val())?getInfo():errorIP()})),$("button").dblclick((function(event){event.stopPropagation(),getVersion()})),$("input").dblclick((function(event){event.stopPropagation()})),$("table").dblclick((function(event){event.stopPropagation()})),$("#output").dblclick((function(){showQRCode()})),$("#output").click((function(){hideQRCode()})),$("#map").click((function(){hideQRCode()})),$("body").mousemove((function(){checkRange()})),$("body").mouseleave((function(){hideQRCode()})),$(window).resize((function(){isPortrait()?($(".positioncontrol").css("left","0"),$(".positioncontrol").css("right","0"),$(".positioncontrol").css("transform","translate(0, 0)")):($(".positioncontrol").css("left","calc(80vw - 180px)"),$(".positioncontrol").css("right",""),$(".positioncontrol").css("transform","translate(-20%, 0)"))}))})),$(document).keydown((function(event){13==event.keyCode&&$("button").focus()})); \ No newline at end of file