User talk:Queue

From Valve Developer Community
Jump to: navigation, search

JQUERY PLUGIN FOR CREATING STEAM SIGNATURE

$.extend($.fn, {
	steamsignature: function(attr){
		var attr = attr;
		var self = this;
		/*A função que converte SteamID em STEAMID64*/
		var SteamID2CommunityID = function(SteamID){
			var steamSplit 	= SteamID.split(":");
			var steamBase	= new String("76561197960265728");
			
			newSteamBase = steamBase % Math.pow(10, steamBase.length - 1);
			SteamID64 = steamBase[0] + Number((newSteamBase + Number(steamSplit[1])) + (Number(steamSplit[2]) * 2));
			return SteamID64;
		}
		
		/*I run the FUNCTION (SteamID2CommunityID) ALL ITEMS THAT I SELECTI */
		
		if(self.length > 0){
			$.each( self, function( index, value ){
				var e = "";
				if(typeof(attr)=="undefined"){
					e = $(value).html();
				}else{
					e = $(value).attr(attr)
				}
				var steamID64 = SteamID2CommunityID(e);
				$(value).html("<a target='_blank' href=\"http://steamcommunity.com/profiles/" + steamID64 + "\"><img src=\"http://steamsignature.com/classic-" + steamID64 + ".png\"></a><a href='steam://friends/add/" + steamID64 + "'><img src='http://steamsignature.com/AddFriend.png'>")
			});
		}

		return this;           
	}
});

/**how to use*/
/**this code can be placed anywhere on your html document*/
$(document).ready(function() {
    $("#element").steamsignature(); /**takes the value of the html element*/
    $(".element").steamsignature("id");/**takes the value that the attribute "id" element*/
})



<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Steam signature</title>
        /** Here you should include the latest version of jquery and of course the code of the plugin */
        <script src="http://code.jquery.com/jquery-latest.js"></script>
        <script src="steamSignature.fn.js"></script>
    </head>
    <body>
        <div id="element">STEAM_0:1:41535435<div>
        <div id="STEAM_0:1:41535435" class="element"><div>
    </body>
</html>

SEE IN USE (CLICK IN 'PARTICIPANTES')