Make asyncForEach available globally to reduce code duplication
This commit is contained in:
@@ -1,23 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
/* global Clipboard */
|
||||
|
||||
// poor man's async
|
||||
function asyncForEach(items, handler, callback) {
|
||||
var cur = 0;
|
||||
|
||||
if (items.length === 0) return callback();
|
||||
|
||||
(function iterator() {
|
||||
handler(items[cur], function (error) {
|
||||
if (error) return callback(error);
|
||||
if (cur >= items.length-1) return callback();
|
||||
++cur;
|
||||
|
||||
iterator();
|
||||
});
|
||||
})();
|
||||
}
|
||||
/* global Clipboard:false */
|
||||
/* global asyncForEach:false */
|
||||
|
||||
angular.module('Application').controller('UsersController', ['$scope', '$location', '$timeout', 'Client', function ($scope, $location, $timeout, Client) {
|
||||
Client.onReady(function () { if (!Client.getUserInfo().admin) $location.path('/'); });
|
||||
|
||||
Reference in New Issue
Block a user