This repository has been archived by the owner on Mar 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.min.js
1 lines (1 loc) · 3.84 KB
/
main.min.js
1
var correctedAddress="",qrcode=new QRCode("qrcode",{text:"",width:128,height:128,colorDark:"#000000",colorLight:"#ffffff",correctLevel:QRCode.CorrectLevel.M}),qrcode2=new QRCode("qrcode2",{text:"",width:128,height:128,colorDark:"#000000",colorLight:"#ffffff",correctLevel:QRCode.CorrectLevel.M});function setResultOldAddress(e){""!=e&&(qrcode.makeCode(document.getElementById("addressToTranslate").value.toUpperCase()),document.getElementById("qrcode").style="display: inline-block;",document.getElementById("resultAddress").value=e,qrcode2.makeCode(document.getElementById("resultAddress").value),document.getElementById("qrcode2").style="display: inline-block;",document.getElementById("resultAddressBlock").style.display="block",document.getElementById("copy").innerHTML="Copy")}function setResultCashAddress(e){qrcode.makeCode(document.getElementById("addressToTranslate").value),document.getElementById("qrcode").style="display: inline-block;",document.getElementById("resultAddress").value=e,qrcode2.makeCode(document.getElementById("resultAddress").value.toUpperCase()),document.getElementById("qrcode2").style="display: inline-block;",document.getElementById("resultAddressBlock").style.display="block",document.getElementById("copy").innerHTML="Copy"}function cleanResultAddress(){document.getElementById("resultAddress").value="",document.getElementById("resultAddressBlock").style.display="none",document.getElementById("correctedButton").style="display: none",document.getElementById("qrcode2").style="display: none;",document.getElementById("qrcode").style="display: none;",document.getElementById("copy").innerHTML="Copy"}window.onload=window.onhashchange=function(){document.getElementById("addressToTranslate").value=window.location.hash.slice(1),document.getElementById("addressToTranslate").oninput()},document.getElementById("demo").onclick=function(){window.location.hash="#1BpEi6DfDAUFd7GtittLSdBeYJvcoaVggu"},document.getElementsByClassName("btn btn-outline-primary btn-lg btn-block")[0].onclick=function(){document.getElementById("addressToTranslate").value="",cleanResultAddress()},document.getElementById("correctedButton").onclick=function(){document.getElementById("correctedButton").style="display: none",document.getElementById("addressToTranslate").value=correctedAddress,document.getElementById("addressToTranslate").oninput()},document.getElementById("copy").onclick=function(){document.getElementById("copy").innerHTML="Copied",document.getElementById("resultAddress").select(),document.execCommand("Copy"),window.getSelection().removeAllRanges()},document.getElementById("addressToTranslate").oninput=function(){cleanResultAddress(),input=document.getElementById("addressToTranslate").value;try{if(":"!=input[11]||54!=input.length||"q"!=input[12]&&"p"!=input[12])if("1"==input[0]||"3"==input[0]&&input.length>25&&input.length<35)setResultCashAddress(parseAndConvertOldAddress(input));else if("q"!=input[0]&&"p"!=input[0]||42!=input.length)if(":"!=input[7]||50!=input.length||"q"!=input[8]&&"p"!=input[8])if(":"!=input[11]||54!=input.length||"Q"!=input[12]&&"P"!=input[12])"m"==input[0]||"n"==input[0]||"2"==input[0]?setResultCashAddress(parseAndConvertOldAddress(input)):("C"==input[0]||"H"==input[0])&&input.length>25&&input.length<36?setResultCashAddress(parseAndConvertOldAddress(input)):cleanResultAddress();else{for(e=0;e<11;e++)if(input[e]!="BITCOINCASH"[e])return void cleanResultAddress();setResultCashAddress(parseAndConvertOldAddress(input.toLowerCase()))}else{for(var e=0;e<7;e++)if(input[e]!="bchtest"[e])return void cleanResultAddress();setResultOldAddress(parseAndConvertCashAddress("bchtest",input.slice(8)))}else setResultOldAddress(parseAndConvertCashAddress("bitcoincash",input));else{for(var e=0;e<11;e++)if(input[e]!="bitcoincash"[e])return void cleanResultAddress();setResultOldAddress(parseAndConvertCashAddress("bitcoincash",input.slice(12)))}}catch(e){cleanResultAddress()}};