'use strict';

angular.module('app')
    .filter('range', function() {
        return function(input, total) {
            total = Math.round(total);
            // total = parseInt(total);
            for (var i = 0; i < total; i++) {
                input.push(i);
            }
            return input;
        };
    })
    .directive('ratingStars', function() {
        return {
            template: '<span class="active glyphicon glyphicon-star star" style="color:#F98C00;" ng-repeat="value in []|range:(value) track by $index"></span>' +
                '<span ng-if="value<5" class="glyphicon glyphicon-star no-active star" style="color:#C1C1C1;" ng-repeat="value in []|range:(5-value) track by $index"></span>',
            restrict: 'E',
            scope: {
                value: '='
            }
        };
    });