Stormieh

Armory Ilvl

Nov 4th, 2015
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. function wowi(toonName,realmName)
  2. {
  3. if (toonName.length == 0)
  4. return null;
  5.  
  6. var toonName = toonName.split(" ")[0];
  7. var publicCache = CacheService.getPublicCache();
  8. var toonUrl = "eu.battle.net/api/wow/character/"+realmName+"/"+toonName+"?fields=items";
  9.  
  10. try {
  11. var toonJSON = UrlFetchApp.fetch(toonUrl);
  12.  
  13. if (toonJSON.getResponseCode() == 200)
  14. publicCache.put(toonUrl, toonJSON.getContentText());
  15. } catch (e) {
  16. Logger.log(e);
  17. }
  18.  
  19. var toonText = publicCache.get(toonUrl);
  20.  
  21. if (toonText == null)
  22. return null;
  23. else
  24. return Utilities.jsonParse(toonText).items.averageItemLevelEquipped;
  25. }
  26.  
  27. function wowiBatch(toonNames, realmName)
  28. {
  29. var arr = []
  30.  
  31. for (var i = 0; i < toonNames.length; i++)
  32. arr.push(wowi(toonNames[i].toString(), realmName));
  33. return arr;
  34. }
  35.  
  36. function idxc(c, v)
  37. {
  38. if (v.length == 0)
  39. return null;
  40.  
  41. for (var i = 0; i < c.length; i++) {
  42. var cc = c[i][0];
  43.  
  44. for (var j = 0; j < cc.length; j++) {
  45. var t_ij = ("" + cc[j]).split(" ");
  46.  
  47. for (var k = 0; k < t_ij.length; k++) {
  48. if (t_ij[k] == v)
  49. return (i + 1);
  50. }
  51. }
  52. }
  53. }
  54.  
  55. function idxcBatch(c, v)
  56. {
  57. var arr = [];
  58.  
  59. for (var i = 0; i < v.length; i++)
  60. arr.push(idxc(c, v[i]));
  61. return arr;
  62. }
Add Comment
Please, Sign In to add comment