| @@ -71,27 +71,14 @@ module Docs · 70 unmodified lines |
| 71 | end | 71 | end |
| 72 | | 72 | |
| 73 | def request_bcd_uris | 73 | def request_bcd_uris |
| 74 | url = current_url.to_s + '/index.json' | 74 | hydration = JSON.load at_css('#hydration').text |
| 75 | response = Request.run url | 75 | files = hydration['doc']['browserCompat'] || [] |
| 76 | index_json = JSON.load response.body | 76 | files.map { |file| "https://bcd.developer.mozilla.org/bcd/api/v0/current/#{file}.json" } |
| 77 | | | |
| 78 | uris = [] | | |
| 79 | | | |
| 80 | index_json['doc']['body'].each do |element| | | |
| 81 | uris.push(element['value']['dataURL']) if element['type'] == 'browser_compatibility' and element['value']['dataURL'] | | |
| 82 | end | | |
| 83 | | | |
| 84 | uris.map! do |uri| | | |
| 85 | tmp_uri = URI.parse(base_url.to_s) | | |
| 86 | tmp_uri.path = uri | | |
| 87 | uri = tmp_uri.to_s | | |
| 88 | end | | |
| 89 | | | |
| 90 | return uris | | |
| 91 | end | 77 | end |
| 92 | | 78 | |
| 93 | def generate_compatibility_table_wrapper(url) | 79 | def generate_compatibility_table_wrapper(url) |
| 94 | response = Request.run url | 80 | response = Request.run url |
| | 81 | return "" unless response.success? |
| 95 | @json_data = JSON.load(response.body)['data'] | 82 | @json_data = JSON.load(response.body)['data'] |
| 96 | | 83 | |
| 97 | html_table = generate_basic_html_table() | 84 | html_table = generate_basic_html_table() |
| @@ -202,32 +189,30 @@ module Docs · 104 unmodified lines |
| 202 | | 189 | |
| 203 | if version_removed[0] | 190 | if version_removed[0] |
| 204 | format_string = "<td class=bc-supports-no>" | 191 | format_string = "<td class=bc-supports-no>" |
| | 192 | elsif version_added[0] == 'No' |
| | 193 | format_string = "<td class=bc-supports-no>" |
| | 194 | elsif version_added[0] == '?' |
| | 195 | format_string = "<td class=bc-supports-unknown>" |
| 205 | else | 196 | else |
| 206 | if version_added[0] == 'No' | 197 | format_string = "<td class=bc-supports-yes>" |
| 207 | format_string = "<td class=bc-supports-no>" | | |
| 208 | elsif version_added[0] == '?' | | |
| 209 | format_string = "<td class=bc-supports-unknown>" | | |
| 210 | else | | |
| 211 | format_string = "<td class=bc-supports-yes>" | | |
| 212 | end | | |
| 213 | end | 198 | end |
| 214 | | 199 | |
| 215 | for value in (0..version_added.length-1) do | 200 | for value in (0..version_added.length-1) do |
| 216 | if version_removed[value] | 201 | if version_removed[value] |
| 217 | format_string += "<div>#{version_added[value]}-#{version_removed[value]}</div>" | 202 | version_string = "#{version_added[value]}–#{version_removed[value]}" |
| 218 | else | 203 | else |
| 219 | if version_added[value] == 'No' | 204 | version_string = version_added[value] |
| 220 | format_string += "<div>#{version_added[value]}</div>" | | |
| 221 | else | | |
| 222 | format_string += "<div>#{version_added[value]}</div>" | | |
| 223 | end | | |
| 224 | end | 205 | end |
| 225 | | 206 | |
| 226 | if notes[value] | 207 | if notes[value] |
| 227 | format_string += "<div>#{notes[value]}</div>" | 208 | format_string += "<details><summary>#{version_string}</summary>#{notes[value]}</details>" |
| | 209 | else |
| | 210 | format_string += "<div>#{version_string}</div>" |
| 228 | end | 211 | end |
| 229 | end | 212 | end |
| 230 | | 213 | |
| | 214 | format_string += "</td>" |
| | 215 | |
| 231 | else | 216 | else |
| 232 | format_string = "<td class=bc-supports-unknown><div>?</div></td>" | 217 | format_string = "<td class=bc-supports-unknown><div>?</div></td>" |
| 233 | end | 218 | end |