Git Product home page Git Product logo

steamid-converter's Introduction

#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="http://peterolson.github.com/BigInteger.js/BigInteger.min.js"></script>
<script src="js/converter-min.js"></script>

Peterolson's BigInteger.js is required for steamid-converter to work, as Steam IDs are BigIntegers, unfortunately.

##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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.