JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://converter.creeation.de/bignumber.min.js"></script>
<div>
<form>
<input type="text" name="id" placeholder="STEAM / COMMUNITY ID" />
<input type="submit" value=">" />
</form>
</div>
JavaScript
$(function() {
var id, server_id, account_id, community_id_start = '76561197960265728';
Number.prototype.mod = function(n) {
return ((this%n)+n)%n;
}
function getCommunityID(id) {
var com_id = id.replace( 'STEAM_', '' );
com_id = com_id.split( ':' );
if ( com_id.length == 3 ) {
server_id = com_id[1];
account_id = com_id[2];
com_id = new BigNumber( account_id * 2 ).add(community_id_start).add(server_id).toString();
}
return com_id;
}
function getSteamID(id) {
var a = new BigNumber(id).subtract(community_id_start).divide(2);
var b = Math.floor( a );
var c = Math.round( a % b );
id = '0:' + c + ':' + b;
return id;
}
$('form').on('submit', function(e) {
var LOL = $('input[type="text"]', this).val();
var OMG = getCommunityID(LOL);
$(this).append(OMG);
var ROFL = getSteamID(OMG);
$(this).append('<br>' + ROFL);
e.preventDefault();
});
});