-
-
Save ashanbrown/1ad9ab33971b64fe6fef to your computer and use it in GitHub Desktop.
Revisions
-
ashanbrown revised this gist
Jul 21, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -41,7 +41,7 @@ remove = (name, options) -> list = queue(name) for [value, _], i in list.entries when value is options list.entries.splice(i, 1) break $.ajaxTransport '+*', (options) -> -
ashanbrown revised this gist
Jun 9, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ next = (name, done) -> list = queue(name) if done queue(name).running-- unless list.entries.length return @@ -22,7 +22,7 @@ next = (name, done) -> list.entries.shift() queue(name).running++ $.ajax(options) .always(-> next(name, true)) -
ashanbrown revised this gist
Jun 9, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ next = (name, done) -> list = queue(name) if done queues(name).running-- unless list.entries.length return @@ -22,7 +22,7 @@ next = (name, done) -> list.entries.shift() queues(name).running++ $.ajax(options) .always(-> next(name, true)) -
ashanbrown revised this gist
Jun 5, 2014 . 1 changed file with 31 additions and 24 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,39 +1,46 @@ $ = jQuery queues = {} queue = (name) -> name = 'default' if name is true queues[name] or= {entries: [], running: 0} next = (name, done) -> list = queue(name) if done queues[name].running-- unless list.entries.length return [options, deferred] = list.entries[0] if list.running >= (options.queueMaxConcurrency || 1) return list.entries.shift() queues[name].running++ $.ajax(options) .always(-> next(name, true)) .done(-> deferred.resolve(arguments...)) .fail(-> deferred.reject(arguments...)) push = (name, options) -> list = queue(name) deferred = $.Deferred() list.entries.push([options, deferred]) next(name) deferred.promise() remove = (name, options) -> list = queue(name) for [value, _], i in list.entries when value is options list.splice(i, 1) break @@ -45,17 +52,17 @@ $.ajaxTransport '+*', (options) -> send: (headers, complete) -> push(options.queue, queuedOptions) .done (data, textStatus, jqXHR) -> complete(jqXHR.status, jqXHR.statusText, text: jqXHR.responseText, jqXHR.getAllResponseHeaders()) .fail (jqXHR, textStatus, errorThrown) -> complete(jqXHR.status, jqXHR.statusText, text: jqXHR.responseText, jqXHR.getAllResponseHeaders()) abort: -> remove(options.queue, queuedOptions) -
maccman revised this gist
Jul 12, 2013 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ next = (name) -> $.ajax(options) .always(-> next(name)) .done(-> deferred.resolve(arguments...)) .fail(-> deferred.reject(arguments...)) push = (name, options) -> list = queue(name) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,7 +29,7 @@ }).done(function() { return deferred.resolve.apply(deferred, arguments); }).fail(function() { return deferred.reject.apply(deferred, arguments); }); }; -
maccman revised this gist
Jun 16, 2013 . 1 changed file with 81 additions and 73 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,83 +1,91 @@ // Generated by CoffeeScript 1.6.2 (function() { var $, next, push, queue, queues, remove, running; $ = jQuery; queues = {}; running = false; queue = function(name) { if (name === true) { name = 'default'; } return queues[name] || (queues[name] = []); }; next = function(name) { var deferred, list, options, _ref; list = queue(name); if (!list.length) { running = false; return; } _ref = list.shift(), options = _ref[0], deferred = _ref[1]; return $.ajax(options).always(function() { return next(name); }).done(function() { return deferred.resolve.apply(deferred, arguments); }).fail(function() { return deferred.error.apply(deferred, arguments); }); }; push = function(name, options) { var deferred, list; list = queue(name); deferred = $.Deferred(); list.push([options, deferred]); if (!running) { next(name); } running = true; return deferred.promise(); }; remove = function(name, options) { var i, list, value, _, _i, _len, _ref, _results; list = queue(name); _results = []; for (i = _i = 0, _len = list.length; _i < _len; i = ++_i) { _ref = list[i], value = _ref[0], _ = _ref[1]; if (!(value === options)) { continue; } list.splice(i, 1); break; } return _results; }; $.ajaxTransport('+*', function(options) { var queuedOptions; if (options.queue) { queuedOptions = $.extend({}, options); queuedOptions.queue = false; queuedOptions.processData = false; return { send: function(headers, complete) { return push(options.queue, queuedOptions).done(function(data, textStatus, jqXHR) { return complete(jqXHR.status, jqXHR.statusText, { text: jqXHR.responseText }, jqXHR.getAllResponseHeaders()); }).fail(function(jqXHR, textStatus, errorThrown) { return complete(jqXHR.status, jqXHR.statusText, { text: jqXHR.responseText }, jqXHR.getAllResponseHeaders()); }); }, abort: function() { return remove(options.queue, queuedOptions); } }; } }); }).call(this); -
maccman created this gist
Jun 16, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,61 @@ $ = jQuery queues = {} running = false queue = (name) -> name = 'default' if name is true queues[name] or= [] next = (name) -> list = queue(name) unless list.length running = false return [options, deferred] = list.shift() $.ajax(options) .always(-> next(name)) .done(-> deferred.resolve(arguments...)) .fail(-> deferred.error(arguments...)) push = (name, options) -> list = queue(name) deferred = $.Deferred() list.push([options, deferred]) next(name) unless running running = true deferred.promise() remove = (name, options) -> list = queue(name) for [value, _], i in list when value is options list.splice(i, 1) break $.ajaxTransport '+*', (options) -> if options.queue queuedOptions = $.extend({}, options) queuedOptions.queue = false queuedOptions.processData = false send: (headers, complete) -> push(options.queue, queuedOptions) .done (data, textStatus, jqXHR) -> complete(jqXHR.status, jqXHR.statusText, text: jqXHR.responseText, jqXHR.getAllResponseHeaders()) .fail (jqXHR, textStatus, errorThrown) -> complete(jqXHR.status, jqXHR.statusText, text: jqXHR.responseText, jqXHR.getAllResponseHeaders()) abort: -> remove(options.queue, queuedOptions) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,83 @@ var $, next, push, queue, queues, remove, running; $ = jQuery; queues = {}; running = false; queue = function(name) { if (name === true) { name = 'default'; } return queues[name] || (queues[name] = []); }; next = function(name) { var deferred, list, options, _ref; list = queue(name); if (!list.length) { running = false; return; } _ref = list.shift(), options = _ref[0], deferred = _ref[1]; return $.ajax(options).always(function() { return next(name); }).done(function() { return deferred.resolve.apply(deferred, arguments); }).fail(function() { return deferred.error.apply(deferred, arguments); }); }; push = function(name, options) { var deferred, list; list = queue(name); deferred = $.Deferred(); list.push([options, deferred]); if (!running) { next(name); } running = true; return deferred.promise(); }; remove = function(name, options) { var i, list, value, _, _i, _len, _ref, _results; list = queue(name); _results = []; for (i = _i = 0, _len = list.length; _i < _len; i = ++_i) { _ref = list[i], value = _ref[0], _ = _ref[1]; if (!(value === options)) { continue; } list.splice(i, 1); break; } return _results; }; $.ajaxTransport('+*', function(options) { var queuedOptions; if (options.queue) { queuedOptions = $.extend({}, options); queuedOptions.queue = false; queuedOptions.processData = false; return { send: function(headers, complete) { return push(options.queue, queuedOptions).done(function(data, textStatus, jqXHR) { return complete(jqXHR.status, jqXHR.statusText, { text: jqXHR.responseText }, jqXHR.getAllResponseHeaders()); }).fail(function(jqXHR, textStatus, errorThrown) { return complete(jqXHR.status, jqXHR.statusText, { text: jqXHR.responseText }, jqXHR.getAllResponseHeaders()); }); }, abort: function() { return remove(options.queue, queuedOptions); } }; } });