Add Angular filter for padding a number

This is needed because of the way Frames are stored on the
filesystem, such as 00051-capture.jpg, vs. how they're stored
in the database, such as 51
This commit is contained in:
Kyle Johnson 2015-01-27 11:15:10 -05:00
parent 8311951c86
commit 786009407c
1 changed files with 11 additions and 0 deletions

View File

@ -187,3 +187,14 @@ ZoneMinder.filter('DateDiff', function() {
} }
}; };
}); });
ZoneMinder.filter('zpad', function() {
return function(input, n) {
if(input === undefined)
input = ""
if(input.length >= n)
return input
var zeros = "0".repeat(n);
return (zeros + input).slice(-1 * n)
};
});