Commit ca026e51ae5acdc4891ef9e14ec6582db92b78bc

Authored by Andrey Karpikov
1 parent ea0fcee8

check repear first item active class

@@ -78,7 +78,6 @@ module Kanjai @@ -78,7 +78,6 @@ module Kanjai
78 field_options: @field_options, 78 field_options: @field_options,
79 conditions: conditions 79 conditions: conditions
80 } 80 }
81 - p '3'  
82 end 81 end
83 end 82 end
84 83
@@ -91,7 +90,7 @@ module Kanjai @@ -91,7 +90,7 @@ module Kanjai
91 result = [] 90 result = []
92 @html_source.scan(/{"static":[\w\W\{]+?}}/).each do |str| 91 @html_source.scan(/{"static":[\w\W\{]+?}}/).each do |str|
93 element_hash = JSON.parse(str) 92 element_hash = JSON.parse(str)
94 - result << {:name => element_hash["static"]["title"], :itemName => element_hash["static"]["itemName"] , :type => element_hash["static"]["type"], :source => str} 93 + result << {:name => identifier(element_hash["static"]), :itemName => element_hash["static"]["itemName"] , :type => element_hash["static"]["type"], :source => str}
95 end 94 end
96 result 95 result
97 end 96 end
@@ -155,16 +154,16 @@ module Kanjai @@ -155,16 +154,16 @@ module Kanjai
155 154
156 source.to_s.scan(/{"element":[\w\W\{]+?}}/).each do |str| 155 source.to_s.scan(/{"element":[\w\W\{]+?}}/).each do |str|
157 element_hash = JSON.parse(str) 156 element_hash = JSON.parse(str)
158 - @field_options << {:name => element_hash["element"]["title"], :itemName => element_hash["element"]["itemName"] , main: element_hash["element"]["main"].to_i, :attributes => {'type' => element_hash["element"]["type"], 'repeat' => repeat, 'repeatItemId' => repeatItemId}, :source => nil, :children => {}}  
159 - source.gsub!(str, element_hash["element"]["title"]) 157 + @field_options << {:name => identifier(element_hash["element"]), :itemName => element_hash["element"]["itemName"] , main: element_hash["element"]["main"].to_i, :attributes => {'type' => element_hash["element"]["type"], 'repeat' => repeat, 'repeatItemId' => repeatItemId}, :source => nil, :children => {}}
  158 + source.gsub!(str, identifier(element_hash["element"]))
160 end 159 end
161 160
162 attr.each do |key, value| 161 attr.each do |key, value|
163 value.to_s.scan(/{"element":[\w\W\{]+?}}/).each do |str| 162 value.to_s.scan(/{"element":[\w\W\{]+?}}/).each do |str|
164 163
165 element_hash = JSON.parse(str) 164 element_hash = JSON.parse(str)
166 - @field_options << {:name => element_hash["element"]["title"], :itemName => element_hash["element"]["itemName"] , main: element_hash["element"]["main"].to_i, :attributes => {'type' => element_hash["element"]["type"], 'repeat' => repeat, 'repeatItemId' => repeatItemId}, :source => nil, :children => {}}  
167 - value.gsub!(str, element_hash["element"]["title"]) 165 + @field_options << {:name => identifier(element_hash["element"]), :itemName => element_hash["element"]["itemName"] , main: element_hash["element"]["main"].to_i, :attributes => {'type' => element_hash["element"]["type"], 'repeat' => repeat, 'repeatItemId' => repeatItemId}, :source => nil, :children => {}}
  166 + value.gsub!(str, identifier(element_hash["element"]))
168 end 167 end
169 end 168 end
170 169
@@ -175,5 +174,9 @@ module Kanjai @@ -175,5 +174,9 @@ module Kanjai
175 mas 174 mas
176 end 175 end
177 176
  177 + def identifier(el)
  178 + el['id'].present? ? el['id'] : el['title']
  179 + end
  180 +
178 end 181 end
179 end 182 end
1 module Kanjai 1 module Kanjai
2 - VERSION = "0.0.289" 2 + VERSION = "0.0.290"
3 end 3 end