From: Matt Corallo Date: Fri, 6 Sep 2024 15:39:28 +0000 (+0000) Subject: Auto-lookup when name parameter is set X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=b2d91813292eae162f794bf428887803ac0d2205;p=satsto.me Auto-lookup when name parameter is set --- diff --git a/index.html b/index.html index 32a22f3..2b48104 100644 --- a/index.html +++ b/index.html @@ -315,16 +315,17 @@ @@ -338,52 +339,56 @@ import {CLIPBOARD_SVG, CLIPBOARD_CHECK_SVG} from './clipboard-svg.js'; init().then(() => { const address_box = document.getElementById("address"); - const check_text = function() { - if (address_box.value.startsWith("₿")) { - address_box.value = address_box.value.substring(1); - } + const text_valid = function() { const addr_parts = address_box.value.split("@"); if (addr_parts.length != 2) { document.getElementById("paybutton").classList.add("go-button-disabled"); document.getElementById("errors").classList.add("errors-filled"); document.getElementById("errors").innerHTML = "Address should have exactly one @"; - return true; + return false; } if (addr_parts[0].length == 0) { document.getElementById("paybutton").classList.add("go-button-disabled"); document.getElementById("errors").classList.add("errors-filled"); document.getElementById("errors").innerHTML = "Missing user part"; - return true; + return false; } if (addr_parts[1].length == 0) { document.getElementById("paybutton").classList.add("go-button-disabled"); document.getElementById("errors").classList.add("errors-filled"); document.getElementById("errors").innerHTML = "Missing domain"; - return true; + return false; } if (!/^[\p{ASCII}]*$/u.test(addr_parts[0])) { document.getElementById("paybutton").classList.add("go-button-disabled"); document.getElementById("errors").classList.add("errors-filled"); document.getElementById("errors").innerHTML = "To protect against Homograph Attacks, the user part of addres must be ASCII"; - return true; + return false; } if (!/^[\p{ASCII}]*$/u.test(addr_parts[1])) { document.getElementById("paybutton").classList.add("go-button-disabled"); document.getElementById("errors").classList.add("errors-filled"); document.getElementById("errors").innerHTML = "To protect against Homograph Attacks, the domain part of address must be ASCII"; - return true; + return false; } document.getElementById("paybutton").classList.remove("go-button-disabled"); document.getElementById("errors").classList.remove("errors-filled"); document.getElementById("errors").innerHTML = ""; return true; } + const check_text = function() { + if (address_box.value.startsWith("₿")) { + address_box.value = address_box.value.substring(1); + } + text_valid(); + return true; + } document.getElementById("address").onchange = check_text; document.getElementById("address").onkeypress = check_text; document.getElementById("address").oninput = check_text; check_text(); document.getElementById("address").onfocus = function() { - if (this.value === window.default_hrn) + if (this.value === window.url_set_hrn) document.getElementById("address").select(); }; document.getElementById("address").onkeydown = function(event) { @@ -509,6 +514,9 @@ copy_elem.innerHTML = CLIPBOARD_SVG; }, 1500); } + if (text_valid() && window.default_hrn != window.url_set_hrn) { + lookup_domain(); + } });