From e9079eeb2aa9dbfcb68003084175a60c27354814 Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Wed, 19 Mar 2025 20:31:49 +0100 Subject: [PATCH] Fix This is a small script, who cares about optimization. --- src/calculator/index.html | 2 +- src/calculator/script.js | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) 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