Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Researsh
- //getWindow('WndScience').reseach(116,$('#WndScience_scl_116').val());
- window.helper = {
- maxTime: '0300',
- runOnce:function()
- {
- var self = this;
- //If has empy research slot
- if($('#WndScience_container span:contains(свободно)').length > 0){
- var tech = [];
- $('tr:has(>td>input[id^=WndScience_scl_])')
- .each(function(index){
- var $tr = $(this);
- var btn = $tr.find('td:eq(1)>button[onclick]');
- if(btn.length == 1){
- var $input = $tr.find('input[id^=WndScience_scl_]');
- var val = $input.val();
- var id = $input.attr('id').substring(15);
- //
- var time = $('#WndScience_sh_'+id+'>table:eq(1)>tbody>tr>td:eq(2)').text().replace(/:/g, '');
- // Only fast tech
- if(time < self.maxTime)
- tech.push({id:id, val:val, time:time});
- else
- console.log('Too long ' + time +' -- ' + self.maxTime);
- }
- });
- //Run most fast tech
- tech = tech.sort(function(a, b){return a.time - b.time;});
- var t=tech[0];
- if(t){
- setTimeout(function(){
- console.log(t);
- getWindow('WndScience').reseach(t.id, t.val);
- }, Math.random()*2*1000);
- }
- //Bind to next call if isRun = true
- }},
- interval:0,
- isRun:false,
- //Start
- start:function(){
- var self = this;
- this.isRun = true;
- $('body').on('Wnd_AfterLoad_WndScience', function(){ if(self.isRun) self.runOnce(); })
- this.runOnce();
- },
- //Stop
- stop:function(){
- this.isRun = false;
- }
- }
- //window.helper.start();
- //window.helper.stop();
- //setInterval(function(){ getWindow('WndScience').reseach(id, val);}, 1000*(index+1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement