Fix
All checks were successful
/ deploy (push) Successful in 1m5s

This is a small script, who cares about optimization.
This commit is contained in:
Minecon724 2025-03-19 20:31:49 +01:00
commit e9079eeb2a
Signed by: Minecon724
GPG key ID: A02E6E67AB961189
2 changed files with 13 additions and 9 deletions

View file

@ -13,6 +13,6 @@
}
</style>
<input type="number" min="0" placeholder="your ASN" oninput="calculate(this)">
<input type="number" min="0" placeholder="your ASN" oninput="onAsnInput(this)">
<p>Port: <span id="result"></span></p>
</html>

View file

@ -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