cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwbro...@apache.org
Subject docs commit: Fix version menu selection of current langauge.
Date Wed, 11 Jun 2014 18:17:32 GMT
Repository: cordova-docs
Updated Branches:
  refs/heads/master f951562da -> 1c287eb46


Fix version menu selection of current langauge.


Project: http://git-wip-us.apache.org/repos/asf/cordova-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-docs/commit/1c287eb4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-docs/tree/1c287eb4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-docs/diff/1c287eb4

Branch: refs/heads/master
Commit: 1c287eb468c9fce641d751ffd4f307a12e4d7277
Parents: f951562
Author: Michael Brooks <michael@michaelbrooks.ca>
Authored: Wed Jun 11 11:17:12 2014 -0700
Committer: Michael Brooks <michael@michaelbrooks.ca>
Committed: Wed Jun 11 11:17:23 2014 -0700

----------------------------------------------------------------------
 lib/cordova/version_menu.rb | 38 +++++++++++++++++---------------------
 1 file changed, 17 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/1c287eb4/lib/cordova/version_menu.rb
----------------------------------------------------------------------
diff --git a/lib/cordova/version_menu.rb b/lib/cordova/version_menu.rb
index c937584..fbb629d 100644
--- a/lib/cordova/version_menu.rb
+++ b/lib/cordova/version_menu.rb
@@ -22,7 +22,7 @@ require 'fileutils'
 
 class VersionMenu
   @@versions = nil
-  @@optgroup_set = nil
+  @@languages = {}
 
   def initialize(options = {})
       @version  = options[:version]
@@ -45,7 +45,6 @@ class VersionMenu
   def generate_set doc
     docs_path    = File.expand_path File.join(__FILE__, '..', '..', '..', 'docs')
     glob_exp     = File.join(docs_path, '*', '*', 'config.json')
-    languages    = {}
     html         = []
 
     # only build versions once for performance
@@ -61,33 +60,30 @@ class VersionMenu
         if language
           @@versions[language] ||= []
           @@versions[language].push version
-          languages[language] = lang
+          @@languages[language] = lang
         else
           puts "Warning: The key 'language' was not defined in #{file}"
         end
       end
     end
 
-    if @@optgroup_set.nil?
-      @@optgroup_set = Nokogiri::XML::NodeSet.new doc
-
-      # generate HTML <select> output
-      @@versions.keys.sort.each do |language|
-        optgroup = Nokogiri::XML::Node.new 'optgroup', doc
-        optgroup['label'] = language
-        optgroup['value'] = languages[language]
-        @@optgroup_set.push optgroup
-
-        @@versions[language].sort.reverse.each do |v|
-          option = Nokogiri::XML::Node.new 'option', doc
-          option['selected'] = 'selected' if @version == v && @language == languages[language]
-          option['value'] = v;
-          option.content = v
-          optgroup.add_child option
-        end
+    # generate HTML <select> output
+    optgroup_set = Nokogiri::XML::NodeSet.new doc
+    @@versions.keys.sort.each do |language|
+      optgroup = Nokogiri::XML::Node.new 'optgroup', doc
+      optgroup['label'] = language
+      optgroup['value'] = @@languages[language]
+      optgroup_set.push optgroup
+
+      @@versions[language].sort.reverse.each do |v|
+        option = Nokogiri::XML::Node.new 'option', doc
+        option['selected'] = 'selected' if @version == v && @language == @@languages[language]
+        option['value'] = v;
+        option.content = v
+        optgroup.add_child option
       end
     end
 
-    return @@optgroup_set
+    return optgroup_set
   end
 end


Mime
View raw message