| @@ -71,27 +71,14 @@ module Docs · 70 unmodified lines |
| 71 | 71 | end |
| 72 | 72 | |
| 73 | 73 | def request_bcd_uris |
| 74 | | − url = current_url.to_s + '/index.json' |
| 75 | | − response = Request.run url |
| 76 | | − index_json = JSON.load response.body |
| 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 |
| 74 | + hydration = JSON.load at_css('#hydration').text |
| 75 | + files = hydration['doc']['browserCompat'] || [] |
| 76 | + files.map { |file| "https://bcd.developer.mozilla.org/bcd/api/v0/current/#{file}.json" } |
| 91 | 77 | end |
| 92 | 78 | |
| 93 | 79 | def generate_compatibility_table_wrapper(url) |
| 94 | 80 | response = Request.run url |
| 81 | + return "" unless response.success? |
| 95 | 82 | @json_data = JSON.load(response.body)['data'] |
| 96 | 83 | |
| 97 | 84 | html_table = generate_basic_html_table() |
| @@ -202,32 +189,30 @@ module Docs · 104 unmodified lines |
| 202 | 189 | |
| 203 | 190 | if version_removed[0] |
| 204 | 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 | 196 | else |
| 206 | | − if version_added[0] == 'No' |
| 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 |
| 197 | + format_string = "<td class=bc-supports-yes>" |
| 213 | 198 | end |
| 214 | 199 | |
| 215 | 200 | for value in (0..version_added.length-1) do |
| 216 | 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 | 203 | else |
| 219 | | − if version_added[value] == 'No' |
| 220 | | − format_string += "<div>#{version_added[value]}</div>" |
| 221 | | − else |
| 222 | | − format_string += "<div>#{version_added[value]}</div>" |
| 223 | | − end |
| 204 | + version_string = version_added[value] |
| 224 | 205 | end |
| 225 | 206 | |
| 226 | 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 | 211 | end |
| 229 | 212 | end |
| 230 | 213 | |
| 214 | + format_string += "</td>" |
| 215 | + |
| 231 | 216 | else |
| 232 | 217 | format_string = "<td class=bc-supports-unknown><div>?</div></td>" |
| 233 | 218 | end |