Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function SyncGetPurchasedData(){
  2.         var intervalID2 = setInterval(function(){
  3.         if(isPayedRequest){
  4.             clearInterval(intervalID2);
  5.             GetPurchasedData();
  6.         }
  7.     }, 200);
  8. }
  9.  
  10.  
  11. // getting items name for analystic
  12.  
  13. var itemsCount = 0;
  14. var currentTick = 0;
  15. var itemDiv = null;
  16. var lastItemName = "";
  17. var isEndGrabbing = false;
  18. var itemsForGrab = [];
  19. var itemsForGrabImg = [];
  20. var itemsForGrabSumm = [];
  21.  
  22. var itemsInOutRange = [];
  23.  
  24.  
  25. function startGrabber()
  26. {
  27.     itemsCount = $("#left .reals .placeholder").length;
  28.     itemsForGrab = [];
  29.     itemsForGrabImg = [];
  30.     itemsForGrabSumm = [];
  31.     for(var i=0;i<itemsCount;i++)
  32.     {
  33.  
  34.         itemDiv = $("#left .reals .placeholder").eq(currentTick);
  35.  
  36.         if(lastItemName==itemDiv.attr("data-name"))
  37.         {
  38.            
  39.             currentTick++;
  40.             continue;
  41.         }
  42.  
  43.         itemsForGrab.push(itemDiv.attr("data-name"));
  44.         itemsForGrabSumm.push(itemDiv.attr("data-price"));
  45.  
  46.  
  47.         var imgUrl = itemDiv.children(".slot").css('background-image').substr(5);
  48.         imgUrl = imgUrl.substr(0,imgUrl.length-2);
  49.  
  50.         itemsForGrabImg.push(imgUrl);
  51.  
  52.         lastItemName = itemDiv.attr("data-name");
  53.         currentTick++;
  54.  
  55.  
  56.  
  57.     }
  58.  
  59.     var jsonObj = {
  60.         itemsNames: itemsForGrab,
  61.         itemsImg: itemsForGrabImg,
  62.         itemsSumm: itemsForGrabSumm
  63.     };
  64.     currentTick = 0;
  65.     isEndGrabbing = true;
  66.     async_worker_grab(function(){
  67.         var jsonForSend = JSON.stringify(jsonObj);
  68.         $.ajax({
  69.             url: 'http://analystic.ru/api/parseDoubleItems',
  70.             type: 'POST',
  71.             data: {itemsForGrab: jsonForSend},
  72.             success: function(data){
  73.  
  74.             }
  75.         })
  76.         .fail(function() {
  77.         });
  78.     });
  79.  
  80. }
  81.  
  82. function async_worker_grab(callback){
  83.     var intervalID = setInterval(function(){
  84.     if(isEndGrabbing){
  85.         clearInterval(intervalID);
  86.         callback();
  87.     }
  88. }, 1000);
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement