From bfc500385fabd1586e7fe15b9b3d9da26cf870c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Sun, 26 May 2024 23:10:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20https://beautifier.io/=20?= =?UTF-8?q?=E7=BE=8E=E5=8C=96js=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wp-includes/js/base.js | 140 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 139 insertions(+), 1 deletion(-) diff --git a/wp-includes/js/base.js b/wp-includes/js/base.js index 6d27bda..41d513c 100644 --- a/wp-includes/js/base.js +++ b/wp-includes/js/base.js @@ -951,4 +951,142 @@ var n, o }); -var clipboard=new ClipboardJS('.btn-copy');var xelem=document.getElementById("d");var sel1elem=document.getElementById("form");var sel2elem=document.getElementById("to");var yelem=document.getElementById("y");var calgroup=document.getElementById("calgroup");var cal1elem=document.getElementById("cal1");var cal2elem=document.getElementById("cal2");window.addEventListener("DOMContentLoaded",function(){calgroup.style.display="none";var params=GetURLParams();if(Object.keys(params).length>0&¶ms.d!=""){xelem.value=params.d;sel1elem.selectedIndex=params.form-2;sel2elem.selectedIndex=params.to-2;onconvert()}});function GetURLParams(){var url=window.location.href;var regex=/[?&]([^=#]+)=([^&#]*)/g,params={},match;while(match=regex.exec(url)){params[match[1]]=match[2]}if(url.indexOf('8jz')>-1){return params}}function swap(){var i1=sel1elem.selectedIndex;var i2=sel2elem.selectedIndex;sel1elem.selectedIndex=i2;sel2elem.selectedIndex=i1;xelem.value=yelem.value;yelem.value=""}function base2decimal(x,dec,b){var txt="("+x+")"+b.toString()+" = ";var d,e,minus=false;var len=x.length;if(x[0]=="-"){txt+="-[";x=x.substr(1);len--;minus=true}var idot=x.indexOf(".");if(idot>=0){x=x.substring(0,idot)+x.substring(idot+1,len);len--}else idot=len;for(var i=0;i"+e+")";if(i10";document.getElementById("cal1txt").innerHTML=txt}function digits_after_period(x){f=x.toString();i=f.indexOf('.');len=f.length-i-1;return len}function decimal2base(dec,y,b){var row,txt="";document.getElementById("cal2tbl").getElementsByTagName('tbody')[0].innerHTML="";if(dec<0)dec=-dec;dec=dec.toString();var id=dec.indexOf(".");var nd=y.length-y.indexOf(".")-1;if(nd>6)nd=6;if(id>=0&&nd>0){txt="\u5c06\u76ee\u6807\u57fa\u6570\u4e58\u4ee5\u7ed3\u679c\u7684\u5c0f\u6570\u4f4d\u6570\u0028\u6700\u9ad8\u53ef\u8fbe\u0036\u4f4d\u6570\u0029\u003a
";txt+="floor("+dec+"×"+b+""+nd+") = ";dec=Math.floor(dec*Math.pow(b,nd));txt+=dec}document.getElementById("cal2dec").innerHTML=txt;for(var n=dec,k=0;n>=1;k++){row="";row+=""+n+"/"+b+"";row+=""+Math.floor(n/b)+"";row+=""+(n%b).toFixed()+"";row+=""+k+"";row+="";n=Math.floor(n/b);var tableRef=document.getElementById('cal2tbl').getElementsByTagName('tbody')[0];var newRow=tableRef.insertRow(k);newRow.innerHTML=row}document.getElementById("cal2result").innerHTML="= ("+y+")"+b+""}function onconvert(){var x=xelem.value;var b1=sel1elem.selectedIndex+2;var b2=sel2elem.selectedIndex+2;try{var y=new BigNumber(x,b1);xelem.style.background="white"}catch(err){xelem.style.background="#fff0f0";yelem.value="";return}var dec=y.toString(10);y=y.toString(b2).toUpperCase();yelem.value=y;var yd=yelem.value.match(/[\dA-Z]/g);var ylabel="\u8f6c\u6362\u7ed3\u679c\uff1a";if(yd!=null)ylabel+=" ("+yd.length+((yd.length==1)?" \u4f4d)":" \u4f4d)");document.getElementById("ylabel").innerHTML=ylabel;document.getElementById("b1txt").innerHTML=b1;document.getElementById("b2txt").innerHTML=b2;base2decimal(x,dec,b1);decimal2base(dec,y,b2);if(b1==10)cal1elem.style.display="none";else cal1elem.style.display="block";if(b2==10)cal2elem.style.display="none";else cal2elem.style.display="block";calgroup.style.display="block"}function onrst(){calgroup.style.display="none"} \ No newline at end of file + +var clipboard = new ClipboardJS('.btn-copy'); +var xelem = document.getElementById("d"); +var sel1elem = document.getElementById("form"); +var sel2elem = document.getElementById("to"); +var yelem = document.getElementById("y"); +var calgroup = document.getElementById("calgroup"); +var cal1elem = document.getElementById("cal1"); +var cal2elem = document.getElementById("cal2"); +window.addEventListener("DOMContentLoaded", function() { + calgroup.style.display = "none"; + var params = GetURLParams(); + if (Object.keys(params).length > 0 && params.d != "") { + xelem.value = params.d; + sel1elem.selectedIndex = params.form - 2; + sel2elem.selectedIndex = params.to - 2; + onconvert() + } +}); + +function GetURLParams() { + var url = window.location.href; + var regex = /[?&]([^=#]+)=([^&#]*)/g, + params = {}, + match; + while (match = regex.exec(url)) { + params[match[1]] = match[2] + } + if (url.indexOf('8jz') > -1) { + return params + } +} + +function swap() { + var i1 = sel1elem.selectedIndex; + var i2 = sel2elem.selectedIndex; + sel1elem.selectedIndex = i2; + sel2elem.selectedIndex = i1; + xelem.value = yelem.value; + yelem.value = "" +} + +function base2decimal(x, dec, b) { + var txt = "(" + x + ")" + b.toString() + " = "; + var d, e, minus = false; + var len = x.length; + if (x[0] == "-") { + txt += "-["; + x = x.substr(1); + len--; + minus = true + } + var idot = x.indexOf("."); + if (idot >= 0) { + x = x.substring(0, idot) + x.substring(idot + 1, len); + len-- + } else idot = len; + for (var i = 0; i < len; i++) { + d = parseInt(x[i], b); + e = idot - i - 1; + e = e.toString(); + txt += "(" + d + " \u00D7 " + b + "" + e + ")"; + if (i < len - 1) txt += " + " + } + if (minus) txt += "]"; + txt += " = (" + dec + ")10"; + document.getElementById("cal1txt").innerHTML = txt +} + +function digits_after_period(x) { + f = x.toString(); + i = f.indexOf('.'); + len = f.length - i - 1; + return len +} + +function decimal2base(dec, y, b) { + var row, txt = ""; + document.getElementById("cal2tbl").getElementsByTagName('tbody')[0].innerHTML = ""; + if (dec < 0) dec = -dec; + dec = dec.toString(); + var id = dec.indexOf("."); + var nd = y.length - y.indexOf(".") - 1; + if (nd > 6) nd = 6; + if (id >= 0 && nd > 0) { + txt = "\u5c06\u76ee\u6807\u57fa\u6570\u4e58\u4ee5\u7ed3\u679c\u7684\u5c0f\u6570\u4f4d\u6570\u0028\u6700\u9ad8\u53ef\u8fbe\u0036\u4f4d\u6570\u0029\u003a
"; + txt += "floor(" + dec + "×" + b + "" + nd + ") = "; + dec = Math.floor(dec * Math.pow(b, nd)); + txt += dec + } + document.getElementById("cal2dec").innerHTML = txt; + for (var n = dec, k = 0; n >= 1; k++) { + row = ""; + row += "" + n + "/" + b + ""; + row += "" + Math.floor(n / b) + ""; + row += "" + (n % b).toFixed() + ""; + row += "" + k + ""; + row += ""; + n = Math.floor(n / b); + var tableRef = document.getElementById('cal2tbl').getElementsByTagName('tbody')[0]; + var newRow = tableRef.insertRow(k); + newRow.innerHTML = row + } + document.getElementById("cal2result").innerHTML = "= (" + y + ")" + b + "" +} + +function onconvert() { + var x = xelem.value; + var b1 = sel1elem.selectedIndex + 2; + var b2 = sel2elem.selectedIndex + 2; + try { + var y = new BigNumber(x, b1); + xelem.style.background = "white" + } catch (err) { + xelem.style.background = "#fff0f0"; + yelem.value = ""; + return + } + var dec = y.toString(10); + y = y.toString(b2).toUpperCase(); + yelem.value = y; + var yd = yelem.value.match(/[\dA-Z]/g); + var ylabel = "\u8f6c\u6362\u7ed3\u679c\uff1a"; + if (yd != null) ylabel += " (" + yd.length + ((yd.length == 1) ? " \u4f4d)" : " \u4f4d)"); + document.getElementById("ylabel").innerHTML = ylabel; + document.getElementById("b1txt").innerHTML = b1; + document.getElementById("b2txt").innerHTML = b2; + base2decimal(x, dec, b1); + decimal2base(dec, y, b2); + if (b1 == 10) cal1elem.style.display = "none"; + else cal1elem.style.display = "block"; + if (b2 == 10) cal2elem.style.display = "none"; + else cal2elem.style.display = "block"; + calgroup.style.display = "block" +} + +function onrst() { + calgroup.style.display = "none" +} \ No newline at end of file