1var countTo = angular.module('countTo', []) 2 .directive('countTo', ['$timeout', function ($timeout) { 3 return { 4 replace: false, 5 scope: true, 6 link: function (scope, element, attrs) { 7 8 var e = element[0]; 9 var num, refreshInterval, duration, steps, step, countTo, value, increment; 10 var delay= attrs.delay; 11 var calculate = function () { 12 refreshInterval = 30; 13 step = 0; 14 scope.timoutId = null; 15 countTo = parseInt(attrs.countTo) || 0; 16 scope.value = parseInt(attrs.value, 10) || 0; 17 duration = (parseFloat(attrs.duration) * 1000) || 0; 18 19 steps = Math.ceil(duration / refreshInterval); 20 increment = ((countTo - scope.value) / steps); 21 num = scope.value; 22 } 23 24 var tick = function () { 25 scope.timoutId = $timeout(function () { 26 num += increment; 27 step++; 28 if (step >= steps) { 29 $timeout.cancel(scope.timoutId); 30 num = countTo; 31 e.textContent = countTo; 32 } else { 33 e.textContent = Math.round(num); 34 tick(); 35 } 36 }, refreshInterval); 37 38 } 39 40 var start = function () { 41 if (scope.timoutId) { 42 $timeout.cancel(scope.timoutId); 43 } 44 if(!delay){ 45 delay = 10; 46 } 47 48 $timeout(function(){ 49 calculate(); 50 tick(); 51 },delay); 52 53 54 } 55 56 attrs.$observe('countTo', function (val) { 57 if (val) { 58 start(); 59 } 60 }); 61 62 attrs.$observe('value', function (val) { 63 start(); 64 }); 65 66 return true; 67 } 68 } 69 70 }]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.