SHARE
TWEET

Untitled

a guest May 21st, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var arryOfURLs = ['T6_ARMOR_LEATHER_SET1%402',
  2.                   'T5_SHOES_LEATHER_SET1',
  3.                   'T6_HEAD_LEATHER_SET2%402',
  4.                   'T5_ARMOR_LEATHER_SET2%402'
  5.                  ];
  6.  
  7. $.each(arryOfURLs, function(index, itemURL) {
  8.   $.getJSON('https://www.albion-online-data.com/api/v2/stats/Prices/' + itemURL + '?locations=Caerleon%2CBlack%20Market', function(data) {
  9.     console.log(data);
  10.    
  11.     var name;
  12.     var quality1BM = 0;
  13.     var quality1C = 0;
  14.     var quality2BM = 0;
  15.     var quality2C = 0;
  16.     var quality3BM = 0;
  17.     var quality3C = 0;
  18.     var quality4BM = 0;
  19.     var quality4C = 0;
  20.     var quality5BM = 0;
  21.     var quality5C = 0;
  22.    
  23.     name = data[0].item_id;
  24.     quality1BM = searchQualityAndMarket(1, "Black Market", data);
  25.     quality1C = searchQualityAndMarket(1, "Caerleon", data);
  26.     quality2BM = searchQualityAndMarket(2, "Black Market", data);
  27.     quality2C = searchQualityAndMarket(2, "Caerleon", data);
  28.     quality3BM = searchQualityAndMarket(3, "Black Market", data);
  29.     quality3C = searchQualityAndMarket(3, "Caerleon", data);
  30.     quality4BM = searchQualityAndMarket(4, "Black Market", data);
  31.     quality4C = searchQualityAndMarket(4, "Caerleon", data);
  32.     quality5BM = searchQualityAndMarket(5, "Black Market", data);
  33.     quality5C = searchQualityAndMarket(5, "Caerleon", data);
  34.    
  35.     console.log("Name: " + name);
  36.     console.log("quality1BM: " + quality1BM);
  37.     console.log("quality1C: " + quality1C);
  38.     console.log("quality2BM: " + quality2BM);
  39.     console.log("quality2C: " + quality2C);
  40.     console.log("quality3BM: " + quality3BM);
  41.     console.log("quality3C: " + quality3C);
  42.     console.log("quality4BM: " + quality4BM);
  43.     console.log("quality4C: " + quality4C);
  44.     console.log("quality5BM: " + quality5BM);
  45.     console.log("quality5C: " + quality5C);
  46.    
  47.     var calcBuyPrice;
  48.     var calcSellPrice;
  49.     var difference;
  50.    
  51.     for(i=0;i<5;i++){
  52.      
  53.       try {
  54.         calcBuyPrice = data[i].buy_price_max;
  55.         calcSellPrice = data[i+5].sell_price_min;
  56.         difference = calcBuyPrice - calcSellPrice;
  57.       }
  58.       catch(TypeError) {
  59.         difference = 0;
  60.       }
  61.       //console.log(difference);
  62.      
  63.     }
  64.    
  65.     //$('.output').append(<h1 class="City">' + city + '</h1><h2 class="Name">' + name + '</h2><h3 class="Quality">' + quality + '</h3><h4 class="Price">' + maxprice + '</h4>);
  66.   });
  67. });
  68.  
  69. function searchQualityAndMarket(quality, market, data){
  70.     for (var i=0; i < data.length; i++) {
  71.         if (data[i].quality === quality && data[i].city === market) {
  72.           if(market == "Black Market"){
  73.             return data[i].buy_price_max;
  74.           }
  75.           else{
  76.             return data[i].sell_price_min;
  77.           }
  78.         }
  79.         else{
  80.           return 0;
  81.         }
  82.     }
  83. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top