Task_Array_Util

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

Stan na 01-06-2020. Zobacz najnowsza wersja.

Ten skrypt nie powinien być instalowany bezpośrednio. Jest to biblioteka dla innych skyptów do włączenia dyrektywą meta // @require https://update.greasyfork.org/scripts/404464/811172/Task_Array_Util.js

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Task_Array_Util
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  //https://stackoverflow.com/questions/15504921/asynchronous-loop-of-jquery-deferreds-promises?answertab=votes#tab-top
// @author       Dylan Banta
// @grant        none
// ==/UserScript==

/*
	TODO Description
*/

function doTask(taskNum) {
	log("doTask Enter");
    var time = Math.floor(Math.random() * 3000);

    setTimeout(function () {
        console.log(taskNum);
        dequeTask();
    }, time)
}

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

function queueTask(tasks) {
	log("queTask Enter");
    //Loops through task array
    for (var i in tasks) {
        $(document).queue('tasks', function(){
			createTask(tasks[i]);
		});
    }

    //Add a logger to the end of the task stating that all tasks have been completed
    $(document).queue('tasks', function () {
        log("All tasks completed");
    });
}

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