mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-19 16:43:26 +02:00
Added sprintf.
Rotation tooltips updated in realtime with current rotation degree.
This commit is contained in:
2
res/app/components/stf/sprintf/index.js
Normal file
2
res/app/components/stf/sprintf/index.js
Normal file
@@ -0,0 +1,2 @@
|
||||
module.exports = angular.module('stf.sprintf', [])
|
||||
.filter('sprintf', require('./sprintf-filter'))
|
||||
14
res/app/components/stf/sprintf/sprintf-filter.js
Normal file
14
res/app/components/stf/sprintf/sprintf-filter.js
Normal file
@@ -0,0 +1,14 @@
|
||||
module.exports = function sprintfFilter() {
|
||||
function parse(str) {
|
||||
var args = [].slice.call(arguments, 1)
|
||||
var i = 0
|
||||
|
||||
return str.replace(/%s/g, function () {
|
||||
return args[i++]
|
||||
})
|
||||
}
|
||||
|
||||
return function (input) {
|
||||
return parse(input, arguments[1], arguments[2], arguments[3], arguments[4], arguments[5])
|
||||
}
|
||||
}
|
||||
13
res/app/components/stf/sprintf/sprintf-spec.js
Normal file
13
res/app/components/stf/sprintf/sprintf-spec.js
Normal file
@@ -0,0 +1,13 @@
|
||||
describe('sprintf', function() {
|
||||
|
||||
beforeEach(module('stf.sprintf'));
|
||||
|
||||
it('should ...', inject(function($filter) {
|
||||
|
||||
var filter = $filter('sprintf');
|
||||
|
||||
expect(filter('input')).toEqual('output');
|
||||
|
||||
}));
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user