Skip to content

JavaScript Library + Demo for Converting between Steam's ID Formats.

Notifications You must be signed in to change notification settings

iBoonie/steamid-converter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Update

Removed the BigInteger.js requirement, browsers are far enought along that it should be fine. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#browser_compatibility

steamid-converter

Simple conversion between Steam's ID formats, and also an example of the validation of inputs that require the various Steam ID formats (not actually handled by this library, but I figured hey, while I'm doing things with Regex...").

Installation

If you just want to cut to the chase and use it in your software, simply download converter-min.js and link it in your html files where you need it:

<script src="js/converter-min.js"></script>

Usage

An example of using every part of steamid-converter can be found in the file ui.js. Here's a brief overview:

SteamIDConverter.toSteamID64("STEAM_0:1:50279161");
// => "76561198060824051"

SteamIDConverter.toSteamID("76561198060824051");
// => "STEAM_0:1:50279161"

SteamIDConverter.toSteamID3("STEAM_0:1:50279161");
// => "[U:1:100558323]"

All three methods can take any of the other two forms of ID. I.e. toSteamID() can take a steamid64 or a steamid3.

There are also equivalent functions that check if the given string is a steamID, steamID64, or steamID3:

SteamIDConverter.isSteamID("STEAM_0:1:50279161");
// => true

SteamIDConverter.isSteamID64("bacon");
// => false

SteamIDConverter.isSteamID64("76561198060824051");
// => true

SteamIDConverter.isSteamID3("[U:1:100558323]");
// => true

Also included is a helper function to generate profile links based on the user's Steam ID:

SteamIDConverter.profileURL("[U:1:100558323]");
// => "http://steamcommunity.com/profiles/76561198060824051"

Just like the other conversion functions, profileURL() can take any form of Steam ID.

About

JavaScript Library + Demo for Converting between Steam's ID Formats.

Resources

Stars

Watchers

Forks

Languages

  • JavaScript 64.5%
  • HTML 21.5%
  • CSS 14.0%