Widget JavaScript refinement

* Dynamically calculate widget URL's hostname based on the protocol,
  hostname and port of the script itself. I had to update the
  signature to showWidgets() and getUrl() so they take the base URL
  as an argument otherwise, the Jasmine tests break with the
  auto domain detection.
* Strip leading/trailing whitespace from URLs
* Catch exceptions in getUrl and return the default widgetUrl on
  exceptions
* Documentation of getUrl function

Addresses #741