Advertisement
Guest User

php ce vrea asta de la mine

a guest
Jun 10th, 2016
2,558
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 127.98 KB | None | 0 0
  1. var lowestPriceWithFeeRegExp = /<span class="market_listing_price market_listing_price_with_fee">\s*(((?!Sold).)*?)\s*<\/span>/i;
  2. var lowestPriceWithoutFeeRegExp = /<span class="market_listing_price market_listing_price_without_fee">\s*(((?!Sold).)*?)\s*<\/span>/i;
  3. var insGemExp = /<span style="font-size: 18px; color: rgb\(255, 255, 255\)">(((?!:).)*?): \d+<\/span><br><span style="font-size: 12px">Inscribed Gem<\/span>/gi;
  4. var kinGemExp = /<span style="font-size: 18px; color: rgb\(255, 255, 255\)">(((?!<).)*?)<\/span><br><span style="font-size: 12px">Kinetic Gem<\/span>/gi;
  5. var priGemExp = /<span style="font-size: 18px; color: rgb\(\d+, \d+, \d+\)">(((?!<).)*?)<\/span><br><span style="font-size: 12px">Prismatic Gem<\/span>/gi;
  6. var ethGemExp = /<span style="font-size: 18px; color: rgb\(255, 255, 255\)">(((?!<).)*?)<\/span><br><span style="font-size: 12px">Ethereal Gem<\/span>/gi;
  7. var corGemExp = /<span style="font-size: 18px; color: rgb\(255, 255, 255\)">(((?!:).)*?): \d+<\/span><br><span style="font-size: 12px">Foulfell Shard<\/span>/gi;
  8. var masGemExp = /<span style="font-size: 18px; color: rgb\(255, 255, 255\)">(((?!:).)*?): \d+<\/span><br><span style="font-size: 12px">Rune of the Duelist Indomitable<\/span>/gi;
  9. var buyingExp = /javascript:BuyMarketListing\('listing', '(\d+)', (\d+), '(\d+)', '(\d+)'\)/;
  10. var cachePrices = {};
  11. var itemsInTrades = [];
  12. var sellingStack = {};
  13. var selectmode = false;
  14. var currencyId = 1;
  15. var sellcurrencyId = 1;
  16. var lastSelectedItem = null;
  17. var apiItems = {};
  18. var dotahatteryAlias = {
  19. 'doom_bringer': 'doom',
  20. 'treant': 'treant_protector',
  21. 'shadow_shaman': 'shadowshaman',
  22. 'naga_siren': 'siren',
  23. 'nyx_assassin': 'nerubian_assassin',
  24. 'drow_ranger': 'drow',
  25. 'riki': 'rikimaru',
  26. 'templar_assassin': 'lanaya',
  27. 'nevermore': 'shadow_fiend',
  28. 'vengefulspirit': 'vengeful',
  29. 'witch_doctor': 'witchdoctor',
  30. 'gyrocopter': 'gyro',
  31. 'tusk': 'tuskarr',
  32. 'bloodseeker': 'blood_seeker',
  33. 'skeleton_king': 'wraith_king'
  34. };
  35.  
  36. if (typeof (BShouldSuppressFades) == 'undefined') {
  37. BShouldSuppressFades = function () { return false; };
  38. }
  39.  
  40. var checkPrice = function () {
  41. var currentIdx = $J('#iteminfo0').is(':visible') ? 0 : 1;
  42. var name = $J('#iteminfo' + currentIdx + '_item_name').text();
  43. getLowestPriceHandler();
  44. }
  45.  
  46. var reloadDes = function () {
  47. var sOldInfo = 'iteminfo' + iActiveSelectView;
  48. var elDescriptors = $(sOldInfo + '_item_descriptors');
  49. PopulateDescriptions(elDescriptors, g_ActiveInventory.selectedItem.descriptions);
  50. }
  51. var mediumPrice = 0;
  52. var mediumName = '';
  53. var getSetLink = function (d, sItem, isGenuine) {
  54. var itname = d.market_hash_name || d.value;
  55. //if (itname.indexOf('The ') == 0) itname = itname.substring(4);
  56. var setLink = window.location.protocol + '//steamcommunity.com/market/priceoverview/?appid=570&country=' + g_strCountryCode + '&currency=' + currencyId + '&market_hash_name=' + (isGenuine ? 'Genuine%20' : '') + encodeURIComponent(itname);
  57. d.setLink = setLink;
  58. d.isinset = true;
  59. if (cachePrices[setLink] && cachePrices[setLink].lowestPrice) {
  60. d.app_data.price = cachePrices[setLink].lowestPrice;
  61. d.app_data.market_hash_name = cachePrices[setLink].market_hash_name;
  62. d.app_data.owned = cachePrices[setLink].owned;
  63.  
  64. //d.value = '<a href="http://steamcommunity.com/market/listings/' + sItem.appid + "/" + cachePrices[setLink].market_hash_name + '" target="_blank" title="' + cachePrices[setLink].nofeePrice + '">' + d.value + ' (' + cachePrices[setLink].lowestPrice + ')</a>';
  65. if (sItem === g_ActiveInventory.selectedItem)
  66. reloadDes();
  67. return;
  68. }
  69. else {
  70. //if (itname.indexOf('The ') == 0) itname = itname.substring(4);
  71. cachePrices[setLink] = { market_hash_name: (isGenuine ? 'Genuine ' : '') + itname };
  72. //var owned = false;
  73. var exp = new RegExp('.*' + cachePrices[setLink].market_hash_name.replace('The ', '(The )?') + '$');
  74. //console.log(exp);
  75. $J.each(g_ActiveInventory.rgInventory, function () {
  76. if (exp.test(this.market_hash_name)) {
  77. cachePrices[setLink].market_hash_name = this.market_hash_name;
  78. cachePrices[setLink].owned = true;
  79. return false;
  80. }
  81. });
  82. d.app_data.market_hash_name = cachePrices[setLink].market_hash_name;
  83. d.app_data.owned = cachePrices[setLink].owned;
  84. d.value = '<a href="http://steamcommunity.com/market/listings/' + sItem.appid + "/" + cachePrices[setLink].market_hash_name + '" target="_blank" >' + d.value + '</a>';
  85. reloadDes();
  86. }
  87.  
  88. return;
  89. PriceQueue.GetPrice({
  90. method: "GET",
  91. url: setLink,
  92. success: function (response, textStatus, jqXHR) {
  93. var lp = 0, nfp = 0;
  94. if (response.success) {
  95. if (response.median_price) {
  96. cachePrices[this.url].lowestPrice = lp = response.lowest_price;
  97. cachePrices[this.url].nofeePrice = nfp = response.median_price;
  98. if (response.volume) {
  99. cachePrices[itemLink].volume = response.volume;
  100. }
  101. if (sItem === g_ActiveInventory.selectedItem) {
  102. for (var k = 0; k < sItem.descriptions.length; k++) {
  103. var dd = sItem.descriptions[k];
  104. if (dd.setLink == this.url) {
  105. dd.app_data.price = cachePrices[this.url].lowestPrice;
  106. dd.app_data.market_hash_name = cachePrices[this.url].market_hash_name;
  107. dd.app_data.owned = cachePrices[this.url].owned;
  108. //dd.value = '<a href="http://steamcommunity.com/market/listings/' + sItem.appid + "/" + cachePrices[this.url].market_hash_name + '" target="_blank" title="' + cachePrices[this.url].nofeePrice + '">' + dd.value + ' (' + cachePrices[this.url].lowestPrice + ')</a>';
  109. break;
  110. }
  111. }
  112. reloadDes();
  113. }
  114. }
  115. else if (itname.indexOf('The ') == 0) {
  116. d.market_hash_name = itname.substring(4);
  117. getSetLink(d, sItem, isGenuine);
  118. }
  119. }
  120. else if (itname.indexOf('The ') == 0) {
  121. d.market_hash_name = itname.substring(4);
  122. getSetLink(d, sItem, isGenuine);
  123. }
  124. },
  125. error: function () {
  126. if (itname.indexOf('The ') == 0) {
  127. d.market_hash_name = itname.substring(4);
  128. getSetLink(d, sItem, isGenuine);
  129. }
  130. }
  131. });
  132.  
  133. }
  134. var getMediumPrice = function (sItem) {
  135. if (!sItem.market_hash_name) {
  136. sItem.market_hash_name = sItem.name;
  137. }
  138. var itemLink = window.location.protocol + "//steamcommunity.com/market/priceoverview/?appid=" + sItem.appid + "&country=" + g_strCountryCode + "&currency=" + currencyId + "&market_hash_name=" + encodeURIComponent(sItem.market_hash_name);
  139. mediumName = sItem.market_hash_name;
  140. PriceQueue.GetPrice({
  141. method: "GET",
  142. url: itemLink,
  143. success: function (response) {
  144. if (response.success) {
  145. //cachePrices[itemLink] = new Object();
  146. mediumPrice = response.lowest_price;
  147. }
  148. }
  149. });
  150.  
  151. }
  152. var getGiftPrice = function (gitem) {
  153. var appIdExp = /http:\/\/store.steampowered.com\/app\/(\d+)\//;
  154. var storeLink = gitem.actions[0].link;
  155. var appid = appIdExp.exec(storeLink)[1];
  156. $J('.dd_price').html("Loading...");
  157. $J.ajax({
  158. url: '//store.steampowered.com/api/appdetails?appids=' + appid,
  159. crossDomain: true,
  160. success: function (res) {
  161. if (res && res[appid] && res[appid].success) {
  162. var price_overview = res[appid].data.price_overview;
  163. var strPrice = '';
  164. if (price_overview.discount_percent > 0) {
  165. strPrice = (price_overview.final / 100) + ' (-' + price_overview.discount_percent + ') ' + price_overview.currency;
  166. }
  167. else {
  168. strPrice = (price_overview.final / 100) + ' ' + price_overview.currency;
  169. }
  170. $J('.dd_price').html(strPrice);
  171. }
  172. },
  173. error: function () {
  174. $J('.dd_price').html("Error");
  175. }
  176. });
  177. }
  178.  
  179. var getLowestPriceHandler = function (gitem, callback) {
  180. var sItem = gitem || g_ActiveInventory.selectedItem;
  181. if (sItem.appid == 753 && sItem.actions && sItem.actions[0].link && sItem.actions[0].link.startsWith('http://store.steampowered.com/app/')) {
  182. //getGiftPrice(sItem);
  183. return;
  184. }
  185. if (!sItem.market_hash_name) {
  186. sItem.market_hash_name = sItem.name;
  187. }
  188. var theItemString = encodeURIComponent(name);
  189. // from Steam's community market website
  190. var appID = g_ActiveInventory.appid;
  191. //var marketLink = sItem.appid + '/' + sItem.market_hash_name + '/';
  192. //$J('.dd_price').html("Loading...");
  193. var isGenuine = false;
  194. var itemLink = window.location.protocol + "//steamcommunity.com/market/priceoverview/?appid=" + sItem.appid + "&country=" + g_strCountryCode + "&currency=" + currencyId + "&market_hash_name=" + encodeURIComponent(sItem.market_hash_name);
  195. var itemLinkW = window.location.protocol + "//steamcommunity.com/market/priceoverview/?appid=" + sItem.appid + "&country=" + g_strCountryCode + "&currency=" + sellcurrencyId + "&market_hash_name=" + encodeURIComponent(sItem.market_hash_name);
  196.  
  197. var marketLink = window.location.protocol + "//steamcommunity.com/market/listings/" + sItem.appid + "/" + encodeURIComponent(sItem.market_hash_name);
  198. if (cachePrices[itemLink] && cachePrices[itemLink].nofeePrice) {
  199. sItem.nofeePrice = cachePrices[itemLink].nofeePrice;
  200. sItem.lowestPrice = cachePrices[itemLink].lowestPrice;
  201. sItem.providerName = cachePrices[itemLink].providerName;
  202. }
  203. else {
  204. cachePrices[itemLink] = { market_hash_name: sItem.market_hash_name, owned: true };
  205. }
  206.  
  207. if (cachePrices[itemLinkW] && cachePrices[itemLinkW].nofeePrice) {
  208. sItem.nofeePriceW = cachePrices[itemLinkW].nofeePrice;
  209. sItem.lowestPriceW = cachePrices[itemLinkW].lowestPrice;
  210. sItem.providerName = cachePrices[itemLinkW].providerName;
  211. }
  212. else {
  213. cachePrices[itemLinkW] = { market_hash_name: sItem.market_hash_name, owned: true };
  214. }
  215.  
  216. $J.each(sItem.tags, function () {
  217. //console.log((this.category == 'Quality' && this.internal_name == 'genuine'));
  218. isGenuine = (isGenuine || (this.category == 'Quality' && this.internal_name == 'genuine'));
  219. if (isGenuine) return false;
  220. });
  221.  
  222.  
  223. if (window.agp_gem && sItem.type !== "Rare Inscribed Gem" && sItem.appid == 570) {
  224. for (var i = 0; i < sItem.descriptions.length; i++) {
  225. var d = sItem.descriptions[i];
  226. //if (d.type != 'html' && d.value.indexOf('Inscribed Gem') < 0 && d.value.indexOf('Kinetic Gem') < 0 && d.value.indexOf('Prismatic Gem') < 0 && d.value.indexOf('Ethereal Gem') < 0) continue;
  227. if (d.app_data && !d.app_data.is_itemset_name && !d.app_data.price && !d.app_data.limited) {
  228. getSetLink(d, sItem, isGenuine);
  229. }
  230. if (d.insgems) {
  231. break;
  232. }
  233.  
  234. var ematch, gidx = 0;
  235. d.insgems = [];
  236.  
  237. while ((ematch = insGemExp.exec(d.value))) {
  238. //console.log(ematch);
  239. var gemLink = window.location.protocol + '//steamcommunity.com/market/priceoverview/?appid=570&country=' + g_strCountryCode + '&currency=' + currencyId + '&market_hash_name=Inscribed ' + ematch[1];
  240. //var nText = ematch[0].replace('<span style="font-size: 12px">Inscribed Gem</span>', '<a href="' + gemLink + '">Inscribed Gem (Loading)</a>');
  241. d.insgems.push({ name: 'Inscribed ' + ematch[1] });
  242.  
  243. PriceQueue.GetPrice({
  244. method: "GET",
  245. url: gemLink,
  246. pars: { gemidx: gidx },
  247. success: function (response, $this) {
  248. var lp = 0, nfp = 0;
  249. if (response.success) {
  250. //cachePrices[this.url] = new Object();
  251. //cachePrices[this.url].lowestPrice =
  252. lp = response.lowest_price;
  253. //cachePrices[this.url].nofeePrice =
  254. nfp = response.median_price;
  255.  
  256. d.insgems[$this.gemidx].lowestPrice = lp;
  257. d.insgems[$this.gemidx].nofeePrice = nfp;
  258.  
  259. if (sItem === g_ActiveInventory.selectedItem) {
  260. reloadDes();
  261. }
  262. }
  263. },
  264. error: function () {
  265.  
  266. }
  267. });
  268. gidx++;
  269. }
  270.  
  271. while (ematch = kinGemExp.exec(d.value)) {
  272. //console.log(ematch);
  273. var gemLink = window.location.protocol + '//steamcommunity.com/market/priceoverview/?appid=570&country=' + g_strCountryCode + '&currency=' + currencyId + '&market_hash_name=Kinetic: ' + ematch[1];
  274.  
  275. d.insgems.push({ name: 'Kinetic: ' + ematch[1] });
  276.  
  277. PriceQueue.GetPrice({
  278. method: "GET",
  279. url: gemLink,
  280. pars: { gemidx: gidx },
  281. success: function (response, $this) {
  282. var lp = 0, nfp = 0;
  283. if (response.success) {
  284. //cachePrices[this.url] = new Object();
  285. //cachePrices[this.url].lowestPrice =
  286. lp = response.lowest_price;
  287. //cachePrices[this.url].nofeePrice =
  288. nfp = response.median_price;
  289.  
  290. d.insgems[$this.gemidx].lowestPrice = lp;
  291. d.insgems[$this.gemidx].nofeePrice = nfp;
  292.  
  293. if (sItem === g_ActiveInventory.selectedItem)
  294. reloadDes();
  295. }
  296.  
  297.  
  298. },
  299. error: function () {
  300.  
  301. }
  302. });
  303. gidx++;
  304. //console.log(gidx);
  305. }
  306.  
  307. while (ematch = masGemExp.exec(d.value)) {
  308. //console.log(ematch);
  309. var gemLink = window.location.protocol + '//steamcommunity.com/market/priceoverview/?appid=570&country=' + g_strCountryCode + '&currency=' + currencyId + '&market_hash_name=Rune%20of%20the%20Duelist%20Indomitable';
  310. d.insgems.push({ name: 'Rune%20of%20the%20Duelist%20Indomitable' });
  311.  
  312. PriceQueue.GetPrice({
  313. method: "GET",
  314. url: gemLink,
  315. pars: { gemidx: gidx },
  316. success: function (response, $this) {
  317. var lp = 0, nfp = 0;
  318. if (response.success) {
  319. //cachePrices[this.url] = new Object();
  320. //cachePrices[this.url].lowestPrice =
  321. lp = response.lowest_price;
  322. //cachePrices[this.url].nofeePrice =
  323. nfp = response.median_price;
  324.  
  325. d.insgems[$this.gemidx].lowestPrice = lp;
  326. d.insgems[$this.gemidx].nofeePrice = nfp;
  327.  
  328. if (sItem === g_ActiveInventory.selectedItem)
  329. reloadDes();
  330. }
  331.  
  332.  
  333. },
  334. error: function () {
  335.  
  336. }
  337. });
  338. gidx++;
  339. //console.log(gidx);
  340. }
  341.  
  342. while (ematch = corGemExp.exec(d.value)) {
  343. //console.log(ematch);
  344. var gemLink = window.location.protocol + '//steamcommunity.com/market/priceoverview/?appid=570&country=' + g_strCountryCode + '&currency=' + currencyId + '&market_hash_name=Foulfell Shard';
  345.  
  346. d.insgems.push({ name: 'Foulfell Shard' });
  347.  
  348. PriceQueue.GetPrice({
  349. method: "GET",
  350. url: gemLink,
  351. pars: { gemidx: gidx },
  352. success: function (response, $this) {
  353. var lp = 0, nfp = 0;
  354. if (response.success) {
  355. //cachePrices[this.url] = new Object();
  356. //cachePrices[this.url].lowestPrice =
  357. lp = response.lowest_price;
  358. //cachePrices[this.url].nofeePrice =
  359. nfp = response.median_price;
  360.  
  361. d.insgems[$this.gemidx].lowestPrice = lp;
  362. d.insgems[$this.gemidx].nofeePrice = nfp;
  363.  
  364. if (sItem === g_ActiveInventory.selectedItem)
  365. reloadDes();
  366. }
  367.  
  368.  
  369. },
  370. error: function () {
  371.  
  372. }
  373. });
  374. gidx++;
  375. //console.log(gidx);
  376. }
  377.  
  378. while (ematch = ethGemExp.exec(d.value)) {
  379. //console.log(ematch);
  380. var gemLink = window.location.protocol + '//steamcommunity.com/market/priceoverview/?appid=570&country=' + g_strCountryCode + '&currency=' + currencyId + '&market_hash_name=Ethereal: ' + ematch[1];
  381.  
  382. d.insgems.push({ name: 'Ethereal: ' + ematch[1] });
  383.  
  384. PriceQueue.GetPrice({
  385. method: "GET",
  386. url: gemLink,
  387. pars: { gemidx: gidx },
  388. success: function (response, $this) {
  389. var lp = 0, nfp = 0;
  390. if (response.success) {
  391. //cachePrices[this.url] = new Object();
  392. //cachePrices[this.url].lowestPrice =
  393. lp = response.lowest_price;
  394. //cachePrices[this.url].nofeePrice =
  395. nfp = response.median_price;
  396.  
  397. d.insgems[$this.gemidx].lowestPrice = lp;
  398. d.insgems[$this.gemidx].nofeePrice = nfp;
  399.  
  400. if (sItem === g_ActiveInventory.selectedItem)
  401. reloadDes();
  402. }
  403.  
  404.  
  405. },
  406. error: function () {
  407.  
  408. }
  409. });
  410. gidx++;
  411. //console.log(gidx);
  412. }
  413.  
  414. while (ematch = priGemExp.exec(d.value)) {
  415. //console.log(ematch);
  416. var gemLink = window.location.protocol + '//steamcommunity.com/market/priceoverview/?appid=570&country=' + g_strCountryCode + '&currency=' + currencyId + '&market_hash_name=Prismatic: ' + ematch[1];
  417.  
  418. d.insgems.push({ name: 'Prismatic: ' + ematch[1] });
  419.  
  420. PriceQueue.GetPrice({
  421. method: "GET",
  422. url: gemLink,
  423. pars: { gemidx: gidx },
  424. success: function (response, $this) {
  425. var lp = 0, nfp = 0;
  426. if (response.success) {
  427. //cachePrices[this.url] = new Object();
  428. //cachePrices[this.url].lowestPrice =
  429. lp = response.lowest_price;
  430. //cachePrices[this.url].nofeePrice =
  431. nfp = response.median_price;
  432.  
  433. d.insgems[$this.gemidx].lowestPrice = lp;
  434. d.insgems[$this.gemidx].nofeePrice = nfp;
  435.  
  436. if (sItem === g_ActiveInventory.selectedItem)
  437. reloadDes();
  438. }
  439.  
  440.  
  441. },
  442. error: function () {
  443.  
  444. }
  445. });
  446. gidx++;
  447. //console.log(gidx);
  448. }
  449.  
  450. if (gidx > 0) {
  451. //console.log(d);
  452. }
  453. else {
  454. delete d.insgems;
  455. }
  456. }
  457. }
  458.  
  459. ///Temporary ignore
  460. if (window.agp_sticker && sItem.appid == 730) {
  461.  
  462. for (var i = 0; i < sItem.descriptions.length; i++) {
  463. var d = sItem.descriptions[i];
  464. if (d.type == 'html' && d.value.startsWith('<br><div id="sticker_info" name="sticker_info" title="Sticker Details"') && !d.stickers) {
  465. d.orgvalue = d.value;
  466. d.isstickers = true;
  467. var stIdx = d.value.indexOf('<br>Sticker:');
  468. if (stIdx == -1 || d.stickers) break;
  469. var stickers = d.value.substr(stIdx + 12, d.value.length - (stIdx + 27)).split(',');
  470. d.stickers = [];
  471. for (var i2 = 0; i2 < stickers.length; i2++) {
  472. d.stickers.push({ name: stickers[i2].trim() });
  473. var stickerLink = window.location.protocol + '//steamcommunity.com/market/priceoverview/?appid=730&country=' + g_strCountryCode + '&currency=' + currencyId + '&market_hash_name=Sticker | ' + stickers[i2].trim();
  474. if (cachePrices[stickerLink]) {
  475. d.stickers[i2].prices = cachePrices[stickerLink];
  476. if (sItem === g_ActiveInventory.selectedItem)
  477. reloadDes();
  478. }
  479. else {
  480. PriceQueue.GetPrice({
  481. method: "GET",
  482. url: stickerLink,
  483. pars: { stickeridx: i2 },
  484. success: function (response, $this) {
  485. var lp = 0, nfp = 0;
  486. if (response.success) {
  487. //cachePrices[this.url] = new Object();
  488. //cachePrices[this.url].lowestPrice =
  489. lp = response.lowest_price;
  490. //cachePrices[this.url].nofeePrice =
  491. nfp = response.median_price;
  492.  
  493. d.stickers[$this.stickeridx].prices = { lowestPrice: lp, nofeePrice: nfp };// cachePrices[this.url];
  494.  
  495. if (sItem === g_ActiveInventory.selectedItem)
  496. reloadDes();
  497. }
  498. },
  499. error: function () {
  500.  
  501. }
  502. });
  503. }
  504. }
  505.  
  506. }
  507. }
  508. }
  509.  
  510. if (!sItem.marketable) {
  511. //$J('.dd_price').html("Not Marketable");
  512. if (callback && itemLinkW == itemLink)
  513. callback(sItem);
  514. return;
  515. }
  516.  
  517. if (sItem.lowestPrice) {
  518. PriceQueue.GenPriceDescription(sItem);
  519.  
  520. if (callback && itemLinkW == itemLink) {
  521. callback(sItem);
  522. return;
  523. }
  524. }
  525. else {
  526. PriceQueue.GetPrice({
  527. method: "GET",
  528. url: itemLink,
  529. success: function (response) {
  530. if (response.success) {
  531. //cachePrices[itemLink] = new Object();
  532. cachePrices[itemLink].lowestPrice = sItem.lowestPrice = response.lowest_price;
  533. cachePrices[itemLink].nofeePrice = sItem.nofeePrice = response.median_price;
  534. if (response.volume) {
  535. cachePrices[itemLink].volume = sItem.volume = response.volume;
  536. }
  537.  
  538. if (response.providerName) {
  539. cachePrices[itemLink].providerName = sItem.providerName = response.providerName;
  540. }
  541.  
  542. PriceQueue.GenPriceDescription(sItem);
  543. if (itemLinkW == itemLink) {
  544. sItem.lowestPriceW = response.lowest_price;
  545. sItem.nofeePriceW = response.median_price;
  546. sItem.providerName = response.providerName;
  547. }
  548. //cachePrices[itemLink].market_hash_name = sItem.market_hash_name;
  549.  
  550. if (sItem === g_ActiveInventory.selectedItem) {
  551. reloadDes();
  552.  
  553. $J('.dd_price').find('a').attr('href', marketLink);
  554. }
  555.  
  556. if (callback && itemLinkW == itemLink)
  557. callback(sItem);
  558. }
  559. }
  560. });
  561. }
  562.  
  563. if (sItem.lowestPriceW) {
  564. if (callback) {
  565. callback(sItem);
  566. }
  567. }
  568. else if (itemLinkW != itemLink) {
  569. PriceQueue.GetPrice({
  570. method: "GET",
  571. url: itemLinkW,
  572. success: function (response) {
  573. if (response.success) {
  574. //cachePrices[itemLink] = new Object();
  575. cachePrices[itemLinkW].lowestPrice = sItem.lowestPriceW = response.lowest_price;
  576. cachePrices[itemLinkW].nofeePrice = sItem.nofeePriceW = response.median_price;
  577. if (response.volume) {
  578. cachePrices[itemLink].volume = sItem.volume = response.volume;
  579. }
  580. //cachePrices[itemLink].market_hash_name = sItem.market_hash_name;
  581.  
  582. if (callback)
  583. callback(sItem);
  584. }
  585. }
  586. });
  587. }
  588. }
  589.  
  590. var selectSimilar = function (classid) {
  591. if (!selectmode)
  592. $J('#Lnk_Sellmulti').trigger('click');
  593. $J('.inventory_ctn:visible .inventory_page .item').each(function (i, el) {
  594. if (this.rgItem.marketable && this.rgItem.classid == classid) {
  595. g_ActiveInventory.LoadItemImage(this);
  596. $J(this).addClass('selectedSell');
  597. }
  598. });
  599.  
  600. var itC = $J('.selectedSell').length;
  601. if (itC > 0) {
  602. $J('#Lnk_ShowSellMulti .item_market_action_button_contents').html((itC > 1 ? SIHLang.sellnitem.replace('$1', itC) : SIHLang.sell1item));
  603. $J('#Lnk_ShowSellMulti').show();
  604. if (g_ActiveInventory.appid == 753) {
  605. $J('#Lnk_TurnIntoGems').show();
  606. $J('#Lnk_SendGifts').show();
  607. }
  608. }
  609. return false;
  610. }
  611. var setGemPrice = function (sItem, gemName, gemType, callback) {
  612. var gemLink = window.location.protocol + '//steamcommunity.com/market/priceoverview/?appid=570&country=VN&currency=1&market_hash_name=' + gemName;
  613. PriceQueue.GetPrice({
  614. method: "GET",
  615. url: gemLink,
  616. success: function (response, textStatus, jqXHR) {
  617. var lp = 0, nfp = 0;
  618. if (response.success) {
  619. lp = response.lowest_price;
  620. var pp = /([\d\.,]+)/.exec(lp.replace(/\&#\d+;/g, '').replace(' p&#1091;&#1073;.', '').replace(/,/g, '.'))[1];
  621. sItem.extimatePrice[gemName] = pp;
  622. callback(sItem);
  623. }
  624. },
  625. error: function () {
  626. }
  627. });
  628. }
  629. var imgRex = /<img.*?src="([^"]+?)"[^>]*>/g,
  630. imgRex2 = /background-image: url\(([^\)]+?)\)/g;
  631. var ShowQueue = function (goo) {
  632. $J('div.queue-container').remove();
  633. var selectedItems = $J('.selectedSell');
  634. var div = $J('<div class="queue-container">');
  635. var rightDiv = $J('<div class="queue-right-panel">');
  636. div.append(rightDiv);
  637.  
  638. var cdiv = $J('<div class="scrollbar-inner">');
  639. div.append(cdiv);
  640.  
  641. selectedItems.sort(function (a, b) {
  642. var rgItemA = a.rgItem, rgItemB = b.rgItem;
  643.  
  644. if (rgItemA.market_hash_name == rgItemB.market_hash_name) {
  645. return 0;
  646. }
  647. else if (rgItemA.market_hash_name < rgItemB.market_hash_name)
  648. return -1;
  649. else
  650. return 1;
  651. });
  652.  
  653. if (window.extmasslisting) {
  654. ExternalPrices.UpdatePrice(typeof (g_rgWalletInfo) != 'undefined' ? g_rgWalletInfo['wallet_currency'] : 1);
  655. }
  656.  
  657. selectedItems.each(function () {
  658.  
  659. var rgItem = null;
  660. if (!(rgItem = this.rgItem) || ((!rgItem.marketable) && !goo) || (goo == '1' && (rgItem.appid != 753 || rgItem.contextid != 6))) {
  661. $J(this).removeClass('selectedSell');
  662. return true;
  663. }
  664. var container = $J('<div class="queue-item-container" data-id="' + rgItem.id + '">');
  665. container.append('<a href="#" class="queue-item-remove" title="Remove from queue">&#x2212;</a>');
  666. var img = '';
  667. if (rgItem.fraudwarnings) {
  668. img += '<img src="http://steamcommunity-a.akamaihd.net/public/images/sharedfiles/icons/icon_warning.png" height="16" />';
  669. }
  670. if (rgItem.descriptions && rgItem.descriptions.length) {
  671. var mm = null;
  672. for (var i = 0; i < rgItem.descriptions.length; i++) {
  673. while ((mm = imgRex.exec(rgItem.descriptions[i].value)) != null || (mm = imgRex2.exec(rgItem.descriptions[i].value)) != null) {
  674. img += '<img src="' + mm[1] + '" height="16"/>';
  675. }
  676. }
  677. }
  678. //console.log(img);
  679. if (img.length > 0) {
  680. container.append('<div class="item-bagde">' + img + '</div>');
  681. }
  682. var item = $J('<div class="queue-item">');
  683. item.css('border-color', '#' + rgItem.name_color)
  684. if ($J(this).hasClass('item-equipped')) {
  685. item.addClass('item-equipped');
  686. }
  687.  
  688. if ($J(this).hasClass('item-in-trade')) {
  689. item.addClass('item-in-trade');
  690. }
  691. if (window.extmasslisting && rgItem.extprice) {
  692. var extpricetag = $J('<div class="p-price"></div>');
  693. extpricetag.prop('title', 'scmspy');
  694. extpricetag.text(ExchangeRates.Format(rgItem.extprice));
  695. item.append(extpricetag);
  696. }
  697.  
  698. item.append($J(this).find('img').clone());
  699. container[0].rgItem = rgItem;
  700. container.append(item);
  701. AddItemHoverToElement(item[0], rgItem);
  702. cdiv.append(container);
  703. });
  704.  
  705. if ($J('.selectedSell').length == 0) {
  706. if (goo == '1')
  707. GrindDialog.Dismiss();
  708. else
  709. SellItemDialog.Dismiss();
  710. $J('div.queue-container').remove();
  711. $J('#Lnk_ShowSellMulti').hide();
  712. $J('#Lnk_TurnIntoGems').hide();
  713. $J('#Lnk_SendGifts').hide();
  714.  
  715. return false;
  716. }
  717.  
  718. rightDiv.append('<div class="queue-panel"><fieldset><div class="queue-item-count">' + $J('.selectedSell').length + '</div>' +
  719. '<div class="queue-total-price"><span class="with-fee" title="Total buyer will pay"></span><span class="without-fee" title="Total will recieve"></span></div>' +
  720. '</fieldset></div>');
  721. rightDiv.append('<div class="queue-remove-panel queue-panel"><fieldset><legend>' + SIHLang.queue.removeitem + '</legend><input type="text" class="num" id="txt_remove_queue" /><a href="#" id="bt_lower">' + SIHLang.queue.removelower + '</a><a href="#" id="bt_higher">' + SIHLang.queue.removehigher + '</a><a href="#" id="bt_intrade">' + SIHLang.queue.removeintrade + '</a><a href="#" id="bt_removeequipped">' + SIHLang.queue.removeequipped + '</a></fieldset></div>');
  722. rightDiv.append('<div class="queue-sort-panel queue-panel"><fieldset><legend>' + SIHLang.sort.sortitem + '</legend><a href="#" id="bt_sort_price">' + SIHLang.sort.price + ' <span class="market_sort_arrow"></span></a></fieldset></div>');
  723.  
  724.  
  725. div.find('#bt_lower, #bt_higher').click(function (e) {
  726. //e.stop();
  727. var operator = ($J(this).attr('id') === 'bt_lower' ? -1 : 1)
  728. var pricetocompare = parseFloat($J('#txt_remove_queue').val());
  729. //console.log('p2c', pricetocompare);
  730. if (isNaN(pricetocompare)) return false;
  731. $J('.queue-item-container').each(function () {
  732. var item = this.rgItem;
  733. //console.log(item);
  734. if (item && (item.lowestPriceW || item.extprice)) {
  735. var price = item.lowestPriceW ? parseFloat(getNumber(item.lowestPriceW)) : (item.extprice || 0);
  736. if ((price * operator) > (pricetocompare * operator)) {
  737. $J(this).find('.queue-item-remove').trigger('click');
  738. }
  739. }
  740. });
  741. return false;
  742. });
  743.  
  744. div.find('#bt_intrade').click(function (e) {
  745. //e.stop();
  746. $J('.queue-item-container').each(function () {
  747. var item = this.rgItem;
  748. //console.log(item);
  749. if ($J(this).find('.item-in-trade').length) {
  750. $J(this).find('.queue-item-remove').trigger('click');
  751. }
  752. });
  753. return false;
  754. });
  755.  
  756. div.find('#bt_removeequipped').click(function (e) {
  757. //e.stop();
  758. $J('.queue-item-container').each(function () {
  759. var item = this.rgItem;
  760. //console.log(item);
  761. if ($J(this).find('.item-equipped').length) {
  762. $J(this).find('.queue-item-remove').trigger('click');
  763. }
  764. });
  765. return false;
  766. });
  767.  
  768. div.find('#bt_sort_price').click(function (e) {
  769. //e.stop();
  770. if (isSorting) return false;
  771. isSorting = true;
  772. var order = 1;
  773. $this = $J(this);
  774. if ($this.find('.market_sort_arrow').is(':contains("â–²")')) {
  775. order = -1;
  776. $this.find('.market_sort_arrow').text('â–¼');
  777. }
  778. else {
  779. $this.find('.market_sort_arrow').text('â–²');
  780. }
  781.  
  782. var $rows = div.find('div:has(>.queue-item-container)'),
  783. $rowsli = $rows.children('.queue-item-container');
  784.  
  785. $rowsli.sort(function (a, b) {
  786. var rgIa = a.rgItem, rgIb = b.rgItem;
  787.  
  788. if (!rgIa)
  789. return order;
  790. if (!rgIb)
  791. return order * -1;
  792.  
  793. var an = (typeof (rgIa.lowestPriceW) == 'undefined' ? (rgIa.extprice || 0) : parseFloat(getNumber(rgIa.lowestPriceW))),
  794. bn = (typeof (rgIb.lowestPriceW) == 'undefined' ? (rgIb.extprice || 0) : parseFloat(getNumber(rgIb.lowestPriceW)));
  795.  
  796. if (an == bn) {
  797. an = rgIa.market_hash_name,
  798. bn = rgIb.market_hash_name;
  799. }
  800.  
  801. if (an > bn) {
  802. return 1 * order;
  803. }
  804. if (an < bn) {
  805. return -1 * order;
  806. }
  807. return 0;
  808. });
  809.  
  810. $rowsli.detach().appendTo($rows);
  811.  
  812. var rgItem = $J('.queue-item-container')[0].rgItem;
  813. g_ActiveInventory.SelectItem(null, rgItem.element, rgItem);
  814. g_ActiveInventory.EnsurePageActiveForItem(rgItem.element);
  815. UpdateSellItem(rgItem);
  816.  
  817. isSorting = false;
  818. return false;
  819. });
  820.  
  821. $J('body').append(div);
  822. $J(cdiv).scrollbar();
  823.  
  824. qTotalPrice = 0;
  825. qTotalBuyerPrice = 0;
  826. if (goo) {
  827. GetQueueGoo();
  828. }
  829. else {
  830. var rgItem = $J('.queue-item-container:visible')[0].rgItem;
  831. g_ActiveInventory.SelectItem(null, rgItem.element, rgItem);
  832. g_ActiveInventory.EnsurePageActiveForItem(rgItem.element);
  833. //var lbp = $J('#market_sell_buyercurrency_input').val(), lsp = $J('#market_sell_currency_input').val();
  834. if (!UpdateSellItem(rgItem)) return;
  835. GetQueuePrice();
  836. PriceQueue.UpdateHandler = ContinueListing;
  837. }
  838. }
  839. var qTimer = null;
  840. var qTotalPrice = 0;
  841. var qTotalBuyerPrice = 0;
  842. var isSorting = false;
  843.  
  844. var GetQueuePrice = function () {
  845. isSorting = false;
  846. if (qTimer) window.clearTimeout(qTimer);
  847. var it = $J('.queue-item-container:not(:has(>span.price))');
  848. for (var i = 0; i < it.length; i++) {
  849.  
  850. var rgItem = it[i].rgItem;
  851. if (window.extmasslisting && rgItem.extprice) {
  852. var num = rgItem.extprice;
  853. var inputValue = GetPriceValueAsInt(num + '');
  854. var nAmount = inputValue;
  855. var priceWithoutFee = null;
  856. if (inputValue > 0 && nAmount == parseInt(nAmount)) {
  857. // Calculate what the seller gets
  858. var publisherFee = typeof SellItemDialog.m_item.market_fee != 'undefined' ? SellItemDialog.m_item.market_fee : g_rgWalletInfo['wallet_publisher_fee_percent_default'];
  859. var feeInfo = CalculateFeeAmount(nAmount, publisherFee);
  860. nAmount = nAmount - feeInfo.fees;
  861.  
  862. priceWithoutFee = v_currencyformat(nAmount, GetCurrencyCode(g_rgWalletInfo['wallet_currency']));
  863. }
  864.  
  865.  
  866. rgItem.buyerPrice = inputValue;
  867. rgItem.sellerPrice = nAmount;
  868.  
  869. qTotalPrice += inputValue;
  870. qTotalBuyerPrice += nAmount;
  871.  
  872. $J('.queue-total-price .with-fee').html(v_currencyformat(qTotalPrice, GetCurrencyCode(g_rgWalletInfo['wallet_currency'])));
  873. $J('.queue-total-price .without-fee').html(v_currencyformat(qTotalBuyerPrice, GetCurrencyCode(g_rgWalletInfo['wallet_currency'])));
  874.  
  875. var pp = $J('<span class="price"></span>');
  876. pp.html(rgItem.extprice);
  877. pp.attr('title', priceWithoutFee);
  878.  
  879. continue;
  880. }
  881.  
  882. getLowestPriceHandler(rgItem, function (item) {
  883.  
  884. if (item && item.lowestPriceW) {
  885. var num = getNumber(item.lowestPriceW);//.replace(/\&#\d+;/g, '').replace(' p&#1091;&#1073;.', '');
  886. var inputValue = GetPriceValueAsInt(num);
  887. var nAmount = inputValue;
  888. var priceWithoutFee = null;
  889. if (inputValue > 0 && nAmount == parseInt(nAmount)) {
  890. // Calculate what the seller gets
  891. var publisherFee = typeof SellItemDialog.m_item.market_fee != 'undefined' ? SellItemDialog.m_item.market_fee : g_rgWalletInfo['wallet_publisher_fee_percent_default'];
  892. var feeInfo = CalculateFeeAmount(nAmount, publisherFee);
  893. nAmount = nAmount - feeInfo.fees;
  894.  
  895. priceWithoutFee = v_currencyformat(nAmount, GetCurrencyCode(g_rgWalletInfo['wallet_currency']));
  896. }
  897.  
  898. var pp = $J('<span class="price"></span>');
  899. pp.html(item.lowestPriceW);
  900. pp.attr('title', priceWithoutFee);
  901.  
  902. item.buyerPrice = inputValue;
  903. item.sellerPrice = nAmount;
  904. var itCnt = $J('.queue-item-container[data-id="' + item.id + '"]');
  905. itCnt.append(pp);
  906. qTotalPrice += inputValue;
  907. qTotalBuyerPrice += nAmount;
  908. $J('.queue-total-price .with-fee').html(v_currencyformat(qTotalPrice, GetCurrencyCode(g_rgWalletInfo['wallet_currency'])));
  909. $J('.queue-total-price .without-fee').html(v_currencyformat(qTotalBuyerPrice, GetCurrencyCode(g_rgWalletInfo['wallet_currency'])));
  910.  
  911. }
  912. else {
  913. var rgItemOrg = item;
  914. $J('#item' + rgItemOrg.appid + '_' + rgItemOrg.contextid + '_' + $J(it[0]).data().id + '.selectedSell').removeClass('selectedSell');
  915.  
  916. var itC = $J('.inventory_page .selectedSell').length;
  917. if (itC <= 0) {
  918. SellItemDialog.Dismiss();
  919. $J('#Lnk_ShowSellMulti').hide();
  920. $J('#Lnk_TurnIntoGems').hide();
  921. $J('#Lnk_SendGifts').hide();
  922. return false;
  923. }
  924.  
  925. var rgItem1 = $J('.queue-item-container')[0].rgItem;
  926.  
  927. UpdateSellItem(rgItem1);
  928. $J('.queue-item-count').html(itC);
  929. $J('#Lnk_ShowSellMulti .item_market_action_button_contents').html((itC > 1 ? SIHLang.sellnitem.replace('$1', itC) : SIHLang.sell1item));
  930. var itCnt = $J('.queue-item-container[data-id="' + item.id + '"]');
  931. itCnt.remove();
  932.  
  933. }
  934. //window.setTimeout('GetQueuePrice();', 50);
  935. });
  936. }
  937.  
  938. }
  939.  
  940. var GetQueueGoo = function () {
  941. isSorting = false;
  942. if (qTimer) window.clearTimeout(qTimer);
  943. var it = $J('.queue-item-container:not(:has(>span.price))');
  944. if (it.length > 0) {
  945. var rgItem = it[0].rgItem;
  946.  
  947. var rgAJAXParams = {
  948. sessionid: g_sessionID,
  949. appid: rgItem.app_data.appid,
  950. assetid: rgItem.id,
  951. contextid: rgItem.contextid
  952. };
  953. var strActionURL = g_strProfileURL + "/ajaxgetgoovalue/";
  954.  
  955. $J.get(strActionURL, rgAJAXParams).done(function (data) {
  956. var $Content = $J(data.strHTML);
  957. var strDialogTitle = data.strTitle;
  958. rgItem.goo_value = data.goo_value;
  959.  
  960. if (rgItem.goo_value > 0) {
  961.  
  962. var pp = $J('<span class="price"></span>');
  963. pp.html(rgItem.goo_value);
  964. pp.attr('title', rgItem.goo_value);
  965. $J(it[0]).append(pp);
  966. qTotalPrice += parseInt(rgItem.goo_value);
  967. $J('.queue-total-price .with-fee').html(qTotalPrice);
  968. $J('.queue-total-price .without-fee').html('gems');
  969.  
  970. }
  971. else {
  972. var rgItemOrg = it[0].rgItem;
  973. $J('#item' + rgItemOrg.appid + '_' + rgItemOrg.contextid + '_' + $J(it[0]).data().id + '.selectedSell').removeClass('selectedSell');
  974.  
  975. var itC = $J('.inventory_page .selectedSell').length;
  976. if (itC <= 0) {
  977. GrindDialog.Dismiss();
  978. $J('#Lnk_ShowSellMulti').hide();
  979. $J('#Lnk_TurnIntoGems').hide();
  980. $J('#Lnk_SendGifts').hide();
  981. return false;
  982. }
  983.  
  984. var rgItem1 = $J('.queue-item-container')[0].rgItem;
  985. g_ActiveInventory.SelectItem(null, rgItem1.element, rgItem1);
  986. g_ActiveInventory.EnsurePageActiveForItem(rgItem1.element);
  987. UpdateSellItem(rgItem1);
  988. $J('.queue-item-count').html(itC);
  989. $J('#Lnk_ShowSellMulti .item_market_action_button_contents').html((itC > 1 ? SIHLang.sellnitem.replace('$1', itC) : SIHLang.sell1item));
  990. $J(it[0]).remove();
  991.  
  992. }
  993. window.setTimeout('GetQueueGoo();', 50);
  994. });
  995.  
  996. }
  997. else {
  998. //isSorting = false;
  999. }
  1000. }
  1001.  
  1002. var SetQueueTotal = function () {
  1003.  
  1004. qTotalPrice = 0;
  1005. qTotalBuyerPrice = 0;
  1006. $J('.queue-item-container').each(function (i, e) {
  1007.  
  1008. });
  1009. }
  1010.  
  1011. var GrindNextItem = function () {
  1012. if ($J('.selectedSell').length == 0) {
  1013. GrindDialog.Dismiss();
  1014. $J('#Lnk_ShowSellMulti').hide();
  1015. $J('#Lnk_TurnIntoGems').hide();
  1016. $J('#Lnk_SendGifts').hide();
  1017. }
  1018. else if ($J('.selectedSell').length > 0 && !GrindDialog.m_bIsDismissed) {
  1019. var itC = $J('.selectedSell').length;
  1020. $J('.queue-item-count').html(itC);
  1021. $J('#Lnk_ShowSellMulti .item_market_action_button_contents').html((itC > 1 ? SIHLang.sellnitem.replace('$1', itC) : SIHLang.sell1item));
  1022. var rgItem = $J('.queue-item-container:visible')[0].rgItem;
  1023. g_ActiveInventory.SelectItem(null, rgItem.element, rgItem);
  1024. g_ActiveInventory.EnsurePageActiveForItem(rgItem.element);
  1025. //var lbp = $J('#market_sell_buyercurrency_input').val(), lsp = $J('#market_sell_currency_input').val();
  1026. //$J('#market_sell_buyercurrency_input').val(lbp);
  1027. //$J('#market_sell_currency_input').val(lsp);
  1028.  
  1029. if (rgItem.goo_value) {
  1030. var rgAJAXParams = {
  1031. sessionid: g_sessionID,
  1032. appid: rgItem.app_data.appid,
  1033. assetid: rgItem.id,
  1034. contextid: rgItem.contextid,
  1035. goo_value_expected: rgItem.goo_value
  1036. };
  1037. strActionURL = g_strProfileURL + "/ajaxgrindintogoo/";
  1038.  
  1039. $J.post(strActionURL, rgAJAXParams).done(function (data) {
  1040.  
  1041. g_ActiveInventory.selectedItem.marketable = 0;
  1042. $J(g_ActiveInventory.selectedItem.element).removeClass('selectedSell');
  1043. $J(g_ActiveInventory.selectedItem.element).css('opacity', '0.3');
  1044. $J('div.queue-item-container[data-id=' + g_ActiveInventory.selectedItem.id + ']').hide(200, function () {
  1045. setTimeout('GrindNextItem()', 100);
  1046. });
  1047. }).fail(function () {
  1048. ShowAlertDialog(strDialogTitle, 'There was an error communicating with the network. Please try again later.');
  1049. });
  1050. }
  1051. }
  1052. else {
  1053. GrindDialog.Dismiss();
  1054. }
  1055. }
  1056.  
  1057. var ModifyMarketActions = function () {
  1058. if (typeof (window.fastdelta) == 'undefined') window.fastdelta = -0.01;
  1059. if (typeof (window.delaylistings) == 'undefined') window.delaylistings = 200;
  1060. if (typeof (window.quicksellbuttons) == 'undefined') window.quicksellbuttons = true;
  1061. if (typeof (window.buysetbuttons) == 'undefined') window.buysetbuttons = true;
  1062. PopulateMarketActions = function (elActions, item) {
  1063. elActions.update('');
  1064. if (!item.marketable || (item.is_currency && CurrencyIsWalletFunds(item))) {
  1065. elActions.hide();
  1066. return;
  1067. }
  1068. if (typeof (g_bViewingOwnProfile) != 'undefined' && g_bViewingOwnProfile) {
  1069. var strMarketName = typeof item.market_hash_name != 'undefined' ? item.market_hash_name : item.market_name || item.name;
  1070.  
  1071. var elPriceInfo = new Element('div');
  1072. var elPriceInfoHeader = new Element('div', { 'style': 'height: 24px;' });
  1073. var elMarketLink = new Element('a', {
  1074. 'href': window.location.protocol + '//steamcommunity.com/market/listings/' + item.appid + '/' + encodeURIComponent(strMarketName)
  1075. });
  1076. elMarketLink.update('View in Community Market');
  1077. elPriceInfoHeader.appendChild(elMarketLink);
  1078. elPriceInfo.appendChild(elPriceInfoHeader);
  1079. if (!window.hidedefaultprice) {
  1080.  
  1081. var elPriceInfoContent = new Element('div', { 'style': 'min-height: 3em; margin-left: 1em;' });
  1082. elPriceInfoContent.update('<img src="' + window.location.protocol + '//steamcommunity-a.akamaihd.net/public/images/login/throbber.gif" alt="Working...">');
  1083. elPriceInfo.appendChild(elPriceInfoContent);
  1084. var fastSellBt = null;
  1085. var itemlink = window.location.protocol + '//steamcommunity.com/market/priceoverview/?appid=' + item.appid + '&country=' + g_strCountryCode + '&currency=' + (typeof (g_rgWalletInfo) != 'undefined' ? g_rgWalletInfo['wallet_currency'] : 1) + '&market_hash_name=' + encodeURIComponent(strMarketName);
  1086. PriceQueue.GetPrice({
  1087. method: "GET",
  1088. url: itemlink,
  1089. insert: true,
  1090. success: function (response) {
  1091. if (response.success) {
  1092. var strInfo = '';
  1093. if (response.lowest_price) {
  1094. strInfo += 'Starting at: ' + response.lowest_price + '<br>'
  1095.  
  1096. var num = getNumber(response.lowest_price);//.replace(/\s/g, '').replace(/\&#\d+;/g, '').replace(' p&#1091;&#1073;.', '').replace(/[^\d,\.]/g, '');
  1097. var inputValue = GetPriceValueAsInt(num);
  1098. var nAmount = inputValue;
  1099. var sellingPrice = null;
  1100. if (inputValue > 0 && nAmount == parseInt(nAmount)) {
  1101. // Calculate what the seller gets
  1102. var publisherFee = typeof item.market_fee != 'undefined' ? item.market_fee : g_rgWalletInfo['wallet_publisher_fee_percent_default'];
  1103. var feeInfo = CalculateFeeAmount(nAmount, publisherFee);
  1104. nAmount = nAmount - feeInfo.fees + (100 * (window.fastdelta));
  1105. if (nAmount <= 0) nAmount = 1;
  1106.  
  1107. var info = CalculateAmountToSendForDesiredReceivedAmount(nAmount, publisherFee);
  1108. inputValue = info.amount;
  1109. sellingPrice = v_currencyformat(inputValue, GetCurrencyCode(g_rgWalletInfo['wallet_currency']));
  1110. }
  1111.  
  1112. if (quicksellbuttons) {
  1113. fastSellBt = CreateMarketActionButton('green', '#', SIHLang.quicksell.replace('$1', sellingPrice));
  1114. $J(fastSellBt).css({ 'marginLeft': '12px' });
  1115. //console.log('Quick sell data ', {
  1116. // sessionid: g_sessionID,
  1117. // appid: item.appid,
  1118. // contextid: item.contextid,
  1119. // assetid: item.id,
  1120. // amount: 1,
  1121. // price: nAmount
  1122. //});
  1123. $J(fastSellBt).click(function () {
  1124. elPriceInfoContent.update('<img src="' + window.location.protocol + '//steamcommunity-a.akamaihd.net/public/images/login/throbber.gif" alt="Working...">');
  1125. SellItemDialog.m_item = item;
  1126. $J.ajax({
  1127. url: 'https://steamcommunity.com/market/sellitem/',
  1128. type: 'POST',
  1129. data: {
  1130. sessionid: g_sessionID,
  1131. appid: item.appid,
  1132. contextid: item.contextid,
  1133. assetid: item.id,
  1134. amount: 1,
  1135. price: nAmount
  1136. },
  1137. crossDomain: true,
  1138. xhrFields: { withCredentials: true }
  1139. }).done(function (data) {
  1140. SellItemDialog.OnSuccess({ responseJSON: data });
  1141. if ($J('#Ck_NoReload').is(':checked'))
  1142. PopulateMarketActions(elActions, item);
  1143. }).fail(function (jqxhr) {
  1144. // jquery doesn't parse json on fail
  1145. elPriceInfoContent.update('Error...');
  1146. var data = $J.parseJSON(jqxhr.responseText);
  1147. SellItemDialog.OnFailure({ responseJSON: data });
  1148. });
  1149. return false;
  1150. });
  1151. if (item == g_ActiveInventory.selectedItem) {
  1152. elActions.appendChild(fastSellBt);
  1153. }
  1154. }
  1155. }
  1156. else {
  1157. strInfo += 'There are no listings currently available for this item.' + '<br>';
  1158. }
  1159.  
  1160. if (response.volume) {
  1161. var strVolume = '%1$s sold in the last 24 hours';
  1162. strVolume = strVolume.replace('%1$s', response.volume);
  1163. strInfo += 'Volume: ' + strVolume + '<br>';
  1164. }
  1165.  
  1166. elPriceInfoContent.update(strInfo);
  1167. }
  1168. }
  1169. });
  1170.  
  1171. //new Ajax.Request(window.location.protocol + '//steamcommunity.com/market/priceoverview/', {
  1172. // method: 'get',
  1173. // parameters: {
  1174. // country: g_strCountryCode,
  1175. // currency: typeof (g_rgWalletInfo) != 'undefined' ? g_rgWalletInfo['wallet_currency'] : 1,
  1176. // appid: item.appid,
  1177. // market_hash_name: strMarketName
  1178. // },
  1179. // onSuccess: function (transport) {
  1180. // if (transport.responseJSON && transport.responseJSON.success) {
  1181. // var strInfo = '';
  1182. // if (transport.responseJSON.lowest_price) {
  1183. // strInfo += 'Starting at: ' + transport.responseJSON.lowest_price + '<br>'
  1184.  
  1185. // var num = getNumber(transport.responseJSON.lowest_price);//.replace(/\s/g, '').replace(/\&#\d+;/g, '').replace(' p&#1091;&#1073;.', '').replace(/[^\d,\.]/g, '');
  1186. // var inputValue = GetPriceValueAsInt(num);
  1187. // var nAmount = inputValue;
  1188. // var sellingPrice = null;
  1189. // if (inputValue > 0 && nAmount == parseInt(nAmount)) {
  1190. // // Calculate what the seller gets
  1191. // var publisherFee = typeof item.market_fee != 'undefined' ? item.market_fee : g_rgWalletInfo['wallet_publisher_fee_percent_default'];
  1192. // var feeInfo = CalculateFeeAmount(nAmount, publisherFee);
  1193. // nAmount = nAmount - feeInfo.fees + (100 * (window.fastdelta));
  1194. // if (nAmount <= 0) nAmount = 1;
  1195.  
  1196. // var info = CalculateAmountToSendForDesiredReceivedAmount(nAmount, publisherFee);
  1197. // inputValue = info.amount;
  1198. // sellingPrice = v_currencyformat(inputValue, GetCurrencyCode(g_rgWalletInfo['wallet_currency']));
  1199. // }
  1200.  
  1201. // if (quicksellbuttons) {
  1202. // var fastSellBt = CreateMarketActionButton('green', '#', SIHLang.quicksell.replace('$1', sellingPrice));
  1203. // $J(fastSellBt).css({ 'marginLeft': '12px' });
  1204. // $J(fastSellBt).click(function () {
  1205. // elPriceInfoContent.update('<img src="' + window.location.protocol + '//steamcommunity-a.akamaihd.net/public/images/login/throbber.gif" alt="Working...">');
  1206. // SellItemDialog.m_item = item;
  1207. // $J.ajax({
  1208. // url: 'https://steamcommunity.com/market/sellitem/',
  1209. // type: 'POST',
  1210. // data: {
  1211. // sessionid: g_sessionID,
  1212. // appid: item.appid,
  1213. // contextid: item.contextid,
  1214. // assetid: item.id,
  1215. // amount: 1,
  1216. // price: nAmount
  1217. // },
  1218. // crossDomain: true,
  1219. // xhrFields: { withCredentials: true }
  1220. // }).done(function (data) {
  1221. // SellItemDialog.OnSuccess({ responseJSON: data });
  1222. // if ($J('#Ck_NoReload').is(':checked'))
  1223. // PopulateMarketActions(elActions, item);
  1224. // }).fail(function (jqxhr) {
  1225. // // jquery doesn't parse json on fail
  1226. // elPriceInfoContent.update('Error...');
  1227. // var data = $J.parseJSON(jqxhr.responseText);
  1228. // SellItemDialog.OnFailure({ responseJSON: data });
  1229. // });
  1230. // return false;
  1231. // });
  1232. // elActions.appendChild(fastSellBt);
  1233. // }
  1234. // }
  1235. // else {
  1236. // strInfo += 'There are no listings currently available for this item.' + '<br>';
  1237. // }
  1238.  
  1239. // if (transport.responseJSON.volume) {
  1240. // var strVolume = '%1$s sold in the last 24 hours';
  1241. // strVolume = strVolume.replace('%1$s', transport.responseJSON.volume);
  1242. // //strInfo += 'Median price: ' + transport.responseJSON.median_price + '<br>';
  1243. // strInfo += 'Volume: ' + strVolume + '<br>';
  1244. // }
  1245.  
  1246. // elPriceInfoContent.update(strInfo);
  1247. // }
  1248. // },
  1249. // onFailure: function (transport) { elPriceInfo.hide(); }
  1250. //});
  1251. }
  1252. elActions.appendChild(elPriceInfo);
  1253.  
  1254. var elSellButton = CreateMarketActionButton('green', '#', 'Sell');
  1255. $J(elSellButton).click(function () {
  1256. if ($J('.selectedSell').length > 0) {
  1257. $J('#div_multi input[type=checkbox]').prop('disabled', false);
  1258. $J('#div_multi').show();
  1259. $J('#ck_autoaccept').prop('checked', true);
  1260. var rgItem = $J('.selectedSell')[0].rgItem;
  1261. //g_ActiveInventory.SelectItem(null, rgItem.element, rgItem);
  1262. //g_ActiveInventory.EnsurePageActiveForItem(rgItem.element);
  1263. SellItemDialog.Show(rgItem);
  1264. ShowQueue();
  1265. }
  1266. else {
  1267. SellCurrentSelection();
  1268. }
  1269. return false;
  1270. });
  1271. elActions.appendChild(elSellButton);
  1272. window.setTimeout(function () {
  1273. if (fastSellBt && item == g_ActiveInventory.selectedItem) {
  1274. elActions.appendChild(fastSellBt);
  1275. }
  1276. }, 50);
  1277.  
  1278.  
  1279. if (!g_bMarketAllowed) {
  1280. var elTooltip = $('market_tip_noaccess');
  1281. InstallHoverTooltip(elSellButton, elTooltip);
  1282. }
  1283. }
  1284. else {
  1285. elActions.hide();
  1286. return;
  1287. }
  1288.  
  1289.  
  1290. elActions.show();
  1291. }
  1292.  
  1293. }
  1294.  
  1295. var ModifyDescriptionFunction = function () {
  1296. PopulateDescriptions = function (elDescriptions, rgDescriptions) {
  1297. elDescriptions.update('');
  1298. if (!rgDescriptions || !rgDescriptions.length) {
  1299. elDescriptions.hide();
  1300. return;
  1301. }
  1302.  
  1303. elDescriptions.show();
  1304. var setEl = null;
  1305. var setName = null;
  1306. var totalPrice = 0;
  1307. var missingParts = [];
  1308. for (var i = 0; i < rgDescriptions.length; i++) {
  1309. var description = rgDescriptions[i];
  1310. if (!description.value)
  1311. continue;
  1312.  
  1313. var strParsedDescription = v_trim(description.value.replace(/\[date\](\d*)\[\/date\]/g, function (match, p1) {
  1314. var date = new Date(p1 * 1000);
  1315. return date.toLocaleString();
  1316. }));
  1317.  
  1318. var elDescription = new Element('div', { 'class': 'descriptor' });
  1319. if (description.color)
  1320. elDescription.style.color = '#' + description.color;
  1321.  
  1322. // just use a blank space for an empty string
  1323. if (strParsedDescription.length == 0) {
  1324. elDescription.update('&nbsp;');
  1325. }
  1326. else if (description.type == 'image') {
  1327. var elImage = new Element('img', { src: v_trim(description.value) });
  1328. elDescription.appendChild(elImage);
  1329. }
  1330. else if (description.type == 'html') {
  1331. var html = strParsedDescription;
  1332. if (description.app_data && !description.app_data.limited && !description.app_data.is_itemset_name) {
  1333. var item = {};
  1334. if (description.app_data.price) {
  1335. var pp = getNumber(description.app_data.price);
  1336. item.price = pp;
  1337. item.link = window.location.protocol + '//steamcommunity.com/market/listings/' + g_ActiveInventory.appid + '/' + encodeURIComponent(description.app_data.market_hash_name);
  1338. item.name = strParsedDescription;
  1339. item.market_hash_name = description.app_data.market_hash_name;
  1340. totalPrice += parseFloat(pp);
  1341. html = '<a href="' + window.location.protocol + '//steamcommunity.com/market/listings/' + g_ActiveInventory.appid + '/' + encodeURIComponent(description.app_data.market_hash_name) + '" target="_blank" style="color:inherit" class="whiteLink">' + html + ' (' + description.app_data.price + ')</a>';
  1342. }
  1343.  
  1344. if (description.isinset) {
  1345. if (description.app_data.owned) {
  1346. html = '&#10003; ' + html;
  1347. }
  1348. else {
  1349. html = '&#10007;&nbsp; ' + html;
  1350. if (description.app_data.price)
  1351. missingParts.push(item);
  1352. }
  1353. }
  1354. }
  1355.  
  1356. if (description.isstickers) {
  1357. html = html.substr(0, html.indexOf('<br>Sticker:') + 12);
  1358. for (var k = 0; k < description.stickers.length; k++) {
  1359. var sticker = description.stickers[k];
  1360. if (k) html += ', ';
  1361. html += sticker.name;
  1362. if (sticker.prices && sticker.prices.lowestPrice) {
  1363. html += ' - <span title="' + sticker.prices.nofeePrice + '" style="color: #FF0">' + sticker.prices.lowestPrice + '</span>'
  1364. }
  1365. }
  1366. html += '</center></div>';
  1367. }
  1368.  
  1369. if (description.insgems && description.insgems.length) {
  1370. if (!description.orgvalue) description.orgvalue = description.value;
  1371. else description.value = description.orgvalue;
  1372.  
  1373. var regexgem = /<span style="font-size: 12px">([\w\s]+)<\/span>/gi;
  1374. for (var j = 0; j < description.insgems.length; j++) {
  1375. var m = regexgem.exec(description.orgvalue);
  1376. var ggem = description.insgems[j];
  1377. var gemLink = window.location.protocol + '//steamcommunity.com/market/listings/570/' + ggem.name;
  1378. if (ggem.lowestPrice) {
  1379. description.value = description.value.replace(m[0], '<a href="' + gemLink + '" target="_blank" title="' + ggem.name + '">' + m[1] + ' <span style="color: #FF0">(' + ggem.lowestPrice + ')</span></a>')
  1380. }
  1381. else {
  1382. description.value = description.value.replace(m[0], '<a href="' + gemLink + '" target="_blank" title="' + ggem.name + '">' + m[1] + '</a>')
  1383. }
  1384. }
  1385. html = description.value;
  1386. }
  1387.  
  1388. elDescription.update(html);
  1389.  
  1390. }
  1391. else {
  1392. elDescription.update(strParsedDescription.escapeHTML().replace(/\n/g, '<br>'));
  1393. }
  1394.  
  1395. if (description.app_data && description.app_data.is_itemset_name) {
  1396. setEl = elDescription;
  1397. setName = description.value;
  1398. }
  1399.  
  1400. if (description.label) {
  1401. var elLabel = new Element('span', { 'class': 'descriptor_label' });
  1402. elLabel.update(description.label + ': ');
  1403. elDescription.insert({ top: elLabel });
  1404. }
  1405.  
  1406. elDescriptions.appendChild(elDescription);
  1407. }
  1408. //console.log(totalPrice);
  1409. if (setEl && totalPrice > 0) {
  1410. //var totalStr = (Math.round(totalPrice * 100) / 100) + '';
  1411. //if (totalStr.lastIndexOf('.') == -1) totalStr += '.00';
  1412. //totalStr = totalStr.replace(/(\d)(\d{3})([,\.])/, '$1,$2$3');
  1413. setEl.update(setName + ' (' + formatNumber(totalPrice) + ')');
  1414.  
  1415. if (missingParts.length > 0 && g_bViewingOwnProfile && g_bMarketAllowed && buysetbuttons && !elDescriptions.id.startsWith('hover')) {
  1416. var buySetBtn = $J('<a href="#" class="buy-set">' + SIHLang.buymissing + '</a>');
  1417. buySetBtn.click(function () {
  1418. BuySetDialog.Show(missingParts);
  1419. return false;
  1420. });
  1421. $J(setEl).append('<br />').append(buySetBtn);
  1422. }
  1423. }
  1424.  
  1425. }
  1426. var orgPopulateTags = PopulateTags;
  1427. PopulateTags = function (elTags, elTagsContent, rgTags) {
  1428. orgPopulateTags(elTags, elTagsContent, rgTags);
  1429. if (rgTags && rgTags.length > 0) {
  1430. var link = $J('<a href="javascript:void(0)">Gen. expression</a>');
  1431. link.click(function () {
  1432. GenExpDialog.Show(rgTags);
  1433. });
  1434. $J(elTagsContent).append('<br />').append(link);
  1435. }
  1436. }
  1437. }
  1438.  
  1439. var ModifyItemDisplay = function () {
  1440. UserYou.OnLoadInventoryComplete = function (transport, appid, contextid) {
  1441. this.cLoadsInFlight--;
  1442. if (transport.responseJSON && transport.responseJSON.success) {
  1443. var inventory = new CInventory(this, appid, contextid, transport.responseJSON.rgInventory, transport.responseJSON.rgCurrency);
  1444.  
  1445. this.addInventory(inventory);
  1446. var elInventory = inventory.getInventoryElement();
  1447. elInventory.hide();
  1448. $('inventories').insert(elInventory);
  1449.  
  1450. var elTags = inventory.getTagContainer();
  1451. var elTagHolder = $('filter_options');
  1452. if (elTagHolder && elTags) {
  1453. elTags.hide();
  1454. elTagHolder.insert(elTags);
  1455. elTagHolder.addClassName('filter_collapsed');
  1456. }
  1457.  
  1458. var classArr = {};
  1459. for (var ii in transport.responseJSON.rgInventory) {
  1460. var rgItem = transport.responseJSON.rgInventory[ii];
  1461. if (!classArr[rgItem.classid])
  1462. classArr[rgItem.classid] = 1;
  1463. else
  1464. classArr[rgItem.classid]++;
  1465. }
  1466. //console.log(classArr);
  1467.  
  1468. for (var ii in transport.responseJSON.rgInventory) {
  1469. var rgItem = transport.responseJSON.rgInventory[ii];
  1470.  
  1471. if (classArr[rgItem.classid] && classArr[rgItem.classid] > 1 && rgItem.descriptions) {
  1472. if (!rgItem.descriptions[0].iscount)
  1473. rgItem.descriptions.unshift({
  1474. iscount: true,
  1475. type: 'html',
  1476. value: 'Number owned: <i style="color: rgb(153, 204, 255); font-size: 16px">' + classArr[rgItem.classid] + '</i>' + (g_bViewingOwnProfile ? ' (<a href="javascript:selectSimilar(' + rgItem.classid + ')">Select all</a>)' : '')
  1477. });
  1478. }
  1479. }
  1480.  
  1481. if (appid == 570) {
  1482. $J.ajax({
  1483. url: 'https://api.steampowered.com/IEconItems_570/GetPlayerItems/v0001/',
  1484. strSteamId: this.strSteamId,
  1485. data: {
  1486. SteamID: this.strSteamId,
  1487. key: apiKey
  1488. },
  1489. success: function (data) {
  1490. if (!apiItems[this.strSteamId])
  1491. apiItems[this.strSteamId] = {};
  1492.  
  1493. if (data && data.result && data.result.status == 1) {
  1494. apiItems[this.strSteamId][appid] = data.result.items;
  1495. $J.each(apiItems[this.strSteamId][appid], function (i, o) {
  1496. var elIt = $J('div.item[id=item570_2_' + o.id + ']');
  1497. if (o.equipped) {
  1498. elIt.addClass('item-equipped');
  1499. elIt.each(function () { this.rgItem.equipped = true; });;
  1500. }
  1501. elIt.each(function () { this.rgItem.defindex = o.defindex; });;
  1502. });
  1503. }
  1504. },
  1505. error: function () {
  1506.  
  1507. }
  1508. });
  1509. }
  1510. else if (appid == 730) {
  1511. numberOfRetries = 0;
  1512. GetCSGOItems();
  1513. }
  1514. else if (appid == 440) {
  1515. $J.ajax({
  1516. url: 'https://api.steampowered.com/IEconItems_440/GetPlayerItems/v0001/',
  1517. strSteamId: this.strSteamId,
  1518. data: {
  1519. SteamID: this.strSteamId,
  1520. key: apiKey
  1521. },
  1522. success: function (data) {
  1523.  
  1524. if (!apiItems[this.strSteamId])
  1525. apiItems[this.strSteamId] = {};
  1526.  
  1527. if (data && data.result && data.result.status == 1) {
  1528. apiItems[this.strSteamId][appid] = data.result.items;
  1529. $J.each(apiItems[this.strSteamId][appid], function (i, o) {
  1530. var elIt = $J('div.item[id=item440_2_' + o.id + ']');
  1531. if (o.equipped) {
  1532. elIt.addClass('item-equipped');
  1533. elIt.each(function () { this.rgItem.equipped = true; });;
  1534. }
  1535. elIt.each(function () {
  1536. this.rgItem.defindex = o.defindex;
  1537. this.rgItem.apivalue = o;
  1538. });;
  1539. });
  1540. }
  1541. if (TF2BP && TF2BP.SetPrice) {
  1542. TF2BP.SetPrice(440);
  1543. }
  1544. },
  1545. error: function () {
  1546.  
  1547. }
  1548. });
  1549. }
  1550. /*
  1551. */
  1552. if (window.extprice) {
  1553. SetupExternalDropdown(g_ActiveInventory.appid);
  1554. if (ExternalPrices[appid]) {
  1555. var lastAPI = GetCookie('lastext_' + appid);
  1556. if (lastAPI != null) {
  1557. lastAPI = parseInt(lastAPI);
  1558. } else {
  1559. lastAPI = 0;
  1560. }
  1561. $J.each(ExternalPrices[appid].apis, function (idx, el) {
  1562. if (this.api && this.api.GetPrices) {
  1563. this.api.GetPrices(inventory.rgInventory, (idx == lastAPI));
  1564. }
  1565. });
  1566. }
  1567. }
  1568. }
  1569. else {
  1570. this.OnInventoryLoadFailed(transport, appid, contextid);
  1571. return;
  1572. }
  1573.  
  1574. this.ShowInventoryIfActive(appid, contextid);
  1575. $J(window).trigger('resize.DynamicInventorySizing');
  1576.  
  1577. $J.each(itemsInTrades, function () {
  1578. var it = this;
  1579. if (it.appid == appid) {
  1580. var elIt = $J('div.item[id=item' + it.appid + '_' + it.context + '_' + it.id + ']');
  1581. elIt.addClass('item-in-trade');
  1582. }
  1583. });
  1584.  
  1585. if (g_bIsTrading)
  1586. RedrawCurrentTradeStatus();
  1587.  
  1588. };
  1589. }
  1590.  
  1591. var numberOfRetries = 0, maxRetries = 10;
  1592. var dopplerPhaseName = {
  1593. 421: 'Phase 4',
  1594. 420: 'Phase 3',
  1595. 419: 'Phase 2',
  1596. 418: 'Phase 1',
  1597. 417: 'Black Pearl',
  1598. 416: 'Sapphire',
  1599. 415: 'Ruby'
  1600. }
  1601. var GetCSGOItems = function () {
  1602. $J.ajax({
  1603. url: 'https://api.steampowered.com/IEconItems_730/GetPlayerItems/v0001/',
  1604. strSteamId: UserYou.strSteamId,
  1605. data: {
  1606. SteamID: UserYou.strSteamId,
  1607. key: apiKey
  1608. },
  1609. success: function (data) {
  1610. if (!apiItems[this.strSteamId])
  1611. apiItems[this.strSteamId] = {};
  1612. if (data && data.result && data.result.status == 1) {
  1613. apiItems[this.strSteamId][730] = data.result.items;
  1614. $J.each(apiItems[this.strSteamId][730], function (i, o) {
  1615. var elIt = $J('div.item[id=item730_2_' + o.id + ']');
  1616. if (o.attributes) {
  1617. var floatValue = -1;
  1618. var dopplerPhase = -1;
  1619. for (var j = 0; j < o.attributes.length; j++) {
  1620. if (o.attributes[j].defindex == 8) {
  1621. floatValue = o.attributes[j].float_value;
  1622. }
  1623. if (o.attributes[j].defindex == 6) {
  1624. dopplerPhase = o.attributes[j].float_value;
  1625. }
  1626. }
  1627. }
  1628. if (floatValue >= 0) {
  1629. var dPstr = '';
  1630. if (dopplerPhase > 0) {
  1631. dPstr = dopplerPhaseName[dopplerPhase] || '';
  1632. }
  1633. elIt.each(function () {
  1634. if (!this.rgItem.float_value) {
  1635. this.rgItem.float_value = floatValue;
  1636. this.rgItem.dopplerPhase = dPstr;
  1637. if (this.rgItem.descriptions) {
  1638. this.rgItem.descriptions = this.rgItem.descriptions.clone();
  1639. this.rgItem.descriptions.unshift({ type: "html", value: "Float value: <strong style='color: #FF0'>" + floatValue.toFixed(4) + "</strong> " + dPstr, floatvalue: true });
  1640. }
  1641. }
  1642. });;
  1643. }
  1644. });
  1645. }
  1646. },
  1647. error: function () {
  1648. numberOfRetries++;
  1649. console.log('Retry', numberOfRetries);
  1650. if (numberOfRetries >= maxRetries) return;
  1651. window.setTimeout(GetCSGOItems, 1000 + (200 * numberOfRetries));
  1652. }
  1653. });
  1654. }
  1655.  
  1656.  
  1657. var ModifyGamesTabs = function () {
  1658. //$J('.games_list_tabs').append($J('.games_list_tabs a.games_list_tab').clone());
  1659. var numberOfGames = $J('.games_list_tabs a.games_list_tab').length;
  1660. var cIdx = $J('.games_list_tabs a.games_list_tab').index($J('.games_list_tabs .active'));
  1661.  
  1662. if (numberOfGames > 10) {
  1663. var divCont = $J('<div class="holder">');
  1664. var divCtrl = $J('<div class="tab-controls">');
  1665. var children = $J('.games_list_tabs').children().remove();
  1666. divCont.append(children);
  1667. divCtrl.append('<a href="#" class="tab-up">up</a><a href="#" class="tab-down">down</a>');
  1668. divCtrl.find('.tab-up').click(function () {
  1669. divCont.stop();
  1670.  
  1671. var cPos = parseInt(divCont.scrollTop() / 56) * 56;
  1672. divCont.animate({ scrollTop: cPos - 112 }, 500);
  1673. return false;
  1674. });
  1675. divCtrl.find('.tab-down').click(function () {
  1676. divCont.stop();
  1677. var cPos = (parseInt(divCont.scrollTop() / 56)) * 56;
  1678. divCont.animate({ scrollTop: cPos + 112 }, 500);
  1679. return false;
  1680. });
  1681. $J('.games_list_tabs').append(divCont);
  1682. $J('.games_list_tabs').append(divCtrl);
  1683. if (cIdx > 5) {
  1684. divCont.animate({ scrollTop: cIdx * 56 }, 500);
  1685. }
  1686. }
  1687. }
  1688.  
  1689. var orgShowItemInventory = null;
  1690. var ModifyShowItemInventory = function () {
  1691. orgShowItemInventory = ShowItemInventory;
  1692. ShowItemInventory = function (appid, contextid, assetid, bLoadCompleted) {
  1693. orgShowItemInventory(appid, contextid, assetid, bLoadCompleted);
  1694. SetupExternalDropdown(appid);
  1695. if (ExternalPrices[appid]) {
  1696. $J.each(ExternalPrices[appid].apis, function (idx, el) {
  1697. if (this.api && this.api.GetPrices) {
  1698. this.api.GetPrices(g_ActiveInventory.rgInventory, (idx == 0));
  1699. }
  1700. });
  1701. }
  1702. }
  1703. }
  1704. var UpdateSellItem = function (item) {
  1705. SellItemDialog.m_item = item;
  1706. if ($J('#ck_autoadjust').is(':checked')) {
  1707. if (!item.sellerPrice) {
  1708. SellItemDialog.b_isInterupted = true;
  1709. return false;
  1710. }
  1711. var calPrice = CalculateSellingPrice(item.sellerPrice);
  1712. if (calPrice <= 0) calPrice = item.sellerPrice;
  1713. var publisherFee = typeof SellItemDialog.m_item.market_fee != 'undefined' ? SellItemDialog.m_item.market_fee : g_rgWalletInfo['wallet_publisher_fee_percent_default'];
  1714. var info = CalculateAmountToSendForDesiredReceivedAmount(calPrice, publisherFee);
  1715.  
  1716. $J('#market_sell_currency_input').val(v_currencyformat(calPrice, GetCurrencyCode(g_rgWalletInfo['wallet_currency'])));
  1717. $J('#market_sell_buyercurrency_input').val(v_currencyformat(info.amount, GetCurrencyCode(g_rgWalletInfo['wallet_currency'])));
  1718. SellItemDialog.m_nConfirmedPrice = calPrice;
  1719. }
  1720.  
  1721. var elItem = $('market_sell_dialog_item');
  1722. if (item.name_color)
  1723. elItem.style.borderColor = '#' + item.name_color;
  1724. if (item.background_color)
  1725. elItem.style.backgroundColor = '#' + item.background_color;
  1726.  
  1727. var elItemImage = $('market_sell_dialog_item_img');
  1728. if (item.is_stackable)
  1729. elItemImage.src = ImageURL(item.icon_url, '96f', '58f');
  1730. else
  1731. elItemImage.src = ImageURL(item.icon_url, '96f', '96f');
  1732.  
  1733. SellItemDialog.m_strName = GetNameForItem(item);
  1734. $('market_sell_dialog_item_name').update(SellItemDialog.m_strName);
  1735. $('market_sell_quantity_available_amt').update(item.amount);
  1736.  
  1737. if (item.name_color) {
  1738. $('market_sell_dialog_item_name').style.color = '#' + item.name_color;
  1739. }
  1740. else {
  1741. $('market_sell_dialog_item_name').style.color = '';
  1742. }
  1743.  
  1744. if (item.appid && g_rgAppContextData[item.appid]) {
  1745. var rgAppData = g_rgAppContextData[item.appid];
  1746. $('market_sell_dialog_game_icon').src = rgAppData.icon;
  1747. $('market_sell_dialog_game_icon').alt = rgAppData.name;
  1748. $('market_sell_dialog_game_name').update(rgAppData.name);
  1749. $('market_sell_dialog_item_type').update(item.type);
  1750. $('market_sell_dialog_game_info').show();
  1751. }
  1752. else {
  1753. $('market_sell_dialog_game_info').hide();
  1754. }
  1755.  
  1756. if (item.amount == 1) {
  1757. $('market_sell_quantity_input').disable();
  1758.  
  1759. $('market_sell_quantity_label').hide();
  1760. $('market_sell_quantity_input').hide();
  1761. $('market_sell_quantity_available').hide();
  1762. }
  1763. else {
  1764. $('market_sell_quantity_label').show();
  1765. $('market_sell_quantity_input').show();
  1766. $('market_sell_quantity_available').show();
  1767. }
  1768. return true;
  1769. };
  1770.  
  1771. var ModifySellingFuntions = function () {
  1772.  
  1773. SellItemDialog.orgOnSuccess = SellItemDialog.OnSuccess;
  1774. SellItemDialog.orgOnFailure = SellItemDialog.OnFailure;
  1775. SellItemDialog.newOnSuccess = function (transport) {
  1776. this.m_bWaitingForUserToConfirm = false;
  1777. this.m_bWaitingOnServer = false;
  1778. if (transport.responseJSON) {
  1779. //this.Dismiss();
  1780. $('market_headertip_itemsold_itemname').update(this.m_strName);
  1781. if (this.m_item.name_color) {
  1782. $('market_headertip_itemsold_itemname').style.color = '#' + this.m_item.name_color;
  1783. }
  1784. else {
  1785. $('market_headertip_itemsold_itemname').style.color = '';
  1786. }
  1787.  
  1788. //new Effect.BlindDown('market_headertip_itemsold', { duration: 0.25 });
  1789. g_ActiveInventory.selectedItem.marketable = 0;
  1790. $J(g_ActiveInventory.selectedItem.element).removeClass('selectedSell');
  1791. $J(g_ActiveInventory.selectedItem.element).css('opacity', '0.3');
  1792. $J('div.queue-item-container[data-id=' + g_ActiveInventory.selectedItem.id + ']').hide(200, function () {
  1793. //$J('div.queue-item-container[data-id=' + g_ActiveInventory.selectedItem.id + ']').remove();
  1794.  
  1795. if ($J('.queue-item-container:visible').length > 0) {
  1796. var itC = $J('.queue-item-container:visible').length;
  1797. $J('.queue-item-count').html(itC);
  1798. $J('#Lnk_ShowSellMulti .item_market_action_button_contents').html((itC > 1 ? SIHLang.sellnitem.replace('$1', itC) : SIHLang.sell1item));
  1799. var rgItem = $J('.queue-item-container:visible')[0].rgItem;
  1800. g_ActiveInventory.SelectItem(null, rgItem.element, rgItem);
  1801. g_ActiveInventory.EnsurePageActiveForItem(rgItem.element);
  1802. //var lbp = $J('#market_sell_buyercurrency_input').val(), lsp = $J('#market_sell_currency_input').val();
  1803. if (!UpdateSellItem(rgItem)) return;
  1804.  
  1805. //$J('#market_sell_buyercurrency_input').val(lbp);
  1806. //$J('#market_sell_currency_input').val(lsp);
  1807.  
  1808. if ($J('#ck_autoaccept').is(':checked')) {
  1809. if ($J('#market_sell_dialog').is(':visible'))
  1810. window.setTimeout('SellItemDialog.OnConfirmationAccept({stop:function(){}});', window.delaylistings);
  1811. //window.setTimeout('$J("#market_sell_dialog_ok").trigger("click");', 200);
  1812. }
  1813. else {
  1814. $('market_sell_dialog_ok').show();
  1815. $('market_sell_dialog_ok').setOpacity('0');
  1816. $('market_sell_dialog_ok').fade({ duration: 0.25, from: 0, to: 1 });
  1817. $('market_sell_dialog_back').show();
  1818. $('market_sell_dialog_back').setOpacity('0');
  1819. $('market_sell_dialog_back').fade({ duration: 0.25, from: 0, to: 1 });
  1820. $('market_sell_dialog_throbber').fade({ duration: 0.25 });
  1821. }
  1822.  
  1823. }
  1824. //else {
  1825. // SellItemDialog.Dismiss();
  1826. // $J('.item.selectedSell').removeClass('selectedSell');
  1827. // $J('.similar-item').removeClass('similar-item');
  1828.  
  1829. // $J('#Lnk_Sellmulti .item_market_action_button_contents').html(SIHLang.sellmulti);
  1830. // $J('#Lnk_ShowSellMulti').hide();
  1831. // selectmode = false;
  1832. // SellItemDialog.OnFailure = SellItemDialog.orgOnFailure;
  1833. // $J('.item_market_actions').html('');
  1834. //}
  1835. });
  1836.  
  1837. if ($J('.selectedSell').length <= 0) {
  1838. SellItemDialog.Dismiss();
  1839. $J('.item.selectedSell').removeClass('selectedSell');
  1840. $J('.similar-item').removeClass('similar-item');
  1841.  
  1842. $J('#Lnk_Sellmulti .item_market_action_button_contents').html(SIHLang.sellmulti);
  1843. $J('#Lnk_ShowSellMulti').hide();
  1844. $J('#Lnk_TurnIntoGems').hide();
  1845. $J('#Lnk_SendGifts').hide();
  1846. selectmode = false;
  1847. SellItemDialog.OnFailure = SellItemDialog.orgOnFailure;
  1848. $J('.item_market_actions').html('');
  1849. }
  1850. }
  1851. else {
  1852. this.DisplayError('There was a problem listing your item. Refresh the page and try again.');
  1853. }
  1854. }
  1855.  
  1856. //SellItemDialog.Dismiss = function () {
  1857. // $(document).stopObserving('keydown', this.m_fnDocumentKeyHandler);
  1858. // $J('div.queue-container').remove();
  1859. // $J('#div_multi').hide();
  1860. // $J('#ck_autoaccept,#ck_autoadjust').prop('checked', false);
  1861. // $J('#Txt_adjust').prop('disabled', false);
  1862. // hideModal('market_sell_dialog');
  1863. // if (this.m_modal)
  1864. // this.m_modal.Dismiss();
  1865. // HideHover();
  1866. //}
  1867.  
  1868. SellItemDialog.orgShow = SellItemDialog.Show;
  1869.  
  1870. SellItemDialog.Show = function (item) {
  1871. SellItemDialog.orgShow(item);
  1872. SellItemDialog.m_modal.m_fnOnDismiss = function () {
  1873. $J('div.queue-container').remove();
  1874. $J('#div_multi').hide();
  1875. $J('#ck_autoaccept,#ck_autoadjust').prop('checked', false);
  1876. $J('#Txt_adjust').prop('disabled', false);
  1877. HideHover();
  1878. }
  1879. }
  1880.  
  1881. SellItemDialog.newOnFailure = function (transport) {
  1882. this.m_bWaitingOnServer = false;
  1883.  
  1884. var queue = Effect.Queues.get('global');
  1885. queue.each(function (effect) { effect.cancel(); });
  1886.  
  1887. $('market_sell_dialog_ok').show();
  1888. $('market_sell_dialog_ok').setOpacity('0');
  1889. $('market_sell_dialog_ok').fade({ duration: 0.25, from: 0, to: 1 });
  1890. $('market_sell_dialog_back').show();
  1891. $('market_sell_dialog_back').setOpacity('0');
  1892. $('market_sell_dialog_back').fade({ duration: 0.25, from: 0, to: 1 });
  1893. $('market_sell_dialog_throbber').fade({ duration: 0.25 });
  1894.  
  1895. if (transport.responseJSON && transport.responseJSON.message) {
  1896. this.DisplayError(transport.responseJSON.message);
  1897. if (transport.responseJSON.message != 'The item specified is no longer in your inventory or is not allowed to be traded on the Community Market.') {
  1898. if ($J('#ck_autoaccept').is(':checked') && transport.responseJSON.message.indexOf('exceed the maximum wallet balance') < 0)
  1899. window.setTimeout('SellItemDialog.OnConfirmationAccept({stop:function(){}});', 200);
  1900. }
  1901. else {
  1902. $J(g_ActiveInventory.selectedItem.element).removeClass('selectedSell');
  1903. $J(g_ActiveInventory.selectedItem.element).css('opacity', '0.3');
  1904. }
  1905. }
  1906. else {
  1907. this.DisplayError('There was a problem listing your item. Refresh the page and try again.');
  1908. }
  1909. };
  1910. //g_bMarketAllowed
  1911. $J('#filter_options').after(
  1912. '<div>' +
  1913. '<label for="Ck_NoReload" style="margin-left: 12px; display: none"><input type="checkbox" name="Ck_NoReload" checked="checked" id="Ck_NoReload" /><span data-lang="noreload">No inventory reloading when sell item</span></label>' +
  1914. //'<br />'+
  1915. '<a href="#" id="Lnk_Reload" accesskey="r" style="margin-left: 12px" class="item_market_action_button item_market_action_button_green"><span class="item_market_action_button_edge item_market_action_button_left"></span><span class="item_market_action_button_contents" data-lang="reloadinvent">Reload inventory (alt + r)</span><span class="item_market_action_button_edge item_market_action_button_right"></span><span class="item_market_action_button_preload"></span></a>' +
  1916. '<a href="#" id="Lnk_Sellmulti" style="margin-left: 12px" class="item_market_action_button item_market_action_button_green" title="Tips: User shift click to select a range of items"><span class="item_market_action_button_edge item_market_action_button_left"></span><span class="item_market_action_button_contents" data-lang="sellmulti">Select items</span><span class="item_market_action_button_edge item_market_action_button_right"></span><span class="item_market_action_button_preload"></span></a>' +
  1917. '<a href="#" id="Lnk_ShowSellMulti" style="display:none; margin-left: 12px" title="Tips: User shift click to select a range of items" class="item_market_action_button item_market_action_button_green"><span class="item_market_action_button_edge item_market_action_button_left"></span><span class="item_market_action_button_contents">Sell</span><span class="item_market_action_button_edge item_market_action_button_right"></span><span class="item_market_action_button_preload"></span></a>' +
  1918. '<a href="#" id="Lnk_TurnIntoGems" style="display:none; margin-left: 12px" class="item_market_action_button item_market_action_button_green"><span class="item_market_action_button_edge item_market_action_button_left"></span><span class="item_market_action_button_contents">Turn into gems</span><span class="item_market_action_button_edge item_market_action_button_right"></span><span class="item_market_action_button_preload"></span></a>' +
  1919. '<a href="#" id="Lnk_SendGifts" style="display:none; margin-left: 12px" class="item_market_action_button item_market_action_button_green"><span class="item_market_action_button_edge item_market_action_button_left"></span><span class="item_market_action_button_contents">Send gifts</span><span class="item_market_action_button_edge item_market_action_button_right"></span><span class="item_market_action_button_preload"></span></a>' +
  1920. ' <br />' +
  1921. '</div>'
  1922. );
  1923. $J('#market_sell_dialog_accept_ssa_label').after('<div id="div_multi" style="display:none">' +
  1924. '<label for="ck_autoaccept"><input type="checkbox" id="ck_autoaccept"> <span data-lang="autoaccept">auto accept</span></label> ' +
  1925. '<label for="ck_autoadjust"><input type="checkbox" id="ck_autoadjust"> <span data-lang="autoadjust">auto adjust price</span></label>' +
  1926. '<input type="number" step="0.01" title="adjust amount" id="Txt_adjust" value="0" />' +
  1927. '<select id="cb_adtype"><option value="1">Value</option><option value="2">Percentage</option></select>' +
  1928. '</div>')
  1929.  
  1930. $J('#market_sell_dialog_accept').click(function () {
  1931. $J('#div_multi input[type=checkbox],#Txt_adjust').prop('disabled', true);
  1932. });
  1933.  
  1934. SellItemDialog.OnSuccess = SellItemDialog.newOnSuccess;
  1935.  
  1936. $J('#Ck_NoReload').click(function () {
  1937. if ($J(this).is(':checked')) {
  1938. SellItemDialog.OnSuccess = SellItemDialog.newOnSuccess;
  1939. }
  1940. else
  1941. SellItemDialog.OnSuccess = SellItemDialog.orgOnSuccess;
  1942. });
  1943. $J('#ck_autoadjust').click(function () {
  1944. var rgItem = g_ActiveInventory.selectedItem;
  1945. var calPrice = CalculateSellingPrice(rgItem.sellerPrice);
  1946. if (calPrice <= 0) calPrice = rgItem.sellerPrice;
  1947. var publisherFee = typeof SellItemDialog.m_item.market_fee != 'undefined' ? SellItemDialog.m_item.market_fee : g_rgWalletInfo['wallet_publisher_fee_percent_default'];
  1948. var info = CalculateAmountToSendForDesiredReceivedAmount(calPrice, publisherFee);
  1949.  
  1950. $J('#market_sell_currency_input').val(v_currencyformat(calPrice, GetCurrencyCode(g_rgWalletInfo['wallet_currency'])));
  1951. $J('#market_sell_buyercurrency_input').val(v_currencyformat(info.amount, GetCurrencyCode(g_rgWalletInfo['wallet_currency'])));
  1952. if ($J(this).is(':checked')) {
  1953. $J('#market_sell_currency_input,#market_sell_buyercurrency_input').prop('disabled', true);
  1954. }
  1955. else {
  1956. $J('#market_sell_currency_input,#market_sell_buyercurrency_input').prop('disabled', false);
  1957. }
  1958. });
  1959. $J('#Lnk_Reload').click(function () {
  1960. var it = g_ActiveInventory.selectedItem;
  1961. UserYou.ReloadInventory(it.appid, it.contextid);
  1962. cachePrices = {};
  1963. selectmode = false;
  1964. $J('#Lnk_Sellmulti .item_market_action_button_contents').html(SIHLang.sellmulti);
  1965. $J('#Lnk_ShowSellMulti').hide();
  1966. $J('#Lnk_TurnIntoGems').hide();
  1967. $J('#Lnk_SendGifts').hide();
  1968. SellItemDialog.OnFailure = SellItemDialog.orgOnFailure;
  1969. $J('.item.selectedSell').removeClass('selectedSell');
  1970. $J('.similar-item').removeClass('similar-item');
  1971.  
  1972. return false;
  1973. });
  1974. $J('#Lnk_Sellmulti').click(function () {
  1975. selectmode = !selectmode;
  1976. if (selectmode) {
  1977. $J('#Lnk_Sellmulti .item_market_action_button_contents').html(SIHLang.cancel);
  1978. $J('#Ck_NoReload').prop('checked', true);
  1979. SellItemDialog.OnSuccess = SellItemDialog.newOnSuccess;
  1980. SellItemDialog.OnFailure = SellItemDialog.newOnFailure;
  1981. }
  1982. else {
  1983. $J('#Lnk_Sellmulti .item_market_action_button_contents').html(SIHLang.sellmulti);
  1984. $J('#Lnk_ShowSellMulti').hide();
  1985. $J('#Lnk_TurnIntoGems').hide();
  1986. $J('#Lnk_SendGifts').hide();
  1987. SellItemDialog.OnFailure = SellItemDialog.orgOnFailure;
  1988. }
  1989. $J('.item.selectedSell').removeClass('selectedSell');
  1990. $J('.similar-item').removeClass('similar-item');
  1991.  
  1992. return false;
  1993. });
  1994. $J('#Lnk_ShowSellMulti').click(function () {
  1995. if ($J('.selectedSell').length > 0) {
  1996. $J('#div_multi input[type=checkbox]').prop('disabled', false);
  1997. $J('#div_multi').show();
  1998. $J('#ck_autoaccept').prop('checked', true);
  1999. var rgItem = $J('.selectedSell')[0].rgItem;
  2000. g_ActiveInventory.SelectItem(null, rgItem.element, rgItem);
  2001. g_ActiveInventory.EnsurePageActiveForItem(rgItem.element);
  2002. SellItemDialog.m_bWaitingOnServer = false;
  2003. SellItemDialog.Show(rgItem);
  2004. ShowQueue();
  2005. }
  2006. return false;
  2007. });
  2008.  
  2009. $J('#Lnk_TurnIntoGems').click(function () {
  2010. if ($J('.selectedSell').length > 0) {
  2011. //$J('#div_multi input[type=checkbox]').prop('disabled', false);
  2012. //$J('#div_multi').show();
  2013. //$J('#ck_autoaccept').prop('checked', true);
  2014. //var rgItem = $J('.selectedSell')[0].rgItem;
  2015. ////g_ActiveInventory.SelectItem(null, rgItem.element, rgItem);
  2016. ////g_ActiveInventory.EnsurePageActiveForItem(rgItem.element);
  2017. ////SellItemDialog.m_bWaitingOnServer = false;
  2018. ////SellItemDialog.Show(rgItem);
  2019.  
  2020. //var rgAJAXParams = {
  2021. // sessionid: g_sessionID,
  2022. // appid: rgItem.app_data.appid,
  2023. // assetid: rgItem.id,
  2024. // contextid: rgItem.contextid
  2025. //};
  2026. var strActionURL = g_strProfileURL + "/ajaxgetgoovalue/";
  2027. GrindDialog.Show();
  2028. ShowQueue(1);
  2029. //$J.get(strActionURL, rgAJAXParams).done(function (data) {
  2030. // var $Content = $J(data.strHTML);
  2031. // var strDialogTitle = data.strTitle;
  2032. // ShowConfirmDialog(strDialogTitle, $Content).done(function () {
  2033. // GrindNextItem();
  2034. // });
  2035. //});
  2036. }
  2037. return false;
  2038. });
  2039.  
  2040. $J('#Lnk_SendGifts').click(function () {
  2041.  
  2042. var url = '';
  2043. $J('.selectedSell').each(function () {
  2044. var rgItem = this.rgItem;
  2045. if (rgItem.appid == 753 && rgItem.contextid == 1) {
  2046. url += rgItem.id + '/';
  2047. }
  2048. });
  2049. if (url != '') {
  2050. url = 'http://store.steampowered.com/checkout/sendgift/' + url + g_steamID;
  2051. window.location.href = url;
  2052. }
  2053. else {
  2054. $J('#Lnk_SendGifts').hide();
  2055. }
  2056. return false;
  2057. });
  2058.  
  2059. $J('body').on('click', '.queue-item-remove', function () {
  2060. var p = $J(this).parent('.queue-item-container');
  2061. var rgItemOrg = p[0].rgItem;
  2062. $J('#item' + rgItemOrg.appid + '_' + rgItemOrg.contextid + '_' + p.data().id + '.selectedSell').removeClass('selectedSell');
  2063. p.hide(200);
  2064. var itC = $J('.selectedSell').length;
  2065. if (itC <= 0) {
  2066. SellItemDialog.Dismiss();
  2067. $J('#Lnk_ShowSellMulti').hide();
  2068. $J('#Lnk_TurnIntoGems').hide();
  2069. $J('#Lnk_SendGifts').hide();
  2070. return false;
  2071. }
  2072.  
  2073. var rgItem = $J('.selectedSell')[0].rgItem;
  2074. g_ActiveInventory.SelectItem(null, rgItem.element, rgItem);
  2075. g_ActiveInventory.EnsurePageActiveForItem(rgItem.element);
  2076. UpdateSellItem(rgItem);
  2077. $J('.queue-item-count').html(itC);
  2078. $J('#Lnk_ShowSellMulti .item_market_action_button_contents').html((itC > 1 ? SIHLang.sellnitem.replace('$1', itC) : SIHLang.sell1item));
  2079. return false;
  2080. });
  2081. }
  2082.  
  2083. var AddDialogHTML = function () {
  2084. var dialog = '<div id="market_buyset_dialog" class="market_modal_dialog" style="display: none;">' +
  2085. '<div class="market_dialog_title">' +
  2086. '<span id="market_buyset_dialog_title" >Buy missing parts</span>' +
  2087. '<span class="market_dialog_cancel">' +
  2088. '<a id="market_buyset_dialog_cancel" href="#" class="market_dialog_title_cancel">Cancel<span class="market_dialog_title_cancel_X">X</span></a>' +
  2089. '</span>' +
  2090. '</div>' +
  2091. '<div class="market_dialog_contents">' +
  2092. '<div class="market_dialog_content_frame">' +
  2093. '<div class="market_dialog_content">' +
  2094. '<div class="market_dialog_iteminfo">' +
  2095. '<div id="lstParts" class="market_content_block market_home_listing_table market_home_main_listing_table market_listing_table"></div>' +
  2096. '</div>' +
  2097. '</div>' +
  2098. '<div class="market_dialog_content_separator"></div>' +
  2099. '<div class="market_dialog_content market_dialog_content_dark">' +
  2100. '<div class="market_sell_dialog_input_area">' +
  2101. //'<a id="market_buyset_dialog_accept" href="#" class="btn_green_white_innerfade btn_small_wide"><span>Buy missing parts</span></a>' +
  2102. '<a id="market_buyset_dialog_reload" href="#" class="btn_green_white_innerfade btn_small_wide"><span>Reload list</span></a>' +
  2103. '<div>&nbsp;<br /><br /></div>' +
  2104. '</div>' +
  2105. '</div>' +
  2106. '</div>' +
  2107. '</div>' +
  2108. '</div>';
  2109. dialog += '<div id="hover" style="display: none; z-index: 1001">' +
  2110. '<div class="shadow_ul"></div><div class="shadow_top"></div><div class="shadow_ur"></div><div class="shadow_left"></div><div class="shadow_right"></div><div class="shadow_bl"></div><div class="shadow_bottom"></div><div class="shadow_br"></div> <div class="inventory_iteminfo hover_box shadow_content" id="iteminfo_clienthover">' +
  2111. '<div class="item_desc_content" id="hover_content">' +
  2112. '<div class="item_desc_icon">' +
  2113. '<div class="item_desc_icon_center">' +
  2114. '<img id="hover_item_icon" src="' + window.location.protocol + '//steamcommunity-a.akamaihd.net/public/images/trans.gif" alt="" />' +
  2115. '</div>' +
  2116. '</div>' +
  2117. '<div class="item_desc_description">' +
  2118. '<h1 class="hover_item_name" id="hover_item_name"></h1>' +
  2119. '<div class="fraud_warning" id="hover_fraud_warnings"></div>' +
  2120. '<div class="item_desc_game_info" id="hover_game_info">' +
  2121. '<div class="item_desc_game_icon">' +
  2122. '<img id="hover_game_icon" src="' + window.location.protocol + '//steamcommunity-a.akamaihd.net/public/images/trans.gif" alt="" />' +
  2123. '</div>' +
  2124. '<div id="hover_game_name" class="ellipsis"></div>' +
  2125. '<div id="hover_item_type" class=""></div>' +
  2126. '</div>' +
  2127. '<div class="item_desc_descriptors" id="hover_item_descriptors">' +
  2128. '</div>' +
  2129. '<div class="item_desc_descriptors" id="hover_item_owner_descriptors">' +
  2130. '</div>' +
  2131. '</div>' +
  2132. '</div>' +
  2133. '</div>' +
  2134. '<div class="hover_arrow_left" id="hover_arrow_left">' +
  2135. '<div class="hover_arrow_inner"></div>' +
  2136. '</div>' +
  2137. '<div class="hover_arrow_right" id="hover_arrow_right">' +
  2138. '<div class="hover_arrow_inner"></div>' +
  2139. '</div>' +
  2140. '</div>';
  2141. dialog += '<div id="market_getexp_dialog" class="market_modal_dialog" style="display: none;">' +
  2142. '<div class="market_dialog_title">' +
  2143. '<span id="market_getexp_dialog_title" >Generate custom button expression</span>' +
  2144. '<span class="market_dialog_cancel">' +
  2145. '<a id="market_getexp_dialog_cancel" href="#" class="market_dialog_title_cancel">Cancel<span class="market_dialog_title_cancel_X">X</span></a>' +
  2146. '</span>' +
  2147. '</div>' +
  2148. '<div class="market_dialog_contents">' +
  2149. '<div class="market_dialog_content_frame">' +
  2150. '<div class="market_dialog_content">' +
  2151. '<div>' +
  2152. '<div class="tags-container"></div>' +
  2153. '<div class="tag-textbox"><input type="text" style="width:100%" id="market_getexp_dialog_exptext" /></div>' +
  2154. '</div>' +
  2155. '</div>' +
  2156. '<div class="market_dialog_content_separator"></div>' +
  2157. '<div class="market_dialog_content market_dialog_content_dark">' +
  2158. '<div class="market_sell_dialog_input_area">' +
  2159. //'<a id="market_getexp_dialog_accept" href="#" class="btn_green_white_innerfade btn_small_wide"><span>Buy missing parts</span></a>' +
  2160. '<a id="market_getexp_dialog_gen" href="#" class="btn_green_white_innerfade btn_small_wide"><span>Generate</span></a>' +
  2161. '<div>&nbsp;<br /><br /></div>' +
  2162. '</div>' +
  2163. '</div>' +
  2164. '</div>' +
  2165. '</div>' +
  2166. '</div>';
  2167.  
  2168. dialog += '<div id="market_grind_dialog" class="market_modal_dialog" style="display: none;">' +
  2169. '<div class="market_dialog_title">' +
  2170. '<span id="market_grind_dialog_title" >Turn into gems</span>' +
  2171. '<span class="market_dialog_cancel">' +
  2172. '<a id="market_grind_dialog_cancel" href="#" class="market_dialog_title_cancel">Cancel<span class="market_dialog_title_cancel_X">X</span></a>' +
  2173. '</span>' +
  2174. '</div>' +
  2175. '<div class="market_dialog_contents">' +
  2176. '<div class="market_dialog_content_frame">' +
  2177. '<div class="market_dialog_content">' +
  2178. '<div>' +
  2179. '<div class="tags-container">Did you want to convert these items into Gems? It cannot be undone.</div>' +
  2180. '</div>' +
  2181. '</div>' +
  2182. '<div class="market_dialog_content_separator"></div>' +
  2183. '<div class="market_dialog_content market_dialog_content_dark">' +
  2184. '<div class="market_sell_dialog_input_area">' +
  2185. //'<a id="market_grind_dialog_accept" href="#" class="btn_green_white_innerfade btn_small_wide"><span>Buy missing parts</span></a>' +
  2186. '<a id="market_grind_dialog_grind" href="#" class="btn_green_white_innerfade btn_small_wide"><span>Ok</span></a>' +
  2187. '<div>&nbsp;<br /><br /></div>' +
  2188. '</div>' +
  2189. '</div>' +
  2190. '</div>' +
  2191. '</div>' +
  2192. '</div>';
  2193. $J('body').append(dialog);
  2194. }
  2195.  
  2196. var CalculateSellingPrice = function (basePrice) {
  2197. var calPrice = basePrice;
  2198. if ($J('#cb_adtype').val() == '2') {
  2199. var per = Math.round((basePrice * parseFloat($J('#Txt_adjust').val())) / 100);
  2200. if (per == 0 && parseFloat($J('#Txt_adjust').val()) != 0) per = (parseFloat($J('#Txt_adjust').val()) < 0 ? -1 : 1);
  2201. calPrice = basePrice + per;
  2202. }
  2203. else {
  2204. calPrice = basePrice + Math.floor(parseFloat($J('#Txt_adjust').val()) * 100);
  2205. }
  2206.  
  2207. if (calPrice <= 0) calPrice = basePrice;
  2208. return calPrice;
  2209. }
  2210.  
  2211. var ContinueListing = function () {
  2212. if (!SellItemDialog.b_isInterupted) return;
  2213. SellItemDialog.b_isInterupted = false;
  2214.  
  2215. console.log('Resume listing');
  2216.  
  2217. var firstItem = $J('.queue-item-container:has(>span.price)');
  2218. if (firstItem.length == 0) return;
  2219. var rgItem = firstItem[0].rgItem;
  2220.  
  2221. if (!UpdateSellItem(rgItem)) return;
  2222.  
  2223. if ($J('#ck_autoaccept').is(':checked')) {
  2224. if ($J('#market_sell_dialog').is(':visible'))
  2225. window.setTimeout('SellItemDialog.OnConfirmationAccept({stop:function(){}});', window.delaylistings);
  2226. }
  2227.  
  2228. }
  2229.  
  2230. var SetupAcceptAllGifts = function () {
  2231.  
  2232. if ($J('#tabcontent_pendinggifts .pending_gift').length == 0) return;
  2233. var divCnt = $J('<div style="padding: 20px" />');
  2234. var AcceptAllGifts = $J('<a href="#" class="btn_darkblue_white_innerfade btn_medium new_trade_offer_btn"><span>Add all to my Steam Gift Inventory</span></a>');// CreateMarketActionButton('yellow', '#', 'Add all to my Steam Gift Inventory');
  2235. divCnt.append(AcceptAllGifts);
  2236.  
  2237. $J(AcceptAllGifts).click(function (e) {
  2238. e.preventDefault();
  2239. var giftIds = [];
  2240. $J('#tabcontent_pendinggifts .pending_gift > div[id^="pending_gift_"]').each(function () {
  2241. var thisID = $J(this).attr('id');
  2242. var giftID = thisID.substring(13);
  2243. giftIds.push(giftID);
  2244. ShowAcceptGiftOptions(giftID);
  2245. DoAcceptGift(giftID, false);
  2246. });
  2247. });
  2248.  
  2249. $J('#tabcontent_pendinggifts .pending_gifts_header').after(divCnt);
  2250.  
  2251. }
  2252.  
  2253. BuySetDialog = {
  2254. m_bInitialized: false,
  2255. m_oItemsToBuy: [],
  2256. m_fnDocumentKeyHandler: null,
  2257. Initialize: function () {
  2258. //$('market_buyset_dialog_accept').observe('click', this.OnAccept.bindAsEventListener(this));
  2259. $('market_buyset_dialog_cancel').observe('click', this.OnCancel.bindAsEventListener(this));
  2260. $('market_buyset_dialog_reload').observe('click', this.OnReload.bindAsEventListener(this));
  2261.  
  2262. $('market_buyset_dialog').style.visibility = 'hidden';
  2263. $('market_buyset_dialog').show();
  2264. // TODO: Slider
  2265. $('market_buyset_dialog').hide();
  2266. $('market_buyset_dialog').style.visibility = '';
  2267.  
  2268. this.m_bInitialized = true;
  2269. },
  2270. Show: function (items) {
  2271. if (!this.m_bInitialized)
  2272. this.Initialize();
  2273. if (items.length == 0) return;
  2274. m_oItemsToBuy = items;
  2275. this.m_fnDocumentKeyHandler = this.OnDocumentKeyPress.bindAsEventListener(this);
  2276. $(document).observe('keydown', this.m_fnDocumentKeyHandler);
  2277. showModal('market_buyset_dialog', true);
  2278. this.OnReload({ stop: function () { } });
  2279. },
  2280. OnCancel: function (event) {
  2281. this.Dismiss();
  2282. event.stop();
  2283. },
  2284.  
  2285. Dismiss: function () {
  2286. $(document).stopObserving('keydown', this.m_fnDocumentKeyHandler);
  2287. hideModal('market_buyset_dialog');
  2288. if (this.m_modal)
  2289. this.m_modal.Dismiss();
  2290. },
  2291. OnAccept: function (event) {
  2292. event.stop();
  2293. },
  2294. OnReload: function (event) {
  2295. event.stop();
  2296.  
  2297. $J('#lstParts').html('<img src="' + window.location.protocol + '//steamcommunity-a.akamaihd.net/public/images/login/throbber.gif" class="loading" alt="Working...">');
  2298. for (var i = 0; i < m_oItemsToBuy.length; i++) {
  2299. var it = m_oItemsToBuy[i];
  2300. //var li = $J('<div>');
  2301. //li.html(it.name + ' (' + it.price + ')');
  2302. //li[0].item = it;
  2303. $J.get(it.link + "/render/?query=&start=0&count=1&country=" + g_rgWalletInfo['wallet_country'] + "&language=" + g_strLanguage +
  2304. "&currency=" + g_rgWalletInfo['wallet_currency'],
  2305. function (data, textStatus) {
  2306. $J('#lstParts').find('img.loading').remove();
  2307. if (data.success) {
  2308. var listDiv = $J(data.results_html);
  2309. $J('#lstParts').append(listDiv);
  2310. $J('#lstParts').find('.market_listing_table_header').remove();
  2311. listDiv.find('a.item_market_action_button.item_market_action_button_green').each(function () {
  2312. var $row = $J(this).parents('.market_listing_row');
  2313. var match = buyingExp.exec($J(this).attr('href'));
  2314. if (match) {
  2315. $J(this).attr('href', '#');
  2316. $J(this).find('.item_market_action_button_contents').html(SIHLang.quickbuy);
  2317. AddItemHoverToElement(this, data.assets[match[2]][match[3]][match[4]]);
  2318. $J(this).click(function () {
  2319. $J(this).hide();
  2320. var obj = {
  2321. listingid: match[1],
  2322. appid: match[2],
  2323. contextid: match[3],
  2324. id: match[4]
  2325. };
  2326. var rgListing = data.listinginfo[obj.listingid]
  2327. var dat = {
  2328. sessionid: g_sessionID,
  2329. currency: g_rgWalletInfo['wallet_currency'],
  2330. subtotal: rgListing['converted_price'],
  2331. fee: rgListing['converted_fee'],
  2332. total: rgListing['converted_price'] + rgListing['converted_fee'],
  2333. quantity: 1
  2334. }
  2335.  
  2336. //var setLink = 'http://steamcommunity.com/market/priceoverview/?appid=570&country=' + g_strCountryCode + '&currency=' + g_rgWalletInfo['wallet_currency'] +
  2337. // '&market_hash_name=' + data.assets[match[2]][match[3]][match[4]].market_hash_name;
  2338.  
  2339. //var itemLink = "http://steamcommunity.com/market/priceoverview/?appid=" + obj.appid + "&country=" + g_strCountryCode +
  2340. // "&currency=" + g_rgWalletInfo['wallet_currency'] + "&market_hash_name=" + data.assets[match[2]][match[3]][match[4]].market_hash_name;
  2341. //console.log(cachePrices[setLink]);
  2342. //cachePrices[setLink].owned = true;
  2343. //return false;
  2344.  
  2345. $row.find('.market_listing_buy_button').append('<img src="' + window.location.protocol + '//steamcommunity-a.akamaihd.net/public/images/login/throbber.gif" alt="Working...">');
  2346. $J.ajax({
  2347. url: 'https://steamcommunity.com/market/buylisting/' + obj.listingid,
  2348. type: 'POST',
  2349. data: dat,
  2350. crossDomain: true,
  2351. xhrFields: { withCredentials: true }
  2352. }).done(function (data1) {
  2353. if ($row.is(':visible'))
  2354. $row.find('.market_listing_buy_button').html('Success');
  2355. else
  2356. alert('Success');
  2357. }).fail(function (jqxhr) {
  2358. $row.find('.market_listing_buy_button img').remove();
  2359. var data1 = $J.parseJSON(jqxhr.responseText);
  2360. if (data1 && data1.message) {
  2361. alert(data1.message);
  2362. }
  2363. });
  2364. return false;
  2365. });
  2366. }
  2367. });
  2368. }
  2369. }
  2370. );
  2371. }
  2372. },
  2373. OnDocumentKeyPress: function (event) {
  2374. if (event.keyCode == Event.KEY_ESC) {
  2375. this.Dismiss();
  2376. event.stop();
  2377. }
  2378. },
  2379. }
  2380.  
  2381. GrindDialog = {
  2382. m_bInitialized: false,
  2383. m_bIsDismissed: true,
  2384. m_fnDocumentKeyHandler: null,
  2385. m_modal: null,
  2386. m_elDialogContent: null,
  2387. Initialize: function () {
  2388. //$('market_grind_dialog_accept').observe('click', this.OnAccept.bindAsEventListener(this));
  2389. $('market_grind_dialog_cancel').observe('click', this.OnCancel.bindAsEventListener(this));
  2390. $('market_grind_dialog_grind').observe('click', this.OnGrind.bindAsEventListener(this));
  2391.  
  2392. $('market_grind_dialog').style.visibility = 'hidden';
  2393. $('market_grind_dialog').show();
  2394. // TODO: Slider
  2395. $('market_grind_dialog').hide();
  2396. $('market_grind_dialog').style.visibility = '';
  2397.  
  2398. this.m_elDialogContent = $('market_grind_dialog');
  2399.  
  2400. this.m_bInitialized = true;
  2401. },
  2402. Show: function () {
  2403.  
  2404. if (!this.m_bInitialized)
  2405. this.Initialize();
  2406. this.m_bIsDismissed = false;
  2407. this.m_fnDocumentKeyHandler = this.OnDocumentKeyPress.bindAsEventListener(this);
  2408. $(document).observe('keydown', this.m_fnDocumentKeyHandler);
  2409. this.m_modal = new CModal($J(this.m_elDialogContent));
  2410. this.m_modal.Show();
  2411. },
  2412. OnCancel: function (event) {
  2413. this.Dismiss();
  2414. event.stop();
  2415. },
  2416.  
  2417. Dismiss: function () {
  2418. $(document).stopObserving('keydown', this.m_fnDocumentKeyHandler);
  2419. //hideModal('market_grind_dialog');
  2420.  
  2421. if (this.m_modal)
  2422. this.m_modal.Dismiss();
  2423. this.m_bIsDismissed = true;
  2424. $J('div.queue-container').remove();
  2425. },
  2426. OnAccept: function (event) {
  2427. event.stop();
  2428. },
  2429. OnGrind: function (event) {
  2430. event.stop();
  2431. GrindNextItem();
  2432. },
  2433. OnDocumentKeyPress: function (event) {
  2434. if (event.keyCode == Event.KEY_ESC) {
  2435. this.Dismiss();
  2436. event.stop();
  2437. }
  2438. },
  2439. }
  2440.  
  2441. GenExpDialog = {
  2442. m_bInitialized: false,
  2443. m_oItem: null,
  2444. m_fnDocumentKeyHandler: null,
  2445. Initialize: function () {
  2446. //$('market_getexp_dialog_accept').observe('click', this.OnAccept.bindAsEventListener(this));
  2447. $('market_getexp_dialog_cancel').observe('click', this.OnCancel.bindAsEventListener(this));
  2448. $('market_getexp_dialog_gen').observe('click', this.OnGenerate.bindAsEventListener(this));
  2449.  
  2450. $('market_getexp_dialog').style.visibility = 'hidden';
  2451. $('market_getexp_dialog').show();
  2452. // TODO: Slider
  2453. $('market_getexp_dialog').hide();
  2454. $('market_getexp_dialog').style.visibility = '';
  2455. $J('#market_getexp_dialog_exptext').click(function () {
  2456. $J(this).select();
  2457. });
  2458. this.m_bInitialized = true;
  2459. },
  2460. Show: function (item) {
  2461. if (!this.m_bInitialized)
  2462. this.Initialize();
  2463. if (!item) return;
  2464. this.m_oItem = item;
  2465. this.m_fnDocumentKeyHandler = this.OnDocumentKeyPress.bindAsEventListener(this);
  2466. $(document).observe('keydown', this.m_fnDocumentKeyHandler);
  2467. this.CreateList();
  2468. showModal('market_getexp_dialog', true);
  2469. },
  2470. CreateList: function () {
  2471. var container = $J('#market_getexp_dialog .tags-container');
  2472. container.empty();
  2473. for (var i = 0; i < this.m_oItem.length; i++) {
  2474. var tag = this.m_oItem[i];
  2475. var ck = $J('<input type="checkbox" checked="checked" id="ck_tag_' + tag.internal_name + '"/>');
  2476. ck.data('exp', tag);
  2477. container.append(ck);
  2478. container.append(' ' + tag.category_name + ': ' + tag.name + '<br />');
  2479. }
  2480. this.OnGenerate({ stop: function () { } });
  2481. //console.log('1');
  2482. },
  2483. OnCancel: function (event) {
  2484. this.Dismiss();
  2485. event.stop();
  2486. },
  2487.  
  2488. Dismiss: function () {
  2489. $(document).stopObserving('keydown', this.m_fnDocumentKeyHandler);
  2490. hideModal('market_getexp_dialog');
  2491.  
  2492. if (this.m_modal)
  2493. this.m_modal.Dismiss();
  2494. },
  2495. OnGenerate: function (event) {
  2496. event.stop();
  2497. var container = $J('#market_getexp_dialog .tags-container');
  2498. var exp = '';
  2499. var cats = [];
  2500. container.find('input[type=checkbox]').each(function () {
  2501. if ($J(this).prop('checked')) {
  2502. var tag = $J(this).data('exp');
  2503. if (cats.indexOf(tag.category) >= 0) return;
  2504. exp += ',"' + tag.category + '":"' + tag.internal_name + '"';
  2505. cats.push(tag.category);
  2506. }
  2507. });
  2508. if (exp.length > 0) exp = "{" + exp.substring(1) + "}";
  2509. $J('#market_getexp_dialog_exptext').val(exp);
  2510. $J('#market_getexp_dialog_exptext').select();
  2511.  
  2512. },
  2513. OnDocumentKeyPress: function (event) {
  2514. if (event.keyCode == Event.KEY_ESC) {
  2515. this.Dismiss();
  2516. event.stop();
  2517. }
  2518. }
  2519. }
  2520.  
  2521.  
  2522.  
  2523. setTimeout(function () {
  2524. //INVENTORY_PAGE_ITEMS = 36;
  2525. //INVENTORY_PAGE_WIDTH = 104 * 6
  2526. sellcurrencyId = typeof (g_rgWalletInfo) != 'undefined' ? g_rgWalletInfo['wallet_currency'] : 1;
  2527. if (typeof (window.currency) != 'undefined' && window.currency != '')
  2528. currencyId = window.currency;
  2529. else
  2530. currencyId = sellcurrencyId;
  2531.  
  2532. var qs = function (key) {
  2533. key = key.replace(/[*+?^$.\[\]{}()|\\\/]/g, "\\$&"); // escape RegEx meta chars
  2534. var match = location.search.match(new RegExp("[?&]" + key + "=([^&]+)(&|$)"));
  2535. return match && decodeURIComponent(match[1].replace(/\+/g, " "));
  2536. };
  2537. $J('.inventory_page_right .hover_item_name').after('<h2 class="dd_price"></h2>');
  2538. if (window.usevector) {
  2539. $J('.inventory_page_right .hover_item_name').after('<a href="javascript:void(0)" id="lnk_Medium" style="clear:both; display: block">use this as vector</a>');
  2540. var _mediumName = GetCookie('mediumname');
  2541. var _mediumAppid = GetCookie('mediumappid');
  2542. $J('#lnk_Medium').click(function () {
  2543. SetCookie('mediumname', g_ActiveInventory.selectedItem.market_hash_name, 365 * 10, '/');
  2544. SetCookie('mediumappid', g_ActiveInventory.selectedItem.appid, 365 * 10, '/');
  2545. getMediumPrice(g_ActiveInventory.selectedItem);
  2546. return false;
  2547. });
  2548.  
  2549. if (_mediumName && _mediumAppid) {
  2550. getMediumPrice({ market_hash_name: _mediumName, appid: _mediumAppid });
  2551. }
  2552. }
  2553. //$('.dd_price').html("Loading...");
  2554. apiKey = (window._apikey != '' ? window._apikey : apiKey);
  2555.  
  2556. $J('body').on('click', '.item', function (e) {
  2557. //extimatePrice(g_ActiveInventory.selectedItem);
  2558. getLowestPriceHandler();
  2559. $J('.equiped').remove();
  2560. $J('.review').remove();
  2561. //if (g_ActiveInventory.selectedItem.equipped)
  2562. // $J('.hover_item_name:visible').after('<div class="equiped" style="float: left">Equipped</div>');
  2563. if (g_ActiveInventory.selectedItem.defindex) {
  2564. var hero = '';
  2565. $J.each(g_ActiveInventory.selectedItem.tags, function (i, e) {
  2566. var tag = g_ActiveInventory.selectedItem.tags[i];
  2567. //console.log(tag);
  2568. if (tag.category === 'Hero') {
  2569. //npc_dota_hero_legion_commander
  2570. hero = tag.internal_name.substring(14);
  2571. if (dotahatteryAlias[hero])
  2572. hero = dotahatteryAlias[hero];
  2573. }
  2574. });
  2575. if (hero != '')
  2576. $J('.hover_item_name:visible').after('<a href="http://dotahattery.com/?h=' + hero + '&id[]=' + g_ActiveInventory.selectedItem.defindex + '" class="equiped" style="display: block; margin:3px; float: left" target="_blank">Preview</a>');
  2577. }
  2578. //$J.each(apiItems[g_ActiveUser.strSteamId], function (i, o) {
  2579. // if (o.id == g_ActiveInventory.selectedItem.id) {
  2580. // if (o.equipped) {
  2581. // $J('.hover_item_name:visible').after('<div class="equiped">Equiped</div>');
  2582. // }
  2583. // //$J(elDescriptions).prepend('<div>Equiped</div>');
  2584. // return false;
  2585. // }
  2586. //});
  2587.  
  2588. if (selectmode) {
  2589. if (this.rgItem && (this.rgItem.marketable || this.rgItem.appid == 753)) {
  2590. $J(this).toggleClass('selectedSell');
  2591. $J('.similar-item').removeClass('similar-item');
  2592. var p_market_hash_name = this.rgItem.market_hash_name;
  2593. var iclassid = this.rgItem.classid;
  2594. var bselected = $J(this).hasClass('selectedSell');
  2595. if (e.ctrlKey) {
  2596. $J('.inventory_ctn:visible .inventory_page .item').each(function (i, el) {
  2597. if (this.rgItem.marketable && this.rgItem.classid == iclassid) {
  2598. if (bselected) {
  2599. g_ActiveInventory.LoadItemImage(this);
  2600. $J(this).addClass('selectedSell');
  2601. }
  2602. else
  2603. $J(this).removeClass('selectedSell');
  2604. }
  2605. });
  2606. }
  2607. else if (bselected) {
  2608. $J('.inventory_ctn:visible .inventory_page .item').each(function (i, el) {
  2609. if (this.rgItem.market_hash_name == p_market_hash_name && this.rgItem.marketable) {
  2610. $J(this).addClass('similar-item');
  2611. }
  2612. });
  2613. }
  2614.  
  2615. if (e.shiftKey && lastSelectedItem) {
  2616. var lastContainer = $J(lastSelectedItem).parent('.itemHolder');
  2617. var itemsPage = lastContainer.parent('.inventory_page');
  2618. var idx1 = lastContainer.index(), idx2 = $J(this).parent('.itemHolder').index(),
  2619. pidx1 = itemsPage.index(), pidx2 = $J(this).parents('.inventory_page').index();
  2620.  
  2621. if ((pidx1 == pidx2 && idx1 > idx2) || (pidx2 < pidx1)) {
  2622. var tmp = idx1;
  2623. idx1 = idx2; idx2 = tmp;
  2624. }
  2625. //console.log(pidx1 + '-' + idx1 + ' ' + pidx2 + '-' + idx2);
  2626. for (var pi = pidx1; pi <= pidx2; pi++) {
  2627. var filter = '.inventory_ctn:visible .inventory_page:eq(' + pi + ') .itemHolder';
  2628. if (pi == pidx1) {
  2629. filter += ':gt(' + idx1 + ')';
  2630.  
  2631. if (pi == pidx2) {
  2632. filter += ':lt(' + (idx2 - idx1) + ')';
  2633. }
  2634. }
  2635. else if (pi == pidx2) {
  2636. filter += ':lt(' + idx2 + ')';
  2637. }
  2638.  
  2639. $J(filter + '[style!="display: none;"] .item').each(function () {
  2640. if (this.rgItem && (this.rgItem.marketable || this.rgItem.appid == 753)) {
  2641. $J(this).addClass('selectedSell');
  2642. }
  2643. });
  2644.  
  2645. //for (var i = idx1 + 1; i <= idx2; i++) {
  2646. // itemsPage.find('.itemHolder:eq(' + i + ')[style!="display: none;"] .item ').addClass('selectedSell');
  2647. //}
  2648. }
  2649.  
  2650. if (itemsPage.is(':visible')) {
  2651.  
  2652. }
  2653. }
  2654.  
  2655. var itC = $J('.selectedSell').length;
  2656. if (itC > 0) {
  2657. $J('#Lnk_ShowSellMulti .item_market_action_button_contents').html((itC > 1 ? SIHLang.sellnitem.replace('$1', itC) : SIHLang.sell1item));
  2658. $J('#Lnk_ShowSellMulti').show();
  2659. if (g_ActiveInventory.appid == 753) {
  2660. $J('#Lnk_TurnIntoGems').show();
  2661. $J('#Lnk_SendGifts').show();
  2662. }
  2663. }
  2664. else {
  2665. $J('#Lnk_ShowSellMulti').hide();
  2666. $J('#Lnk_TurnIntoGems').hide();
  2667. $J('#Lnk_SendGifts').hide();
  2668. }
  2669.  
  2670. lastSelectedItem = this;
  2671. }
  2672. return false;
  2673. }
  2674. });
  2675.  
  2676. //var btSellSelected = '<a class="item_market_action_button item_market_action_button_green" href="javascript:void();" id="btSellSelected"><span class="item_market_action_button_edge item_market_action_button_left"></span><span class="item_market_action_button_contents">Sell selected items</span><span class="item_market_action_button_edge item_market_action_button_right"></span><span class="item_market_action_button_preload"></span></a>'
  2677. //$J('.item_market_actions').append(btSellSelected);
  2678. if (g_bViewingOwnProfile) {
  2679. ModifySellingFuntions();
  2680. ModifyMarketActions();
  2681. }
  2682.  
  2683. ModifyDescriptionFunction();
  2684. AddDialogHTML();
  2685. ModifyItemDisplay();
  2686. SetupAcceptAllGifts();
  2687.  
  2688.  
  2689. if (window.extprice) {
  2690. var divRight = $J('<div class="sih-functions-panel" />');
  2691.  
  2692. var divExtPrices = $J('<div>External prices: </div>');
  2693. var cb = $J('<select class="side-dropdown" id="cb_ExternalPrices"></select>');
  2694. divExtPrices.append(cb);
  2695. divRight.append(divExtPrices);
  2696.  
  2697. cb.change(function () {
  2698. var _api = ExternalPrices[g_ActiveInventory.appid].apis[parseInt($J(this).val())];
  2699. if (_api && _api.api && _api.api.SetPrice) {
  2700. _api.api.SetPrice(g_ActiveInventory.appid);
  2701. SetCookie('lastext_' + g_ActiveInventory.appid, $J(this).val(), 356);
  2702. }
  2703. });
  2704. $J('#inventory_pagecontrols').before(divRight);
  2705. if (g_ActiveInventory && g_ActiveInventory.appid) {
  2706. SetupExternalDropdown(g_ActiveInventory.appid);
  2707. }
  2708. ModifyShowItemInventory();
  2709. }
  2710.  
  2711.  
  2712. if (window.simplyinvent) {
  2713. ModifyGamesTabs();
  2714. }
  2715. if (window.gpdelayscc) {
  2716. PriceQueue._successDelay = window.gpdelayscc;
  2717. } if (window.gpdelayerr) {
  2718. PriceQueue._failureDelay = window.gpdelayerr;
  2719. }
  2720. ReloadLang();
  2721. }, 10);
  2722.  
  2723. var SetupExternalDropdown = function (appid) {
  2724. $J('#cb_ExternalPrices').empty();
  2725. if (ExternalPrices[appid]) {
  2726. var lastAPI = GetCookie('lastext_' + appid);
  2727. if (lastAPI != null) {
  2728. lastAPI = parseInt(lastAPI);
  2729. } else {
  2730. lastAPI = 0;
  2731. }
  2732. $J.each(ExternalPrices[appid].apis, function (idx, el) {
  2733. if (this.api && this.api.GetPrices) {
  2734. var opt = $J('<option value="' + idx + '"></option>');
  2735. opt.text(this.name);
  2736. if (idx == lastAPI) {
  2737. opt.prop('selected', true);
  2738. }
  2739. if (this.isApproved) {
  2740. opt.prop('selected', true);
  2741. }
  2742. $J('#cb_ExternalPrices').append(opt);
  2743. }
  2744. });
  2745. }
  2746. }
  2747.  
  2748. var econItemExp = /data-economy-item="(\d+)\/(\d+)\/(\d+)\/(\d+)"/gi
  2749. var GetItemsInTrades = function () {
  2750. $J.ajax({
  2751. url: '//steamcommunity.com/my/tradeoffers/sent/',
  2752.  
  2753. success: function (res) {
  2754. var m = null;
  2755. while (m = econItemExp.exec(res)) {
  2756.  
  2757. itemsInTrades.push({
  2758. id: m[3],
  2759. appid: parseInt(m[1]),
  2760. context: parseInt(m[2])
  2761. });
  2762. var elIt = $J('div.item[id=item' + m[1] + '_' + m[2] + '_' + m[3] + ']');
  2763. elIt.addClass('item-in-trade');
  2764. }
  2765. }
  2766. });
  2767. }();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement