[Kimchi-devel] [PATCH 2/3] Define the default tab more clearly

Crístian Viana vianac at linux.vnet.ibm.com
Tue Apr 29 15:19:39 UTC 2014


In order to define the default tab, the developer needs to update the
code in more than one place. Also, the corresponding variable name does
not reflect what it actually means.

Define the default tab in a single variable and make all the other
values dependent on it.
Also, rename the variable from "firstTab" to "defaultTab".

Signed-off-by: Crístian Viana <vianac at linux.vnet.ibm.com>
---
 ui/js/src/kimchi.main.js | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/ui/js/src/kimchi.main.js b/ui/js/src/kimchi.main.js
index 2999aa2..a016bee 100644
--- a/ui/js/src/kimchi.main.js
+++ b/ui/js/src/kimchi.main.js
@@ -75,10 +75,12 @@ kimchi.main = function() {
                 tabs.push.apply(tabs, retrieveTabs(url));
             });
 
-            var firstTabPath = tabs[0] && tabs[0]['path'];
-            // Remove file extension from 'firstTabPath'
-            DEFAULT_HASH = firstTabPath &&
-                firstTabPath.substring(0, firstTabPath.lastIndexOf('.'))
+            var defaultTab = tabs[0]
+
+            var defaultTabPath = defaultTab && defaultTab['path']
+            // Remove file extension from 'defaultTabPath'
+            DEFAULT_HASH = defaultTabPath &&
+                defaultTabPath.substring(0, defaultTabPath.lastIndexOf('.'))
 
             $('#nav-menu').append(genTabs(tabs));
 
-- 
1.9.0




More information about the Kimchi-devel mailing list