From 889814a1af3eb69fe2f1f254365185890c3e0c2a Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Tue, 17 Oct 2017 07:56:36 +0000 Subject: [PATCH] gui: Add uncamel filter GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4428 LGTM: imsodin, calmh --- gui/default/index.html | 1 + gui/default/syncthing/core/uncamelFilter.js | 27 +++++++++++++++++++ .../settings/advancedSettingsModalView.html | 8 +++--- 3 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 gui/default/syncthing/core/uncamelFilter.js diff --git a/gui/default/index.html b/gui/default/index.html index 5de3f9c0c..c1f4d7116 100644 --- a/gui/default/index.html +++ b/gui/default/index.html @@ -750,6 +750,7 @@ + diff --git a/gui/default/syncthing/core/uncamelFilter.js b/gui/default/syncthing/core/uncamelFilter.js new file mode 100644 index 000000000..269a42e90 --- /dev/null +++ b/gui/default/syncthing/core/uncamelFilter.js @@ -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); + }; + }); diff --git a/gui/default/syncthing/settings/advancedSettingsModalView.html b/gui/default/syncthing/settings/advancedSettingsModalView.html index 58f689173..37d048489 100644 --- a/gui/default/syncthing/settings/advancedSettingsModalView.html +++ b/gui/default/syncthing/settings/advancedSettingsModalView.html @@ -16,7 +16,7 @@
- +
@@ -35,7 +35,7 @@
- +
@@ -59,7 +59,7 @@
- +
@@ -80,7 +80,7 @@
- +