This works as well:
Code:
setTimeout(function() {
if (_private.use_optional_assets)
_private.jobs.assign_optional_assets();
else
_private.jobs.start();
}, (2000 + (Math.random() * 1000)));
},
// merged assign_person and assign_asset, assign_asset was only ever called from assign_person anyway
assign_optional_assets: function() {
// see if we have any empty slots - if we don't, just start the job
var empty_slots = $('.taskdetails-assets .icon-block.large.any-crafting.Junk.empty .input-field button');
if(empty_slots.length > 0) {
// we have empty slots, click the first
empty_slots.eq(0).trigger('click');
setTimeout(function(){
// get available assets
var assets = $('.modal-item-list .icon-block');
if(assets.length > 0) {
// if we have a suitable asset, assign it
assets.eq(0).trigger('click');
// and recurse
setTimeout(function() {
_private.jobs.assign_optional_assets();
}, (1000 + (Math.random() * 1000)));
}
else {
// otherwise, close the modal window and get ready to start job
$('.modal-window .close-button').eq(0).trigger('click');
setTimeout(function() {
_private.jobs.start();
}, (1000 + (Math.random() * 1000)));
}
}, (1500 + (Math.random() * 1000)));
}
else
_private.jobs.start();
},