usnationalarchives / federalregister-api-core

Federal Register 2.0 API and Data Importer
https://www.federalregister.gov
Other
136 stars 34 forks source link

"dev formats" modal doesn't display; javascript error #4

Closed daveloyall closed 11 years ago

daveloyall commented 11 years ago

Hello.

I encountered a bug on the live federalregister.gov site today (2013-08-05).

Steps to reproduce: Visit https://www.federalregister.gov/articles/2012/09/04/2012-20982/health-information-technology-standards-implementation-specifications-and-certification-criteria-for using browser: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36

Open the javascript console in your browser.

Click "Dev" button (view "developer friendly" file formats) button.

Observe the error message:

Uncaught TypeError: Cannot read property 'modal_id' of undefined
  display_modal
  (anonymous function)
  Y.event.dispatch
  o.handle.u

Also note that the modal doesn't show up in the browser, so we can't download the dev-friendly formats!

daveloyall commented 11 years ago

Workaround: there is a javascript snippet inside the page that defines a variable dev_formats.

For example (pretty printed for your convenience):

var dev_formats = {
                    "formats": [
                      {
                        "type": "xml",
                        "url": "\/articles\/xml\/201\/220\/982.xml",
                        "title": "Original full text XML",
                        "name": "XML"
                      },
                      {
                        "type": "mods",
                        "url": "http:\/\/www.gpo.gov\/fdsys\/granule\/FR-2012-09-04\/2012-20982\/mods.xml",
                        "title": "Government Printing Office metadata",
                        "name": "MODS"
                      },
                      {
                        "type": "json",
                        "url": "https:\/\/www.federalregister.gov\/api\/v1\/articles\/2012-20982",
                        "title": "Normalized attributes and metadata",
                        "name": "JSON"
                      }
                    ]
                  };
peregrinator commented 11 years ago

We've deployed a fix to this issue. We were improperly handling optional arguments in the javascript message. See commit #ab48c.

Thanks for bringing this to our attention!

andrewcarpenter commented 11 years ago

Please let us know if we can help explain any of the 'dev' formats, or if you have suggestions for improvements. The FederalRegister.gov API ( https://www.federalregister.gov/learn/developers ) may also be of interest.