Task_Array_Util

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

Verze ze dne 01. 06. 2020. Zobrazit nejnovější verzi.

Tento skript by neměl být instalován přímo. Jedná se o knihovnu, kterou by měly jiné skripty využívat pomocí meta příkazu // @require https://update.greasyfork.org/scripts/404464/811187/Task_Array_Util.js

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

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

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

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

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

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

//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) {
    log("doTask Enter");
    setTimeout(function () {
        log(taskNum);
        next();
    }, time)
}

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

function queueTask(tasks) {
    log("queueTask Enter");
    //tasks is an array of functions
    for (var i in tasks) {
        $(document).queue('tasks', createTask(tasks[i]));
		log("queued task " + i);
    }

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

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