gui: Add uncamel filter

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4428
LGTM: imsodin, calmh
This commit is contained in:
Audrius Butkevicius
2017-10-17 07:56:36 +00:00
committed by Jakob Borg
parent 694a7de59d
commit 889814a1af
3 changed files with 32 additions and 4 deletions

View 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);
};
});