GUI -- Clean up of index.html and onos.js generation.
Change-Id: Icc1cdeb0e36b29bb76cee9d90fb342e131b78644
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 defb845..14060b9 100644
--- a/web/gui/src/main/webapp/app/fw/util/fn.js
+++ b/web/gui/src/main/webapp/app/fw/util/fn.js
@@ -223,9 +223,7 @@
// return the given string with the first character capitalized.
function cap(s) {
- return s.toLowerCase().replace(/^[a-z]/, function (m) {
- return m.toUpperCase();
- });
+ return s ? s[0].toUpperCase() + s.slice(1) : s;
}
// return the parameter without a px suffix
diff --git a/web/gui/src/main/webapp/app/view/app/app.js b/web/gui/src/main/webapp/app/view/app/app.js
index 2cca7c0..16c1e72 100644
--- a/web/gui/src/main/webapp/app/view/app/app.js
+++ b/web/gui/src/main/webapp/app/view/app/app.js
@@ -326,13 +326,9 @@
['scroll down', 'See more apps']
]);
- function capitalize(s) {
- return s ? s[0].toUpperCase() + s.slice(1) : s;
- }
-
function createConfirmationText(action, itemId) {
var content = ds.createDiv();
- content.append('p').text(capitalize(action) + ' ' + itemId);
+ content.append('p').text(fs.cap(action) + ' ' + itemId);
if (strongWarning[itemId]) {
content.append('p').text(discouragement).classed('strong', true);
}
diff --git a/web/gui/src/main/webapp/index.html b/web/gui/src/main/webapp/index.html
index adead69..3d22c9a 100644
--- a/web/gui/src/main/webapp/index.html
+++ b/web/gui/src/main/webapp/index.html
@@ -130,7 +130,7 @@
<script src="app/view/processor/processor.js"></script>
<script src="app/view/tunnel/tunnel.js"></script>
- <!-- This is where contributed javascript will get injected -->
+ <!-- Contributed javascript injected here -->
<!-- {INJECTED-JAVASCRIPT-START} -->
<!-- {INJECTED-JAVASCRIPT-END} -->
@@ -150,7 +150,7 @@
<link rel="stylesheet" href="app/view/processor/processor.css">
<link rel="stylesheet" href="app/view/tunnel/tunnel.css">
- <!-- This is where contributed stylesheets will get injected -->
+ <!-- Contributed stylesheets injected here -->
<!-- {INJECTED-STYLESHEETS-START} -->
<!-- {INJECTED-STYLESHEETS-END} -->
diff --git a/web/gui/src/main/webapp/onos.js b/web/gui/src/main/webapp/onos.js
index fcb9310..2fffb24 100644
--- a/web/gui/src/main/webapp/onos.js
+++ b/web/gui/src/main/webapp/onos.js
@@ -33,38 +33,27 @@
'onosWidget'
];
- // view IDs.. note the first view listed is loaded at startup
+ // view IDs.. injected via the servlet
var viewIds = [
// {INJECTED-VIEW-IDS-START}
- 'topo',
- 'device',
- 'flow',
- 'port',
- 'group',
- 'meter',
- 'host',
- 'app',
- 'intent',
- 'cluster',
- 'link',
// {INJECTED-VIEW-IDS-END}
-
// dummy entry
''
];
- var viewDependencies = [];
+ var defaultView = 'topo',
+ viewDependencies = [];
viewIds.forEach(function (id) {
if (id) {
- viewDependencies.push('ov' + capitalize(id));
+ viewDependencies.push('ov' + cap(id));
}
});
var moduleDependencies = coreDependencies.concat(viewDependencies);
- function capitalize(word) {
- return word ? word[0].toUpperCase() + word.slice(1) : word;
+ function cap(s) {
+ return s ? s[0].toUpperCase() + s.slice(1) : s;
}
angular.module('onosApp', moduleDependencies)
@@ -97,8 +86,6 @@
flash.initFlash();
qhs.initQuickHelp();
- // TODO: register handler for user settings, etc.
-
wss.createWebSocket({
wsport: $location.search().wsport
});
@@ -111,14 +98,14 @@
}])
.config(['$routeProvider', function ($routeProvider) {
- // If view ID not provided, route to the first view in the list.
+ // If view ID not provided, route to the default view
$routeProvider
.otherwise({
- redirectTo: '/topo'
+ redirectTo: '/' + defaultView
});
function viewCtrlName(vid) {
- return 'Ov' + capitalize(vid) + 'Ctrl';
+ return 'Ov' + cap(vid) + 'Ctrl';
}
function viewTemplateUrl(vid) {