JavaScript:parsing HTML and re-presenting it

With this useful site as my test source, I wanted to grab a bunch of composers and present them in a different way. To avoid Cross-Domain issues, I had to a) get a simple web server running (see previous post), and b) import the html. I am something of a novice at HTML and JavaScript. So while being sure there is a better way, right now, I just needed to get it done. I left the original HTML as-is (I realise now that although I changed the class names to ComposerSet… I didn’t need to – the classes already had a name, so I could have used those).

The “site” consists of index.html which just references the workhorse Composers.html, and ComposerApp.js. The latter consists of an IIFE and does the work of a) parsing the original HTML, b) getting into an array of objects, c) writing it back out to HTML.

index.html first… gist

Composers.html… gist

ComposerApp.js… gist

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s