diff --git a/src/calculator/index.html b/src/calculator/index.html index 1be4fe3..0f330c2 100644 --- a/src/calculator/index.html +++ b/src/calculator/index.html @@ -13,6 +13,6 @@ } - +

Port:

\ No newline at end of file diff --git a/src/calculator/script.js b/src/calculator/script.js index 998cbbc..3594755 100644 --- a/src/calculator/script.js +++ b/src/calculator/script.js @@ -1,18 +1,22 @@ -const result = document.getElementById('result'); +function onAsnInput(inputElement) { + let portElement = document.getElementById('result'); -function calculate(el) { - if (el.value == '') { - result.innerText = ''; + if (inputElement.value == '') { + portElement.innerText = ''; return; } - let cand = cyrb53(el.value).toString().slice(0, 5); + portElement.innerText = calculate(inputElement.value); +} + +function calculate(asn) { + let result = cyrb53(asn).toString().slice(0, 5); - if (cand > 65535 || cand < 30000) { - cand = (cand % 3 + 3) * 10000 + (cand % 10000); + if (result > 65535 || result < 30000) { + result = (result % 3 + 3) * 10000 + (result % 10000); } - result.innerText = cand; + return result; } // https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js