Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function loadPrices(priceIDs,systemID){
- if (typeof regionID == 'undefined'){
- regionID=10000002;
- }
- if (typeof priceIDs == 'undefined'){
- // throw 'need typeids';
- }
- var prices = new Array();
- var dirtyTypeIds = new Array();
- var cleanTypeIds = new Array();
- var url="http://api.eve-central.com/api/marketstat?usesystem="+systemID+"&typeid=";
- priceIDs.forEach (function (row) {
- row.forEach ( function (cell) {
- if (typeof(cell) === 'number' ) {
- dirtyTypeIds.push(cell);
- }
- });
- });
- cleanTypeIds = dirtyTypeIds.filter(function(v,i,a) {
- return a.indexOf(v)===i;
- });
- var parameters = {method : "get", payload : ""};
- var xmlFeed = UrlFetchApp.fetch(url+cleanTypeIds.join("&typeid="), parameters).getContentText();
- var xml = XmlService.parse(xmlFeed);
- if(xml) {
- var rows=xml.getRootElement().getChild("marketstat").getChildren("type");
- for(var i = 0; i < rows.length; i++) {
- var price=[
- //rows[i].getAttribute("id").getValue(),
- rows[i].getChild("buy").getChild("percentile").getValue(),
- rows[i].getChild("sell").getChild("percentile").getValue()];
- prices.push(price);
- }
- }
- return prices;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement