Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. //Researsh
  2. //getWindow('WndScience').reseach(116,$('#WndScience_scl_116').val());
  3.  
  4. window.helper = {
  5. maxTime: '0300',
  6. runOnce:function()
  7. {
  8. var self = this;
  9. //If has empy research slot
  10. if($('#WndScience_container span:contains(свободно)').length > 0){
  11. var tech = [];
  12. $('tr:has(>td>input[id^=WndScience_scl_])')
  13. .each(function(index){
  14. var $tr = $(this);
  15. var btn = $tr.find('td:eq(1)>button[onclick]');
  16. if(btn.length == 1){
  17. var $input = $tr.find('input[id^=WndScience_scl_]');
  18. var val = $input.val();
  19. var id = $input.attr('id').substring(15);
  20. //
  21. var time = $('#WndScience_sh_'+id+'>table:eq(1)>tbody>tr>td:eq(2)').text().replace(/:/g, '');
  22. // Only fast tech
  23. if(time < self.maxTime)
  24. tech.push({id:id, val:val, time:time});
  25. else
  26. console.log('Too long ' + time +' -- ' + self.maxTime);
  27. }
  28. });
  29. //Run most fast tech
  30. tech = tech.sort(function(a, b){return a.time - b.time;});
  31. var t=tech[0];
  32. if(t){
  33. setTimeout(function(){
  34. console.log(t);
  35. getWindow('WndScience').reseach(t.id, t.val);
  36. }, Math.random()*2*1000);
  37. }
  38. //Bind to next call if isRun = true
  39. }},
  40.  
  41. interval:0,
  42. isRun:false,
  43. //Start
  44. start:function(){
  45. var self = this;
  46. this.isRun = true;
  47. $('body').on('Wnd_AfterLoad_WndScience', function(){ if(self.isRun) self.runOnce(); })
  48. this.runOnce();
  49. },
  50. //Stop
  51. stop:function(){
  52. this.isRun = false;
  53. }
  54.  
  55. }
  56.  
  57. //window.helper.start();
  58. //window.helper.stop();
  59.  
  60.  
  61.  
  62.  
  63. //setInterval(function(){ getWindow('WndScience').reseach(id, val);}, 1000*(index+1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement