Untitled diff

Created Diff never expires
525 removals
Words removed1812
Total words2815
Words removed (%)64.37
937 lines
537 additions
Words added1683
Total words2686
Words added (%)62.66
950 lines
var INVENTORY_PAGE_ITEMS = 16;
var INVENTORY_PAGE_ITEMS = 16;
var INVENTORY_PAGE_WIDTH = 416;
var INVENTORY_PAGE_WIDTH = 416;
var g_bIsTrading = false;
var g_bIsTrading = false;
var g_bTradeOffer = false; // implies g_bIsTrading
var g_bTradeOffer = false; // implies g_bIsTrading
var g_bIsInventoryPage = false;
var g_bIsInventoryPage = false;


var g_bReadOnly = false;
var g_bReadOnly = false;


var g_bWalletTradeUnavailable = false;
var g_bWalletTradeUnavailable = false;
var g_bSellItemOnInventoryLoad = false;
var g_bSellItemOnInventoryLoad = false;
var g_bShowTradableItemsOnly = false;
var g_bShowTradableItemsOnly = false;


var g_bEnableDynamicSizing = false;
var g_bEnableDynamicSizing = false;
var g_bAllowHighDPIItemImages = false; // true if the page is responsive, otherwise we assume page is not updated to allow high dpi images
var g_bAllowHighDPIItemImages = false; // true if the page is responsive, otherwise we assume page is not updated to allow high dpi images
var g_ActiveItemPopupModal = null;
var g_ActiveItemPopupModal = null;


var g_ActiveUser = null;
var g_ActiveUser = null;
var ITEM_HOVER_DELAY = 500;
var ITEM_HOVER_DELAY = 500;


function Economy_UseResponsiveLayout()
function Economy_UseResponsiveLayout()
{
{
if ( !window.UseSmallScreenMode || !window.UseSmallScreenMode() )
if ( !window.UseSmallScreenMode || !window.UseSmallScreenMode() )
return false;
return false;


// trading has a special break point
// trading has a special break point
if ( g_bIsTrading && $J(window).width() > 600 )
if ( g_bIsTrading && $J(window).width() > 600 )
return false;
return false;


return true;
return true;
}
}


/*
/*
* Initialization
* Initialization
*/
*/


function InitInventoryPage( bHasPendingGifts, showAppId, bShowTradableItemsOnly )
function InitInventoryPage( bHasPendingGifts, showAppId, bShowTradableItemsOnly )
{
{
INVENTORY_PAGE_ITEMS = 25; //5 x 5 grid
INVENTORY_PAGE_ITEMS = 25; //5 x 5 grid
INVENTORY_PAGE_WIDTH = 104 * 5;
INVENTORY_PAGE_WIDTH = 104 * 5;
g_bIsInventoryPage = true;
g_bIsInventoryPage = true;
g_bShowTradableItemsOnly = bShowTradableItemsOnly;
g_bShowTradableItemsOnly = bShowTradableItemsOnly;
g_bAllowHighDPIItemImages = $J('html').hasClass('responsive');
g_bAllowHighDPIItemImages = $J('html').hasClass('responsive');


// set up the filter control
// set up the filter control
Filter.InitFilter( $('filter_control') );
Filter.InitFilter( $('filter_control') );


// decide what page we're going to start with
// decide what page we're going to start with
// priority: hash params > cookie > first non-empty inventory > first inventory
// priority: hash params > cookie > first non-empty inventory > first inventory
var oHashParams = ReadInventoryHash( window.location.hash );
var oHashParams = ReadInventoryHash( window.location.hash );
var oCookieParams = ReadInventoryCookie( GetCookie( 'strInventoryLastContext' ) );
var oCookieParams = ReadInventoryCookie( GetCookie( 'strInventoryLastContext' ) );


if ( window.location.hash == '#pending_gifts' && $('tabcontent_pendinggifts') )
if ( window.location.hash == '#pending_gifts' && $('tabcontent_pendinggifts') )
{
{
if ( bHasPendingGifts )
if ( bHasPendingGifts )
ShowPendingGifts();
ShowPendingGifts();
else
else
ShowItemInventory( 753, 1 );
ShowItemInventory( 753, 1 );
}
}
else if ( window.location.hash == '#gift_history' && g_bViewingOwnProfile )
else if ( window.location.hash == '#gift_history' && g_bViewingOwnProfile )
{
{
ShowGiftHistory();
ShowGiftHistory();
}
}
else if ( oHashParams && BValidateHashParams( oHashParams ) )
else if ( oHashParams && BValidateHashParams( oHashParams ) )
{
{
ShowItemInventory( oHashParams.appid, oHashParams.contextid, oHashParams.assetid );
ShowItemInventory( oHashParams.appid, oHashParams.contextid, oHashParams.assetid );
}
}
else if ( showAppId != -1 )
else if ( showAppId != -1 )
{
{
if ( showAppId == 0 )
if ( showAppId == 0 )
showAppId = 753;
showAppId = 753;


ShowItemInventory( showAppId, 0 );
ShowItemInventory( showAppId, 0 );
}
}
else if ( oCookieParams )
else if ( oCookieParams )
{
{
ShowItemInventory( oCookieParams.appid, oCookieParams.contextid );
ShowItemInventory( oCookieParams.appid, oCookieParams.contextid );
UserYou.SetDefaultInventoryId( oCookieParams );
UserYou.SetDefaultInventoryId( oCookieParams );
}
}
else
else
{
{
var oFirstInventory = null;
var oFirstInventory = null;
var oFirstNonEmptyInventory = null;
var oFirstNonEmptyInventory = null;
for ( var appid in g_rgAppContextData )
for ( var appid in g_rgAppContextData )
{
{
var rgApp = g_rgAppContextData[appid];
var rgApp = g_rgAppContextData[appid];
for ( var contextid in rgApp.rgContexts )
for ( var contextid in rgApp.rgContexts )
{
{
var rgContext = rgApp.rgContexts[contextid];
var rgContext = rgApp.rgContexts[contextid];
if ( rgContext.asset_count && !oFirstNonEmptyInventory )
if ( rgContext.asset_count && !oFirstNonEmptyInventory )
{
{
oFirstNonEmptyInventory = { appid: appid, contextid: contextid };
oFirstNonEmptyInventory = { appid: appid, contextid: contextid };
break;
break;
}
}
else if ( !oFirstInventory )
else if ( !oFirstInventory )
{
{
oFirstInventory = { appid: appid, contextid: contextid };
oFirstInventory = { appid: appid, contextid: contextid };
}
}
}
}
if ( oFirstNonEmptyInventory )
if ( oFirstNonEmptyInventory )
break;
break;
}
}
var oInventoryToShow = oFirstNonEmptyInventory ? oFirstNonEmptyInventory : oFirstInventory;
var oInventoryToShow = oFirstNonEmptyInventory ? oFirstNonEmptyInventory : oFirstInventory;
if ( oInventoryToShow )
if ( oInventoryToShow )
{
{
ShowItemInventory( oInventoryToShow.appid, oInventoryToShow.contextid );
ShowItemInventory( oInventoryToShow.appid, oInventoryToShow.contextid );
UserYou.SetDefaultInventoryId( oInventoryToShow );
UserYou.SetDefaultInventoryId( oInventoryToShow );
}
}


}
}


InitDynamicInventoryItemAutosizing( $J('#inventories'), '.trade_item_box', true );
InitDynamicInventoryItemAutosizing( $J('#inventories'), '.trade_item_box', true );
$J(window).on('Responsive_SmallScreenModeToggled', function() {
$J(window).on('Responsive_SmallScreenModeToggled', function() {
if ( window.UseSmallScreenMode && window.UseSmallScreenMode() )
if ( window.UseSmallScreenMode && window.UseSmallScreenMode() )
{
{
$J('#inventory_pagecontrols').hide();
$J('#inventory_pagecontrols').hide();
}
}
else
else
{
{
$J('#inventory_pagecontrols').show();
$J('#inventory_pagecontrols').show();
}
}
});
});


// watch for incoming # urls
// watch for incoming # urls
new LocationHashObserver( null, 0.2, OnLocationChange );
$J(window).on('hashchange', function() {
OnLocationChange( null, window.location.hash );
});

$J('.inventory_page_right').on( 'v_contentschanged', function() {
var $element = $J(this);
if ( !$element.is(':visible') )
return;

var nMinHeight = parseInt( $element.css('minHeight') ) || 0;
if ( $element.height() > nMinHeight )
$element.css( 'minHeight', $element.height() + 'px' );
});
}
}


function ReadInventoryHash( hash )
function ReadInventoryHash( hash )
{
{
if ( hash && hash.length > 1 )
if ( hash && hash.length > 1 )
{
{
var rgHashElements = hash.substring(1).split('_');
var rgHashElements = hash.substring(1).split('_');
if ( rgHashElements.length >= 1 && rgHashElements.length < 4 )
if ( rgHashElements.length >= 1 && rgHashElements.length < 4 )
{
{
var oLocation = { appid: parseInt( rgHashElements[0] ) };
var oLocation = { appid: parseInt( rgHashElements[0] ) };
if ( rgHashElements.length >= 2 )
if ( rgHashElements.length >= 2 )
oLocation.contextid = rgHashElements[1];
oLocation.contextid = rgHashElements[1];
if ( rgHashElements.length == 3 )
if ( rgHashElements.length == 3 )
oLocation.assetid = rgHashElements[2];
oLocation.assetid = rgHashElements[2];
return oLocation;
return oLocation;
}
}
}
}
return null;
return null;
}
}


function ReadInventoryCookie( cookie )
function ReadInventoryCookie( cookie )
{
{
if( cookie )
if( cookie )
{
{
var rgCookieElements = cookie.split('_');
var rgCookieElements = cookie.split('_');
if ( rgCookieElements.length == 2 )
if ( rgCookieElements.length == 2 )
{
{
var oCookieParams = {};
var oCookieParams = {};
oCookieParams.appid = parseInt( rgCookieElements[0] );
oCookieParams.appid = parseInt( rgCookieElements[0] );
oCookieParams.contextid = rgCookieElements[1];
oCookieParams.contextid = rgCookieElements[1];
if ( BValidateHashParams( oCookieParams ) )
if ( BValidateHashParams( oCookieParams ) )
return oCookieParams;
return oCookieParams;
else if ( g_rgAppContextData[ oCookieParams.appid ] )
else if ( g_rgAppContextData[ oCookieParams.appid ] )
{
{
// cookie wasn't valid, but we do know the app, see if there's another context we can use
// cookie wasn't valid, but we do know the app, see if there's another context we can use
var rgContexts = g_rgAppContextData[ oCookieParams.appid ].rgContexts;
var rgContexts = g_rgAppContextData[ oCookieParams.appid ].rgContexts;
for ( var contextid in rgContexts )
for ( var contextid in rgContexts )
{
{
if ( rgContexts[contextid].asset_count )
if ( rgContexts[contextid].asset_count )
{
{
oCookieParams.contextid = contextid;
oCookieParams.contextid = contextid;
break;
break;
}
}
}
}
// one more time
// one more time
if ( BValidateHashParams( oCookieParams ) )
if ( BValidateHashParams( oCookieParams ) )
return oCookieParams;
return oCookieParams;
}
}
}
}
}
}
return null;
return null;
}
}


function BValidateHashParams( oHashParams )
function BValidateHashParams( oHashParams )
{
{
// Context ID, if present, is a 64-bit value that can contain only digits
// Context ID, if present, is a 64-bit value that can contain only digits
if ( oHashParams && oHashParams.contextid && !/^\d+$/.test( oHashParams.contextid ) )
if ( oHashParams && oHashParams.contextid && !/^\d+$/.test( oHashParams.contextid ) )
{
{
return false;
return false;
}
}


if ( oHashParams && oHashParams.appid && g_rgAppContextData[oHashParams.appid] )
if ( oHashParams && oHashParams.appid && g_rgAppContextData[oHashParams.appid] )
{
{
if ( oHashParams.contextid && !g_rgAppContextData[oHashParams.appid].rgContexts[oHashParams.contextid] )
if ( oHashParams.contextid && !g_rgAppContextData[oHashParams.appid].rgContexts[oHashParams.contextid] )
oHashParams.contextid = APPWIDE_CONTEXT;
oHashParams.contextid = APPWIDE_CONTEXT;
return true;
return true;
}
}
return false;
return false;


}
}


LocationHashObserver = Class.create(Abstract.TimedObserver, {
LocationHashObserver = Class.create(Abstract.TimedObserver, {
getValue: function() {
getValue: function() {
return window.location.hash;
return window.location.hash;
}
}
} );
} );


function OnLocationChange ( elIgnored, hash )
function OnLocationChange ( elIgnored, hash )
{
{
var oHashParams = ReadInventoryHash( hash );
var oHashParams = ReadInventoryHash( hash );
if ( hash == '#pending_gifts' && $('tabcontent_pendinggifts') )
if ( hash == '#pending_gifts' && $('tabcontent_pendinggifts') )
{
{
ShowPendingGifts();
ShowPendingGifts();
}
}
else if ( oHashParams && BValidateHashParams( oHashParams ) )
else if ( oHashParams && BValidateHashParams( oHashParams ) )
{
{
ShowItemInventory( oHashParams.appid, oHashParams.contextid, oHashParams.assetid );
ShowItemInventory( oHashParams.appid, oHashParams.contextid, oHashParams.assetid );
}
}
else
else
{
{
var inventoryDefault = UserYou.GetDefaultInventoryId();
var inventoryDefault = UserYou.GetDefaultInventoryId();
ShowItemInventory( inventoryDefault.appid, inventoryDefault.contextid );
ShowItemInventory( inventoryDefault.appid, inventoryDefault.contextid );
}
}
}
}


/*
/*
* Inventory
* Inventory
*/
*/
var g_ActiveInventory = null;
var g_ActiveInventory = null;


function InventoryNextPage()
function InventoryNextPage()
{
{
g_ActiveInventory.NextPage();
g_ActiveInventory.NextPage();
}
}
function InventoryPreviousPage()
function InventoryPreviousPage()
{
{
g_ActiveInventory.PreviousPage();
g_ActiveInventory.PreviousPage();
}
}


function ShowTagFilters()
function ShowTagFilters()
{
{
if( g_ActiveInventory && g_ActiveInventory.getTagContainer() )
if( g_ActiveInventory )
g_ActiveInventory.getTagContainer().show();
g_ActiveInventory.ShowTags();


$( 'filter_tag_show' ).hide();
$( 'filter_tag_show' ).hide();
$( 'filter_tag_hide' ).show();
$( 'filter_tag_hide' ).show();


var elTagHolder = $( 'filter_options' );
var elTagHolder = $( 'filter_options' );
if( elTagHolder )
if( elTagHolder )
{
{
elTagHolder.removeClassName( 'filter_collapsed' );
elTagHolder.removeClassName( 'filter_collapsed' );
elTagHolder.addClassName( 'filter_expanded' );
elTagHolder.addClassName( 'filter_expanded' );
}
}
}
}


function HideTagFilters()
function HideTagFilters()
{
{
$$( '.econ_tag_filter_checkbox' ).each( function( elCheckbox ) {
$$( '.econ_tag_filter_checkbox' ).each( function( elCheckbox ) {
if( $( elCheckbox ).checked )
if( $( elCheckbox ).checked )
$( elCheckbox ).checked = false;
$( elCheckbox ).checked = false;
});
});


if( g_ActiveInventory && g_ActiveInventory.getTagContainer() )
if( g_ActiveInventory && g_ActiveInventory.getTagContainer() )
{
{
g_ActiveInventory.getTagContainer().hide();
$( 'filter_tag_show' ).show();
$( 'filter_tag_show' ).show();
$( 'filter_tag_hide' ).hide();
$( 'filter_tag_hide' ).hide();
Filter.UpdateTagFiltering( {} );
Filter.UpdateTagFiltering( {} );

if( Object.values( g_ActiveInventory.tags ).length == 0 )
{
Text moved with changes to lines 675-680 (87.9% similarity)
$( 'filter_tag_show' ).hide();
}
else
{
$( 'filter_tag_show' ).show();
}
}
}


var elTagHolder = $( 'filter_options' );
var elTagHolder = $( 'filter_options' );
if( elTagHolder )
if( elTagHolder )
{
{
elTagHolder.addClassName( 'filter_collapsed' );
elTagHolder.addClassName( 'filter_collapsed' );
elTagHolder.removeClassName( 'filter_expanded' );
elTagHolder.removeClassName( 'filter_expanded' );
}
}
}
}


var kStandardTag_Tradable =
var kStandardTag_Tradable =
{
{
name: 'Tradable',
localized_tag_name: 'Tradable',
internal_name: "tradable",
internal_name: "tradable",
category: "misc",
category: "misc",
category_name: 'Misc'
localized_category_name: 'Misc'
};
};


var kStandardTag_Untradable =
var kStandardTag_Untradable =
{
{
name: 'Not Tradable',
localized_tag_name: 'Not Tradable',
internal_name: "untradable",
internal_name: "untradable",
category: "misc",
category: "misc",
category_name: 'Misc'
localized_category_name: 'Misc'
};
};


var kStandardTag_Marketable =
var kStandardTag_Marketable =
{
{
name: 'Marketable',
localized_tag_name: 'Marketable',
internal_name: "marketable",
internal_name: "marketable",
category: "misc",
category: "misc",
category_name: 'Misc'
localized_category_name: 'Misc'
};
};


var kStandardTag_Unmarketable =
var kStandardTag_Unmarketable =
{
{
name: 'Not Marketable',
localized_tag_name: 'Not Marketable',
internal_name: "unmarketable",
internal_name: "unmarketable",
category: "misc",
category: "misc",
category_name: 'Misc'
localized_category_name: 'Misc'
};
};


function CreateItemContextMenuButton( elItemHolder, strCompositeId, owner )
function CreateItemContextMenuButton( elItemHolder, strCompositeId, owner )
{
{
// add the context menu
// add the context menu
var elActionMenuButton = new Element( 'a', {'id': strCompositeId + '_actionmenu_button', 'class': 'slot_actionmenu_button' } );
var elActionMenuButton = new Element( 'a', {'id': strCompositeId + '_actionmenu_button', 'class': 'slot_actionmenu_button' } );
elActionMenuButton.href = "javascript:void(0)";
elActionMenuButton.href = "javascript:void(0)";
elItemHolder.appendChild( elActionMenuButton );
elItemHolder.appendChild( elActionMenuButton );


$J(elActionMenuButton).click( function() {
$J(elActionMenuButton).click( function() {
HandleTradeActionMenu( elActionMenuButton, elItemHolder.rgItem, owner );
HandleTradeActionMenu( elActionMenuButton, elItemHolder.rgItem, owner );
} );
} );
}
}


var CInventory = Class.create( {
APPWIDE_CONTEXT = 0;
owner: null,
appid: 0,
contextid: 0,
rgInventory: null,
rgCurrency: null,


elInventory: null,
rgItemElements: null,
elTagContainer: null,


initialized: false,
function CInventory( owner, appid, contextid, rgContextData )
{
cItemsPerPage: 0,
this.m_owner = owner;
cPageWidth: 0,
this.m_steamid = owner.GetSteamId();
this.m_appid = appid;
this.m_contextid = contextid;


pageCurrent: 0,
// we reference these directly
pageList: null,
this.appid = appid;
pageTotal: 0,
this.contextid = contextid;
selectedItem: null,


bInPagingTransition: false,
this.m_rgAssets = [];
this.m_rgCurrencies = [];
this.m_rgDescriptions = {};


bNeedsRepagination: true,
this.m_strCompositeID = this.m_steamid + '_' + this.appid + '_' + this.contextid;
m_rgLazyLoadImages: null,
initialize: function( owner, appid, contextid, rgInventory, rgCurrency )
{
this.owner = owner;
this.appid = appid;
this.contextid = contextid;
this.rgInventory = rgInventory;
this.rgCurrency = rgCurrency;
var strCompositeId = this.getCompositeID();
this.elInventory = new Element( 'div', {id: 'inventory_' + strCompositeId, 'class': 'inventory_ctn' } );
this.rgItemElements = new Array();
this.elTagContainer = new Element( 'div', {id: 'tags_' + strCompositeId } );


// make sure inventory is stored as an object, not an array
this.m_$Inventory = $J('<div/>', {id: 'inventory_' + this.m_strCompositeID, 'class': 'inventory_ctn' } );
if ( this.rgInventory instanceof Array )
this.m_rgItemElements = [];
{
this.m_rgLazyLoadImages = [];
if ( this.rgInventory.length == 0 )
this.m_iNextEmptyItemElement = 0;
this.rgInventory = null;
else
this.rgInventory = Object.extend( {}, this.rgInventory );
}
// make sure inventory is stored as an object, not an array
if ( this.rgCurrency instanceof Array )
{
if ( this.rgCurrency.length == 0 )
this.rgCurrency = null;
else
this.rgCurrency = Object.extend( {}, this.rgCurrency );
}


this.tags = {};
// metadata from the context
if ( this.rgInventory )
this.m_cItems = rgContextData.asset_count || 0;
{
for ( var itemid in this.rgInventory )
{
var rgItem = this.rgInventory[itemid];
rgItem.appid = this.appid;
rgItem.contextid = this.contextid;


if ( rgItem.amount && rgItem.amount > 1 )
// tags
{
this.tags = null;
rgItem.original_amount = rgItem.amount;
this.m_$TagContainer = $J('<div/>', {id: 'tags_' + this.m_strCompositeID, 'class': 'app_tags_container' } );
rgItem.is_stackable = true;
}


if( !rgItem.tags )
// things we'll know after the initial load
rgItem.tags = [];
this.m_ulLastAssetID = 0;
this.m_bFullyLoaded = false;
this.m_bPerformedInitialLoad = false;


if ( !g_bIsTrading && !g_bShowTradableItemsOnly )
this.m_rgPages = [];
{
this.m_cPages = 0;
if( rgItem.tradable )
this.m_iCurrentPage = 0;
rgItem.tags.push( kStandardTag_Tradable );
this.m_bNeedsRepagination = true;
else
this.m_fnQueuedPageTransition = null;
rgItem.tags.push( kStandardTag_Untradable );
}


if( rgItem.marketable )
this.m_tsLastError = 0;
rgItem.tags.push( kStandardTag_Marketable );
this.m_$ErrorDisplay = null;
else
rgItem.tags.push( kStandardTag_Unmarketable );


for( var tagid in rgItem.tags )
// appwide parent inventory, if viewing "all {gamename} items"
{
this.m_parentInventory;
var rgTag = rgItem.tags[ tagid ];
var rgCategory = this.tags[ rgTag.category ];


if( !rgCategory )
this.m_bActive = false;
{
if( typeof rgTag.category != "string" )
continue;


rgCategory = this.tags[ rgTag.category ] = { "name": rgTag.category_name ? rgTag.category_name : rgTag.category, "tags": {} };
this.m_ActivePromise = null;
}
}


if( rgCategory.tags[ rgTag.internal_name ] )
CInventory.prototype.SetActivePromise = function( promise )
rgCategory.tags[ rgTag.internal_name ].count++;
{
else
// hopefully there is not one already?
{
this.m_ActivePromise = promise;
var rgNewTag = { "name": rgTag.name, "count": 1 };
var _this = this;
if( rgTag.color )
promise.always( function() { _this.m_ActivePromise = null; } );
rgNewTag.color = rgTag.color;
rgCategory.tags[ rgTag.internal_name ] = rgNewTag;
}
}
}
}


if ( this.rgCurrency )
return promise;
{
};
for ( var currencyid in this.rgCurrency )
{
var rgCurrency = this.rgCurrency[currencyid];
rgCurrency.appid = this.appid;
rgCurrency.contextid = this.contextid;
rgCurrency.original_amount = rgCurrency.amount;
rgCurrency.is_currency = true;
rgCurrency.is_stackable = true;


if( !rgCurrency.tags )
CInventory.prototype.BIsPendingInventory = function()
rgCurrency.tags = [];
{
// lie
return false;
};


if ( !g_bIsTrading && !g_bShowTradableItemsOnly )
CInventory.prototype.BIsEmptyInventory = function()
{
{
if( rgCurrency.tradable )
return this.m_cItems == 0;
rgCurrency.tags.push( kStandardTag_Tradable );
};
else
rgCurrency.tags.push( kStandardTag_Untradable );
}


if( rgCurrency.marketable )
CInventory.prototype.BIsFullyLoaded = function()
rgCurrency.tags.push( kStandardTag_Marketable );
{
else
return this.m_bFullyLoaded;
rgCurrency.tags.push( kStandardTag_Unmarketable );
};


for( var tagid in rgCurrency.tags )
CInventory.prototype.RetryLoad = function()
{
{
var rgTag = rgCurrency.tags[ tagid ];
this.m_tsLastError = 0;
var rgCategory = this.tags[ rgTag.category ];
return this.LoadMoreAssets();
};


if( !rgCategory )
CInventory.prototype.destroy = function()
{
{
if( typeof rgTag.category != "string" )
$J(window).off('scroll.LazyLoad_' + this.m_strCompositeID );
continue;
this.m_$Inventory.remove();
this.m_$TagContainer.remove();
};


rgCategory = this.tags[ rgTag.category ] = { "name": rgTag.category_name ? rgTag.category_name : rgTag.category, "tags": {} };
CInventory.prototype.getInventoryElement = function()
}
{
return this.m_$Inventory[0];
};


if( rgCategory.tags[ rgTag.internal_name ] )
CInventory.prototype.getTagContainer = function()
rgCategory.tags[ rgTag.internal_name ].count++;
{
else
return this.m_$TagContainer[0];
{
};
var rgNewTag = { "name": rgTag.name, "count": 1 };
if( rgTag.color )
rgNewTag.color = rgTag.color;
rgCategory.tags[ rgTag.internal_name ] = rgNewTag;
}
}
}


}
CInventory.prototype.GetInventoryLoadURL = function()
},
{
return 'https://steamcommunity.com/inventory/' + this.m_steamid + '/' + this.m_appid + '/' + this.m_contextid;
};


getCompositeID: function()
CInventory.prototype.hide = function() {
{
$J(window).off('scroll.LazyLoad_' + this.m_strCompositeID );
return this.owner.GetSteamId() + '_' + this.appid + '_' + this.contextid;
this.m_$Inventory.hide();
},
this.m_$TagContainer.hide();


destroy: function()
if ( this.m_$ErrorDisplay )
{
this.m_$ErrorDisplay.hide();
$J(window).off('scroll.LazyLoad_' + this.getCompositeID() );
if ( this.elInventory )
{
if ( this.elInventory.parentNode )
this.elInventory.remove();


this.elInventory = null;
this.m_bActive = false;
}
};
if ( this.elTagContainer )
{
if ( this.elTagContainer.parentNode )
this.elTagContainer.remove();
this.elTagContainer = null;
}
},


getInventoryElement: function()
CInventory.prototype.show = function()
{
{
return this.elInventory;
if ( !this.m_bPerformedInitialLoad )
},
this.PerformInitialLoad();


getTagContainer: function()
this.m_$Inventory.show();
{
this.m_$TagContainer.show();
return this.elTagContainer;
this.m_bActive = true;
},
this.ShowPageControlsIfNeeded();


hide: function()
if ( this.m_tsLastError && this.m_$ErrorDisplay )
{
this.m_$ErrorDisplay.show();
$J(window).off('scroll.LazyLoad_' + this.getCompositeID() );
if ( this.elInventory )
this.elInventory.hide();
if( this.elTagContainer )
this.elTagContainer.hide();
},


show: function()
var _this = this;
{
this.elInventory.show();


var _this = this;
$J(window).on('scroll.LazyLoad_' + this.m_strCompositeID, function() {


$J(window).on('scroll.LazyLoad_' + this.getCompositeID(), function() {
if ( !_this.m_rgLazyLoadImages || !_this.m_rgLazyLoadImages.length )
if ( !_this.m_rgLazyLoadImages || !_this.m_rgLazyLoadImages.length )
return;
return;


var nPageHeight = $J(window).height();
var nPageHeight = $J(window).height();
var nStartOffset = $J(window).scrollTop() - ( nPageHeight * 0.5 );
var nStartOffset = $J(window).scrollTop() - ( nPageHeight * 0.5 );
var nEndOffset = $J(window).scrollTop() + ( nPageHeight * 1.5 );
var nEndOffset = $J(window).scrollTop() + ( nPageHeight * 1.5 );
var rgLazyLoadImages = _this.m_rgLazyLoadImages;
var rgLazyLoadImages = _this.m_rgLazyLoadImages;


var iStart, iEnd;
var iStart, iEnd;
for ( iStart = 0; iStart < rgLazyLoadImages.length; iStart++ )
for ( iStart = 0; iStart < rgLazyLoadImages.length; iStart++ )
{
if ( rgLazyLoadImages[iStart].offset().top > nStartOffset )
break;
}
if ( iStart < rgLazyLoadImages.length )
{
for ( iEnd = iStart; iEnd < rgLazyLoadImages.length; iEnd++ )
{
{
if ( rgLazyLoadImages[iStart].offset().top > nStartOffset )
if ( rgLazyLoadImages[iEnd].offset().top > nEndOffset )
break;
break;
}
}
if ( iStart < rgLazyLoadImages.length )
{
for ( iEnd = iStart; iEnd < rgLazyLoadImages.length; iEnd++ )
{
if ( rgLazyLoadImages[iEnd].offset().top > nEndOffset )
break;
}


if ( iStart != iEnd )
if ( iStart != iEnd )
{
{
// we could have loaded these in the loop above, but there is better
_this.LazyLoadImageRange( iStart, iEnd );
// perf doing it all at once rather than alternating between loading images and querying position()
for ( var i = iStart; i < iEnd; i++ )
_this.LoadItemImage( rgLazyLoadImages[i][0].firstChild );

rgLazyLoadImages.splice( iStart, iEnd - iStart );
}
}
}
});
}

});
},
};

BIsEmptyInventory: function()
{
return !this.rgInventory && !this.rgCurrency;
},


BIsPendingInventory: function()
// appwide inventory has special logic here
CInventory.prototype.LazyLoadImageRange = function( iStart, iEnd )
{
// we could have loaded these in the loop above, but there is better
// perf doing it all at once rather than alternating between loading images and querying position()
var $LastItem;
for ( var i = iStart; i < iEnd; i++ )
{
{
// pending means we are still waiting for the inventory to load
$LastItem = $J( this.m_rgLazyLoadImages[i][0].firstChild );
return false;
this.LoadItemImage( $LastItem );
},
}


Initialize: function()
// make sure we've loaded inventory up until where they've scrolled
if ( $LastItem.hasClass( 'pendingItem' ) )
{
{
if ( !this.BIsEmptyInventory() )
this.LoadUntilConditionMet( function() { return !$LastItem.hasClass( 'pendingItem' ); } );
{
}
this.BuildInventoryDisplayElements();
}

this.BuildInventoryTagFilters();


this.bNeedsRepagination = true;
this.m_rgLazyLoadImages.splice( iStart, iEnd - iStart );
};


this.initialized = true;
CInventory.prototype.AddInventoryData = function( data )
},
{
this.m_bFullyLoaded = !data.more_items;
this.m_ulLastAssetID = data.last_assetid;


TagCheckboxChanged: function( )
if ( data.descriptions )
{
{
// build an array of the selected tags
for ( var i = 0; i < data.descriptions.length; i++ )
var rgCategories = {};
{
var description = data.descriptions[i];
var key = description.classid;
if ( description.instanceid && description.instanceid != '0' )
key += '_' + description.instanceid;


this.elTagContainer.select('.econ_tag_filter_category').each(function( elCategory ){
if ( !this.m_rgDescriptions[ key ] )
var rgTags = [];
{
if ( !description.tags )
description.tags = [];


$( elCategory ).select( '.econ_tag_filter_checkbox' ).each( function( elCheckbox ) {
if ( !g_bIsTrading && !g_bShowTradableItemsOnly )
if( $(elCheckbox).checked )
{
{
var elParent = $(elCheckbox).up();
if ( description.tradable )
elParent.addClassName( "filtered" );
description.tags.push( kStandardTag_Tradable );
rgTags.push($(elCheckbox).readAttribute( 'tag_name' ) );
else
description.tags.push( kStandardTag_Untradable );
}
}

if( description.marketable )
description.tags.push( kStandardTag_Marketable );
else
else
{
description.tags.push( kStandardTag_Unmarketable );
$(elCheckbox).up().removeClassName( "filtered" );
}
});


if( rgTags.length )
description.use_count = 0;
rgCategories[ elCategory.category_name ] = rgTags;
});


Filter.UpdateTagFiltering( rgCategories );
this.m_rgDescriptions[key] = description;
},
}
}
}


BuildInventoryTagFilters: function()
// make sure we have enough element containers for the total number of items
if ( data.total_inventory_count != this.m_cItems )
{
{
if( !this.elTagContainer )
this.m_cItems = data.total_inventory_count;
return;
this.EnsureItemHoldersCreated();

}
$J('#' + this.elTagContainer.id).empty();


for( var sCategoryName in this.tags )
if ( data.assets )
{
for ( var i = 0; i < data.assets.length; i++ )
{
{
if( typeof sCategoryName != "string" )
var asset = data.assets[i];
continue;
var rgCategory = this.tags[ sCategoryName ];
var elTagCategory = new Element( 'div', { 'class' : 'econ_tag_filter_category' } );
elTagCategory.category_name = sCategoryName;


var elTagCategoryLabel = new Element( 'div', { 'class' : 'econ_tag_filter_category_label' } );
// add some fields we use in javascript
$J(elTagCategoryLabel).text( rgCategory.name );
asset.is_currency = !!asset.currencyid;
elTagCategory.appendChild( elTagCategoryLabel );


var rgCategoryTags = [];
var bIsStackable = asset.is_currency || ( asset.amount && asset.amount > 1 );
//quickly determine the total number of valid tags

var cTagsTotal = 0;
if ( bIsStackable )
for ( var sInternalName in rgCategory.tags )
{
{
if ( typeof sInternalName == 'string' )
asset.original_amount = asset.amount;
cTagsTotal++;
asset.is_stackable = true;
}
}


var elTagCtn = elTagCategory;
var strDescriptionKey = asset.classid;
if ( asset.instanceid && asset.instanceid != '0' )
strDescriptionKey += '_' + asset.instanceid;

var description = this.m_rgDescriptions[ strDescriptionKey ];
asset.description = description;
asset.description.use_count++;

if ( asset.is_currency )
this.m_rgCurrencies[ asset.currencyid ] = asset;
else
this.m_rgAssets[ asset.assetid ] = asset;


var cTagsDisplayed = 0;
var $ItemHolder = this.m_rgItemElements[ this.m_iNextEmptyItemElement++ ];
for( var sInternalName in rgCategory.tags )
var $Item = $ItemHolder.children( '.item' );
{
if( !rgCategory.tags.hasOwnProperty( sInternalName ) )
continue;


var rgTag = rgCategory.tags[ sInternalName ];
this.BuildItemElement( asset, $Item );
rgTag.internal_name = sInternalName;
rgCategoryTags.push( rgTag );
}


rgCategoryTags.sort( function( a, b ) {
var aName = a.name.toUpperCase();
var bName = b.name.toUpperCase();
if ( aName < bName ) return -1;
if ( aName > bName ) return 1;
return 0;
} );


for( var index in rgCategoryTags )
$ItemHolder[0].rgItem = asset;
{
if( !rgCategoryTags.hasOwnProperty( index ) )
continue;


var rgTag = rgCategoryTags[ index ];
if ( g_bTradeOffer && this.m_owner == UserThem )
var sInternalName = rgTag.internal_name;
{
asset.is_their_item = true;
}


var elTagDiv = new Element( 'div', { 'class' : 'econ_tag_filter_container' } );
asset.element = $Item[0];
asset.homeElement = $ItemHolder[0];


var sCheckboxName = 'tag_filter_' + ( this.owner && this.owner != UserYou ? 'them_' : '' );
sCheckboxName += this.appid + '_' + this.contextid + '_' + sCategoryName + '_' + sInternalName;
var elTagFilter = new Element( 'input', { 'class' : 'econ_tag_filter_checkbox', 'type' : 'checkbox', 'name' : sCheckboxName, 'id' : sCheckboxName, 'tag_name' : sInternalName } );
var elTagLabel = new Element( 'label', { 'class' : 'econ_tag_filter_label', 'for' : sCheckboxName } );


if( rgTag.color )
if ( g_bIsTrading )
{
{
var elTagName = new Element( 'span' );
CreateItemContextMenuButton( $ItemHolder[0], this.m_strCompositeID, this.m_owner );
$J(elTagName).text( rgTag.name );
if ( !g_bReadOnly )
elTagName.style.color = "#" + rgTag.color;
elTagLabel.appendChild( elTagName );
}
else
{
{
$J(elTagLabel).text( rgTag.name );
if ( asset.is_stackable )
{
MakeCurrencyDraggable( $Item[0] );
}
else
{
MakeItemDraggable( $Item[0] );
}
}
}

}
var elItemCount = new Element( 'span', { 'class' : 'econ_tag_count' } );
}
elItemCount.update( " (" + rgTag.count + ")" );
}
elTagLabel.appendChild( elItemCount );

$( elTagFilter ).observe( 'change', this.TagCheckboxChanged.bind( this ) );


elTagDiv.appendChild( elTagFilter );
if ( this.m_bNeedsRepagination && this.m_bActive )
elTagDiv.appendChild( elTagLabel );
{
this.LayoutPages();
this.show();
}
};


if ( ++cTagsDisplayed == 5 && cTagsTotal > 7 )
CInventory.prototype.EnsureItemHoldersCreated = function()
{
{
var elExpandTags = new Element( 'div',{'class': 'econ_tag_filter_collapsable_tags_showlink whiteLink' } );
if ( this.m_rgItemElements.length != this.m_cItems )
var elCollapsedTagCtn = new Element( 'div', {'class': 'econ_tag_filter_collapsable_tags', style: 'display: none;' } );
{
elExpandTags.update( '+ Show more' );
this.m_bNeedsRepagination = true;
Event.observe( elExpandTags, 'click', (function( elExpandLink, elDivToExpand ) { elExpandLink.hide(); new Effect.BlindDown( elDivToExpand, {duration: 0.25} ); } ).bind( null, elExpandTags, elCollapsedTagCtn ) );


elTagCtn.appendChild( elExpandTags );
if ( this.m_rgItemElements.length < this.m_cItems )
elTagCtn.appendChild( elCollapsedTagCtn );
{
var $ItemHolder = $J('<div/>', {'class': 'itemHolder'} );


elTagCtn = elCollapsedTagCtn;
var $Item = $J('<div/>', {'class': 'item pendingItem app' + this.m_appid + ' context' + this.m_contextid } );
}
$Item.append( $J('<img/>', {src: 'https://steamcommunity-a.akamaihd.net/public/images/trans.gif' } ) );
$ItemHolder.append( $Item );


elTagCtn.appendChild( elTagDiv );
while ( this.m_rgItemElements.length < this.m_cItems )
{
var $NewItem = $ItemHolder.clone();
this.m_rgItemElements.push( $NewItem );
}
}

this.elTagContainer.appendChild( elTagCategory );
}
}

else
// add a div to clear the floating
{
this.elTagContainer.appendChild( new Element( 'div', { "style" : "clear: left;" } ) );
// count went down - unexpected but just handle it. it shouldn't be possible to load past the item count, so
},
// these should be empty elements we're removing
this.m_rgItemElements = this.m_rgItemElements.slice( 0, this.m_cItems );
}
}
};


BuildInventoryDisplayElements: function()
// called when readonly mode is disabled
CInventory.prototype.MakeElementsDraggable = function()
{
for ( var currencyid in this.m_rgCurrencies )
{
{
for ( var currencyid in this.rgCurrency )
var asset = this.m_rgCurrencies[currencyid];
MakeCurrencyDraggable( asset.element );
}
for ( var assetid in this.m_rgAssets )
{
var asset = this.m_rgAssets[assetid];
if ( asset.is_stackable )
{
{
Text moved with changes from lines 266-271 (87.9% similarity)
var rgCurrency = this.rgCurrency[currencyid];
MakeCurrencyDraggable( asset.element );
}
else
{
MakeItemDraggable( asset.element );
}
}
};


// hide wallet currencies this user does not care about
CInventory.prototype.PerformInitialLoad = function( count )
if ( CurrencyIsWalletFunds( rgCurrency ) &&
{
( g_bWalletTradeUnavailable ||
if ( this.m_bPerformedInitialLoad )
( typeof(g_rgWalletInfo) != 'undefined' && g_rgWalletInfo['wallet_currency'] != ( rgCurrency.id % 1000 ) ) ) )
return $J.Deferred().resolve();
{
else
continue;
return this.LoadMoreAssets( count );
}
};


var elCurrency = this.BuildItemElement( rgCurrency );
CInventory.prototype.LoadMoreAssets = function( count )
{
if ( this.m_ActivePromise )
return this.m_ActivePromise;


var elItemHolder = new Element( 'div', {'class': 'itemHolder' } );
if ( this.m_bFullyLoaded )
elItemHolder.appendChild( elCurrency );
return $J.Deferred().resolve().promise();
elItemHolder.rgItem = elCurrency.rgItem;


this.rgItemElements.push( elItemHolder );
// we won't re-request for 5 seconds after a failure
if ( this.m_tsLastError && $J.now() - this.m_tsLastError < 5000 )
return $J.Deferred().reject().promise();


var strCompositeId = this.owner.GetSteamId() + '_' + this.appid + '_' + this.contextid;
this.m_$Inventory.addClass('loading');
if ( g_bIsTrading )
var _this = this;
{
CreateItemContextMenuButton( elItemHolder, strCompositeId, this.owner );
}


rgCurrency.element = elCurrency;
if ( !count )
rgCurrency.homeElement = elItemHolder;
count = this.m_bPerformedInitialLoad ? 250 : 75;
}


var rgSortedInventory = { };
var params = {
for ( var itemid in this.rgInventory )
'l': 'english',
{
'count': count
var rgItem = this.rgInventory[itemid];
};
rgSortedInventory[rgItem.pos] = rgItem;
}


for ( var pos in rgSortedInventory )
if ( this.m_ulLastAssetID )
{
params.start_assetid = this.m_ulLastAssetID;
var rgItem = rgSortedInventory[pos];
var itemid = rgItem.id;
var elItem;


try {
this.m_owner.ShowLoadingIndicator();
elItem = this.BuildItemElement( rgItem );
}
catch ( e )
{
elItem = this.BuildUnknownItemElement( itemid );
}


if ( g_bTradeOffer && this.owner == UserThem )
return this.SetActivePromise( $J.get( this.GetInventoryLoadURL(), params
{
).done( function( data ) {
rgItem.is_their_item = true;
_this.m_bPerformedInitialLoad = true;
}
_this.m_$Inventory.removeClass('loading');
_this.AddInventoryData( data );
_this.m_tsLastError = 0;
_this.HideInventoryLoadError();
}).fail( function() {
_this.m_tsLastError = $J.now();
_this.ShowInventoryLoadError();
}).always( function() {
_this.m_owner.HideLoadingIndicator();
}) ).promise();
};


var elItemHolder = new Element( 'div', {'class': 'itemHolder' } );
CInventory.prototype.ShowInventoryLoadError = function()
elItemHolder.appendChild( elItem );
{
elItemHolder.rgItem = elItem.rgItem;
if ( !this.m_$ErrorDisplay )
{
/*
*/


this.rgItemElements.push( elItemHolder );
this.m_$ErrorDisplay = $J('<div/>').html( "\t\t\t<div class=\"inventory_load_error\">\r\n\t\t\t\t<div class=\"inventory_load_error_header\">\r\n\t\t\t\t\t<img src=\"https:\/\/steamcommunity-a.akamaihd.net\/public\/images\/economy\/market\/icon_alertlistings.png\" class=\"load_error_icon\">\r\n\t\t\t\t\tThis inventory is not available at this time. Please try again later.\t\t\t\t\t&nbsp;\r\n\t\t\t\t\t<div class=\"btnv6_blue_hoverfade btn_small retry_load_btn\">\r\n\t\t\t\t\t\t<span>Try Again<\/span>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t\t&nbsp;\r\n\t\t\t\t\t<span class=\"inventory_loading_indicator\">\r\n\t\t\t\t\t\t<img src=\"https:\/\/steamcommunity-a.akamaihd.net\/public\/images\/login\/throbber.gif\">\r\n\t\t\t\t\t<\/span>\r\n\t\t\t\t<\/div>\r\n\t\t\t<\/div>\r\n\t\t" ).hide();


var strCompositeId = this.owner.GetSteamId() + '_' + this.appid + '_' + this.contextid;
var _this = this;
if ( g_bIsTrading )
this.m_$ErrorDisplay.find( '.retry_load_btn').click( function() { _this.RetryLoad(); } );
{

CreateItemContextMenuButton( elItemHolder, strCompositeId, this.owner );
this.m_owner.GetInventoryLoadDisplayElement().append( this.m_$ErrorDisplay );
}
}

if ( this.m_bActive )
this.m_$ErrorDisplay.slideDown();

if ( this.m_parentInventory )
this.m_parentInventory.ShowInventoryLoadError();
};

CInventory.prototype.HideInventoryLoadError = function()
{
if ( this.m_$ErrorDisplay && this.m_$ErrorDisplay.is(':visible') )
this.m_$ErrorDisplay.slideUp();


rgItem.element = elItem;
if ( this.m_parentInventory )
rgItem.homeElement = elItemHolder;
this.m_parentInventory.HideInventoryLoadError();
}
};


if ( g_bIsTrading && !g_bReadOnly )
CInventory.prototype.LoadUntilConditionMet = function( fnCondition, count )
this.MakeElementsDraggable();
{
},
var deferred = new $J.Deferred();
this.LoadUntilConditionMetInternal( fnCondition, count, deferred );
return deferred.promise();
};


MakeElementsDraggable: function()
CInventory.prototype.LoadUntilConditionMetInternal = function( fnCondition, count, deferred )
{
if ( !fnCondition() )
{
{
for ( var currencyid in this.rgCurrency )
// keep queueing more loads until it evaluates to true
{
var _this = this;
var rgCurrency = this.rgCurrency[currencyid];


if ( rgCurrency.element )
if ( this.m_bFullyLoaded )
MakeCurrencyDraggable( rgCurrency.element );
{
deferred.reject(); // never happening
}
}
for ( var itemid in this.rgInventory )
else
{
{
var rgItem = this.rgInventory[itemid];
this.LoadMoreAssets( count ).done( function() {
if ( rgItem.is_stackable )
// will check immediately
MakeCurrencyDraggable( rgItem.element );
_this.LoadUntilConditionMetInternal( fnCondition, count, deferred );
else
}).fail( function() {
MakeItemDraggable( rgItem.element );
deferred.reject();
});
}
}
},
}
else
{
deferred.resolve();
}
};


LayoutPages: function()
CInventory.prototype.LoadCompleteInventory = function()
{
var _this = this;
return this.LoadUntilConditionMet( function() { return _this.m_bFullyLoaded; }, 5000 /* a lot at a time */ );
};

CInventory.prototype.BuildItemElement = function( asset, $Item )
{
var description = asset.description || {};

var assetid = asset.is_currency ? 'c' + asset.currencyid : asset.assetid;

$Item.attr('id', this.appid + '_' + this.contextid + '_' + assetid ).removeClass('pendingItem');

if ( description.name_color )
$Item.css( 'borderColor', '#' + description.name_color );
if ( description.background_color )
$Item.css( 'backgroundColor', '#' + description.background_color );

// compat
$Item[0].rgItem = asset;

var strImageURL;

if ( asset.is_stackable )
strImageURL = ImageURL( description.icon_url, '96f', '58f', true );
else
strImageURL = ImageURL( description.icon_url, '96f', '96f', true );

if ( $Item.data('imageLoaded') )
$Item.children( 'img' ).attr( 'src', strImageURL );
else
$Item.data( 'lazyLoadImage', strImageURL );

if ( asset.is_stackable )
{
{
// remove any current page elements
var $Amount = $J( '<div/>', { 'class': 'item_currency_amount' } );
this.elInventory.childElements().invoke('remove');
if ( description.name_color )
$Amount.css( 'color', '#' + description.name_color );


var elPage = new Element( 'div', {'class': 'inventory_page' } );
$Amount.text( v_numberformat( asset.amount ) );
this.m_rgLazyLoadImages = [];
var oPageBuilder = { elPage: elPage, cPageItemsRemaining: INVENTORY_PAGE_ITEMS };


for ( var iItem = 0; iItem < this.rgItemElements.length; iItem++ )
var $CurrencyName = $J( '<div/>', { 'class': 'item_currency_name' } );
{
if ( description.name_color )
var elItemHolder = this.rgItemElements[iItem];
$CurrencyName.css( 'color', '#' + description.name_color );


if ( elItemHolder.parentNode )
$CurrencyName.text( asset.is_currency ? description.name : '' );
elItemHolder.remove();
this.AddElementToPage( elItemHolder, oPageBuilder );
}


if ( !g_bEnableDynamicSizing )
$Item.append( $Amount, $CurrencyName );
{
}
for ( var i = 0; i < oPageBuilder.cPageItemsRemaining; i++ )

{
if ( g_bIsTrading )
oPageBuilder.elPage.appendChild( new Element( 'div', {'class': 'itemHolder disabled' } ) );
{
}
// TODO
}
Event.observe( $Item[0], 'mouseover', MouseOverItem.bindAsEventListener( null, this.m_owner, $Item[0], asset ) );
oPageBuilder.elPage.hide();
Event.observe( $Item[0], 'mouseout', MouseOutItem.bindAsEventListener( null, this.m_owner, $Item[0], asset ) );
this.elInventory.appendChild( oPageBuilder.elPage );
}

var url = ( g_bIsTrading ? this.GetInventoryPageURL() : '' ) + '#' + this.appid + '_' + this.contextid + '_' + asset.assetid;
var $Link = $J( '<a/>', { href: url, 'class': 'inventory_item_link' } );
$Item.append( $Link );
this.BindMouseEvents( $Link, $Item, asset );


var rgPages = this.elInventory.childElements();
if ( description.fraudwarnings )
this.pageList = rgPages;
{
this.pageTotal = rgPages.length;
var $FraudWarningIcon = $J( '<div/>', {'class': 'slot_app_fraudwarning' } );
for ( var i = 0; i < rgPages.length; i++ )
$Item.append( $FraudWarningIcon );
rgPages[i].iPage = i;
}


this.elInventory.appendChild( new Element ('div', {'style': 'clear: left;' } ) );
return $Item;
};


this.bNeedsRepagination = false;
CInventory.prototype.GetInventoryPageURL = function()
},
{
return this.m_owner.GetProfileURL() + '/inventory/';
};


AddElementToPage: function( elItemHolder, oPageBuilder )
CInventory.prototype.BindMouseEvents = function( $Link, $Item, asset )
{
{
if ( g_bEnableDynamicSizing )
// on trade UI, we only do "select item" for touches
{
var _this = this;
if ( elItemHolder.firstChild.lazyload_image )
$Link.on( 'click', function( e ) {
{
e.preventDefault();
this.m_rgLazyLoadImages.push( $J(elItemHolder) );
_this.SelectItem( e, $Item, asset, true );
}
if ( asset.in_touch )
}
else if ( oPageBuilder.cPageItemsRemaining-- <= 0 )
{
{
oPageBuilder.elPage.hide();
$Item.parents('.itemHolder').removeClass('in_touch');
this.elInventory.appendChild( oPageBuilder.elPage );
delete asset.in_touch;
oPageBuilder.elPage = new Element( 'div', {'class': 'inventory_page' } );
oPageBuilder.cPageItemsRemaining = INVENTORY_PAGE_ITEMS - 1;
}
}
} );


oPageBuilder.elPage.appendChild( elItemHolder );
if ( g_bIsTrading )
},
{
$Link.on( 'touchstart', function() {
asset.in_touch = true;
$Item.parents('.itemHolder').addClass('in_touch');
} );
}
};


CInventory.prototype.ShowTags = function()
{
var _this = this;


BuildItemElement: function( rgItem )
if ( !this.m_bFullyLoaded )
{
{
var elItem = new Element( 'div', { id: 'item' + this.appid + '_' + this.contextid + '_' + rgItem.id, 'class': 'item app' + this.appid + ' context' + this.contextid } );
this.m_$TagContainer.html( '<div class="inventory_loading_indicator "><img src="https://steamcommunity-a.akamaihd.net/public/images/login/throbber.gif"></div>');
if ( rgItem.name_color )
}
elItem.style.borderColor = '#' + rgItem.name_color;

if ( rgItem.background_color )
this.LoadCompleteInventory().done( function() {
elItem.style.backgroundColor = '#' + rgItem.background_color;
if ( !_this.tags )
_this.ReadTags();


rgItem.appid = this.appid;
_this.BuildInventoryTagFilters();
rgItem.contextid = this.contextid;
});
elItem.rgItem = rgItem;
};


if ( rgItem.is_stackable )
CInventory.prototype.ReadTags = function()
elItem.lazyload_image = ImageURL( rgItem.icon_url, '96f', '58f', true );
{
else
this.tags = {};
elItem.lazyload_image = ImageURL( rgItem.icon_url, '96f', '96f', true );


if ( typeof( rgItem.icon_drag_url ) != 'undefined' && rgItem.icon_drag_url != '' )
for ( var key in this.m_rgDescriptions )
{
{
if ( rgItem.is_stackable )
var description = this.m_rgDescriptions[key];
elItem.drag_image = ImageURL( rgItem.icon_drag_url, '96f', '58f', true );
if ( !description.use_count )
else
continue;
elItem.drag_image = ImageURL( rgItem.icon_drag_url, '96f', '96f', true );
}


if ( rgItem.is_stackable )
for ( var tagid in description.tags )
{
{
var elAmount = new Element( 'div', { 'class': 'item_currency_amount' } );
var rgTag = description.tags[tagid];
if ( rgItem.name_color )
var rgCategory = this.tags[ rgTag.category ];
elAmount.style.color = '#' + rgItem.name_color;


if ( CurrencyIsWalletFunds( rgItem ) )
if( !rgCategory )
elAmount.update( v_currencyformat( rgItem.amount, rgItem.name ) );
{
else
if( typeof rgTag.category != "string" )
elAmount.update( v_numberformat( rgItem.amount ) );
continue;


elItem.appendChild( elAmount );
rgCategory = this.tags[ rgTag.category ] = { "name": rgTag.localized_category_name ? rgTag.localized_category_name : rgTag.category, "tags": {} };
}


var elCurrencyName = new Element( 'div', { 'class': 'item_currency_name' } );
if( rgCategory.tags[ rgTag.internal_name ] )
if ( rgItem.name_color )
{
elCurrencyName.style.colo
rgCategory.tags[ rgTag.internal_name ].count += description.use_count;
}
else
{
var rgNewTag = { "name": rgTag.localized_tag_name, "count": description.use_count };
if( rgTag.color )
rgNewTag.color = rgTag.color;
rgCategory.tags[ rgTag.internal_name ] = rgNewTag;
}