Advertisement
nzisaacnz

Guild wars 2 spidey

May 11th, 2013
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html><head></head>
  3. <body>
  4. <a href="http://www.gw2spidy.com/">Search this for items, item ID will be http://www.gw2spidy.com/item/{item ID}</a>
  5. <script>
  6. var item = null;
  7. var m = null;
  8. var moneyToSpend= 0;
  9. var moneyYoullGet= 0;
  10. var itemsGetting = "";
  11. var itemsSelling= "";
  12.  
  13. function Item(I)
  14. {
  15.     if(I.result)
  16.     {
  17.         item=I.result;
  18.         if(m>0)
  19.         {
  20.             moneyToSpend+=m*item["max_offer_unit_price"];
  21.             itemsGetting+=m+" "+item['name']+", ";
  22.         }
  23.         if(m<0)
  24.         {
  25.             moneyYoullGet+= -m*item["min_sale_unit_price"];
  26.             itemsSelling+= -m+" "+item['name']+", ";
  27.         }
  28.         var npc = +document.getElementById('npc').value;
  29.         var multi = +document.getElementById('multiplier').value;
  30.         var span = document.getElementById("output");
  31.         span.innerText = "To Buy: "+itemsGetting+"\n";
  32.         span.innerText+= "To Sell: "+itemsSelling+"\n";
  33.         span.innerText+="Minimum purchase price:"+numberToGSC((moneyToSpend+npc)*multi)+"\n";
  34.         span.innerText+="Maximum Sale Price with after market fee:"+numberToGSC(parseInt(moneyYoullGet*0.85*multi))+"\n";
  35.         span.innerText+="Profit:"+numberToGSC(parseInt((moneyYoullGet*0.85-moneyToSpend-npc)*multi))+"\n";
  36.     }
  37.     else m = I;
  38. }
  39. function refreshClicked()
  40. {
  41.     var scripts = document.getElementById("loadScript");
  42.     while(scripts.childNodes.length>0)
  43.     {
  44.         scripts.removeChild(scripts.childNodes[0]);
  45.     }
  46.     moneyToSpend= 0;
  47.     moneyYoullGet= 0;
  48.     itemsGetting = "";
  49.     itemsSelling="";
  50.     var area = document.getElementById("items");
  51.     var txt = area.value;
  52.     var items = txt.split(";");
  53.     for(var i=0; i<items.length; i++)
  54.     {
  55.         if(items[i].length>0)
  56.         {
  57.             var csv = items[i].split(' ');
  58.             var multiplier = parseInt(csv[0]);
  59.             var src= parseInt(csv[1]);
  60.             if(multiplier&&src)
  61.             {
  62.                
  63.                 var script = document.createElement("script");
  64.                 script.src = 'http://www.gw2spidy.com/api/v0.9/json/item/'+src+'?callback=Item%28'+multiplier+'%29%3BItem';
  65.                 scripts.appendChild(script);
  66.             }
  67.         }
  68.     }
  69. }
  70. function numberToGSC(num)
  71. {
  72.     var txt = num.toString();
  73.     var response = "";
  74.     for(var i=1; i<=txt.length; i++)
  75.     {
  76.         var nxt =txt.charAt(txt.length-i);
  77.         if(i==1&&txt.length!=i-1)nxt+="(c)";
  78.         if(i==3&&txt.length!=i-1)nxt+="(s) ";
  79.         if(i==5&&txt.length!=i-1)nxt+="(g) ";
  80.         response = nxt+response;
  81.     }
  82.     return response;
  83. }
  84. function saveLastResult()
  85. {
  86.     document.getElementById("saved").innerHTML+=document.getElementById("output").innerHTML+"<br>";
  87.    
  88. }
  89. function updateNPCOut(npc)
  90. {
  91.     var npcOut = document.getElementById("npcOut");
  92.     npcOut.innerText = numberToGSC(npc.value);
  93. }
  94. </script>
  95. <div style="display:hidden" id="loadScript"></div>
  96. <textarea id="items">
  97. 5 19721;
  98. 28 19701;
  99. -1 13459;
  100. 25 24276;
  101. 10 24474;
  102. </textarea><br>
  103. Multiplier<input id="multiplier" value="1" type="number"/><br>
  104. NPC Purchaces(<span id="npcOut">0</span>)<input id="npc" value="0" type="number" oninput="updateNPCOut(this)"/><br>
  105. <button onclick="refreshClicked()">Load Items</button><br><br>
  106. <span id="output"></span><br>
  107. <button onclick="saveLastResult()">Keep Result</button><br>
  108. <span id="saved" style="background-color:#AAF"></span>
  109. <textarea>
  110. --Notes
  111. </textarea>
  112. </body>
  113. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement