This is a small script, who cares about optimization.
This commit is contained in:
parent
1349163ba5
commit
e9079eeb2a
2 changed files with 13 additions and 9 deletions
|
@ -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>
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue