GUI -- Moved cap() utility function into FnService.

Change-Id: I0afdb38e5b37e085ffebaedc74d3cb2857472b12
diff --git a/web/gui/src/main/webapp/app/fw/layer/quickhelp.js b/web/gui/src/main/webapp/app/fw/layer/quickhelp.js
index 8d533c7..4e8ac05a 100644
--- a/web/gui/src/main/webapp/app/fw/layer/quickhelp.js
+++ b/web/gui/src/main/webapp/app/fw/layer/quickhelp.js
@@ -63,16 +63,9 @@
     // ===========================================
     // === Function Definitions ===
 
-
-    // TODO: move this to FnService.
-    function cap(s) {
-        return s.replace(/^[a-z]/, function (m) { return m.toUpperCase(); });
-    }
-
-
     function mkKeyDisp(id) {
         var v = keyDisp[id] || id;
-        return cap(v);
+        return fs.cap(v);
     }
 
     function addSeparator(el, i) {
diff --git a/web/gui/src/main/webapp/app/fw/util/fn.js b/web/gui/src/main/webapp/app/fw/util/fn.js
index dcc2725..5f1280e 100644
--- a/web/gui/src/main/webapp/app/fw/util/fn.js
+++ b/web/gui/src/main/webapp/app/fw/util/fn.js
@@ -143,6 +143,13 @@
         return found;
     }
 
+    // return the given string with the first character capitalized.
+    function cap(s) {
+        return s.replace(/^[a-z]/, function (m) {
+            return m.toUpperCase();
+        });
+    }
+
     angular.module('onosUtil')
         .factory('FnService', ['$window', function (_$window_) {
             $window = _$window_;
@@ -158,7 +165,8 @@
                 windowSize: windowSize,
                 find: find,
                 inArray: inArray,
-                removeFromArray: removeFromArray
+                removeFromArray: removeFromArray,
+                cap: cap
             };
     }]);
 
diff --git a/web/gui/src/main/webapp/tests/app/fw/util/fn-spec.js b/web/gui/src/main/webapp/tests/app/fw/util/fn-spec.js
index 27b6ba3..2ec8088 100644
--- a/web/gui/src/main/webapp/tests/app/fw/util/fn-spec.js
+++ b/web/gui/src/main/webapp/tests/app/fw/util/fn-spec.js
@@ -202,7 +202,7 @@
         expect(fs.areFunctions(fs, [
             'isF', 'isA', 'isS', 'isO', 'contains',
             'areFunctions', 'areFunctionsNonStrict', 'windowSize', 'find',
-            'inArray', 'removeFromArray'
+            'inArray', 'removeFromArray', 'cap'
         ])).toBeTruthy();
     });
 
@@ -325,4 +325,14 @@
         expect(array).toEqual(['z', 'z', 'y']);
     });
 
+    // === Tests for cap()
+    it('should ignore non-alpha', function () {
+        expect(fs.cap('123')).toEqual('123');
+    });
+    it('should capitalize first char', function () {
+        expect(fs.cap('Foo')).toEqual('Foo');
+        expect(fs.cap('foo')).toEqual('Foo');
+        expect(fs.cap('foo bar')).toEqual('Foo bar');
+    });
+
 });