Task_Array_Util

//https://stackoverflow.com/questions/15504921/asynchronous-loop-of-jquery-deferreds-promises?answertab=votes#tab-top

اعتبارا من 01-06-2020. شاهد أحدث إصدار.

لا ينبغي أن لا يتم تثبيت هذا السكريت مباشرة. هو مكتبة لسكبتات لتشمل مع التوجيه الفوقية // @require https://update.greasyfork.org/scripts/404464/811281/Task_Array_Util.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

//slightly modified from
//https://stackoverflow.com/questions/15504921/asynchronous-loop-of-jquery-deferreds-promises?answertab=votes#tab-top

/*
TODO Description
 */

var time = Math.floor(Math.random() * 3000);

function doTask(taskNum, next, args) {
    log("doTask Enter");
    setTimeout(function () {
		log("TEST");
		taskNum(args);
        next();
    }, time)
}

function createTask(taskNum, args){
	log("createTask Enter");
    return function(next){
        doTask(taskNum, next, args);
    }
}

function queueTask(tasks, args) {
    log("queueTask Enter!");
	log("tasks | " + tasks);
	log("args | " + args);
    //tasks is an array of functions
    for (var i = 0; i < tasks.length; i++) {
		log("queueTask i " + i);
        $(document).queue('tasks', createTask(tasks[i], args[i]));
    }

    $(document).queue('tasks', function () {
        log("All tasks dequeued");
    });
	
	dequeueTask();
}

function dequeueTask() {
    log("dequeueTask Enter");
    $(document).dequeue('tasks');
}