angular.module('SolvIn') .controller('WizardController', function ($scope, $state, $stateParams, $mdToast, PureBeing, PureNothing, Becoming, Passing, Uprising, ExtantBeing, Nihility, Quality, Something, FluentSomething, Definition, Limit, Quantity, Progress) { $scope.steps = []; $scope.stepsMap = {}; var injected = arguments; function pushSteps(...ids) { Array.from(ids).forEach(function (id) { var step = Array.from(injected).find(s => _.isEqual(s.id, id) && _.isArray(s.words)); if (_.isObject(step)) { $scope.steps.push(step); $scope.stepsMap[id] = $scope.steps.length - 1; } else { console.log(`no step for ${id}`); } }); } pushSteps('PureBeing', 'PureNothing', 'Becoming', 'Passing', 'Uprising', 'ExtantBeing', 'Nihility', 'Quality', 'Something', 'FluentSomething', 'Definition', 'Limit', 'Quantity', 'Progress'); $scope.rotate = function (w) { return [0, 0, 0, 90, -90][Math.round(4 * Math.random())]; }; let update = $scope.update = function () { $scope.words = []; const maxWords = 200; let step = $scope.step = $scope.steps[$scope.stepIdx]; for(var i = 0; i= 0; }; if (_.isUndefined($stateParams.id)) { $scope.showStep('PureBeing'); } else { $scope.stepIdx = $scope.stepsMap[$stateParams.id]; update(); } });