gui: Add uncamel filter
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4428 LGTM: imsodin, calmh
This commit is contained in:
committed by
Jakob Borg
parent
694a7de59d
commit
889814a1af
27
gui/default/syncthing/core/uncamelFilter.js
Normal file
27
gui/default/syncthing/core/uncamelFilter.js
Normal file
@@ -0,0 +1,27 @@
|
||||
angular.module('syncthing.core')
|
||||
.filter('uncamel', function () {
|
||||
return function (input) {
|
||||
input = input.replace(/(.)([A-Z][a-z]+)/g, '$1 $2').replace(/([a-z0-9])([A-Z])/g, '$1 $2');
|
||||
var parts = input.split(' ');
|
||||
var lastPart = parts.splice(-1)[0];
|
||||
switch (lastPart) {
|
||||
case "S":
|
||||
parts.push('(seconds)');
|
||||
break;
|
||||
case "M":
|
||||
parts.push('(minutes)');
|
||||
break;
|
||||
case "H":
|
||||
parts.push('(hours)');
|
||||
break;
|
||||
case "Ms":
|
||||
parts.push('(milliseconds)');
|
||||
break;
|
||||
default:
|
||||
parts.push(lastPart);
|
||||
break;
|
||||
}
|
||||
input = parts.join(' ');
|
||||
return input.charAt(0).toUpperCase() + input.slice(1);
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user